flavor-code 1.4.3-beta.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +25 -0
  2. package/README.zh-CN.md +25 -0
  3. package/dist/agent/loop.d.ts +1 -0
  4. package/dist/{app-G35YBHPR.js → app-TVY2HM5L.js} +342 -112
  5. package/dist/{chunk-FAJ6YDZK.js → chunk-36IDJRLQ.js} +1 -1
  6. package/dist/{chunk-HGTCIHWA.js → chunk-5BDKRA6U.js} +30 -1
  7. package/dist/{chunk-T6RE76D2.js → chunk-IKGT4MDT.js} +35 -23
  8. package/dist/{chunk-K7UGGWJV.js → chunk-JQM2L2YM.js} +1 -1
  9. package/dist/{chunk-6X62CGMA.js → chunk-ONRY3C2L.js} +3 -0
  10. package/dist/{chunk-IDJAHEG6.js → chunk-QACFKPZP.js} +391 -188
  11. package/dist/{chunk-SJUIIHIA.js → chunk-X6U6BO5D.js} +1 -1
  12. package/dist/{claude-ink-BE56DB6N.js → claude-ink-F554I3GJ.js} +1 -1
  13. package/dist/{cli-3MF6EL2H.js → cli-MAWCV2YR.js} +7 -7
  14. package/dist/cli-main.js +16 -16
  15. package/dist/config/protected-file.d.ts +2 -0
  16. package/dist/config/schema.d.ts +3 -0
  17. package/dist/context/global-instructions.d.ts +12 -0
  18. package/dist/context/manager.d.ts +2 -0
  19. package/dist/desktop/main.js +651 -419
  20. package/dist/desktop-renderer/assets/{index-DCqIrF1S.js → index-CjC0Ibiq.js} +2 -2
  21. package/dist/desktop-renderer/assets/{interactive-terminal-B6GbpzIn.js → interactive-terminal-IjIT3Xoa.js} +1 -1
  22. package/dist/desktop-renderer/index.html +1 -1
  23. package/dist/{doctor-OHCGK52S.js → doctor-SEL32R7M.js} +3 -3
  24. package/dist/harness/local.d.ts +1 -0
  25. package/dist/{load-QK6CMLDF.js → load-RHWXNUCS.js} +2 -2
  26. package/dist/{manager-5SI4MPES.js → manager-IYBNNKUP.js} +2 -2
  27. package/dist/{production-6DIZ6YLQ.js → production-TQROFEPV.js} +6 -6
  28. package/dist/sdk/index.js +6 -6
  29. package/dist/{store-ZIHN6363.js → store-MZZERW7K.js} +2 -2
  30. package/dist/ui/commands.d.ts +11 -3
  31. package/dist/ui/session.d.ts +2 -1
  32. package/package.json +1 -1
  33. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +649 -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=er,s=!Bn.jitless,c=s&&tr.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?ba([],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=>!gr(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=>br(e,r,Vn())))}),t)}var wa=z(`$ZodUnion`,(e,t)=>{Li.init(e,t),B(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),B(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),B(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),B(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=>Kn(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)}}),Ta=z(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,wa.init(e,t);let n=e._zod.parse;B(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=Wn(()=>{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(!er(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)}}),Ea=z(`$ZodIntersection`,(e,t)=>{Li.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])=>Oa(e,t,n)):Oa(e,i,a)}});function Da(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(nr(e)&&nr(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=Da(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=Da(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 Oa(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}),gr(e))return e;let o=Da(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ka=z(`$ZodRecord`,(e,t)=>{Li.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!nr(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=>br(e,r,Vn())),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(...vr(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...vr(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`&&hi.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=>br(e,r,Vn())),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(...vr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...vr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Aa=z(`$ZodEnum`,(e,t)=>{Li.init(e,t);let n=Hn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ir.has(typeof e)).map(e=>typeof e==`string`?ar(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}}),ja=z(`$ZodLiteral`,(e,t)=>{if(Li.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`?ar(e):e?ar(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}}),Ma=z(`$ZodTransform`,(e,t)=>{Li.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zn(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 Rn;return n.value=i,n.fallback=!0,n}});function Na(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Pa=z(`$ZodOptional`,(e,t)=>{Li.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,B(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Kn(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=>Na(e,r)):Na(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Fa=z(`$ZodExactOptional`,(e,t)=>{Pa.init(e,t),B(e._zod,`values`,()=>t.innerType._zod.values),B(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ia=z(`$ZodNullable`,(e,t)=>{Li.init(e,t),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Kn(e.source)}|null)$`):void 0}),B(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)}),La=z(`$ZodDefault`,(e,t)=>{Li.init(e,t),e._zod.optin=`optional`,B(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=>Ra(e,t)):Ra(r,t)}});function Ra(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var za=z(`$ZodPrefault`,(e,t)=>{Li.init(e,t),e._zod.optin=`optional`,B(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))}),Ba=z(`$ZodNonOptional`,(e,t)=>{Li.init(e,t),B(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=>Va(t,e)):Va(i,e)}});function Va(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 Ha=z(`$ZodCatch`,(e,t)=>{Li.init(e,t),e._zod.optin=`optional`,B(e._zod,`optout`,()=>t.innerType._zod.optout),B(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=>br(e,n,Vn()))},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=>br(e,n,Vn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ua=z(`$ZodPipe`,(e,t)=>{Li.init(e,t),B(e._zod,`values`,()=>t.in._zod.values),B(e._zod,`optin`,()=>t.in._zod.optin),B(e._zod,`optout`,()=>t.out._zod.optout),B(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=>Wa(e,t.in,n)):Wa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Wa(e,t.out,n)):Wa(r,t.out,n)}});function Wa(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 Ga=z(`$ZodPreprocess`,(e,t)=>{Ua.init(e,t)}),Ka=z(`$ZodReadonly`,(e,t)=>{Li.init(e,t),B(e._zod,`propValues`,()=>t.innerType._zod.propValues),B(e._zod,`values`,()=>t.innerType._zod.values),B(e._zod,`optin`,()=>t.innerType?._zod?.optin),B(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(qa):qa(r)}});function qa(e){return e.value=Object.freeze(e.value),e}var Ja=z(`$ZodCustom`,(e,t)=>{yi.init(e,t),Li.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=>Ya(t,n,r,e));Ya(i,n,r,e)}});function Ya(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(Sr(e))}}var Xa,Za=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 Qa(){return new Za}(Xa=globalThis).__zod_globalRegistry??(Xa.__zod_globalRegistry=Qa());var $a=globalThis.__zod_globalRegistry;function eo(e,t){return new e({type:`string`,...V(t)})}function to(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...V(t)})}function no(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...V(t)})}function ro(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...V(t)})}function io(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...V(t)})}function ao(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...V(t)})}function oo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...V(t)})}function so(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...V(t)})}function co(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...V(t)})}function W(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...V(t)})}function lo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...V(t)})}function uo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...V(t)})}function fo(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...V(t)})}function po(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...V(t)})}function mo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...V(t)})}function ho(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...V(t)})}function go(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...V(t)})}function _o(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...V(t)})}function vo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...V(t)})}function yo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...V(t)})}function bo(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...V(t)})}function xo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...V(t)})}function So(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...V(t)})}function Co(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...V(t)})}function wo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...V(t)})}function To(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...V(t)})}function Eo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...V(t)})}function Do(e,t){return new e({type:`number`,checks:[],...V(t)})}function Oo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...V(t)})}function ko(e,t){return new e({type:`boolean`,...V(t)})}function Ao(e){return new e({type:`unknown`})}function jo(e,t){return new e({type:`never`,...V(t)})}function Mo(e,t){return new xi({check:`less_than`,...V(t),value:e,inclusive:!1})}function No(e,t){return new xi({check:`less_than`,...V(t),value:e,inclusive:!0})}function Po(e,t){return new Si({check:`greater_than`,...V(t),value:e,inclusive:!1})}function Fo(e,t){return new Si({check:`greater_than`,...V(t),value:e,inclusive:!0})}function Io(e,t){return new Ci({check:`multiple_of`,...V(t),value:e})}function Lo(e,t){return new Ti({check:`max_length`,...V(t),maximum:e})}function Ro(e,t){return new Ei({check:`min_length`,...V(t),minimum:e})}function zo(e,t){return new Di({check:`length_equals`,...V(t),length:e})}function Bo(e,t){return new ki({check:`string_format`,format:`regex`,...V(t),pattern:e})}function Vo(e){return new Ai({check:`string_format`,format:`lowercase`,...V(e)})}function Ho(e){return new ji({check:`string_format`,format:`uppercase`,...V(e)})}function Uo(e,t){return new H({check:`string_format`,format:`includes`,...V(t),includes:e})}function Wo(e,t){return new Mi({check:`string_format`,format:`starts_with`,...V(t),prefix:e})}function Go(e,t){return new Ni({check:`string_format`,format:`ends_with`,...V(t),suffix:e})}function Ko(e){return new Pi({check:`overwrite`,tx:e})}function qo(e){return Ko(t=>t.normalize(e))}function Jo(){return Ko(e=>e.trim())}function Yo(){return Ko(e=>e.toLowerCase())}function Xo(){return Ko(e=>e.toUpperCase())}function Zo(){return Ko(e=>Qn(e))}function Qo(e,t,n){return new e({type:`array`,element:t,...V(n)})}function $o(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}function es(e,t){let n=ts(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Sr(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(Sr(r))}},e(t.value,t)),t);return n}function ts(e,t){let n=new yi({check:`custom`,...V(t)});return n._zod.check=e,n}function ns(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??$a,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 rs(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,rs(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`&&os(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 is(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 as(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:cs(t,`input`,e.processors),output:cs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function os(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 os(r.element,n);if(r.type===`set`)return os(r.valueType,n);if(r.type===`lazy`)return os(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 os(r.innerType,n);if(r.type===`intersection`)return os(r.left,n)||os(r.right,n);if(r.type===`record`||r.type===`map`)return os(r.keyType,n)||os(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:os(r.in,n)||os(r.out,n);if(r.type===`object`){for(let e in r.shape)if(os(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(os(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(os(e,n))return!0;return!!(r.rest&&os(r.rest,n))}return!1}var ss=(e,t={})=>n=>{let r=ns({...n,processors:t});return rs(e,r),is(r,e),as(r,e)},cs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ns({...i??{},target:a,io:t,processors:n});return rs(e,o),is(o,e),as(o,e)},ls={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},us=(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=ls[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}))])}},ds=(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)},fs=(e,t,n,r)=>{n.type=`boolean`},ps=(e,t,n,r)=>{n.not={}},ms=(e,t,n,r)=>{let i=e._zod.def,a=Hn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},hs=(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},gs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},vs=(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=rs(a.element,t,{...r,path:[...r.path,`items`]})},ys=(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]=rs(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=rs(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},bs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>rs(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},xs=(e,t,n,r)=>{let i=e._zod.def,a=rs(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=rs(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=rs(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=rs(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=rs(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=rs(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`}]},ws=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ts=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Es=(e,t,n,r)=>{let i=e._zod.def;rs(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)))},Ds=(e,t,n,r)=>{let i=e._zod.def;rs(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},Os=(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;rs(o,t,r);let s=t.seen.get(e);s.ref=o},ks=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},As=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},js=z(`ZodISODateTime`,(e,t)=>{Xi.init(e,t),rc.init(e,t)});function Ms(e){return Co(js,e)}var Ns=z(`ZodISODate`,(e,t)=>{Zi.init(e,t),rc.init(e,t)});function Ps(e){return wo(Ns,e)}var Fs=z(`ZodISOTime`,(e,t)=>{Qi.init(e,t),rc.init(e,t)});function Is(e){return To(Fs,e)}var Ls=z(`ZodISODuration`,(e,t)=>{$i.init(e,t),rc.init(e,t)});function Rs(e){return Eo(Ls,e)}var zs=z(`ZodError`,(e,t)=>{wr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Dr(e,t)},flatten:{value:t=>Er(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Un,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Un,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Bs=Or(zs),Vs=kr(zs),Hs=Ar(zs),Us=Mr(zs),Ws=Pr(zs),Gs=Fr(zs),Ks=Ir(zs),qs=Lr(zs),Js=Rr(zs),Ys=zr(zs),Xs=Br(zs),Zs=Vr(zs),Qs=new WeakMap;function $s(e,t,n){let r=Object.getPrototypeOf(e),i=Qs.get(r);if(i||(i=new Set,Qs.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 ec=z(`ZodType`,(e,t)=>(Li.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:cs(e,`input`),output:cs(e,`output`)}}),e.toJSONSchema=ss(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Bs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Hs(e,t,n),e.parseAsync=async(t,n)=>Vs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Us(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ws(e,t,n),e.decode=(t,n)=>Gs(e,t,n),e.encodeAsync=async(t,n)=>Ks(e,t,n),e.decodeAsync=async(t,n)=>qs(e,t,n),e.safeEncode=(t,n)=>Js(e,t,n),e.safeDecode=(t,n)=>Ys(e,t,n),e.safeEncodeAsync=async(t,n)=>Xs(e,t,n),e.safeDecodeAsync=async(t,n)=>Zs(e,t,n),$s(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Xn(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 or(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(gl(e,t))},superRefine(e,t){return this.check(_l(e,t))},overwrite(e){return this.check(Ko(e))},optional(){return Zc(this)},exactOptional(){return $c(this)},nullable(){return tl(this)},nullish(){return Zc(tl(this))},nonoptional(e){return sl(this,e)},array(){return Pc(this)},or(e){return Lc([this,e])},and(e){return Vc(this,e)},transform(e){return dl(this,Yc(e))},default(e){return rl(this,e)},prefault(e){return al(this,e)},catch(e){return ll(this,e)},pipe(e){return dl(this,e)},readonly(){return ml(this)},describe(e){let t=this.clone();return $a.add(t,{description:e}),t},meta(...e){if(e.length===0)return $a.get(this);let t=this.clone();return $a.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 $a.get(e)?.description},configurable:!0}),e)),tc=z(`_ZodString`,(e,t)=>{Ri.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,$s(e,`_ZodString`,{regex(...e){return this.check(Bo(...e))},includes(...e){return this.check(Uo(...e))},startsWith(...e){return this.check(Wo(...e))},endsWith(...e){return this.check(Go(...e))},min(...e){return this.check(Ro(...e))},max(...e){return this.check(Lo(...e))},length(...e){return this.check(zo(...e))},nonempty(...e){return this.check(Ro(1,...e))},lowercase(e){return this.check(Vo(e))},uppercase(e){return this.check(Ho(e))},trim(){return this.check(Jo())},normalize(...e){return this.check(qo(...e))},toLowerCase(){return this.check(Yo())},toUpperCase(){return this.check(Xo())},slugify(){return this.check(Zo())}})}),nc=z(`ZodString`,(e,t)=>{Ri.init(e,t),tc.init(e,t),e.email=t=>e.check(to(ic,t)),e.url=t=>e.check(so(cc,t)),e.jwt=t=>e.check(So(Cc,t)),e.emoji=t=>e.check(co(lc,t)),e.guid=t=>e.check(no(ac,t)),e.uuid=t=>e.check(ro(oc,t)),e.uuidv4=t=>e.check(io(oc,t)),e.uuidv6=t=>e.check(ao(oc,t)),e.uuidv7=t=>e.check(oo(oc,t)),e.nanoid=t=>e.check(W(uc,t)),e.guid=t=>e.check(no(ac,t)),e.cuid=t=>e.check(lo(dc,t)),e.cuid2=t=>e.check(uo(fc,t)),e.ulid=t=>e.check(fo(pc,t)),e.base64=t=>e.check(yo(bc,t)),e.base64url=t=>e.check(bo(xc,t)),e.xid=t=>e.check(po(mc,t)),e.ksuid=t=>e.check(mo(hc,t)),e.ipv4=t=>e.check(ho(gc,t)),e.ipv6=t=>e.check(go(_c,t)),e.cidrv4=t=>e.check(_o(vc,t)),e.cidrv6=t=>e.check(vo(yc,t)),e.e164=t=>e.check(xo(Sc,t)),e.datetime=t=>e.check(Ms(t)),e.date=t=>e.check(Ps(t)),e.time=t=>e.check(Is(t)),e.duration=t=>e.check(Rs(t))});function G(e){return eo(nc,e)}var rc=z(`ZodStringFormat`,(e,t)=>{U.init(e,t),tc.init(e,t)}),ic=z(`ZodEmail`,(e,t)=>{Vi.init(e,t),rc.init(e,t)}),ac=z(`ZodGUID`,(e,t)=>{zi.init(e,t),rc.init(e,t)}),oc=z(`ZodUUID`,(e,t)=>{Bi.init(e,t),rc.init(e,t)});function sc(e){return ro(oc,e)}var cc=z(`ZodURL`,(e,t)=>{Hi.init(e,t),rc.init(e,t)}),lc=z(`ZodEmoji`,(e,t)=>{Ui.init(e,t),rc.init(e,t)}),uc=z(`ZodNanoID`,(e,t)=>{Wi.init(e,t),rc.init(e,t)}),dc=z(`ZodCUID`,(e,t)=>{Gi.init(e,t),rc.init(e,t)}),fc=z(`ZodCUID2`,(e,t)=>{Ki.init(e,t),rc.init(e,t)}),pc=z(`ZodULID`,(e,t)=>{qi.init(e,t),rc.init(e,t)}),mc=z(`ZodXID`,(e,t)=>{Ji.init(e,t),rc.init(e,t)}),hc=z(`ZodKSUID`,(e,t)=>{Yi.init(e,t),rc.init(e,t)}),gc=z(`ZodIPv4`,(e,t)=>{ea.init(e,t),rc.init(e,t)}),_c=z(`ZodIPv6`,(e,t)=>{ta.init(e,t),rc.init(e,t)}),vc=z(`ZodCIDRv4`,(e,t)=>{na.init(e,t),rc.init(e,t)}),yc=z(`ZodCIDRv6`,(e,t)=>{ra.init(e,t),rc.init(e,t)}),bc=z(`ZodBase64`,(e,t)=>{aa.init(e,t),rc.init(e,t)}),xc=z(`ZodBase64URL`,(e,t)=>{sa.init(e,t),rc.init(e,t)}),Sc=z(`ZodE164`,(e,t)=>{ca.init(e,t),rc.init(e,t)}),Cc=z(`ZodJWT`,(e,t)=>{ua.init(e,t),rc.init(e,t)}),wc=z(`ZodNumber`,(e,t)=>{da.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),$s(e,`ZodNumber`,{gt(e,t){return this.check(Po(e,t))},gte(e,t){return this.check(Fo(e,t))},min(e,t){return this.check(Fo(e,t))},lt(e,t){return this.check(Mo(e,t))},lte(e,t){return this.check(No(e,t))},max(e,t){return this.check(No(e,t))},int(e){return this.check(Ec(e))},safe(e){return this.check(Ec(e))},positive(e){return this.check(Po(0,e))},nonnegative(e){return this.check(Fo(0,e))},negative(e){return this.check(Mo(0,e))},nonpositive(e){return this.check(No(0,e))},multipleOf(e,t){return this.check(Io(e,t))},step(e,t){return this.check(Io(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 K(e){return Do(wc,e)}var Tc=z(`ZodNumberFormat`,(e,t)=>{fa.init(e,t),wc.init(e,t)});function Ec(e){return Oo(Tc,e)}var Dc=z(`ZodBoolean`,(e,t)=>{pa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function Oc(e){return ko(Dc,e)}var kc=z(`ZodUnknown`,(e,t)=>{ma.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ac(){return Ao(kc)}var jc=z(`ZodNever`,(e,t)=>{ha.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r)});function Mc(e){return jo(jc,e)}var Nc=z(`ZodArray`,(e,t)=>{_a.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.element=t.element,$s(e,`ZodArray`,{min(e,t){return this.check(Ro(e,t))},nonempty(e){return this.check(Ro(1,e))},max(e,t){return this.check(Lo(e,t))},length(e,t){return this.check(zo(e,t))},unwrap(){return this.element}})});function Pc(e,t){return Qo(Nc,e,t)}var Fc=z(`ZodObject`,(e,t)=>{Sa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),B(e,`shape`,()=>t.shape),$s(e,`ZodObject`,{keyof(){return Gc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ac()})},loose(){return this.clone({...this._zod.def,catchall:Ac()})},strict(){return this.clone({...this._zod.def,catchall:Mc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return dr(this,e)},safeExtend(e){return fr(this,e)},merge(e){return pr(this,e)},pick(e){return lr(this,e)},omit(e){return ur(this,e)},partial(...e){return mr(Xc,this,e[0])},required(...e){return hr(ol,this,e[0])}})});function q(e,t){return new Fc({type:`object`,shape:e??{},...V(t)})}var Ic=z(`ZodUnion`,(e,t)=>{wa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.options=t.options});function Lc(e,t){return new Ic({type:`union`,options:e,...V(t)})}var Rc=z(`ZodDiscriminatedUnion`,(e,t)=>{Ic.init(e,t),Ta.init(e,t)});function zc(e,t,n){return new Rc({type:`union`,options:t,discriminator:e,...V(n)})}var Bc=z(`ZodIntersection`,(e,t)=>{Ea.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Vc(e,t){return new Bc({type:`intersection`,left:e,right:t})}var Hc=z(`ZodRecord`,(e,t)=>{ka.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Uc(e,t,n){return!t||!t._zod?new Hc({type:`record`,keyType:G(),valueType:e,...V(t)}):new Hc({type:`record`,keyType:e,valueType:t,...V(n)})}var Wc=z(`ZodEnum`,(e,t)=>{Aa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(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 Wc({...t,checks:[],...V(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 Wc({...t,checks:[],...V(r),entries:i})}});function Gc(e,t){return new Wc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...V(t)})}var Kc=z(`ZodLiteral`,(e,t)=>{ja.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(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 qc(e,t){return new Kc({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}var Jc=z(`ZodTransform`,(e,t)=>{Ma.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Sr(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(Sr(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 Yc(e){return new Jc({type:`transform`,transform:e})}var Xc=z(`ZodOptional`,(e,t)=>{Pa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`optional`,innerType:e})}var Qc=z(`ZodExactOptional`,(e,t)=>{Fa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e){return new Qc({type:`optional`,innerType:e})}var el=z(`ZodNullable`,(e,t)=>{Ia.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tl(e){return new el({type:`nullable`,innerType:e})}var nl=z(`ZodDefault`,(e,t)=>{La.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rl(e,t){return new nl({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var il=z(`ZodPrefault`,(e,t)=>{za.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e,t){return new il({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var ol=z(`ZodNonOptional`,(e,t)=>{Ba.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sl(e,t){return new ol({type:`nonoptional`,innerType:e,...V(t)})}var cl=z(`ZodCatch`,(e,t)=>{Ha.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ll(e,t){return new cl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ul=z(`ZodPipe`,(e,t)=>{Ua.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.in=t.in,e.out=t.out});function dl(e,t){return new ul({type:`pipe`,in:e,out:t})}var fl=z(`ZodPreprocess`,(e,t)=>{ul.init(e,t),Ga.init(e,t)}),pl=z(`ZodReadonly`,(e,t)=>{Ka.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ml(e){return new pl({type:`readonly`,innerType:e})}var hl=z(`ZodCustom`,(e,t)=>{Ja.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r)});function gl(e,t={}){return $o(hl,e,t)}function _l(e,t){return es(e,t)}function vl(e,t){return new fl({type:`pipe`,in:Yc(e),out:t})}var yl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function bl(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var xl=vl(bl,Gc(yl).default(`default`)),Sl=q({type:G(),baseURL:G().url().optional(),apiKey:G().optional(),defaultModel:G().min(1).optional(),cheapModel:G().min(1).optional(),models:Pc(G().min(1)).max(100).optional(),maxOutputTokens:K().int().positive().optional(),thinkingBudget:K().int().min(0).optional(),cacheTtl:Gc([`5m`,`1h`]).optional(),thinkingEffort:Gc([`minimal`,`low`,`medium`,`high`,`xhigh`,`ultra`]).optional(),claudeClient:Oc().optional(),apiType:Gc([`openai`,`anthropic`]).optional(),authorizationUrl:G().url().optional(),tokenUrl:G().url().optional(),clientId:G().min(1).optional(),scope:G().optional()}),Cl={disabled:Oc().default(!1),timeoutMs:K().int().min(100).max(30*6e4).default(6e4)},wl=Lc([q({command:G().min(1),args:Pc(G()).default([]),env:Uc(G(),G()).default({}),cwd:G().min(1).optional(),...Cl}).strict(),q({url:G().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Uc(G(),G()).default({}),...Cl}).strict()]),Tl=G().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),El=G().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`),Dl=q({sleep:Oc().default(!1),providers:Uc(G(),Sl).default({}),mcpServers:Uc(Tl,wl).default({}),skills:q({disabled:Pc(El).max(1e3).default([])}).prefault({}),agents:q({main:q({model:G()}).optional(),subagent:q({model:G()}).optional()}).optional(),maxSubagents:K().int().min(1).max(16).default(3),maxSessions:K().int().min(1).max(1e3).default(50),memory:q({enabled:Oc().default(!0),autoExtract:Oc().default(!0),autoExtractMinChars:K().int().min(200).max(1e5).default(200),scoreThreshold:K().int().min(0).max(12).default(9),autoStoreThreshold:K().int().min(0).max(12).default(11),ignoreStreakLimit:K().int().min(2).max(100).default(5),reviewAutoDismissSeconds:K().int().min(0).max(300).default(5),maxCandidatesPerTask:qc(1).default(1),retrievalTopK:K().int().min(1).max(20).default(5),maxEntries:K().int().min(1).max(1e4).default(200),maxEntryChars:K().int().min(32).max(2e4).default(1e3),maxPromptChars:K().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:xl,execution:q({mode:Gc([`local`,`docker`]).default(`local`),image:G().trim().min(1).default(`node:24-bookworm-slim`),network:Oc().default(!1),memory:G().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:K().positive().max(64).default(2)}).prefault({}),language:G().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:q({showWarnings:Oc().default(!1),evaluationTimeoutMs:K().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:q({main:K().int().min(10).max(500).default(300),subagent:K().int().min(10).max(200).default(100),softLimitFactor:K().min(.5).max(1).default(.8),extendBy:K().int().min(5).max(100).default(50)}).prefault({}),loop:q({maxCycles:K().int().positive().max(1e4).default(100),maxTokens:K().int().positive().max(2**53-1).default(5e5),isolation:qc(`auto`).default(`auto`)}).prefault({}),goal:q({maxRounds:K().int().positive().max(1e4).default(100),maxStallStreak:K().int().positive().max(100).default(3)}).prefault({}),context:q({windowTokens:K().int().positive().default(2e5),reservedOutputTokens:K().int().nonnegative().default(2e4),autoCompactBufferTokens:K().int().nonnegative().default(27e3),warningBufferTokens:K().int().nonnegative().default(2e4),blockingBufferTokens:K().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:K().int().nonnegative().default(5),recentTokens:K().int().nonnegative().default(1e4),recentTextMessages:K().int().nonnegative().default(5),maxRecentTokens:K().int().nonnegative().default(4e4),compactAtChars:K().int().positive().optional(),toolOutputChars:K().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:q({enabled:Oc().default(!1),webhookUrl:G().url().optional()}).prefault({}),evolve:q({promptTop:K().int().min(1).max(10).default(3),minRepeats:K().int().min(2).max(100).default(2),testCommand:G().trim().min(1).default(`npm test`),testTimeoutMs:K().int().min(1e3).max(6e5).default(12e4)}).prefault({})});Object.keys(Dl.shape);var Ol=[`user`,`feedback`,`project`,`reference`],kl=32*1024,Al=64*1024,jl=1024,Ml=24*1024,Nl=56*1024,Pl=4*1024,Fl=12*1024,Il=qc(1),J=sc(),Ll=G().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),Y=Ll,X=Ll,Z=G().refine(e=>Buffer.byteLength(e,`utf8`)<=kl,`Text must not exceed ${kl} UTF-8 bytes`),Rl=Z.refine(e=>e.length>0,`Text must not be empty`),zl=G().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=Pl,`Completion evidence must not exceed ${Pl} UTF-8 bytes`),Bl=q({version:Il,id:J,alias:Y,projectPath:G().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=jl,`Project path must not exceed ${jl} UTF-8 bytes`),connectedAt:Ms(),lastSeenAt:Ms()}).strict();Pc(Bl).max(16),q({version:Il,type:qc(`task`),messageId:J,target:X,goal:Rl}).strict();var Vl=q({version:Il,type:qc(`task-event`),messageId:J,taskId:J,senderId:J,recipientId:J,status:Gc([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Z.optional()}).strict(),Hl=q({version:Il,type:qc(`delivery-receipt`),messageId:J,status:Gc([`delivered`,`duplicate`,`rejected`]),recipientIds:Pc(J).max(16),error:Z.optional()}).strict(),Ul=q({palId:J,required:Oc()}).strict(),Wl=Pc(Ul).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)}}),Gl=q({id:G().min(1).max(128),assigneeId:J,description:Rl,dependsOn:Pc(G().min(1).max(128)).max(32)}).strict(),Kl=q({version:Il,coWorkId:J,epoch:K().int().positive(),goal:Rl,participants:Pc(Ul).min(1).max(16),tasks:Pc(Gl).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 ${Ml} 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}}),ql=Gc([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Jl=q({passed:Oc(),evidence:zl}).strict(),Yl=q({participantId:J,passed:Oc(),detail:zl.optional()}).strict(),Xl=q({version:Il,coWorkId:J,epoch:K().int().positive(),phase:ql,goal:Rl,participants:Pc(Ul).min(1).max(16),integrationOwnerId:J,acceptedParticipantIds:Pc(J).max(16),planHash:G().regex(/^[a-f0-9]{64}$/).nullable(),plan:Kl.nullable(),planAcceptedParticipantIds:Pc(J).max(16),readyParticipantIds:Pc(J).max(16),completedParticipantIds:Pc(J).max(16),completionAssertions:Pc(Yl).max(16),integration:Jl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${Nl} 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 ${Fl} UTF-8 bytes in aggregate`})}),Zl={version:Il,requestId:J};zc(`type`,[q({...Zl,type:qc(`register`),authToken:G().regex(/^[a-f0-9]{64}$/).optional(),presence:Bl}).strict(),q({...Zl,type:qc(`heartbeat`)}).strict(),q({...Zl,type:qc(`list`)}).strict(),q({...Zl,type:qc(`disconnect`)}).strict(),q({...Zl,type:qc(`chat`),messageId:J,target:X,message:Rl}).strict(),q({...Zl,type:qc(`task`),messageId:J,target:X,goal:Rl}).strict(),q({...Zl,type:qc(`cowork-propose`),coWorkId:J,goal:Rl,participants:Wl}).strict(),q({...Zl,type:qc(`cowork-accept`),coWorkId:J,epoch:K().int().positive()}).strict(),q({...Zl,type:qc(`cowork-plan`),plan:Kl}).strict(),q({...Zl,type:qc(`cowork-plan-accept`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/)}).strict(),q({...Zl,type:qc(`cowork-ready`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/)}).strict(),q({...Zl,type:qc(`cowork-complete`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/),passed:Oc(),detail:zl.optional()}).strict(),q({...Zl,type:qc(`cowork-integration`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/),passed:Oc(),evidence:zl}).strict(),q({...Zl,type:qc(`cowork-get`),coWorkId:J}).strict(),q({...Zl,type:qc(`cowork-cancel`),coWorkId:J,reason:Rl}).strict()]);var Ql=q({version:Il,type:qc(`ok`),requestId:J,data:Ac()}).strict(),$l=q({version:Il,type:qc(`error`),requestId:J,code:Gc([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Z}).strict(),eu=Lc([q({version:Il,type:qc(`chat-event`),messageId:J,senderId:J,recipientId:J,message:Rl}).strict(),Vl,Hl,q({version:Il,type:qc(`cowork-event`),action:Gc([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:J,coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Xl}).strict()]);zc(`type`,[Ql,$l,q({version:Il,type:qc(`event`),event:eu}).strict()]),G().refine(e=>Buffer.byteLength(e,`utf8`)<=Al,`Control frame must not exceed ${Al} UTF-8 bytes`);var tu=`model.init.config.login.logout.permissions.skills.plugins.hooks.tasks.finish.compact.clear.paste-image.help.exit.audit.usage.doctor.loop.goal.evolve.mcp.commit.review.explain.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work.tool`.split(`.`),nu={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,logout:`Clear stored OAuth credentials and restore configured models`,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`,"paste-image":`Attach the clipboard image explicitly`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,doctor:`Diagnose the local runtime, configuration, tools, plugins, and npm access`,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`,explain:`Explain a symbol for newcomers (AST graph + source + git history)`,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`,tool:`Run a registered managed tool with a JSON object`},ru={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 as(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:cs(t,`input`,e.processors),output:cs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function os(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 os(r.element,n);if(r.type===`set`)return os(r.valueType,n);if(r.type===`lazy`)return os(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 os(r.innerType,n);if(r.type===`intersection`)return os(r.left,n)||os(r.right,n);if(r.type===`record`||r.type===`map`)return os(r.keyType,n)||os(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:os(r.in,n)||os(r.out,n);if(r.type===`object`){for(let e in r.shape)if(os(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(os(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(os(e,n))return!0;return!!(r.rest&&os(r.rest,n))}return!1}var ss=(e,t={})=>n=>{let r=ns({...n,processors:t});return rs(e,r),is(r,e),as(r,e)},cs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ns({...i??{},target:a,io:t,processors:n});return rs(e,o),is(o,e),as(o,e)},ls={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},us=(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=ls[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}))])}},ds=(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)},fs=(e,t,n,r)=>{n.type=`boolean`},ps=(e,t,n,r)=>{n.not={}},ms=(e,t,n,r)=>{let i=e._zod.def,a=Hn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},hs=(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},gs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},vs=(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=rs(a.element,t,{...r,path:[...r.path,`items`]})},ys=(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]=rs(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=rs(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},bs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>rs(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},xs=(e,t,n,r)=>{let i=e._zod.def,a=rs(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=rs(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=rs(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=rs(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=rs(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=rs(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`}]},ws=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ts=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Es=(e,t,n,r)=>{let i=e._zod.def;rs(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)))},Ds=(e,t,n,r)=>{let i=e._zod.def;rs(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},Os=(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;rs(o,t,r);let s=t.seen.get(e);s.ref=o},ks=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},As=(e,t,n,r)=>{let i=e._zod.def;rs(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},js=z(`ZodISODateTime`,(e,t)=>{Xi.init(e,t),rc.init(e,t)});function Ms(e){return Co(js,e)}var Ns=z(`ZodISODate`,(e,t)=>{Zi.init(e,t),rc.init(e,t)});function Ps(e){return wo(Ns,e)}var Fs=z(`ZodISOTime`,(e,t)=>{Qi.init(e,t),rc.init(e,t)});function Is(e){return To(Fs,e)}var Ls=z(`ZodISODuration`,(e,t)=>{$i.init(e,t),rc.init(e,t)});function Rs(e){return Eo(Ls,e)}var zs=z(`ZodError`,(e,t)=>{wr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Dr(e,t)},flatten:{value:t=>Er(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Un,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Un,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Bs=Or(zs),Vs=kr(zs),Hs=Ar(zs),Us=Mr(zs),Ws=Pr(zs),Gs=Fr(zs),Ks=Ir(zs),qs=Lr(zs),Js=Rr(zs),Ys=zr(zs),Xs=Br(zs),Zs=Vr(zs),Qs=new WeakMap;function $s(e,t,n){let r=Object.getPrototypeOf(e),i=Qs.get(r);if(i||(i=new Set,Qs.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 ec=z(`ZodType`,(e,t)=>(Li.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:cs(e,`input`),output:cs(e,`output`)}}),e.toJSONSchema=ss(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Bs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Hs(e,t,n),e.parseAsync=async(t,n)=>Vs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Us(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ws(e,t,n),e.decode=(t,n)=>Gs(e,t,n),e.encodeAsync=async(t,n)=>Ks(e,t,n),e.decodeAsync=async(t,n)=>qs(e,t,n),e.safeEncode=(t,n)=>Js(e,t,n),e.safeDecode=(t,n)=>Ys(e,t,n),e.safeEncodeAsync=async(t,n)=>Xs(e,t,n),e.safeDecodeAsync=async(t,n)=>Zs(e,t,n),$s(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Xn(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 or(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(gl(e,t))},superRefine(e,t){return this.check(_l(e,t))},overwrite(e){return this.check(Ko(e))},optional(){return Zc(this)},exactOptional(){return $c(this)},nullable(){return tl(this)},nullish(){return Zc(tl(this))},nonoptional(e){return sl(this,e)},array(){return Pc(this)},or(e){return Lc([this,e])},and(e){return Vc(this,e)},transform(e){return dl(this,Yc(e))},default(e){return rl(this,e)},prefault(e){return al(this,e)},catch(e){return ll(this,e)},pipe(e){return dl(this,e)},readonly(){return ml(this)},describe(e){let t=this.clone();return $a.add(t,{description:e}),t},meta(...e){if(e.length===0)return $a.get(this);let t=this.clone();return $a.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 $a.get(e)?.description},configurable:!0}),e)),tc=z(`_ZodString`,(e,t)=>{Ri.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,$s(e,`_ZodString`,{regex(...e){return this.check(Bo(...e))},includes(...e){return this.check(Uo(...e))},startsWith(...e){return this.check(Wo(...e))},endsWith(...e){return this.check(Go(...e))},min(...e){return this.check(Ro(...e))},max(...e){return this.check(Lo(...e))},length(...e){return this.check(zo(...e))},nonempty(...e){return this.check(Ro(1,...e))},lowercase(e){return this.check(Vo(e))},uppercase(e){return this.check(Ho(e))},trim(){return this.check(Jo())},normalize(...e){return this.check(qo(...e))},toLowerCase(){return this.check(Yo())},toUpperCase(){return this.check(Xo())},slugify(){return this.check(Zo())}})}),nc=z(`ZodString`,(e,t)=>{Ri.init(e,t),tc.init(e,t),e.email=t=>e.check(to(ic,t)),e.url=t=>e.check(so(cc,t)),e.jwt=t=>e.check(So(Cc,t)),e.emoji=t=>e.check(co(lc,t)),e.guid=t=>e.check(no(ac,t)),e.uuid=t=>e.check(ro(oc,t)),e.uuidv4=t=>e.check(io(oc,t)),e.uuidv6=t=>e.check(ao(oc,t)),e.uuidv7=t=>e.check(oo(oc,t)),e.nanoid=t=>e.check(W(uc,t)),e.guid=t=>e.check(no(ac,t)),e.cuid=t=>e.check(lo(dc,t)),e.cuid2=t=>e.check(uo(fc,t)),e.ulid=t=>e.check(fo(pc,t)),e.base64=t=>e.check(yo(bc,t)),e.base64url=t=>e.check(bo(xc,t)),e.xid=t=>e.check(po(mc,t)),e.ksuid=t=>e.check(mo(hc,t)),e.ipv4=t=>e.check(ho(gc,t)),e.ipv6=t=>e.check(go(_c,t)),e.cidrv4=t=>e.check(_o(vc,t)),e.cidrv6=t=>e.check(vo(yc,t)),e.e164=t=>e.check(xo(Sc,t)),e.datetime=t=>e.check(Ms(t)),e.date=t=>e.check(Ps(t)),e.time=t=>e.check(Is(t)),e.duration=t=>e.check(Rs(t))});function G(e){return eo(nc,e)}var rc=z(`ZodStringFormat`,(e,t)=>{U.init(e,t),tc.init(e,t)}),ic=z(`ZodEmail`,(e,t)=>{Vi.init(e,t),rc.init(e,t)}),ac=z(`ZodGUID`,(e,t)=>{zi.init(e,t),rc.init(e,t)}),oc=z(`ZodUUID`,(e,t)=>{Bi.init(e,t),rc.init(e,t)});function sc(e){return ro(oc,e)}var cc=z(`ZodURL`,(e,t)=>{Hi.init(e,t),rc.init(e,t)}),lc=z(`ZodEmoji`,(e,t)=>{Ui.init(e,t),rc.init(e,t)}),uc=z(`ZodNanoID`,(e,t)=>{Wi.init(e,t),rc.init(e,t)}),dc=z(`ZodCUID`,(e,t)=>{Gi.init(e,t),rc.init(e,t)}),fc=z(`ZodCUID2`,(e,t)=>{Ki.init(e,t),rc.init(e,t)}),pc=z(`ZodULID`,(e,t)=>{qi.init(e,t),rc.init(e,t)}),mc=z(`ZodXID`,(e,t)=>{Ji.init(e,t),rc.init(e,t)}),hc=z(`ZodKSUID`,(e,t)=>{Yi.init(e,t),rc.init(e,t)}),gc=z(`ZodIPv4`,(e,t)=>{ea.init(e,t),rc.init(e,t)}),_c=z(`ZodIPv6`,(e,t)=>{ta.init(e,t),rc.init(e,t)}),vc=z(`ZodCIDRv4`,(e,t)=>{na.init(e,t),rc.init(e,t)}),yc=z(`ZodCIDRv6`,(e,t)=>{ra.init(e,t),rc.init(e,t)}),bc=z(`ZodBase64`,(e,t)=>{aa.init(e,t),rc.init(e,t)}),xc=z(`ZodBase64URL`,(e,t)=>{sa.init(e,t),rc.init(e,t)}),Sc=z(`ZodE164`,(e,t)=>{ca.init(e,t),rc.init(e,t)}),Cc=z(`ZodJWT`,(e,t)=>{ua.init(e,t),rc.init(e,t)}),wc=z(`ZodNumber`,(e,t)=>{da.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),$s(e,`ZodNumber`,{gt(e,t){return this.check(Po(e,t))},gte(e,t){return this.check(Fo(e,t))},min(e,t){return this.check(Fo(e,t))},lt(e,t){return this.check(Mo(e,t))},lte(e,t){return this.check(No(e,t))},max(e,t){return this.check(No(e,t))},int(e){return this.check(Ec(e))},safe(e){return this.check(Ec(e))},positive(e){return this.check(Po(0,e))},nonnegative(e){return this.check(Fo(0,e))},negative(e){return this.check(Mo(0,e))},nonpositive(e){return this.check(No(0,e))},multipleOf(e,t){return this.check(Io(e,t))},step(e,t){return this.check(Io(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 K(e){return Do(wc,e)}var Tc=z(`ZodNumberFormat`,(e,t)=>{fa.init(e,t),wc.init(e,t)});function Ec(e){return Oo(Tc,e)}var Dc=z(`ZodBoolean`,(e,t)=>{pa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r)});function Oc(e){return ko(Dc,e)}var kc=z(`ZodUnknown`,(e,t)=>{ma.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ac(){return Ao(kc)}var jc=z(`ZodNever`,(e,t)=>{ha.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r)});function Mc(e){return jo(jc,e)}var Nc=z(`ZodArray`,(e,t)=>{_a.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.element=t.element,$s(e,`ZodArray`,{min(e,t){return this.check(Ro(e,t))},nonempty(e){return this.check(Ro(1,e))},max(e,t){return this.check(Lo(e,t))},length(e,t){return this.check(zo(e,t))},unwrap(){return this.element}})});function Pc(e,t){return Qo(Nc,e,t)}var Fc=z(`ZodObject`,(e,t)=>{Sa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),B(e,`shape`,()=>t.shape),$s(e,`ZodObject`,{keyof(){return Gc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ac()})},loose(){return this.clone({...this._zod.def,catchall:Ac()})},strict(){return this.clone({...this._zod.def,catchall:Mc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return dr(this,e)},safeExtend(e){return fr(this,e)},merge(e){return pr(this,e)},pick(e){return lr(this,e)},omit(e){return ur(this,e)},partial(...e){return mr(Xc,this,e[0])},required(...e){return hr(ol,this,e[0])}})});function q(e,t){return new Fc({type:`object`,shape:e??{},...V(t)})}var Ic=z(`ZodUnion`,(e,t)=>{wa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.options=t.options});function Lc(e,t){return new Ic({type:`union`,options:e,...V(t)})}var Rc=z(`ZodDiscriminatedUnion`,(e,t)=>{Ic.init(e,t),Ta.init(e,t)});function zc(e,t,n){return new Rc({type:`union`,options:t,discriminator:e,...V(n)})}var Bc=z(`ZodIntersection`,(e,t)=>{Ea.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function Vc(e,t){return new Bc({type:`intersection`,left:e,right:t})}var Hc=z(`ZodRecord`,(e,t)=>{ka.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Uc(e,t,n){return!t||!t._zod?new Hc({type:`record`,keyType:G(),valueType:e,...V(t)}):new Hc({type:`record`,keyType:e,valueType:t,...V(n)})}var Wc=z(`ZodEnum`,(e,t)=>{Aa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(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 Wc({...t,checks:[],...V(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 Wc({...t,checks:[],...V(r),entries:i})}});function Gc(e,t){return new Wc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...V(t)})}var Kc=z(`ZodLiteral`,(e,t)=>{ja.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(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 qc(e,t){return new Kc({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}var Jc=z(`ZodTransform`,(e,t)=>{Ma.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Sr(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(Sr(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 Yc(e){return new Jc({type:`transform`,transform:e})}var Xc=z(`ZodOptional`,(e,t)=>{Pa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`optional`,innerType:e})}var Qc=z(`ZodExactOptional`,(e,t)=>{Fa.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e){return new Qc({type:`optional`,innerType:e})}var el=z(`ZodNullable`,(e,t)=>{Ia.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tl(e){return new el({type:`nullable`,innerType:e})}var nl=z(`ZodDefault`,(e,t)=>{La.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rl(e,t){return new nl({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var il=z(`ZodPrefault`,(e,t)=>{za.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e,t){return new il({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():rr(t)}})}var ol=z(`ZodNonOptional`,(e,t)=>{Ba.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sl(e,t){return new ol({type:`nonoptional`,innerType:e,...V(t)})}var cl=z(`ZodCatch`,(e,t)=>{Ha.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ll(e,t){return new cl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ul=z(`ZodPipe`,(e,t)=>{Ua.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.in=t.in,e.out=t.out});function dl(e,t){return new ul({type:`pipe`,in:e,out:t})}var fl=z(`ZodPreprocess`,(e,t)=>{ul.init(e,t),Ga.init(e,t)}),pl=z(`ZodReadonly`,(e,t)=>{Ka.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ml(e){return new pl({type:`readonly`,innerType:e})}var hl=z(`ZodCustom`,(e,t)=>{Ja.init(e,t),ec.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r)});function gl(e,t={}){return $o(hl,e,t)}function _l(e,t){return es(e,t)}function vl(e,t){return new fl({type:`pipe`,in:Yc(e),out:t})}var yl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function bl(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var xl=vl(bl,Gc(yl).default(`default`)),Sl=q({type:G(),baseURL:G().url().optional(),apiKey:G().optional(),defaultModel:G().min(1).optional(),cheapModel:G().min(1).optional(),models:Pc(G().min(1)).max(100).optional(),maxOutputTokens:K().int().positive().optional(),thinkingBudget:K().int().min(0).optional(),cacheTtl:Gc([`5m`,`1h`]).optional(),thinkingEffort:Gc([`minimal`,`low`,`medium`,`high`,`xhigh`,`ultra`]).optional(),claudeClient:Oc().optional(),apiType:Gc([`openai`,`anthropic`]).optional(),authorizationUrl:G().url().optional(),tokenUrl:G().url().optional(),clientId:G().min(1).optional(),scope:G().optional()}),Cl={disabled:Oc().default(!1),timeoutMs:K().int().min(100).max(30*6e4).default(6e4)},wl=Lc([q({command:G().min(1),args:Pc(G()).default([]),env:Uc(G(),G()).default({}),cwd:G().min(1).optional(),...Cl}).strict(),q({url:G().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Uc(G(),G()).default({}),...Cl}).strict()]),Tl=G().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),El=G().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`),Dl=q({sleep:Oc().default(!1),providers:Uc(G(),Sl).default({}),mcpServers:Uc(Tl,wl).default({}),skills:q({disabled:Pc(El).max(1e3).default([])}).prefault({}),globalInstructions:q({enabled:Oc().default(!0)}).prefault({}),agents:q({main:q({model:G()}).optional(),subagent:q({model:G()}).optional()}).optional(),maxSubagents:K().int().min(1).max(16).default(3),maxSessions:K().int().min(1).max(1e3).default(50),memory:q({enabled:Oc().default(!0),autoExtract:Oc().default(!0),autoExtractMinChars:K().int().min(200).max(1e5).default(200),scoreThreshold:K().int().min(0).max(12).default(9),autoStoreThreshold:K().int().min(0).max(12).default(11),ignoreStreakLimit:K().int().min(2).max(100).default(5),reviewAutoDismissSeconds:K().int().min(0).max(300).default(5),maxCandidatesPerTask:qc(1).default(1),retrievalTopK:K().int().min(1).max(20).default(5),maxEntries:K().int().min(1).max(1e4).default(200),maxEntryChars:K().int().min(32).max(2e4).default(1e3),maxPromptChars:K().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:xl,execution:q({mode:Gc([`local`,`docker`]).default(`local`),image:G().trim().min(1).default(`node:24-bookworm-slim`),network:Oc().default(!1),memory:G().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:K().positive().max(64).default(2)}).prefault({}),language:G().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:q({showWarnings:Oc().default(!1),evaluationTimeoutMs:K().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:q({main:K().int().min(10).max(500).default(300),subagent:K().int().min(10).max(200).default(100),softLimitFactor:K().min(.5).max(1).default(.8),extendBy:K().int().min(5).max(100).default(50)}).prefault({}),loop:q({maxCycles:K().int().positive().max(1e4).default(100),maxTokens:K().int().positive().max(2**53-1).default(5e5),isolation:qc(`auto`).default(`auto`)}).prefault({}),goal:q({maxRounds:K().int().positive().max(1e4).default(100),maxStallStreak:K().int().positive().max(100).default(3)}).prefault({}),context:q({windowTokens:K().int().positive().default(2e5),reservedOutputTokens:K().int().nonnegative().default(2e4),autoCompactBufferTokens:K().int().nonnegative().default(27e3),warningBufferTokens:K().int().nonnegative().default(2e4),blockingBufferTokens:K().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:K().int().nonnegative().default(5),recentTokens:K().int().nonnegative().default(1e4),recentTextMessages:K().int().nonnegative().default(5),maxRecentTokens:K().int().nonnegative().default(4e4),compactAtChars:K().int().positive().optional(),toolOutputChars:K().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:q({enabled:Oc().default(!1),webhookUrl:G().url().optional()}).prefault({}),evolve:q({promptTop:K().int().min(1).max(10).default(3),minRepeats:K().int().min(2).max(100).default(2),testCommand:G().trim().min(1).default(`npm test`),testTimeoutMs:K().int().min(1e3).max(6e5).default(12e4)}).prefault({})});Object.keys(Dl.shape);var Ol=[`user`,`feedback`,`project`,`reference`],kl=32*1024,Al=64*1024,jl=1024,Ml=24*1024,Nl=56*1024,Pl=4*1024,Fl=12*1024,Il=qc(1),J=sc(),Ll=G().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),Y=Ll,X=Ll,Z=G().refine(e=>Buffer.byteLength(e,`utf8`)<=kl,`Text must not exceed ${kl} UTF-8 bytes`),Rl=Z.refine(e=>e.length>0,`Text must not be empty`),zl=G().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=Pl,`Completion evidence must not exceed ${Pl} UTF-8 bytes`),Bl=q({version:Il,id:J,alias:Y,projectPath:G().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=jl,`Project path must not exceed ${jl} UTF-8 bytes`),connectedAt:Ms(),lastSeenAt:Ms()}).strict();Pc(Bl).max(16),q({version:Il,type:qc(`task`),messageId:J,target:X,goal:Rl}).strict();var Vl=q({version:Il,type:qc(`task-event`),messageId:J,taskId:J,senderId:J,recipientId:J,status:Gc([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Z.optional()}).strict(),Hl=q({version:Il,type:qc(`delivery-receipt`),messageId:J,status:Gc([`delivered`,`duplicate`,`rejected`]),recipientIds:Pc(J).max(16),error:Z.optional()}).strict(),Ul=q({palId:J,required:Oc()}).strict(),Wl=Pc(Ul).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)}}),Gl=q({id:G().min(1).max(128),assigneeId:J,description:Rl,dependsOn:Pc(G().min(1).max(128)).max(32)}).strict(),Kl=q({version:Il,coWorkId:J,epoch:K().int().positive(),goal:Rl,participants:Pc(Ul).min(1).max(16),tasks:Pc(Gl).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 ${Ml} 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}}),ql=Gc([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Jl=q({passed:Oc(),evidence:zl}).strict(),Yl=q({participantId:J,passed:Oc(),detail:zl.optional()}).strict(),Xl=q({version:Il,coWorkId:J,epoch:K().int().positive(),phase:ql,goal:Rl,participants:Pc(Ul).min(1).max(16),integrationOwnerId:J,acceptedParticipantIds:Pc(J).max(16),planHash:G().regex(/^[a-f0-9]{64}$/).nullable(),plan:Kl.nullable(),planAcceptedParticipantIds:Pc(J).max(16),readyParticipantIds:Pc(J).max(16),completedParticipantIds:Pc(J).max(16),completionAssertions:Pc(Yl).max(16),integration:Jl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${Nl} 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 ${Fl} UTF-8 bytes in aggregate`})}),Zl={version:Il,requestId:J};zc(`type`,[q({...Zl,type:qc(`register`),authToken:G().regex(/^[a-f0-9]{64}$/).optional(),presence:Bl}).strict(),q({...Zl,type:qc(`heartbeat`)}).strict(),q({...Zl,type:qc(`list`)}).strict(),q({...Zl,type:qc(`disconnect`)}).strict(),q({...Zl,type:qc(`chat`),messageId:J,target:X,message:Rl}).strict(),q({...Zl,type:qc(`task`),messageId:J,target:X,goal:Rl}).strict(),q({...Zl,type:qc(`cowork-propose`),coWorkId:J,goal:Rl,participants:Wl}).strict(),q({...Zl,type:qc(`cowork-accept`),coWorkId:J,epoch:K().int().positive()}).strict(),q({...Zl,type:qc(`cowork-plan`),plan:Kl}).strict(),q({...Zl,type:qc(`cowork-plan-accept`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/)}).strict(),q({...Zl,type:qc(`cowork-ready`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/)}).strict(),q({...Zl,type:qc(`cowork-complete`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/),passed:Oc(),detail:zl.optional()}).strict(),q({...Zl,type:qc(`cowork-integration`),coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/),passed:Oc(),evidence:zl}).strict(),q({...Zl,type:qc(`cowork-get`),coWorkId:J}).strict(),q({...Zl,type:qc(`cowork-cancel`),coWorkId:J,reason:Rl}).strict()]);var Ql=q({version:Il,type:qc(`ok`),requestId:J,data:Ac()}).strict(),$l=q({version:Il,type:qc(`error`),requestId:J,code:Gc([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Z}).strict(),eu=Lc([q({version:Il,type:qc(`chat-event`),messageId:J,senderId:J,recipientId:J,message:Rl}).strict(),Vl,Hl,q({version:Il,type:qc(`cowork-event`),action:Gc([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:J,coWorkId:J,epoch:K().int().positive(),planHash:G().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Xl}).strict()]);zc(`type`,[Ql,$l,q({version:Il,type:qc(`event`),event:eu}).strict()]),G().refine(e=>Buffer.byteLength(e,`utf8`)<=Al,`Control frame must not exceed ${Al} UTF-8 bytes`);var tu=`model.init.config.login.logout.permissions.skills.plugins.hooks.tasks.finish.compact.clear.paste-image.help.exit.audit.usage.doctor.loop.goal.evolve.mcp.commit.review.explain.ide.memory.remember.forget.forget-cold.global.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work.tool`.split(`.`),nu={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,logout:`Clear stored OAuth credentials and restore configured models`,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`,"paste-image":`Attach the clipboard image explicitly`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,doctor:`Diagnose the local runtime, configuration, tools, plugins, and npm access`,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`,explain:`Explain a symbol for newcomers (AST graph + source + git history)`,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`,global:`Show or edit global coding instructions`,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`,tool:`Run a registered managed tool with a JSON object`},ru={name:``,description:``,body:`# Instructions
136
136
 
137
137
  Describe when and how the agent should use this skill.`,disableModelInvocation:!1};function iu({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(ru),[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!==ru.body:i!==void 0&&(o.description!==i.description||o.body!==i.body||!!o.disableModelInvocation!==i.disableModelInvocation),S=e=>t(e instanceof Error?e.message:String(e)),C=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 w(n):c||(a(void 0),s(ru))},w=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){S(e)}};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listSkills().then(async t=>{e&&(r(t),t[0]!==void 0&&await w(t[0].name))}).catch(S).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let T=()=>{l(!0),a(void 0),s(ru),v(!1)},E=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 C(e.name)}catch(e){S(e)}finally{p(!1)}}},ee=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}),S(n)}},te=async()=>{if(!(i===void 0||f)){p(!0);try{await window.flavorDesktop.deleteSkill(i.name),v(!1),a(void 0),s(ru);let e=await window.flavorDesktop.listSkills();r(e),e[0]!==void 0&&await w(e[0].name)}catch(e){S(e)}finally{p(!1)}}};return(0,R.jsxs)(`section`,{className:`skill-workbench`,"aria-label":`技能管理`,children:[(0,R.jsxs)(`header`,{className:`skill-workbench-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{className:`skill-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`项目能力`}),(0,R.jsx)(`h1`,{children:`技能管理`})]})]}),(0,R.jsxs)(`div`,{className:`skill-health`,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:b}),` / `,n.length,` 已开启`]})]})]}),(0,R.jsxs)(`div`,{className:`skill-workbench-body`,children:[(0,R.jsxs)(`aside`,{className:`skill-catalog`,children:[(0,R.jsxs)(`div`,{className:`skill-catalog-tools`,children:[(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`⌕`}),(0,R.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索技能`})]}),(0,R.jsxs)(`button`,{className:`skill-create`,onClick:T,children:[(0,R.jsx)(`span`,{children:`+`}),` 新建技能`]})]}),(0,R.jsxs)(`div`,{className:`skill-list`,"aria-busy":u,children:[u&&(0,R.jsx)(`p`,{className:`skill-list-empty`,children:`正在读取技能…`}),!u&&y.length===0&&(0,R.jsxs)(`div`,{className:`skill-list-empty`,children:[(0,R.jsx)(`strong`,{children:`没有匹配的技能`}),(0,R.jsx)(`span`,{children:`创建一个项目技能,或调整搜索词。`})]}),y.map(e=>(0,R.jsxs)(`article`,{className:`skill-list-item`,"data-selected":!c&&i?.name===e.name,"data-enabled":e.enabled,children:[(0,R.jsxs)(`button`,{className:`skill-select`,onClick:()=>void w(e.name),children:[(0,R.jsx)(`span`,{className:`skill-glyph`,children:e.name.slice(0,1).toUpperCase()}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.name}),(0,R.jsx)(`small`,{children:e.description})]})]}),(0,R.jsxs)(`label`,{className:`skill-toggle`,title:e.enabled?`关闭后 Agent 无法读取`:`开启后 Agent 可以读取`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void ee(e,t.target.checked)}),(0,R.jsx)(`span`,{})]})]},e.name))]}),(0,R.jsxs)(`p`,{className:`skill-catalog-note`,children:[`启停状态保存在 `,(0,R.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,R.jsx)(`main`,{className:`skill-editor`,children:i===void 0&&!c?(0,R.jsxs)(`div`,{className:`skill-editor-empty`,children:[(0,R.jsx)(`span`,{children:`◇`}),(0,R.jsx)(`h2`,{children:`选择或创建一个技能`}),(0,R.jsx)(`p`,{children:`技能会在任务匹配时为 Agent 注入专门的工作说明。`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`skill-editor-heading`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:c?`新建项目技能`:i?.editable?`项目技能`:i?.source===`global`?`全局技能`:`插件技能`}),(0,R.jsx)(`h2`,{children:c?`定义一项新能力`:i?.name})]}),!c&&i!==void 0&&(0,R.jsxs)(`span`,{className:`skill-status`,"data-enabled":i.enabled,children:[(0,R.jsx)(`i`,{}),i.enabled?`Agent 可读取`:`已隔离`]})]}),!c&&i?.editable===!1&&(0,R.jsx)(`div`,{className:`skill-readonly-note`,children:`此技能由全局目录或插件提供,在此项目中只读。你仍可以为当前项目开启或关闭它。`}),(0,R.jsxs)(`div`,{className:`skill-form`,children:[(0,R.jsxs)(`label`,{children:[(0,R.jsxs)(`span`,{children:[`名称 `,(0,R.jsx)(`small`,{children:`小写字母、数字和连字符`})]}),(0,R.jsx)(`input`,{value:o.name,disabled:!c,onChange:e=>s({...o,name:e.target.value}),placeholder:`code-review`})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsxs)(`span`,{children:[`描述 `,(0,R.jsx)(`small`,{children:`帮助 Agent 判断何时使用`})]}),(0,R.jsx)(`textarea`,{rows:3,value:o.description,disabled:!c&&!i?.editable,onChange:e=>s({...o,description:e.target.value}),placeholder:`在提交代码前检查正确性、安全性与可维护性`})]}),(0,R.jsxs)(`label`,{className:`skill-instructions`,children:[(0,R.jsxs)(`span`,{children:[`SKILL.md 指令 `,(0,R.jsx)(`small`,{children:`支持 Markdown`})]}),(0,R.jsx)(`textarea`,{value:o.body,disabled:!c&&!i?.editable,onChange:e=>s({...o,body:e.target.value}),spellCheck:!1})]}),(0,R.jsxs)(`label`,{className:`manual-invocation`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!o.disableModelInvocation,disabled:!c&&!i?.editable,onChange:e=>s({...o,disableModelInvocation:e.target.checked})}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:`仅允许手动调用`}),(0,R.jsxs)(`small`,{children:[`开启技能,但不让 Agent 自动匹配;仍可通过 /`,o.name||`skill-name`,` 调用。`]})]})]})]}),(0,R.jsxs)(`footer`,{className:`skill-editor-actions`,children:[!c&&i?.editable&&(0,R.jsx)(`button`,{className:`skill-delete`,onClick:()=>v(!0),children:`删除技能`}),c&&(0,R.jsx)(`button`,{onClick:()=>{l(!1),C()},children:`取消`}),(c||i?.editable)&&(0,R.jsx)(`button`,{className:`skill-save`,disabled:!x||f||!o.name.trim()||!o.description.trim()||!o.body.trim(),onClick:()=>void E(),children:f?`正在保存…`:c?`创建技能`:`保存更改`})]})]})})]}),g&&i!==void 0&&(0,R.jsx)(`div`,{className:`skill-delete-layer`,children:(0,R.jsxs)(`div`,{className:`skill-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`skill-delete-title`,children:[(0,R.jsx)(`span`,{children:`!`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`删除项目技能`}),(0,R.jsxs)(`h2`,{id:`skill-delete-title`,children:[`删除“`,i.name,`”?`]}),(0,R.jsx)(`small`,{children:`技能目录及其中的资源会被永久删除,此操作无法撤销。`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{onClick:()=>v(!1),children:`取消`}),(0,R.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void te(),children:f?`正在删除…`:`删除技能`})]})]})]})})]})}var au={user:{label:`用户偏好`,hint:`长期稳定的角色、表达和工作偏好`},feedback:{label:`行为反馈`,hint:`希望 Agent 以后持续遵守的纠正`},project:{label:`项目约定`,hint:`不能只靠代码推导出的规则和决策`},reference:{label:`外部引用`,hint:`以后仍会用到的文档或系统入口`}},ou={enabled:!0,path:``,entries:[]},su={type:`project`,content:``};function cu({heat:e=`normal`,recallTotal:t=0}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`memory-heat-badge`,"data-heat":e,children:e}),(0,R.jsxs)(`span`,{className:`memory-recall-count`,children:[`↻ `,t]})]})}function lu({onClose:e,onError:t}){let[n,r]=(0,_.useState)(ou),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(su),[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)(`all`),[x,S]=(0,_.useState)(!1),C=e=>t(e instanceof Error?e.message:String(e)),w=(0,_.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return n.entries.filter(t=>(g===`all`||t.type===g)&&(y===`all`||t.heat===y)&&(e.length===0||t.content.toLocaleLowerCase().includes(e)||t.id.includes(e)))},[g,y,m,n.entries]),T=c?o.content.trim().length>0:i!==void 0&&(o.type!==i.type||o.content!==i.content),E=(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?su:{type:n.type,content:n.content})},ee=async e=>{let t=await window.flavorDesktop.listMemory();return r(t),E(t,e),t};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listMemory().then(t=>{e&&(r(t),E(t))}).catch(C).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let te=()=>{l(!0),a(void 0),s(su),S(!1)},ne=e=>{l(!1),a(e),s({type:e.type,content:e.content}),S(!1)},re=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 ee(e.id)}catch(e){C(e)}finally{p(!1)}}},ie=async()=>{if(!(i===void 0||f)){p(!0);try{if(!await window.flavorDesktop.deleteMemory(i.id))throw Error(`这条记忆已不存在,请重新载入后再试。`);S(!1),a(void 0),s(su),await ee()}catch(e){C(e)}finally{p(!1)}}},ae=async()=>{let e=n.entries.filter(e=>e.heat===`cold`).length;if(!(e===0||!window.confirm(`删除全部 ${e} 条 cold 记忆?此操作不可撤销。`))){p(!0);try{await window.flavorDesktop.deleteColdMemory(),a(void 0),await ee()}catch(e){C(e)}finally{p(!1)}}};return(0,R.jsxs)(`section`,{className:`memory-workbench`,"aria-label":`长期记忆管理`,children:[(0,R.jsxs)(`header`,{className:`memory-workbench-header`,children:[(0,R.jsxs)(`div`,{className:`memory-heading`,children:[(0,R.jsx)(`button`,{className:`memory-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`项目上下文`}),(0,R.jsx)(`h1`,{children:`长期记忆`})]})]}),(0,R.jsxs)(`div`,{className:`memory-header-actions`,children:[(0,R.jsxs)(`div`,{className:`memory-ledger-status`,"data-enabled":n.enabled,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:n.entries.length}),` 条记忆`]})]}),(0,R.jsx)(`button`,{className:`memory-purge-cold`,disabled:f||!n.entries.some(e=>e.heat===`cold`),onClick:()=>void ae(),children:`清理 cold`})]})]}),(0,R.jsxs)(`div`,{className:`memory-workbench-body`,children:[(0,R.jsxs)(`aside`,{className:`memory-catalog`,children:[(0,R.jsxs)(`div`,{className:`memory-catalog-tools`,children:[(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`⌕`}),(0,R.jsx)(`input`,{"aria-label":`搜索记忆`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索记忆`})]}),(0,R.jsxs)(`button`,{className:`memory-create`,onClick:te,disabled:!n.enabled,children:[(0,R.jsx)(`span`,{children:`+`}),` 新建记忆`]})]}),(0,R.jsxs)(`div`,{className:`memory-index`,"aria-label":`按类型筛选`,children:[(0,R.jsxs)(`button`,{"data-active":g===`all`,onClick:()=>v(`all`),children:[(0,R.jsx)(`span`,{children:`全部`}),(0,R.jsx)(`b`,{children:n.entries.length})]}),Ol.map(e=>(0,R.jsxs)(`button`,{"data-type":e,"data-active":g===e,onClick:()=>v(e),children:[(0,R.jsx)(`span`,{children:au[e].label}),(0,R.jsx)(`b`,{children:n.entries.filter(t=>t.type===e).length})]},e))]}),(0,R.jsx)(`div`,{className:`memory-heat-index`,"aria-label":`按热度筛选`,children:[`all`,`hot`,`normal`,`cold`].map(e=>(0,R.jsxs)(`button`,{"data-active":y===e,"data-heat":e,onClick:()=>b(e),children:[e===`all`?`全部热度`:e,(0,R.jsx)(`b`,{children:e===`all`?n.entries.length:n.entries.filter(t=>t.heat===e).length})]},e))}),(0,R.jsxs)(`div`,{className:`memory-list`,"aria-busy":u,children:[u&&(0,R.jsx)(`p`,{className:`memory-list-empty`,children:`正在读取记忆…`}),!u&&!n.enabled&&(0,R.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,R.jsx)(`strong`,{children:`长期记忆已关闭`}),(0,R.jsx)(`span`,{children:`在项目配置中将 memory.enabled 设为 true 后可维护。`})]}),!u&&n.enabled&&w.length===0&&(0,R.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,R.jsx)(`strong`,{children:n.entries.length===0?`还没有长期记忆`:`没有匹配项`}),(0,R.jsx)(`span`,{children:n.entries.length===0?`新建一条明确、稳定、以后仍有用的信息。`:`尝试其他关键词或类型。`})]}),w.map(e=>(0,R.jsxs)(`button`,{className:`memory-card`,"data-selected":!c&&i?.id===e.id,"data-type":e.type,onClick:()=>ne(e),children:[(0,R.jsxs)(`span`,{className:`memory-card-meta`,children:[(0,R.jsx)(`span`,{className:`memory-card-tab`,children:au[e.type].label}),(0,R.jsx)(cu,{heat:e.heat,recallTotal:e.recallTotal})]}),(0,R.jsx)(`strong`,{children:e.content}),(0,R.jsx)(`code`,{children:e.id})]},e.id))]}),(0,R.jsxs)(`p`,{className:`memory-catalog-note`,children:[`存储于 `,(0,R.jsx)(`code`,{children:n.path||`.flavor/memory/MEMORY.md`})]})]}),(0,R.jsx)(`main`,{className:`memory-editor`,children:n.enabled?i===void 0&&!c?(0,R.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,R.jsx)(`span`,{children:`⌁`}),(0,R.jsx)(`h2`,{children:`建立项目的共同记忆`}),(0,R.jsx)(`p`,{children:`保存少量稳定事实。当前指令和仓库内容始终优先。`}),(0,R.jsx)(`button`,{onClick:te,children:`新建第一条记忆`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`memory-editor-heading`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:c?`新记忆`:`记忆 ${i?.id}`}),(0,R.jsx)(`h2`,{children:c?`记录一件以后仍有用的事`:au[o.type].label})]}),(0,R.jsx)(`span`,{className:`memory-type-seal`,"data-type":o.type,children:o.type})]}),(0,R.jsxs)(`div`,{className:`memory-priority-note`,children:[(0,R.jsx)(`span`,{children:`i`}),(0,R.jsx)(`p`,{children:`记忆是历史背景,不是强制指令。新建或修改后,从下一次模型请求开始生效。`})]}),(0,R.jsxs)(`div`,{className:`memory-form`,children:[(0,R.jsxs)(`fieldset`,{children:[(0,R.jsx)(`legend`,{children:`记忆类型`}),(0,R.jsx)(`div`,{className:`memory-type-options`,children:Ol.map(e=>(0,R.jsxs)(`label`,{"data-type":e,"data-selected":o.type===e,children:[(0,R.jsx)(`input`,{type:`radio`,name:`memory-type`,value:e,checked:o.type===e,onChange:()=>s({...o,type:e})}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:au[e].label}),(0,R.jsx)(`small`,{children:au[e].hint})]})]},e))})]}),(0,R.jsxs)(`label`,{className:`memory-content-field`,children:[(0,R.jsxs)(`span`,{children:[`内容 `,(0,R.jsx)(`small`,{children:`只写一件事,避免密码、Token 和临时任务状态`})]}),(0,R.jsx)(`textarea`,{autoFocus:!0,value:o.content,maxLength:2e4,onChange:e=>s({...o,content:e.target.value}),placeholder:`例如:不要在未明确要求时创建 Git 提交。`}),(0,R.jsxs)(`em`,{children:[o.content.length,` 字符`]})]})]}),(0,R.jsxs)(`footer`,{className:`memory-editor-actions`,children:[!c&&(0,R.jsx)(`button`,{className:`memory-delete`,onClick:()=>S(!0),children:`删除记忆`}),c&&(0,R.jsx)(`button`,{onClick:()=>{l(!1),ee()},children:`取消`}),(0,R.jsx)(`button`,{className:`memory-save`,disabled:!T||f||o.content.trim().length===0,onClick:()=>void re(),children:f?`正在保存…`:c?`保存记忆`:`保存更改`})]})]}):(0,R.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,R.jsx)(`span`,{children:`⊘`}),(0,R.jsx)(`h2`,{children:`长期记忆没有启用`}),(0,R.jsx)(`p`,{children:`启用后才能读取和修改项目记忆。`})]})})]}),x&&i!==void 0&&(0,R.jsx)(`div`,{className:`memory-delete-layer`,children:(0,R.jsxs)(`div`,{className:`memory-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`memory-delete-title`,children:[(0,R.jsx)(`span`,{children:`!`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`删除长期记忆`}),(0,R.jsxs)(`h2`,{id:`memory-delete-title`,children:[`删除这条`,au[i.type].label,`?`]}),(0,R.jsx)(`small`,{children:i.content}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{onClick:()=>S(!1),children:`取消`}),(0,R.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ie(),children:f?`正在删除…`:`删除记忆`})]})]})]})})]})}var uu={name:``,transport:`stdio`,enabled:!0,command:``,args:``,env:``,cwd:``,url:``,headers:``,timeoutMs:`60000`};function du({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(uu),[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(fu(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(fu(n)))}).catch(n=>{e||t(yu(n))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[]);let x=e=>{l(!1),a(e.name),s(fu(e))},S=()=>{l(!0),a(void 0),s(uu)},C=async()=>{p(!0);try{let e=await window.flavorDesktop.saveMcpServer(c?void 0:i,pu(o));l(!1),a(e.name),await b(e.name)}catch(e){t(yu(e))}finally{p(!1)}},w=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(fu(t))}catch(e){t(yu(e))}},T=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(uu),await b()}catch(e){t(yu(e))}finally{p(!1)}}},E=n.find(e=>e.name===i);return(0,R.jsxs)(`section`,{className:`mcp-workbench`,"aria-label":`MCP 服务管理`,children:[(0,R.jsxs)(`header`,{className:`mcp-workbench-header`,children:[(0,R.jsxs)(`div`,{className:`mcp-heading`,children:[(0,R.jsx)(`button`,{className:`mcp-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`PROJECT CONNECTIONS`}),(0,R.jsx)(`h1`,{children:`MCP 服务`})]})]}),(0,R.jsxs)(`div`,{className:`mcp-health`,children:[(0,R.jsx)(`i`,{}),`项目配置 `,(0,R.jsx)(`strong`,{children:n.filter(e=>e.enabled).length}),` 已开启`]})]}),(0,R.jsxs)(`div`,{className:`mcp-workbench-body`,children:[(0,R.jsxs)(`aside`,{className:`mcp-catalog`,children:[(0,R.jsxs)(`div`,{className:`mcp-catalog-tools`,children:[(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`⌕`}),(0,R.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索服务`,"aria-label":`搜索服务`})]}),(0,R.jsxs)(`button`,{className:`mcp-create`,onClick:S,children:[(0,R.jsx)(`span`,{children:`+`}),`添加服务`]})]}),(0,R.jsx)(`div`,{className:`mcp-list`,children:u?(0,R.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,R.jsx)(`strong`,{children:`正在读取项目配置`}),(0,R.jsx)(`span`,{children:`.flavor/flavor.json`})]}):y.length===0?(0,R.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,R.jsx)(`strong`,{children:m?`没有匹配的服务`:`还没有项目 MCP 服务`}),(0,R.jsx)(`span`,{children:m?`尝试其他名称或传输类型`:`添加 stdio 或 Streamable HTTP 服务`})]}):y.map(e=>(0,R.jsxs)(`div`,{className:`mcp-list-item`,"data-selected":!c&&i===e.name,"data-transport":e.transport,"data-enabled":e.enabled,children:[(0,R.jsxs)(`button`,{className:`mcp-select`,onClick:()=>x(e),children:[(0,R.jsx)(`span`,{className:`mcp-transport-glyph`,children:e.transport===`stdio`?`>_`:`↗`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.name}),(0,R.jsx)(`small`,{children:e.transport===`stdio`?_u(e.config):vu(e.config)})]})]}),(0,R.jsxs)(`label`,{className:`mcp-toggle`,title:e.enabled?`关闭服务`:`开启服务`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void w(e,t.target.checked),"aria-label":`${e.enabled?`关闭`:`开启`} ${e.name}`}),(0,R.jsx)(`span`,{})]})]},e.name))}),(0,R.jsxs)(`p`,{className:`mcp-catalog-note`,children:[`仅管理项目配置 `,(0,R.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,R.jsx)(`article`,{className:`mcp-editor`,children:c||E!==void 0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mcp-editor-heading`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:c?`NEW CONNECTION`:`SERVICE CONFIGURATION`}),(0,R.jsx)(`h2`,{children:c?`添加 MCP 服务`:i})]}),(0,R.jsx)(`span`,{className:`mcp-transport-seal`,"data-transport":o.transport,children:o.transport})]}),(0,R.jsxs)(`div`,{className:`mcp-lifecycle-note`,children:[(0,R.jsx)(`span`,{children:`↻`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`从下一个任务开始生效`}),(0,R.jsx)(`small`,{children:`现有对话不会因配置更改而中断。`})]})]}),(0,R.jsxs)(`form`,{className:`mcp-form`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,R.jsxs)(`div`,{className:`mcp-form-grid`,children:[(0,R.jsxs)(`label`,{children:[(0,R.jsxs)(`span`,{children:[`服务名称 `,(0,R.jsx)(`small`,{children:`字母、数字、_ 或 -`})]}),(0,R.jsx)(`input`,{value:o.name,onChange:e=>s({...o,name:e.target.value}),required:!0,pattern:`[A-Za-z0-9_-]+`})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`传输方式`}),(0,R.jsxs)(`select`,{value:o.transport,onChange:e=>s({...o,transport:e.target.value}),children:[(0,R.jsx)(`option`,{value:`stdio`,children:`stdio · 本地进程`}),(0,R.jsx)(`option`,{value:`http`,children:`HTTP · 远程服务`})]})]})]}),o.transport===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`启动命令`}),(0,R.jsx)(`input`,{value:o.command,onChange:e=>s({...o,command:e.target.value}),placeholder:`npx`,required:!0})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsxs)(`span`,{children:[`参数 `,(0,R.jsx)(`small`,{children:`每行一个参数`})]}),(0,R.jsx)(`textarea`,{rows:4,value:o.args,onChange:e=>s({...o,args:e.target.value}),placeholder:`-y
138
138
  @modelcontextprotocol/server-filesystem
@@ -147,7 +147,7 @@ Describe when and how the agent should use this skill.`,disableModelInvocation:!
147
147
  `).length+3)),value:xe,onChange:e=>Se(e.target.value),onDoubleClick:e=>e.stopPropagation(),spellCheck:!1})]}):(0,R.jsx)(on,{text:Lu(e)})},e.id)})??(k.prdMarkdown!==void 0&&(0,R.jsx)(on,{text:k.prdMarkdown}))}),(0,R.jsxs)(`section`,{className:`d2c-prd-regenerate`,children:[(0,R.jsx)(`header`,{children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`需要整体调整?`}),(0,R.jsx)(`span`,{children:`描述期望变化,AI 会基于当前 PRD 生成一份新草案。`})]})}),(0,R.jsx)(`textarea`,{rows:3,value:_e,"aria-label":`PRD 重新生成要求`,placeholder:`例如:保留现有范围,补充退款失败后的恢复流程`,onChange:e=>ve(e.target.value)}),(0,R.jsxs)(`footer`,{children:[(0,R.jsx)(`span`,{children:`当前版本不会在生成过程中被覆盖`}),(0,R.jsxs)(`button`,{type:`button`,className:`d2c-prd-regenerate-button`,disabled:Ce||s||_e.trim().length===0,onClick:()=>void nn(),children:[(0,R.jsx)(`i`,{"aria-hidden":`true`,children:`↻`}),`重新生成 PRD`]})]})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`退回意见`}),(0,R.jsx)(`textarea`,{rows:3,value:he,placeholder:`例如:补充退款失败后的恢复路径`,onChange:e=>ge(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:Ce||s||he.trim().length===0,onClick:()=>void L(`prd`,!1),children:`退回修改`}),(0,R.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ce||s,onClick:()=>void L(`prd`,!0),children:`确认 PRD,生成交互稿`})]})]}),k?.plan.phase===`design-generating`&&(0,R.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-invalid":k.validationError?.stage===`design`,"aria-live":`polite`,children:[(0,R.jsx)(`i`,{}),(0,R.jsx)(`div`,{children:k.validationError?.stage===`design`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`strong`,{children:`交互契约未通过预检`}),(0,R.jsx)(`span`,{children:k.validationError.message})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`strong`,{children:`正在生成可交互体验基线`}),(0,R.jsx)(`span`,{children:`视觉、关键状态和行为契约会一起落盘。`})]})}),k.validationError?.stage===`design`?(0,R.jsx)(`button`,{type:`button`,disabled:Ce||s,onClick:()=>void Dt(),children:`自动修复清单`}):(0,R.jsx)(`button`,{type:`button`,onClick:()=>void en(k.plan.task),children:`刷新`})]}),k?.plan.phase===`design-review`&&(0,R.jsxs)(`div`,{className:`d2c-artifact-review d2c-design-review`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`span`,{children:`INTERACTIVE PROTOTYPE`}),(0,R.jsx)(`h3`,{children:`直接体验,再决定是否开发`}),(0,R.jsx)(`p`,{children:`点击、输入并检查主流程和异常状态;确认后它会成为 E2E 中 D2C 视觉还原的设计基线。`})]}),(0,R.jsx)(id,{url:pe.url,onStart:()=>void Qt(k.plan.task)}),(0,R.jsxs)(`div`,{className:`d2c-prototype-tools`,children:[(0,R.jsx)(`span`,{children:pe.running?`● LOOPBACK PREVIEW`:`PREVIEW STOPPED`}),pe.running&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cProductPreview(k.plan.task),children:`浏览器打开`})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`退回意见`}),(0,R.jsx)(`textarea`,{rows:3,value:he,placeholder:`例如:筛选结果缺少空状态,趋势图悬停信息不够明确`,onChange:e=>ge(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:Ce||s||he.trim().length===0,onClick:()=>void L(`design`,!1),children:`退回修改`}),(0,R.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ce||s,onClick:()=>void L(`design`,!0),children:`确认设计,进入 D2C 视觉还原`})]})]}),k?.plan.phase===`ready-for-d2c`&&(0,R.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-ready":`true`,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`设计基线已确认`}),(0,R.jsx)(`span`,{children:`如果生成任务未启动或应用曾关闭,可从这里安全地继续 D2C 视觉还原。`})]}),(0,R.jsx)(`button`,{type:`button`,disabled:Ce||s,onClick:()=>void L(`design`,!0),children:`继续视觉还原 →`})]}),s&&(0,R.jsx)(`p`,{className:`d2c-start-warning`,children:`当前会话正在执行其他任务,完成或中断后可开始 E2E。`})]})]}):yn===`pending`&&a!==void 0?(0,R.jsx)(fd,{pending:a,onOpenLog:e,onInterrupt:t}):(De===`integration`||De===`acceptance`)&&M.running&&M.url!==void 0?(0,R.jsxs)(`main`,{className:`d2c-live-preview`,"aria-label":`Interactive integration preview`,children:[(0,R.jsxs)(`header`,{className:`d2c-live-toolbar`,children:[(0,R.jsxs)(`span`,{className:`d2c-live-state`,children:[(0,R.jsx)(`i`,{}),` LIVE`]}),(0,R.jsx)(`code`,{title:M.url,children:M.url}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>ct(e=>e+1),children:`Refresh`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`Open in browser`})]}),(0,R.jsx)(ad,{url:M.url,reloadKey:st,task:u.report.task})]}):(0,R.jsxs)(`main`,{className:`d2c-canvas-area`,"data-pages":hn.length>1?`multiple`:`single`,children:[u!==void 0&&I!==void 0&&un!==void 0&&dn!==void 0&&(0,R.jsxs)(R.Fragment,{children:[hn.length>1&&(0,R.jsxs)(`nav`,{className:`d2c-page-rail`,"aria-label":`页面评测结果`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`页面`}),(0,R.jsx)(`span`,{children:u.report.page===void 0?``:`${u.report.page.index+1} / ${u.report.page.count}`})]}),(0,R.jsx)(`div`,{children:hn.map(e=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e.reportId===u.report.reportId,"data-selected":e.reportId===u.report.reportId,"data-status":e.evaluationStatus,onClick:()=>void Tt(e),children:[(0,R.jsx)(`span`,{children:e.page?.label??e.reportId}),(0,R.jsx)(`small`,{children:e.evaluationStatus===`invalid`?`待重测`:`${e.total.toFixed(1)} · ${e.issueCount} 项`})]},e.reportId))})]}),(0,R.jsxs)(`div`,{className:`d2c-trust-bar`,"data-status":dn.status,children:[(0,R.jsx)(`strong`,{children:Xu[dn.verdict]}),(0,R.jsx)(`span`,{children:dn.summary}),(0,R.jsx)(`div`,{children:dn.checks.map(e=>(0,R.jsxs)(`span`,{"data-status":e.status,title:e.message,children:[e.status===`pass`?`✓`:e.status===`warn`?`!`:`×`,` `,e.label]},e.key))})]}),(0,R.jsxs)(`div`,{className:`d2c-canvas-toolbar`,children:[(0,R.jsx)(`div`,{className:`d2c-mode-switch`,role:`tablist`,"aria-label":`画布显示模式`,children:fn.map(e=>(0,R.jsx)(`button`,{role:`tab`,"aria-selected":g===e,"data-active":g===e,onClick:()=>v(e),children:Yu[e]},e))}),g===`overlay`&&(0,R.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-overlay`,children:[(0,R.jsxs)(`span`,{children:[`实现 `,Math.round(y*100),`%`]}),(0,R.jsx)(`input`,{type:`range`,min:0,max:100,value:Math.round(y*100),onChange:e=>b(Number(e.target.value)/100)})]}),g===`wipe`&&(0,R.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-wipe`,children:[(0,R.jsxs)(`span`,{children:[`分界 `,x,`%`]}),(0,R.jsx)(`input`,{type:`range`,min:0,max:100,value:x,onChange:e=>S(Number(e.target.value))})]}),(0,R.jsxs)(`div`,{className:`d2c-zoom-tools`,"aria-label":`缩放控制`,children:[(0,R.jsx)(`button`,{onClick:()=>Ft(1/1.2),"aria-label":`缩小`,children:`−`}),(0,R.jsx)(`button`,{onClick:Lt,children:`100%`}),(0,R.jsx)(`button`,{onClick:wt,children:`适应`}),(0,R.jsx)(`button`,{onClick:()=>Ft(1.2),"aria-label":`放大`,children:`+`}),(0,R.jsxs)(`output`,{children:[Math.round(P.scale*100),`%`]})]})]}),(0,R.jsxs)(`div`,{className:`d2c-canvas-viewport`,ref:ft,tabIndex:0,"aria-label":`差异画布。滚轮缩放,拖动平移,F 适应,0 显示 100%。`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();Ft(Math.exp(-e.deltaY*.0015),{x:e.clientX-t.left,y:e.clientY-t.top},!1),vt.current!==void 0&&clearTimeout(vt.current),vt.current=setTimeout(()=>{dt({...gt.current}),vt.current=void 0},120)},onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),yt.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:gt.current.x,originY:gt.current.y},e.currentTarget.dataset.dragging=`true`)},onPointerMove:e=>{let t=yt.current;t===void 0||t.pointerId!==e.pointerId||Ct({...gt.current,x:t.originX+e.clientX-t.x,y:t.originY+e.clientY-t.y},!1)},onPointerUp:e=>{yt.current?.pointerId===e.pointerId&&(yt.current=void 0,e.currentTarget.dataset.dragging=`false`,dt({...gt.current}))},onKeyDown:e=>{if(e.key===`+`||e.key===`=`)Ft(1.2);else if(e.key===`-`)Ft(1/1.2);else if(e.key===`0`)Lt();else if(e.key.toLowerCase()===`f`)wt();else if(e.key.toLowerCase()===`b`&&bt.current===void 0)bt.current=g,v(`blink`);else if(/^[1-6]$/.test(e.key)){let t=fn[Number(e.key)-1];t!==void 0&&v(t)}},onKeyUp:e=>{e.key.toLowerCase()===`b`&&bt.current!==void 0&&(v(bt.current),bt.current=void 0)},children:[(0,R.jsxs)(`div`,{className:`d2c-canvas-stage d2c-mode-${g}`,ref:ht,style:{width:I.width,height:I.height,"--d2c-scale":P.scale,"--d2c-x":`${P.x}px`,"--d2c-y":`${P.y}px`,"--d2c-impl-opacity":y,"--d2c-wipe":`${x}%`},children:[(0,R.jsx)(`img`,{className:`d2c-layer d2c-layer-design`,src:u.designPng,alt:`设计稿截图`,draggable:!1}),(0,R.jsx)(`img`,{className:`d2c-layer d2c-layer-impl`,src:u.implementationPng,alt:`实现截图`,draggable:!1}),(0,R.jsx)(`img`,{className:`d2c-layer d2c-layer-heatmap`,src:u.heatmapPng,alt:`像素差异热力图`,draggable:!1}),dn.status===`invalid`&&(0,R.jsx)(`div`,{className:`d2c-invalid-capture-badge`,children:`错误现场 · 不参与评分`}),g===`wipe`&&(0,R.jsx)(`button`,{className:`d2c-wipe-handle`,"aria-label":`拖动拉帘分界,当前 ${Math.round(x)}%`,onPointerDown:e=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&It(e.clientX,!1)},onPointerUp:e=>{It(e.clientX,!0),e.currentTarget.releasePointerCapture(e.pointerId)},children:(0,R.jsx)(`span`,{})}),(0,R.jsx)(`div`,{className:`d2c-annotations`,"aria-hidden":`true`,children:Nt.map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,R.jsx)(`div`,{className:`d2c-annotation`,"data-kind":e.kind,"data-severity":e.severity,"data-selected":e.fingerprint===C,style:od(t)},e.fingerprint)})}),Mt?.designRect!==void 0&&(0,R.jsx)(`div`,{className:`d2c-focus-box d2c-focus-design`,style:od(Mt.designRect),children:(0,R.jsx)(`span`,{children:`设计`})}),Mt?.implementationRect!==void 0&&(0,R.jsx)(`div`,{className:`d2c-focus-box d2c-focus-implementation`,style:od(Mt.implementationRect),children:(0,R.jsx)(`span`,{children:`实现`})}),Mt?.designRect!==void 0&&Mt.implementationRect!==void 0&&(0,R.jsx)(sd,{design:Mt.designRect,implementation:Mt.implementationRect,canvas:I,scale:P.scale})]}),(0,R.jsx)(`aside`,{className:`d2c-difference-ruler`,"aria-label":`垂直差异分布`,children:kt.slice(0,500).map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,R.jsx)(`button`,{style:{top:`${(t.y+t.height/2)/I.height*100}%`},"data-severity":e.severity,"aria-label":`定位 ${e.label}`,title:e.label,onClick:()=>Pt(e)},e.fingerprint)})}),(0,R.jsx)(`div`,{className:`d2c-canvas-hint`,children:`滚轮缩放 · 拖动平移 · F 适应 · 0 原始尺寸 · 按住 B 闪烁`})]})]}),m&&(0,R.jsx)(`div`,{className:`d2c-loading`,"aria-busy":`true`,children:`正在加载报告…`})]}),yn===`report`&&(0,R.jsx)(`aside`,{className:`d2c-inspector`,"aria-label":`差异检查器`,children:u!==void 0&&I!==void 0&&un!==void 0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`section`,{className:`d2c-inspector-verdict`,"data-verdict":u.report.evaluation.verdict,children:[(0,R.jsx)(`span`,{className:`d2c-verdict-mark`,"aria-hidden":`true`,children:u.report.evaluation.verdict===`pass`?`✓`:u.report.evaluation.verdict===`conditional`?`!`:`×`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`EVALUATION INTERRUPTED`:`PAGE VERDICT`}),(0,R.jsx)(`h2`,{children:u.report.evaluation.verdict===`pass`?kt.length===0?`本页已通过验收`:`已通过,仍可继续优化`:u.report.evaluation.verdict===`conditional`?`有差异需要确认`:u.report.evaluation.verdict===`invalid`?`评测需要重新运行`:`本页尚未通过验收`}),(0,R.jsx)(`span`,{children:u.report.evaluation.summary})]})]}),(0,R.jsxs)(`nav`,{className:`d2c-stage-tabs`,"aria-label":`E2E 交付阶段`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-active":De===`review`,"aria-pressed":De===`review`,onClick:()=>Oe(`review`),children:[(0,R.jsx)(`span`,{children:`04`}),`D2C 视觉还原`]}),(0,R.jsxs)(`button`,{type:`button`,"data-active":De===`integration`,"aria-pressed":De===`integration`,disabled:_n===void 0||!_n.complete||u.report.evaluation.status===`invalid`,title:_n?.complete?`进入接口联调`:`全部差异通过后解锁`,onClick:Vt,children:[(0,R.jsx)(`span`,{children:`05`}),`接口联调`]}),(0,R.jsxs)(`button`,{type:`button`,"data-active":De===`acceptance`,"aria-pressed":De===`acceptance`,disabled:u.workflow.integrationFiles===void 0,title:u.workflow.integrationFiles===void 0?`生成联调代码后解锁`:`进入验收与交付`,onClick:Ht,children:[(0,R.jsx)(`span`,{children:`06—07`}),`验收与交付`]})]}),De===`review`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`section`,{className:`d2c-score-card`,"aria-label":`分项得分`,"data-status":u.report.evaluation.status,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`QUALITY PROFILE`}),(0,R.jsx)(`h2`,{children:`五项质量`})]}),u.report.evaluation.status!==`invalid`&&(0,R.jsxs)(`span`,{children:[Ku.filter(({key:e})=>(un[e]??0)>=.9).length,` / 5 达标`]})]}),u.report.evaluation.status===`invalid`&&(0,R.jsx)(`p`,{className:`d2c-score-invalid`,children:`实现页面渲染失败,当前截图仅用于诊断,不生成正式分数。`}),u.report.evaluation.status!==`invalid`&&(0,R.jsx)(`div`,{className:`d2c-score-list`,children:Ku.map(({key:e,label:t})=>un[e]===void 0?null:(0,R.jsxs)(`div`,{"data-level":nd(un[e]),children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsx)(`i`,{children:(0,R.jsx)(`b`,{style:{"--score":un[e]}})}),(0,R.jsx)(`strong`,{children:Math.round(un[e]*100)})]},e))})]}),u.report.evaluation.status!==`invalid`&&_n!==void 0&&(0,R.jsxs)(`section`,{className:`d2c-review-console`,"data-complete":_n.complete,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`REVIEW QUEUE`}),(0,R.jsx)(`h2`,{children:_n.complete?`视觉审阅已完成`:`等待你的验收`})]}),(0,R.jsxs)(`strong`,{children:[_n.accepted,(0,R.jsxs)(`span`,{children:[` / `,_n.total]})]})]}),(0,R.jsxs)(`div`,{className:`d2c-review-meter`,"aria-label":`已通过 ${_n.accepted},待审 ${_n.pending},退回 ${_n.needsFix}`,children:[(0,R.jsx)(`i`,{style:{"--accepted":_n.total===0?1:_n.accepted/_n.total}}),(0,R.jsxs)(`span`,{children:[`待审 `,(0,R.jsx)(`b`,{children:_n.pending})]}),(0,R.jsxs)(`span`,{children:[`通过 `,(0,R.jsx)(`b`,{children:_n.accepted})]}),(0,R.jsxs)(`span`,{children:[`退回 `,(0,R.jsx)(`b`,{children:_n.needsFix})]})]}),(0,R.jsxs)(`div`,{className:`d2c-review-bulk`,children:[!_n.complete&&(0,R.jsx)(`button`,{type:`button`,disabled:ke||s||kt.length===0,onClick:()=>void zt(kt.map(e=>e.fingerprint),`accepted`),children:`全部跳过(不扣分)`}),!_n.complete&&(0,R.jsx)(`button`,{type:`button`,className:`d2c-review-reject`,disabled:ke||s||kt.length===0,onClick:()=>void zt(kt.map(e=>e.fingerprint),`needs-fix`,`集中修复所有退回差异,仍需严格限制在各自模块文件内。`),children:`全部退回并修复`}),_n.complete&&(0,R.jsxs)(`button`,{type:`button`,className:`d2c-review-next`,onClick:Vt,children:[`进入接口联调 `,(0,R.jsx)(`span`,{children:`→`})]})]})]}),(0,R.jsxs)(`div`,{className:`d2c-issue-heading`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{children:u.report.evaluation.status===`invalid`?`错误诊断`:`差异问题`}),u.report.evaluation.status!==`invalid`&&(0,R.jsxs)(`span`,{children:[jt.length,` / `,kt.length]})]}),u.report.evaluation.status!==`invalid`&&(0,R.jsx)(`div`,{className:`d2c-issue-filters`,children:[`all`,`blocking`,`content`,`geometry`].map(e=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":T===e,"data-active":T===e,onClick:()=>{E(e),te(Fu)},children:[(0,R.jsx)(`span`,{children:qu[e]}),(0,R.jsx)(`small`,{children:At[e]})]},e))})]}),jt.length===0?(0,R.jsxs)(`div`,{className:`d2c-issue-empty`,"data-kind":u.report.evaluation.status===`invalid`?`invalid`:kt.length===0?`clear`:`filtered`,children:[(0,R.jsx)(`span`,{className:`d2c-empty-mark`,"aria-hidden":`true`,children:u.report.evaluation.status===`invalid`?`!`:kt.length===0?`✓`:`⌁`}),(0,R.jsx)(`strong`,{children:u.report.evaluation.status===`invalid`?`等待有效评测`:kt.length===0?`未发现可定位的差异`:`这个筛选下没有问题`}),(0,R.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`修复项目并重新运行 E2E 中的 D2C 视觉还原后,这里会生成可定位的差异清单。`:kt.length===0?`布局、色彩、字体、内容与像素结果均已通过检查。`:`切换分类或显示全部问题,继续检查其他差异。`}),u.report.evaluation.status!==`invalid`&&(0,R.jsxs)(`div`,{className:`d2c-empty-stats`,children:[(0,R.jsxs)(`span`,{children:[`阻断 `,(0,R.jsx)(`b`,{children:At.blocking})]}),(0,R.jsxs)(`span`,{children:[`内容 `,(0,R.jsx)(`b`,{children:At.content})]}),(0,R.jsxs)(`span`,{children:[`几何 `,(0,R.jsx)(`b`,{children:At.geometry})]})]}),u.report.evaluation.status!==`invalid`&&(kt.length===0?(0,R.jsx)(`button`,{type:`button`,onClick:()=>{v(`overlay`),wt()},children:`查看叠加结果`}):(0,R.jsx)(`button`,{type:`button`,onClick:()=>{E(`all`),te(Fu)},children:`显示全部问题`}))]}):(0,R.jsx)(`ol`,{className:`d2c-issue-list`,children:jt.slice(0,ee).map(e=>{let t=vn(e.fingerprint);return(0,R.jsxs)(`li`,{"data-severity":e.severity,"data-selected":C===e.fingerprint,"data-review":t?.decision??`pending`,children:[(0,R.jsxs)(`button`,{className:`d2c-issue-main`,onClick:()=>Pt(e),"aria-pressed":C===e.fingerprint,children:[(0,R.jsx)(`span`,{className:`d2c-impact`,children:t?.decision===`accepted`?`✓`:t?.decision===`needs-fix`?`↻`:e.impact.toFixed(1)}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.label}),ed(e).map(e=>(0,R.jsx)(`small`,{children:e},e))]})]}),C===e.fingerprint&&(0,R.jsxs)(`div`,{className:`d2c-evidence`,children:[(0,R.jsxs)(`div`,{className:`d2c-evidence-pair`,children:[e.designRect!==void 0&&(0,R.jsx)(rd,{src:u.designPng,rect:e.designRect,canvas:I,label:`设计`}),e.implementationRect!==void 0&&(0,R.jsx)(rd,{src:u.implementationPng,rect:e.implementationRect,canvas:I,label:`实现`})]}),(0,R.jsxs)(`div`,{className:`d2c-copy-actions`,children:[e.selector!==void 0&&(0,R.jsx)(`button`,{onClick:()=>Rt(e.selector),children:`复制选择器`}),(0,R.jsx)(`button`,{onClick:()=>Rt(`${e.label}\n${ed(e).join(`
148
148
  `)}\n位置:${JSON.stringify(gn)}`),children:`复制修复线索`})]}),(0,R.jsxs)(`label`,{className:`d2c-review-instruction`,children:[(0,R.jsx)(`span`,{children:`补充修改要求`}),(0,R.jsx)(`textarea`,{rows:2,value:je,placeholder:`例如:保持卡片高度,只调整内部间距`,onChange:e=>Me(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`d2c-review-actions`,children:[(0,R.jsx)(`button`,{type:`button`,className:`d2c-accept`,disabled:ke||s||t?.decision===`accepted`,onClick:()=>void zt([e.fingerprint],`accepted`),children:`跳过(本项不扣分)`}),(0,R.jsx)(`button`,{type:`button`,className:`d2c-fix`,disabled:ke||s,onClick:()=>void zt([e.fingerprint],`needs-fix`,je||void 0),children:`修复并自动视觉复验`})]})]})]},e.fingerprint)})}),jt.length>ee&&(0,R.jsxs)(`button`,{className:`d2c-show-more`,onClick:()=>te(e=>e+Fu),children:[`再显示 `,Math.min(Fu,jt.length-ee),` 条`]})]}):(0,R.jsxs)(`section`,{className:`d2c-integration-panel`,"data-stage":De,"aria-label":De===`acceptance`?`验收与交付`:`接口联调`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`p`,{children:De===`acceptance`?`ACCEPTANCE & DELIVERY`:`API INTEGRATION`}),(0,R.jsx)(`h2`,{children:De===`acceptance`?`验收与交付`:Ne===void 0?u.deliveryOrigin===`requirement`?`自动准备接口契约`:`导入接口描述`:Ne.document.title}),(0,R.jsx)(`span`,{children:De===`acceptance`?`通过自动回放、人工操作与多模态质量门,完成最终交付验收。`:Ne===void 0?u.deliveryOrigin===`requirement`?`根据已确认 PRD 与实现模块生成 OpenAPI,无需手动上传。`:`上传 Swagger / OpenAPI JSON,自动匹配页面模块和接口出入参。`:`${Ne.document.version}${Ne.document.baseUrl?` · ${Ne.document.baseUrl}`:``}`})]}),Ne===void 0?(0,R.jsxs)(`div`,{className:`d2c-api-import`,"data-origin":u.deliveryOrigin,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`{}`}),(0,R.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?`正在根据 PRD 与模块准备 OpenAPI 契约`:`Swagger JSON`}),(0,R.jsx)(`p`,{children:u.deliveryOrigin===`requirement`?`契约会自动生成并映射到当前实现;也可接入已有后端契约覆盖默认结果。`:`支持 Swagger 2.0、OpenAPI 3.0/3.1 和文档内引用。`}),(0,R.jsx)(`button`,{type:`button`,disabled:Fe,onClick:()=>void Ut(),children:Fe?u.deliveryOrigin===`requirement`?`自动准备中…`:`正在解析…`:u.deliveryOrigin===`requirement`?`接入已有 Swagger / OpenAPI`:`选择 swagger.json`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`d2c-api-summary`,children:[(0,R.jsxs)(`span`,{children:[`模块 `,(0,R.jsx)(`b`,{children:Ne.mappings.length})]}),(0,R.jsxs)(`span`,{children:[`自动匹配 `,(0,R.jsx)(`b`,{children:Ne.mappings.filter(e=>e.status===`auto`).length})]}),(0,R.jsxs)(`span`,{children:[`待确认 `,(0,R.jsx)(`b`,{children:Ne.mappings.filter(e=>e.status===`needs-confirmation`).length})]})]}),(0,R.jsx)(`ol`,{className:`d2c-mapping-list`,children:Ne.mappings.map(e=>(0,R.jsxs)(`li`,{"data-status":e.status,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`span`,{children:e.moduleLabel}),(0,R.jsx)(`small`,{children:e.status===`auto`?`自动匹配`:e.status===`confirmed`?`已确认`:`需要确认`})]}),(0,R.jsx)(`select`,{"aria-label":`${e.moduleLabel} 接口`,value:e.operationKey,disabled:Fe,onChange:t=>void Wt(e,t.target.value),children:Ne.document.operations.map(e=>(0,R.jsxs)(`option`,{value:e.id,children:[e.operationId,` · `,e.id]},e.id))}),e.status===`needs-confirmation`&&(0,R.jsx)(`button`,{type:`button`,className:`d2c-confirm-mapping`,disabled:Fe,onClick:()=>void Wt(e,e.operationKey),children:`确认此映射`}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{children:[`请求 `,e.parameters.length+e.requestFields.length,` 字段`]}),(0,R.jsxs)(`span`,{children:[`响应 `,e.responseFields.length,` 字段`]}),(0,R.jsxs)(`b`,{children:[Math.round(e.confidence*100),`%`]})]})]},e.moduleId))}),(0,R.jsxs)(`div`,{className:`d2c-integration-launch`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{children:`接口映射已就绪`}),(0,R.jsx)(`small`,{children:Ne.mappings.some(e=>e.status===`needs-confirmation`)?`仍有接口需要人工确认`:`${Ne.mappings.length} 个模块将接入真实请求链路`})]}),(0,R.jsxs)(`button`,{type:`button`,className:`d2c-generate-integration`,disabled:Fe||Ne.mappings.some(e=>e.status===`needs-confirmation`),onClick:()=>void Gt(),children:[Fe?`正在准备联调…`:u.workflow.integrationFiles===void 0?`生成并开始联调`:`重新生成联调代码`,(0,R.jsx)(`span`,{children:`→`})]})]}),Ne.mappings.some(e=>e.status===`needs-confirmation`)&&(0,R.jsx)(`p`,{className:`d2c-api-hint`,children:`确认所有标记为“需要确认”的接口后即可生成。`}),(0,R.jsxs)(`section`,{className:`d2c-mock-control`,"data-running":Le.running,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?Le.running?`真实后端服务运行中`:`真实后端服务未启动`:Le.running?`本地契约服务运行中`:`本地契约服务未启动`}),(0,R.jsx)(`small`,{children:Le.url??`生成联调代码后可启动`})]})]}),u.workflow.integrationFiles!==void 0&&(0,R.jsx)(`button`,{type:`button`,disabled:Fe||M.running,title:M.running?`请先停止交互页面`:void 0,onClick:()=>void Kt(),children:Le.running?`停止`:`启动`})]}),u.workflow.integrationFiles!==void 0&&(0,R.jsxs)(`section`,{className:`d2c-integration-ready`,"data-running":M.running,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`联调环境已生成`}),(0,R.jsx)(`small`,{children:M.running?`前端页面与后端服务已连接,可进入最终验收。`:`启动联调页面后即可进入自动与人工验收。`})]}),(0,R.jsx)(`button`,{type:`button`,onClick:Ht,children:`进入验收与交付 →`})]}),(0,R.jsxs)(`section`,{className:`d2c-preview-control`,"data-running":M.running,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`INTERACTIVE ACCEPTANCE`}),(0,R.jsx)(`h3`,{children:M.running?`可交互页面运行中`:`等待启动可交互页面`})]}),(0,R.jsx)(`i`,{})]}),(0,R.jsx)(`code`,{children:M.url??`Vite preview not started`}),(0,R.jsxs)(`div`,{className:`d2c-preview-actions`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:Ue||u.workflow.integrationFiles===void 0,onClick:()=>void(M.running?Jt():qt()),children:M.running?`停止页面`:`启动页面`}),(0,R.jsx)(`button`,{type:`button`,disabled:Ue||!M.running,onClick:()=>void Yt(),children:Ge?`可视回放中…`:Ue?`处理中…`:`运行自动验收`}),M.running&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`浏览器打开`})]}),Ge&&(0,R.jsxs)(`div`,{className:`d2c-playback-notice`,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`i`,{"aria-hidden":`true`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:`正在可视化回放`}),(0,R.jsx)(`small`,{children:Ze.configured?`多模态模型正在观察并规划用户旅程;随后青色指针会完成点击、输入、导航和检查。`:`请观察左侧页面:青色指针会依次完成设计契约中的定位、点击、输入和检查。配置多模态模型后可启用自主审阅。`})]})]}),Ve!==void 0&&(0,R.jsxs)(`div`,{className:`d2c-review-plan`,"data-mode":Ve.mode,children:[(0,R.jsx)(`strong`,{children:Ve.mode===`autonomous`?`自主审阅已执行`:Ve.mode===`contract-fallback`?`自主规划失败,已执行设计契约`:`设计契约已执行`}),(0,R.jsxs)(`span`,{children:[Ve.plannedScenarios,` 条用户旅程`,Ve.model?` · ${Ve.model}`:``]}),Ve.summary&&(0,R.jsx)(`p`,{children:Ve.summary}),Ve.warning&&(0,R.jsx)(`p`,{role:`alert`,children:Ve.warning})]}),N!==void 0&&(0,R.jsxs)(`div`,{className:`d2c-test-results`,"data-passed":N.passed,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:N.passed?`自动验收通过`:`${N.failures} 条自动验收失败`}),(0,R.jsxs)(`span`,{children:[N.total,` scenarios · `,N.apiRequestCount,` API requests`]})]}),!N.passed&&(0,R.jsx)(`button`,{type:`button`,disabled:qe!==void 0||s,onClick:()=>void Zt(N.scenarios.filter(e=>!e.passed)),children:qe===`all`?`正在发起修复…`:Ye.trim()?`按要求修复全部`:`修复全部失败`})]}),!N.passed&&(0,R.jsxs)(`label`,{className:`d2c-interaction-repair-guide`,children:[(0,R.jsxs)(`span`,{children:[`补充修复要求 `,(0,R.jsx)(`small`,{children:`可选`})]}),(0,R.jsx)(`textarea`,{rows:3,value:Ye,placeholder:`例如:不要修改接口契约;优先检查登录响应的 data 包装层与会话持久化`,onChange:e=>Xe(e.target.value)}),(0,R.jsx)(`small`,{children:`留空则按失败证据自动修复;填写后会连同请求日志一起交给修复任务。`})]}),(0,R.jsx)(`ol`,{children:N.scenarios.map(e=>(0,R.jsxs)(`li`,{"data-passed":e.passed,children:[(0,R.jsxs)(`span`,{children:[e.passed?`✓`:`×`,` `,e.id]}),(0,R.jsxs)(`small`,{children:[e.apiRequestCount,` API · `,e.durationMs,`ms`]}),e.failure!==void 0&&(0,R.jsx)(`p`,{children:e.failure}),!e.passed&&(0,R.jsx)(`button`,{type:`button`,className:`d2c-fix-scenario`,disabled:qe!==void 0||s,"aria-label":`修复失败场景 ${e.id}`,onClick:()=>void Zt([e]),children:qe===e.id?`正在发起修复…`:Ye.trim()?`按要求修复此项`:`修复此项`})]},e.id))})]}),(0,R.jsxs)(`div`,{className:`d2c-manual-acceptance`,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:`人工验收`}),(0,R.jsx)(`small`,{children:`请直接在左侧页面完成点击、输入和提交流程`})]}),(0,R.jsx)(`button`,{type:`button`,disabled:Ue||!M.running,"data-accepted":u.workflow.interaction?.manualDecision===`accepted`,onClick:()=>void Xt(u.workflow.interaction?.manualDecision!==`accepted`),children:u.workflow.interaction?.manualDecision===`accepted`?`已通过(撤回)`:`确认人工验收通过`})]}),(0,R.jsxs)(`section`,{className:`d2c-quality-gate`,"data-verdict":u.workflow.quality?.verdict??`pending`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`LLM-AS-A-JUDGE`}),(0,R.jsx)(`h3`,{children:`最终质量门`})]}),u.workflow.quality!==void 0&&(0,R.jsx)(`strong`,{children:u.workflow.quality.overallScore.toFixed(1)})]}),!Ze.configured||rt?(0,R.jsxs)(`form`,{className:`d2c-judge-config`,onSubmit:e=>void sn(e),children:[(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`协议`}),(0,R.jsxs)(`select`,{value:at.protocol,onChange:e=>ot(t=>({...t,protocol:e.target.value})),children:[(0,R.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容`}),(0,R.jsx)(`option`,{value:`anthropic`,children:`Anthropic`})]})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`Base URL`}),(0,R.jsx)(`input`,{required:!0,type:`url`,placeholder:`https://api.example.com/v1`,value:at.baseURL,onChange:e=>ot(t=>({...t,baseURL:e.target.value}))})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`模型`}),(0,R.jsx)(`input`,{required:!0,placeholder:`支持视觉的模型名称`,value:at.model,onChange:e=>ot(t=>({...t,model:e.target.value}))})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`API Key`}),(0,R.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,value:at.apiKey,onChange:e=>ot(t=>({...t,apiKey:e.target.value}))})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`通过阈值`}),(0,R.jsx)(`input`,{required:!0,type:`number`,min:0,max:100,value:at.passThreshold,onChange:e=>ot(t=>({...t,passThreshold:Number(e.target.value)}))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{type:`submit`,disabled:$e,children:$e?`保存中…`:`保存多模态模型`}),Ze.configured&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>it(!1),children:`取消`})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`d2c-judge-model`,children:[(0,R.jsx)(`span`,{children:Ze.model}),(0,R.jsxs)(`small`,{children:[Ze.baseURL,` · 阈值 `,Ze.passThreshold]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>it(!0),children:`修改配置`})]}),u.workflow.quality===void 0?(0,R.jsx)(`p`,{children:`可随时评测当前版本;自动与人工验收未通过时,评分只用于诊断,不会放行最终交付。`}):(0,R.jsxs)(`div`,{className:`d2c-quality-result`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`span`,{children:[`视觉质量 `,(0,R.jsx)(`b`,{children:u.workflow.quality.visualScore})]}),(0,R.jsxs)(`span`,{children:[`交互质量 `,(0,R.jsx)(`b`,{children:u.workflow.quality.interactionScore})]}),(0,R.jsxs)(`span`,{children:[`综合得分 `,(0,R.jsx)(`b`,{children:u.workflow.quality.overallScore})]})]}),(0,R.jsx)(`strong`,{children:u.workflow.quality.verdict===`pass`?`质量门通过`:`质量门未通过`}),(0,R.jsx)(`p`,{children:u.workflow.quality.summary}),u.workflow.quality.issues.length>0&&(0,R.jsx)(`ol`,{children:u.workflow.quality.issues.map(e=>(0,R.jsxs)(`li`,{"data-severity":e.severity,"data-decision":e.decision,children:[(0,R.jsx)(`span`,{children:e.description}),(0,R.jsx)(`small`,{children:e.recommendation}),(0,R.jsxs)(`em`,{children:[e.category,` · 影响 `,e.scoreImpact,` 分 · `,e.decision===`skipped`?`已跳过,不扣分`:e.decision===`fixing`?`修复中,完成后自动复验`:`待处理`]}),(0,R.jsxs)(`div`,{className:`d2c-quality-issue-actions`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:tt!==void 0||e.decision===`skipped`,onClick:()=>void ln(e,`skipped`),children:`跳过(不扣分)`}),(0,R.jsx)(`button`,{type:`button`,disabled:tt!==void 0||e.decision===`fixing`,onClick:()=>void ln(e,`fixing`),children:`修复并自动复验`})]})]},e.id))})]}),(0,R.jsx)(`button`,{type:`button`,className:`d2c-run-judge`,disabled:$e||!M.running||u.workflow.interaction?.automated===void 0,title:u.workflow.interaction?.automated===void 0?`至少运行一次自动验收后可评分;验收失败也可以评分诊断`:void 0,onClick:()=>void cn(),children:$e?`AI 评审中…`:u.workflow.quality===void 0?`运行 AI 质量评审`:`重新运行 AI 质量评审`})]})]}),u.workflow.stage===`completed`&&(0,R.jsx)(`p`,{className:`d2c-acceptance-complete`,children:`✓ 自动、人工与多模态质量验收均已完成`})]})]})]})]}):(0,R.jsxs)(`div`,{className:`d2c-inspector-empty`,children:[(0,R.jsx)(`strong`,{children:`问题检查器`}),(0,R.jsx)(`span`,{children:`选择报告后,可按影响度逐项定位和取证。`})]})})]})]})}var md={repository:!1,branch:``,head:``,files:[]};function hd(e,t=!1){let n=e.replace(/\r\n/g,`
149
149
  `).split(`
150
- `);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function gd({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(md),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>hd(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(vd(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=vd(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},T=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(vd(e))}},E=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(vd(e))}};return(0,R.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,R.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{children:`Git 变更`}),(0,R.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,R.jsxs)(`span`,{className:`git-branch`,children:[(0,R.jsx)(`i`,{}),r.branch,(0,R.jsx)(`b`,{children:r.head})]})]}),d?(0,R.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,R.jsxs)(`div`,{className:`git-layout`,children:[(0,R.jsxs)(`aside`,{className:`git-files`,children:[(0,R.jsxs)(`div`,{className:`git-toolbar`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`变更`}),(0,R.jsx)(`span`,{children:r.files.length})]}),(0,R.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,R.jsxs)(`div`,{className:`git-clean`,children:[(0,R.jsx)(`i`,{children:`✓`}),(0,R.jsx)(`strong`,{children:`工作区干净`}),(0,R.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=_d(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,R.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,R.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,R.jsx)(`code`,{"data-state":n,children:n}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{children:t.name}),t.directory&&(0,R.jsx)(`small`,{children:t.directory})]})]}),(0,R.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,R.jsx)(`button`,{onClick:()=>void T(`unstage`,e),children:`取消暂存`}):(0,R.jsx)(`button`,{className:`stage-action`,onClick:()=>void T(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,R.jsx)(`button`,{className:`danger-text`,onClick:()=>void T(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,R.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,R.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{children:`−`}),(0,R.jsx)(`span`,{children:`+`})]}),(0,R.jsx)(`strong`,{children:`选择文件查看差异`}),(0,R.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:`git-diff-header`,children:[(0,R.jsxs)(`div`,{className:`git-diff-title`,children:[(0,R.jsx)(`span`,{children:_d(a.path).directory||`项目根目录`}),(0,R.jsx)(`strong`,{children:_d(a.path).name})]}),(0,R.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,R.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,R.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,R.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,R.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,R.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,R.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,R.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,R.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,R.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,R.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,R.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,R.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,R.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,R.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,R.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,R.jsxs)(`footer`,{className:`git-footer`,children:[(0,R.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,R.jsxs)(`div`,{className:`commit-field`,children:[(0,R.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,R.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,R.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void E(),children:`提交`})]})]})}function _d(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function vd(e){return e instanceof Error?e.message:String(e)}function $(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function yd(e){return Math.min(2.4,Math.max(.55,e))}function bd(e,t,n){let r=yd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function xd(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function Sd(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function Cd(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function wd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function Td(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var Ed=`modulepreload`,Dd=function(e,t){return new URL(e,t).href},Od={},kd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Dd(t,n),t=s(t),t in Od)return;Od[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ed,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ad=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],jd=_.lazy(()=>kd(()=>import(`./interactive-terminal-B6GbpzIn.js`),[],import.meta.url));function Md({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Kd(e.jobs.map(e=>e.label).join(`
150
+ `);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function gd({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(md),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>hd(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(vd(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=vd(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},T=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(vd(e))}},E=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(vd(e))}};return(0,R.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,R.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{children:`Git 变更`}),(0,R.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,R.jsxs)(`span`,{className:`git-branch`,children:[(0,R.jsx)(`i`,{}),r.branch,(0,R.jsx)(`b`,{children:r.head})]})]}),d?(0,R.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,R.jsxs)(`div`,{className:`git-layout`,children:[(0,R.jsxs)(`aside`,{className:`git-files`,children:[(0,R.jsxs)(`div`,{className:`git-toolbar`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`变更`}),(0,R.jsx)(`span`,{children:r.files.length})]}),(0,R.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,R.jsxs)(`div`,{className:`git-clean`,children:[(0,R.jsx)(`i`,{children:`✓`}),(0,R.jsx)(`strong`,{children:`工作区干净`}),(0,R.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=_d(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,R.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,R.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,R.jsx)(`code`,{"data-state":n,children:n}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{children:t.name}),t.directory&&(0,R.jsx)(`small`,{children:t.directory})]})]}),(0,R.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,R.jsx)(`button`,{onClick:()=>void T(`unstage`,e),children:`取消暂存`}):(0,R.jsx)(`button`,{className:`stage-action`,onClick:()=>void T(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,R.jsx)(`button`,{className:`danger-text`,onClick:()=>void T(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,R.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,R.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{children:`−`}),(0,R.jsx)(`span`,{children:`+`})]}),(0,R.jsx)(`strong`,{children:`选择文件查看差异`}),(0,R.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:`git-diff-header`,children:[(0,R.jsxs)(`div`,{className:`git-diff-title`,children:[(0,R.jsx)(`span`,{children:_d(a.path).directory||`项目根目录`}),(0,R.jsx)(`strong`,{children:_d(a.path).name})]}),(0,R.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,R.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,R.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,R.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,R.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,R.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,R.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,R.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,R.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,R.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,R.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,R.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,R.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,R.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,R.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,R.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,R.jsxs)(`footer`,{className:`git-footer`,children:[(0,R.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,R.jsxs)(`div`,{className:`commit-field`,children:[(0,R.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,R.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,R.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void E(),children:`提交`})]})]})}function _d(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function vd(e){return e instanceof Error?e.message:String(e)}function $(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function yd(e){return Math.min(2.4,Math.max(.55,e))}function bd(e,t,n){let r=yd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function xd(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function Sd(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function Cd(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function wd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function Td(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var Ed=`modulepreload`,Dd=function(e,t){return new URL(e,t).href},Od={},kd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Dd(t,n),t=s(t),t in Od)return;Od[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Ed,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ad=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],jd=_.lazy(()=>kd(()=>import(`./interactive-terminal-IjIT3Xoa.js`),[],import.meta.url));function Md({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Kd(e.jobs.map(e=>e.label).join(`
151
151
  `))),c=(0,_.useRef)(new Map),l=e=>s(t=>[...new Set([...t,...Kd(e)])].slice(-20));return(0,_.useEffect)(()=>{let t=!1;return Promise.all(e.jobs.map(async e=>{let n=await window.flavorDesktop.readJob(e.id,c.current.get(e.id)??0).catch(()=>void 0);n===void 0||t||(c.current.set(e.id,n.cursor),l(n.output))})),()=>{t=!0}},[e.jobs]),(0,R.jsxs)(`section`,{className:`agent-workbench manager-view`,children:[(0,R.jsxs)(`header`,{className:`manager-header workbench-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{onClick:t,children:`‹`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`FLAVOR DESKTOP 1.3.4`}),(0,R.jsx)(`h2`,{children:`Agent 工作台`})]})]}),(0,R.jsx)(`span`,{children:e.activeSession?.environment===`worktree`?`隔离工作树`:`本地检出`})]}),(0,R.jsx)(`nav`,{className:`workbench-tabs`,"aria-label":`工作台功能`,children:Ad.map(e=>(0,R.jsx)(`button`,{"data-active":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,R.jsxs)(`div`,{className:`workbench-stage`,children:[i===`cockpit`&&(0,R.jsx)(Nd,{snapshot:e,onCompose:r}),i===`timeline`&&(0,R.jsx)(Pd,{onError:n}),i===`terminal`&&(0,R.jsx)(Fd,{onError:n,onDiscover:l}),i===`review`&&(0,R.jsx)(Id,{onError:n,onCompose:r}),i===`preview`&&(0,R.jsx)(Rd,{onError:n,suggestions:o}),i===`context`&&(0,R.jsx)(zd,{snapshot:e,onError:n}),i===`ast`&&(0,R.jsx)(Bd,{onError:n,onCompose:r}),i===`pals`&&(0,R.jsx)(Ud,{onError:n}),i===`worktrees`&&(0,R.jsx)(Wd,{snapshot:e,onError:n})]})]})}function Nd({snapshot:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(()=>void 0)},[e.activeSession?.sessionId]);let o=n?.goals[0];(0,_.useEffect)(()=>{o!==void 0&&a(o.objective)},[o?.id]);let s=e.tasks?.plan?.tasks??[],c=Object.entries(e.tasks?.subagents.states??{});return(0,R.jsxs)(`div`,{className:`cockpit-grid`,children:[(0,R.jsxs)(`section`,{className:`cockpit-trace`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`small`,{children:`EXECUTION TRACE`}),(0,R.jsx)(`h3`,{children:o?.objective??`当前会话尚未启动持久目标`})]}),(0,R.jsx)(`ol`,{children:s.length===0?(0,R.jsxs)(`li`,{"data-state":`pending`,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`等待执行计划`}),(0,R.jsx)(`small`,{children:`TaskPlan 出现后会自动同步`})]})]}):s.map(e=>(0,R.jsxs)(`li`,{"data-state":e.status,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:e.subject}),(0,R.jsxs)(`small`,{children:[e.status,e.result?` · ${e.result}`:``]})]})]},e.id))})]}),(0,R.jsxs)(`aside`,{className:`cockpit-evidence`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`small`,{children:`目标状态`}),(0,R.jsx)(`b`,{"data-phase":o?.phase,children:o?.phase??`idle`}),(0,R.jsx)(`p`,{children:o?`${o.status} · worker ${o.workerRounds} · verify ${o.verifyRounds}`:`使用 /goal 启动带验证的长期任务`}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`textarea`,{className:`cockpit-goal-editor`,value:i,onChange:e=>a(e.target.value),"aria-label":`继续目标`}),(0,R.jsxs)(`div`,{className:`cockpit-goal-actions`,children:[e.activeSession?.busy&&(0,R.jsx)(`button`,{onClick:()=>void window.flavorDesktop.interrupt(),children:`安全暂停`}),(0,R.jsx)(`button`,{disabled:!i.trim(),onClick:()=>t(`/goal ${i.trim()}`),children:`以编辑目标继续`})]})]})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`small`,{children:`协作 Agent`}),c.length===0?(0,R.jsx)(`p`,{children:`没有活跃子 Agent`}):c.map(([e,t])=>(0,R.jsxs)(`div`,{className:`cockpit-row`,children:[(0,R.jsx)(`code`,{children:e}),(0,R.jsx)(`span`,{"data-state":t,children:t})]},e))]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`small`,{children:`后台作业`}),e.jobs.length===0?(0,R.jsx)(`p`,{children:`没有后台作业`}):e.jobs.map(e=>(0,R.jsxs)(`div`,{className:`cockpit-row`,children:[(0,R.jsx)(`code`,{children:e.label}),(0,R.jsx)(`span`,{"data-state":e.state,children:e.state})]},e.id))]}),o&&o.evidenceRounds.length>0&&(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`small`,{children:`验证证据`}),o.evidenceRounds.slice(-3).reverse().map(e=>(0,R.jsxs)(`div`,{className:`cockpit-evidence-round`,children:[(0,R.jsxs)(`b`,{children:[`ROUND `,e.round]}),(0,R.jsx)(`p`,{children:e.hostVerification?.summary??`workspace ${e.workspaceDiffHash.slice(0,10)}`}),(0,R.jsx)(`span`,{"data-passed":e.hostVerification?.passed,children:e.hostVerification===void 0?`workspace evidence`:e.hostVerification.passed?`passed`:`failed`})]},e.round))]}),o&&o.lastGaps.length>0&&(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`small`,{children:`验证缺口`}),o.lastGaps.map((e,t)=>(0,R.jsx)(`p`,{className:`cockpit-gap`,children:e.description},t))]})]})]})}function Pd({onError:e}){let[t,n]=(0,_.useState)({leafId:null,nodes:[]}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>window.flavorDesktop.historySnapshot().then(n).catch(t=>e(Gd(t)));(0,_.useEffect)(()=>{s()},[]);let c=async t=>{o(!0);try{await t(),await s()}catch(t){e(Gd(t))}finally{o(!1)}},l=Cd(t.nodes);return(0,R.jsxs)(`div`,{className:`timeline-layout`,children:[(0,R.jsxs)(`section`,{className:`timeline-canvas`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`small`,{children:`SESSION TREE`}),(0,R.jsxs)(`h3`,{children:[t.nodes.length,` 个可恢复节点`]})]}),(0,R.jsx)(`ol`,{children:l.map(({node:e,depth:n})=>(0,R.jsxs)(`li`,{className:`timeline-node`,style:{paddingLeft:n*26},"data-depth":n,"data-current":e.id===t.leafId,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:e.prompt||e.id}),(0,R.jsxs)(`small`,{children:[new Date(e.createdAt).toLocaleString(),` · `,e.checkpointId]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.rewindHistory(e.id)),children:`回到这里`}),(0,R.jsx)(`button`,{disabled:a,onClick:()=>{window.confirm(`从这个节点建立新分支?当前上下文将切换。`)&&c(()=>window.flavorDesktop.forkHistory(e.id))},children:`Fork`})]})]},e.id))})]}),(0,R.jsxs)(`aside`,{className:`timeline-actions`,children:[(0,R.jsx)(`h3`,{children:`建立安全点`}),(0,R.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`例如:重构前`}),(0,R.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.createCheckpoint(r||void 0)),children:`创建 checkpoint`}),(0,R.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.unrevertHistory()),children:`撤销上次回退`})]})]})}function Fd({onError:e,onDiscover:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),o=n.find(e=>e.id===i),s=(e,t)=>{let n=e.filter(e=>e.state!==`closed`);r(n),a(e=>Td(t??e,n))},c=async e=>s(await window.flavorDesktop.listTerminals(),e);(0,_.useEffect)(()=>{c().catch(t=>e(Gd(t)))},[]);let l=async()=>{try{let e=await window.flavorDesktop.openTerminal();await c(e.id)}catch(t){e(Gd(t))}},u=async()=>{if(i!==void 0)try{await window.flavorDesktop.closeTerminal(i),await c()}catch(t){e(Gd(t))}};return(0,R.jsxs)(`div`,{className:`terminal-layout`,children:[(0,R.jsxs)(`aside`,{children:[(0,R.jsx)(`button`,{className:`primary`,onClick:()=>void l(),children:`+ 新终端`}),n.map(e=>(0,R.jsxs)(`button`,{"data-active":e.id===i,onClick:()=>a(e.id),title:e.shell,children:[(0,R.jsx)(`strong`,{children:wd(e.shell)}),(0,R.jsxs)(`small`,{children:[e.state,` · `,e.id]})]},e.id))]}),(0,R.jsxs)(`main`,{children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`span`,{title:o?.cwd,children:o?.cwd??`尚未打开终端`}),o&&(0,R.jsx)(`button`,{onClick:()=>void u(),children:`关闭终端`})]}),o===void 0?(0,R.jsxs)(`div`,{className:`terminal-empty`,children:[(0,R.jsx)(`b`,{children:`没有打开终端`}),(0,R.jsx)(`span`,{children:`新建终端后,直接在终端区域输入和操作。`})]}):(0,R.jsx)(_.Suspense,{fallback:(0,R.jsxs)(`div`,{className:`terminal-empty`,children:[(0,R.jsx)(`b`,{children:`正在连接终端`}),(0,R.jsx)(`span`,{children:`正在加载交互渲染器…`})]}),children:(0,R.jsx)(jd,{terminal:o,onError:e,onDiscover:t},o.id)})]})]})}function Id({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(`working`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(),m=(0,_.useMemo)(()=>$(o),[o]),h=m.find(e=>e.path===u)??m[0],g=async()=>{l(!0);try{let e=await window.flavorDesktop.gitReview(n,i||void 0);s(e);let t=$(e);d(t[0]?.path),p(t[0]?.hunks[0]?.id)}catch(t){e(Gd(t))}finally{l(!1)}};return(0,_.useEffect)(()=>{if(n===`commit`||n===`base`){s(``),d(void 0),p(void 0);return}g()},[n]),(0,R.jsxs)(`div`,{className:`review-layout`,children:[(0,R.jsxs)(`aside`,{className:`review-scope`,children:[(0,R.jsx)(`small`,{children:`DIFF SCOPE`}),[`working`,`staged`,`last-turn`,`commit`,`base`].map(e=>(0,R.jsx)(`button`,{"data-active":n===e,onClick:()=>r(e),children:e},e)),(n===`commit`||n===`base`)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:n===`base`?`main / origin/main`:`commit SHA`}),(0,R.jsx)(`button`,{onClick:()=>void g(),children:`载入范围`})]})]}),(0,R.jsxs)(`section`,{className:`review-files`,"aria-label":`变更文件`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`strong`,{children:`文件`}),(0,R.jsx)(`span`,{children:m.length})]}),m.map(e=>(0,R.jsxs)(`button`,{"data-active":e.path===h?.path,onClick:()=>{d(e.path),p(e.hunks[0]?.id)},children:[(0,R.jsx)(`strong`,{children:e.path.split(`/`).at(-1)}),(0,R.jsx)(`small`,{children:e.path}),(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`b`,{children:[`+`,e.additions]}),(0,R.jsxs)(`em`,{children:[`-`,e.deletions]})]})]},e.path))]}),(0,R.jsxs)(`main`,{children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:h?.path??n}),(0,R.jsxs)(`span`,{children:[h?.hunks.length??0,` hunks`]})]}),(0,R.jsx)(`button`,{onClick:()=>t(`/review 请审查 ${n}${i?` ${i}`:``}${h?` 中的 ${h.path}`:``},按 P0/P1/P2 分级输出发现,必须给出文件行号和触发场景。`),children:`交给 Agent 审查`})]}),h&&h.hunks.length>0&&(0,R.jsx)(`nav`,{className:`review-hunks`,"aria-label":`Hunk 导航`,children:h.hunks.map((e,t)=>(0,R.jsxs)(`button`,{"data-active":f===e.id,onClick:()=>p(e.id),children:[`H`,t+1,(0,R.jsx)(`span`,{children:e.header})]},e.id))}),(0,R.jsx)(Ld,{file:h,activeHunk:f,loading:c,empty:o}),(0,R.jsxs)(`footer`,{className:`review-priority-legend`,children:[(0,R.jsx)(`span`,{"data-priority":`0`,children:`P0 阻断`}),(0,R.jsx)(`span`,{"data-priority":`1`,children:`P1 高风险`}),(0,R.jsx)(`span`,{"data-priority":`2`,children:`P2 一般`}),(0,R.jsx)(`small`,{children:`审查结果将在对话中返回,并携带文件行号。`})]})]})]})}function Ld({file:e,activeHunk:t,loading:n,empty:r}){return n?(0,R.jsx)(`div`,{className:`review-empty`,children:`正在生成 diff…`}):e===void 0?(0,R.jsx)(`div`,{className:`review-empty`,children:r||`此范围没有差异`}):(0,R.jsx)(`div`,{className:`review-code`,role:`region`,"aria-label":`${e.path} 差异`,children:(0,R.jsx)(`pre`,{children:e.lines.map((n,r)=>{let i=e.hunks.find(e=>r>=e.start&&r<e.end);return(0,R.jsx)(`code`,{"data-kind":n.startsWith(`+++`)||n.startsWith(`---`)?`meta`:n.startsWith(`+`)?`addition`:n.startsWith(`-`)?`deletion`:n.startsWith(`@@`)?`hunk`:`context`,"data-active":i?.id===t,children:n||` `},r)})})})}function Rd({onError:e,suggestions:t}){let[n,r]=(0,_.useState)(`http://localhost:3000`),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(0),c=async()=>{try{a(await window.flavorDesktop.validatePreviewUrl(n))}catch(t){e(Gd(t))}};return(0,R.jsxs)(`div`,{className:`preview-layout`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()}}),(0,R.jsx)(`button`,{onClick:()=>void c(),children:`打开`}),(0,R.jsx)(`button`,{disabled:!i,onClick:()=>s(e=>e+1),children:`刷新`}),(0,R.jsx)(`button`,{disabled:!i,onClick:()=>{i&&window.flavorDesktop.openPreviewUrl(i)},children:`外部打开`}),(0,R.jsx)(`button`,{disabled:!i,onClick:()=>{i&&navigator.clipboard.writeText(i)},children:`复制`})]}),t.length>0&&(0,R.jsxs)(`div`,{className:`preview-suggestions`,children:[`检测到:`,t.map(t=>(0,R.jsx)(`button`,{onClick:()=>{r(t),window.flavorDesktop.validatePreviewUrl(t).then(a).catch(t=>e(Gd(t)))},children:t},t))]}),i?(0,R.jsx)(`iframe`,{src:i,title:`本地应用预览`,sandbox:`allow-forms allow-modals allow-popups allow-scripts allow-same-origin`},o):(0,R.jsxs)(`div`,{className:`preview-empty`,children:[(0,R.jsx)(`strong`,{children:`安全的本地预览`}),(0,R.jsx)(`p`,{children:`仅允许 localhost、127.0.0.1 和 ::1 的 HTTP(S) 地址。`})]})]})}function zd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)();return(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(e=>t(Gd(e)))},[]),(0,R.jsxs)(`div`,{className:`context-grid`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`small`,{children:`RUNTIME`}),(0,R.jsx)(`h3`,{children:`上下文 Epoch`})]}),(0,R.jsxs)(`dl`,{children:[(0,R.jsx)(`dt`,{children:`Permission`}),(0,R.jsx)(`dd`,{children:e.activeSession?.permissionMode??`—`}),(0,R.jsx)(`dt`,{children:`Model`}),(0,R.jsx)(`dd`,{children:e.activeSession?.mainModel??`—`}),(0,R.jsx)(`dt`,{children:`Checkout`}),(0,R.jsx)(`dd`,{children:e.activeSession?.workingDirectory??e.workspace??`—`})]}),n?.context?.epoch!==void 0&&(0,R.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(n.context.epoch,null,2)}),n?.context?.visibility.map((e,t)=>(0,R.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t)),n?.context?.usage.map((e,t)=>(0,R.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},`usage-${t}`)),e.diagnostics.map((e,t)=>(0,R.jsx)(`p`,{className:`context-record`,children:e},`diag-${t}`))]}),(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`small`,{children:`INSTRUCTIONS`}),(0,R.jsx)(`h3`,{children:`生效的项目指令`})]}),n?.instructions.map(e=>(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{children:e.name}),(0,R.jsx)(`pre`,{children:e.content})]},e.path))]}),(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`small`,{children:`SAFETY`}),(0,R.jsx)(`h3`,{children:`权限规则与审计`})]}),n?.permissionFiles.map(e=>(0,R.jsxs)(`details`,{children:[(0,R.jsxs)(`summary`,{children:[e.tier,` · `,e.path]}),(0,R.jsx)(`pre`,{children:e.content})]},e.path)),n?.audit.slice(0,30).map((e,t)=>(0,R.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t))]})]})}function Bd({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(2),[m,h]=(0,_.useState)(!1);(0,_.useEffect)(()=>{window.flavorDesktop.astStatus().then(r).catch(t=>e(Gd(t)))},[]);let g=async()=>{try{s(await window.flavorDesktop.astSearch(i))}catch(t){e(Gd(t))}},v=async(t,n=f)=>{l(t),h(!0);try{d(await window.flavorDesktop.astRelations(t.id,n))}catch(t){e(Gd(t))}finally{h(!1)}},y=c===void 0||u===void 0?void 0:Sd(c,u);return(0,R.jsxs)(`div`,{className:`ast-layout`,children:[(0,R.jsxs)(`aside`,{className:`ast-symbols`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`SYMBOL INDEX`}),(0,R.jsx)(`strong`,{children:`代码索引`})]}),(0,R.jsx)(`span`,{"data-ready":n?.available,children:n?.available?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`b`,{children:n.nodes}),` symbols`,(0,R.jsx)(`br`,{}),(0,R.jsx)(`b`,{children:n.edges}),` edges`]}):`尚未建立索引`})]}),(0,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`⌕`}),(0,R.jsx)(`input`,{"aria-label":`搜索代码符号`,value:i,onChange:e=>a(e.target.value),placeholder:`函数、类型或模块`}),(0,R.jsx)(`button`,{children:`搜索`})]}),(0,R.jsx)(`div`,{className:`ast-symbol-list`,children:o.length===0?(0,R.jsx)(`p`,{children:n?.available===!1?`项目尚未建立代码索引`:`输入名称,定位代码中的关键符号`}):o.map(e=>(0,R.jsxs)(`button`,{"data-active":e.id===c?.id,onClick:()=>void v(e),children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.name}),(0,R.jsx)(`em`,{children:e.kind})]}),(0,R.jsxs)(`small`,{children:[e.filePath,`:`,e.startLine]})]},e.id))})]}),(0,R.jsxs)(`main`,{className:`ast-graph-stage`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`RELATION MAP`}),(0,R.jsx)(`h3`,{children:c?.qualifiedName??`代码关系浏览器`}),(0,R.jsx)(`code`,{children:c?`${c.filePath}:${c.startLine}-${c.endLine}`:`搜索并选择一个符号作为图中心`})]}),(0,R.jsxs)(`div`,{className:`ast-depth`,"aria-label":`影响深度`,children:[(0,R.jsx)(`span`,{children:`影响深度`}),[1,2,3,4].map(e=>(0,R.jsx)(`button`,{"aria-label":`${e} 层影响深度`,"data-active":f===e,onClick:()=>{p(e),c&&v(c,e)},children:e},e))]})]}),m?(0,R.jsx)(`div`,{className:`ast-graph-empty`,children:`正在展开关系图…`}):y?(0,R.jsx)(Vd,{graph:y,selected:c,onSelect:e=>void v(e)}):(0,R.jsxs)(`div`,{className:`ast-graph-empty`,children:[(0,R.jsx)(`strong`,{children:`从一个符号开始`}),(0,R.jsx)(`p`,{children:`搜索函数、类或模块,在同一张图上查看调用者、被调用项和多跳影响范围。`})]})]}),(0,R.jsxs)(`aside`,{className:`ast-inspector`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`SYMBOL INSPECTOR`}),(0,R.jsx)(`h3`,{children:c?.name??`未选择符号`})]}),c&&(0,R.jsx)(`span`,{children:c.kind})]}),c?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`dl`,{children:[(0,R.jsx)(`dt`,{children:`语言`}),(0,R.jsx)(`dd`,{children:c.language}),(0,R.jsx)(`dt`,{children:`位置`}),(0,R.jsxs)(`dd`,{children:[c.filePath,`:`,c.startLine]}),c.signature&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`签名`}),(0,R.jsx)(`dd`,{children:c.signature})]})]}),(0,R.jsxs)(`button`,{className:`ast-compose`,onClick:()=>t(`请查看 @${c.filePath}#L${c.startLine}-L${c.endLine} 中的 ${c.qualifiedName}`),children:[(0,R.jsx)(`span`,{children:`加入输入框`}),(0,R.jsx)(`b`,{"aria-hidden":`true`,children:`↗`})]}),(0,R.jsx)(Hd,{title:`Callers`,nodes:u?.callers??[],onSelect:e=>void v(e)}),(0,R.jsx)(Hd,{title:`Callees`,nodes:u?.callees??[],onSelect:e=>void v(e)}),(0,R.jsx)(Hd,{title:`Impact`,nodes:u?.impact??[],onSelect:e=>void v(e)})]}):(0,R.jsx)(`p`,{className:`ast-inspector-empty`,children:`选择一个符号后,这里会显示源码位置和完整关系。`})]})]})}function Vd({graph:e,selected:t,onSelect:n}){let r={x:0,y:0,scale:1},[i,a]=(0,_.useState)(r),[o,s]=(0,_.useState)({width:0,height:0}),[c,l]=(0,_.useState)(!1),u=(0,_.useRef)(null),d=(0,_.useRef)(void 0),f=new Map(e.nodes.map(e=>[e.id,e]));(0,_.useEffect)(()=>{a(r)},[t.id]),(0,_.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>{let t=e.getBoundingClientRect();s({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let p=(e,t)=>{let n=u.current?.getBoundingClientRect(),r=t??{x:(n?.width??0)/2,y:(n?.height??0)/2};a(t=>bd(t,r,e))},m=e=>{d.current?.pointerId===e.pointerId&&(d.current=void 0,l(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,R.jsxs)(`div`,{ref:u,className:`ast-graph`,"data-dragging":c,role:`region`,"aria-label":`${t.name} 代码关系图,可拖动和滚轮缩放`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();p(i.scale*Math.exp(-e.deltaY*.0014),{x:e.clientX-t.left,y:e.clientY-t.top})},onPointerDown:e=>{e.button!==0||e.target.closest(`button`)||(e.currentTarget.setPointerCapture(e.pointerId),d.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=d.current;if(t?.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;d.current={...t,x:e.clientX,y:e.clientY},a(e=>({...e,x:e.x+n,y:e.y+r}))},onPointerUp:m,onPointerCancel:m,children:[(0,R.jsx)(`div`,{className:`ast-graph-viewport`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`},children:(0,R.jsx)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.edges.map((e,t)=>{let n=f.get(e.from),r=f.get(e.to);if(!n||!r)return null;let i=(n.x+r.x)/2;return(0,R.jsx)(`path`,{"data-kind":e.kind,d:`M ${n.x} ${n.y} C ${i} ${n.y}, ${i} ${r.y}, ${r.x} ${r.y}`},`${e.from}-${e.to}-${t}`)})})}),e.nodes.map(e=>{let t=xd(e,i,o);return(0,R.jsxs)(`button`,{className:`ast-graph-node`,"data-role":e.role,style:{left:t.x,top:t.y,visibility:o.width>0?`visible`:`hidden`},onClick:()=>n(e),title:`${e.qualifiedName}\n${e.filePath}:${e.startLine}`,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.name}),(0,R.jsx)(`small`,{children:e.role===`impact`?`hop ${e.hop}`:e.kind})]})]},e.id)}),(0,R.jsxs)(`div`,{className:`ast-graph-hint`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`↔`}),` 拖动平移 `,(0,R.jsx)(`i`,{}),` 滚轮缩放`]}),(0,R.jsxs)(`div`,{className:`ast-graph-controls`,"aria-label":`画布缩放`,children:[(0,R.jsx)(`button`,{"aria-label":`放大`,onClick:()=>p(i.scale*1.2),children:`+`}),(0,R.jsxs)(`span`,{children:[Math.round(i.scale*100),`%`]}),(0,R.jsx)(`button`,{"aria-label":`缩小`,onClick:()=>p(i.scale/1.2),children:`−`}),(0,R.jsx)(`button`,{className:`ast-graph-reset`,"aria-label":`复位画布`,onClick:()=>a(r),children:`复位`})]}),(0,R.jsxs)(`div`,{className:`ast-graph-legend`,children:[(0,R.jsx)(`span`,{"data-kind":`caller`,children:`调用者`}),(0,R.jsx)(`span`,{"data-kind":`origin`,children:`中心符号`}),(0,R.jsx)(`span`,{"data-kind":`callee`,children:`被调用`}),(0,R.jsx)(`span`,{"data-kind":`impact`,children:`影响范围`})]})]})}function Hd({title:e,nodes:t,onSelect:n}){return(0,R.jsxs)(`section`,{className:`ast-relation`,children:[(0,R.jsxs)(`h4`,{children:[e,(0,R.jsx)(`span`,{children:t.length})]}),t.length===0?(0,R.jsx)(`p`,{children:`没有关系记录`}):t.slice(0,20).map(e=>(0,R.jsxs)(`button`,{onClick:()=>n(e),children:[(0,R.jsx)(`strong`,{children:e.name}),(0,R.jsxs)(`code`,{children:[e.filePath,`:`,e.startLine]})]},e.id))]})}function Ud({onError:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=()=>window.flavorDesktop.listPals().then(e=>{f(void 0),n(e),i(t=>e.some(e=>e.alias===t)?t:e[0]?.alias)}).catch(e=>{n([]),f(Gd(e))});(0,_.useEffect)(()=>{v();let e=window.setInterval(v,4e3);return()=>window.clearInterval(e)},[]);let y=async(t,n,r)=>{m(t),g(void 0);try{r(await n())}catch(t){e(Gd(t))}finally{m(void 0)}},b=t.find(e=>e.alias===r),x=b?.alias,S=typeof l==`object`&&l?l:void 0,C=typeof S?.coWorkId==`string`?S.coWorkId:void 0,w=typeof S?.status==`string`?S.status:`created`,T=e=>{x===void 0||!a.trim()||y(e,()=>window.flavorDesktop.sendPalMessage(x,a.trim(),e),()=>{o(``),g(e===`chat`?`消息已发送给 ${x}`:`任务已委托给 ${x}`)})};return(0,R.jsxs)(`div`,{className:`pals-layout`,children:[(0,R.jsxs)(`aside`,{children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`LOCAL BROKER`}),(0,R.jsx)(`h3`,{children:`在线 Pals`})]}),(0,R.jsx)(`span`,{children:t.length})]}),d===void 0?t.length===0&&(0,R.jsxs)(`div`,{className:`pals-list-empty`,children:[(0,R.jsx)(`b`,{children:`等待其他实例`}),(0,R.jsx)(`p`,{children:`同一台设备上的 Flavor 实例上线后会出现在这里。`})]}):(0,R.jsxs)(`div`,{className:`pals-unavailable`,children:[(0,R.jsx)(`strong`,{children:`正在恢复本地协作`}),(0,R.jsx)(`p`,{children:`broker 暂时不可用,工作台会自动重试。`}),(0,R.jsx)(`button`,{onClick:()=>void v(),children:`立即重试`})]}),(0,R.jsx)(`div`,{className:`pals-list`,children:t.map(e=>(0,R.jsxs)(`button`,{"data-active":r===e.alias,onClick:()=>{i(e.alias),g(void 0)},children:[(0,R.jsx)(`span`,{className:`pal-presence`,children:(0,R.jsx)(`i`,{})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:e.alias}),(0,R.jsx)(`small`,{title:e.projectPath??e.id,children:e.projectPath??e.id})]}),(0,R.jsx)(`em`,{children:`在线`})]},e.id))})]}),(0,R.jsxs)(`main`,{children:[(0,R.jsxs)(`header`,{className:`pals-channel-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`CO-WORK CHANNEL`}),(0,R.jsx)(`h3`,{children:x??`没有选中 Pal`}),(0,R.jsx)(`p`,{title:b?.projectPath,children:b?.projectPath??`从左侧选择一个在线实例后即可发送消息、委托任务或共同执行目标。`})]}),(0,R.jsxs)(`span`,{"data-online":b!==void 0,children:[(0,R.jsx)(`i`,{}),b===void 0?`等待选择`:`连接正常`]})]}),(0,R.jsxs)(`div`,{className:`pals-compose-grid`,children:[(0,R.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`message`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`span`,{children:`MESSAGE`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{children:`发消息或委托任务`}),(0,R.jsx)(`p`,{children:`同一段内容,可以即时沟通,也可以交给对方独立执行。`})]})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`内容`}),(0,R.jsx)(`textarea`,{"aria-label":`消息或任务内容`,value:a,onChange:e=>o(e.target.value),placeholder:`写下背景、期望结果和必要约束…`})]}),(0,R.jsxs)(`footer`,{children:[(0,R.jsx)(`small`,{children:a.length===0?`建议说明交付结果`:`${a.length} 字符`}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>T(`chat`),children:[(0,R.jsx)(`b`,{children:p===`chat`?`发送中…`:`发送 Chat`}),(0,R.jsx)(`span`,{children:`直接沟通`})]}),(0,R.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>T(`task`),children:[(0,R.jsx)(`b`,{children:p===`task`?`委托中…`:`委托 Task`}),(0,R.jsx)(`span`,{children:`异步执行`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`cowork`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`span`,{children:`CO-WORK`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{children:`共同完成一个目标`}),(0,R.jsx)(`p`,{children:`双方先共同规划,再持续同步执行状态与结果。`})]})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`共同目标`}),(0,R.jsx)(`textarea`,{"aria-label":`共同目标`,value:s,onChange:e=>c(e.target.value),placeholder:`描述目标、完成标准和双方需要协作的部分…`})]}),(0,R.jsxs)(`footer`,{children:[(0,R.jsx)(`small`,{children:s.length===0?`适合跨实例并行工作`:`${s.length} 字符`}),(0,R.jsxs)(`button`,{className:`primary`,disabled:p!==void 0||x===void 0||!s.trim(),onClick:()=>{x===void 0||!s.trim()||y(`cowork`,()=>window.flavorDesktop.startCoWork(x,s.trim()),e=>{u(e),c(``),g(`已与 ${x} 建立共同目标`)})},children:[(0,R.jsx)(`b`,{children:p===`cowork`?`建立中…`:`开始 Co-work`}),(0,R.jsx)(`span`,{children:`共同规划并执行`})]})]})]})]}),h!==void 0&&(0,R.jsxs)(`div`,{className:`pals-notice`,children:[(0,R.jsx)(`i`,{}),` `,h]}),l!==void 0&&(0,R.jsxs)(`section`,{className:`cowork-state`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`LIVE CO-WORK`}),(0,R.jsx)(`strong`,{children:`最新协作状态`})]}),(0,R.jsx)(`span`,{"data-status":w,children:w}),(0,R.jsxs)(`nav`,{children:[(0,R.jsx)(`button`,{disabled:p!==void 0,onClick:()=>void y(`refresh`,()=>window.flavorDesktop.coWorkStatus(C),u),children:`刷新状态`}),C&&(0,R.jsx)(`button`,{className:`danger`,disabled:p!==void 0,onClick:()=>{window.confirm(`取消这个 Co-work?`)&&y(`cancel`,()=>window.flavorDesktop.cancelCoWork(C,`cancelled from desktop workbench`),e=>{u(e),g(`协作已取消`)})},children:`取消协作`})]})]}),(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{children:`查看原始协作数据`}),(0,R.jsx)(`pre`,{children:JSON.stringify(l,null,2)})]})]})]})]})}function Wd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)([]),i=()=>window.flavorDesktop.listWorktrees().then(r).catch(e=>t(Gd(e)));return(0,_.useEffect)(()=>{i()},[]),(0,R.jsxs)(`div`,{className:`worktree-pane`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`small`,{children:`TASK ISOLATION`}),(0,R.jsx)(`h3`,{children:`工作树`}),(0,R.jsx)(`p`,{children:`新任务可在独立分支中运行,不改动当前检出。`})]}),(0,R.jsxs)(`span`,{children:[n.length,` active`]})]}),n.length===0?(0,R.jsx)(`div`,{className:`manager-empty`,children:`还没有隔离工作树。新建任务时选择“隔离工作树”。`}):(0,R.jsx)(`div`,{className:`worktree-list`,children:n.map(n=>(0,R.jsxs)(`article`,{"data-current":e.activeSession?.worktreeId===n.id,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`i`,{}),(0,R.jsx)(`strong`,{children:n.branch}),(0,R.jsx)(`small`,{children:n.path})]}),(0,R.jsx)(`span`,{"data-dirty":n.dirty,children:n.merged?`merged`:n.dirty?`dirty`:`clean`}),(0,R.jsxs)(`div`,{className:`worktree-actions`,children:[(0,R.jsx)(`button`,{disabled:n.dirty||n.merged,onClick:()=>{window.confirm(`将 ${n.branch} 合并回当前项目分支?`)&&window.flavorDesktop.mergeWorktree(n.id).then(i).catch(e=>t(Gd(e)))},children:`合并交付`}),(0,R.jsx)(`button`,{onClick:()=>{window.confirm(`移除工作树 ${n.branch}?${n.dirty?`存在未提交变更,将强制移除。`:`分支会保留。`}`)&&window.flavorDesktop.removeWorktree(n.id,n.dirty).then(i).catch(e=>t(Gd(e)))},children:`移除并保留分支`})]})]},n.id))})]})}function Gd(e){return e instanceof Error?e.message:String(e)}function Kd(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[?::1\]?)(?::\d{1,5})?(?:\/[^\s"'<>]*)?/gi)??[]}var qd={click:`◉`,dblclick:`◎`,fill:`✎`,focus:`⌖`,hover:`✧`,press:`⏎`,select:`▾`,navigate:`⤳`,type:`⌨`,scroll:`↕`,move:`➤`,drag:`⤧`,wheel:`↛`},Jd=0;function Yd(e){let t=e.trim();if(t!==``)return/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)?t:`https://${t}`}function Xd({open:e,setOpen:t,onClose:n,fullscreen:r,setFullscreen:i,onWidth:a}){let[o,s]=(0,_.useState)(void 0),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(void 0),[f,p]=(0,_.useState)([]),m=(0,_.useRef)(void 0),h=(0,_.useRef)(null),g=(0,_.useRef)(e);g.current=e;let v=(0,_.useCallback)(async()=>{try{let e=await window.flavorDesktop.browserListTabs();return m.current=e,s(e),e}catch{m.current=void 0,s(void 0);return}},[]);(0,_.useEffect)(()=>(v(),window.flavorDesktop.onBrowserEvent(e=>{if(e.kind===`activity`){let n=n=>{if(n?.id!==e.spaceId)return;let r={id:++Jd,action:e.action,label:e.label};p([r]),g.current||t(!0)};m.current===void 0?window.flavorDesktop.browserListTabs().then(e=>{m.current=e,s(e),n(e)}).catch(()=>void 0):n(m.current);return}let n=m.current;if(e.kind===`tab-state`&&n?.id===e.spaceId){let t={...n,tabs:n.tabs.map(t=>t.id===e.tabId?{...t,url:e.url,title:e.title,loading:e.loading,canGoBack:e.canGoBack,canGoForward:e.canGoForward,...e.crashed===void 0?{}:{crashed:e.crashed}}:t)};m.current=t,s(t);return}if(e.kind===`ownership-changed`&&n?.id===e.spaceId){let t={...n,ownership:e.ownership};m.current=t,s(t),e.ownership===`user`&&p([]);return}let r=new Set((m.current?.tabs??[]).map(e=>e.id));window.flavorDesktop.browserListTabs().then(n=>{if(m.current=n,s(n),e.kind===`tabs-changed`&&n?.id===e.spaceId&&!g.current){let e=n.tabs.some(e=>!r.has(e.id)),i=r.size>0;(e||!i)&&t(!0)}}).catch(()=>{})})),[v,t]);let y=o===void 0?void 0:o.tabs.find(e=>e.id===o.activeTabId)??o.tabs[0],b=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{y!==void 0&&(b.current===y.id?!y.loading&&document.activeElement?.tagName!==`INPUT`&&l(y.url):(b.current=y.id,l(y.url)))},[y]);let x=(0,_.useRef)(!1),S=(0,_.useCallback)(async()=>{let e=h.current;if(e===null)return!1;let t=e.getBoundingClientRect(),n={x:Math.max(0,Math.round(t.left)),y:Math.max(0,Math.round(t.top)),width:Math.round(t.width),height:Math.round(t.height)};return n.width<2||n.height<2?!1:(await window.flavorDesktop.browserSetBounds(n),!0)},[]);(0,_.useEffect)(()=>{let t=()=>{window.flavorDesktop.browserSetVisible(!1).catch(()=>void 0)};if(!e){t();return}let n=!1,r=()=>{S().then(e=>{if(e&&!n&&!x.current)return window.flavorDesktop.browserSetVisible(!0)}).catch(()=>void 0)},i=requestAnimationFrame(r),a=new ResizeObserver(r);return h.current!==null&&a.observe(h.current),window.addEventListener(`resize`,r),()=>{n=!0,cancelAnimationFrame(i),a.disconnect(),window.removeEventListener(`resize`,r),t()}},[e,S]);let C=e=>{if(r)return;e.preventDefault();let t=h.current?.closest(`.conversation-row`);if(t==null)return;let n=t.getBoundingClientRect(),i=Math.max(440,Math.round(n.width-420));x.current=!0,window.flavorDesktop.browserSetVisible(!1).catch(()=>void 0),document.body.classList.add(`browser-resizing`);let o=e=>{a(Math.max(320,Math.min(i,Math.round(n.right-e.clientX))))},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),document.body.classList.remove(`browser-resizing`),x.current=!1,requestAnimationFrame(()=>{S().then(e=>e?window.flavorDesktop.browserSetVisible(!0):void 0).catch(()=>void 0)})};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s,{once:!0})},w=(0,_.useCallback)((e,t)=>{d(void 0),e.then(()=>void v()).catch(e=>{d(e instanceof Error?e.message:`${t}失败`)})},[v]);if(!e)return null;let T=o?.ownership===`agent`,E=y?.loading===!0?`页面加载中…`:o===void 0?``:T?`等待助手操作…`:`你正在控制浏览器`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`browser-splitter`,role:`separator`,"aria-orientation":`vertical`,title:`拖拽调整浏览器面板宽度`,onPointerDown:C}),(0,R.jsxs)(`aside`,{className:`browser-panel`,"data-fullscreen":r,"aria-label":`内嵌浏览器`,children:[(0,R.jsxs)(`header`,{className:`browser-toolbar`,children:[(0,R.jsx)(`button`,{title:`后退`,disabled:T||y===void 0||!y.canGoBack,onClick:()=>y!==void 0&&w(window.flavorDesktop.browserHistory(y.id,`back`),`后退`),children:`←`}),(0,R.jsx)(`button`,{title:`前进`,disabled:T||y===void 0||!y.canGoForward,onClick:()=>y!==void 0&&w(window.flavorDesktop.browserHistory(y.id,`forward`),`前进`),children:`→`}),(0,R.jsx)(`button`,{title:`刷新`,disabled:T||y===void 0,onClick:()=>y!==void 0&&w(window.flavorDesktop.browserHistory(y.id,`reload`),`刷新`),children:`↻`}),(0,R.jsx)(`form`,{className:`browser-address`,onSubmit:e=>{if(e.preventDefault(),y===void 0){let e=Yd(c);e!==void 0&&w(window.flavorDesktop.browserNewTab(e),`打开页面`);return}let t=Yd(c);t!==void 0&&w(window.flavorDesktop.browserNavigate(y.id,t),`打开页面`)},children:(0,R.jsx)(`input`,{value:c,disabled:T,onChange:e=>{l(e.target.value),b.current=y?.id},placeholder:y===void 0?`输入网址,打开新标签页`:`输入网址后回车`,spellCheck:!1})}),(0,R.jsx)(`button`,{title:`新标签页`,className:`browser-new-tab`,disabled:T,onClick:()=>w(window.flavorDesktop.browserNewTab(),`新建标签页`),children:`+`}),(0,R.jsx)(`button`,{className:`browser-ownership`,"data-agent":T,title:T?`助手正在操作页面;接管后你可以手动浏览`:`把控制权交还给助手`,onClick:()=>w(T?window.flavorDesktop.browserTakeControl():window.flavorDesktop.browserHandOff(),`切换控制权`),children:T?`我来操作`:`交还控制`}),(0,R.jsx)(`button`,{className:`browser-fullscreen`,title:r?`退出全屏`:`浏览器面板全屏`,onClick:()=>{r||a(void 0),i(!r)},children:r?`退出全屏`:`⛶ 全屏`}),(0,R.jsx)(`button`,{title:`关闭浏览器并中断当前任务`,className:`browser-close`,onClick:n,children:`×`})]}),(0,R.jsx)(`nav`,{className:`browser-tabbar`,"aria-label":`浏览器标签页`,children:(o?.tabs??[]).map(e=>(0,R.jsxs)(`div`,{className:`browser-tab-shell`,children:[(0,R.jsxs)(`button`,{className:`browser-tab`,"data-active":e.id===y?.id,title:e.url||e.label,disabled:T,onClick:()=>w(window.flavorDesktop.browserActivateTab(e.id),`切换标签页`),children:[(0,R.jsx)(`span`,{className:`browser-tab-label`,children:e.label}),(0,R.jsxs)(`span`,{className:`browser-tab-title`,children:[e.loading?`加载中…`:e.crashed===!0?`(已崩溃)`:``,e.title||e.url||`空白页`]})]}),(0,R.jsx)(`button`,{className:`browser-tab-close`,title:`关闭 ${e.label}`,"aria-label":`关闭标签页 ${e.label}`,disabled:T,onClick:()=>w(window.flavorDesktop.browserCloseTab(e.id),`关闭标签页`),children:`×`})]},e.id))}),u!==void 0&&(0,R.jsx)(`div`,{className:`browser-error`,role:`alert`,children:u}),(0,R.jsx)(`div`,{className:`browser-status`,"data-live":T,children:f.length===0?(0,R.jsx)(`span`,{className:`browser-status-hint`,children:E}):f.map((e,t)=>(0,R.jsxs)(`div`,{className:`browser-activity`,"data-index":t,children:[(0,R.jsx)(`span`,{className:`browser-activity-icon`,children:qd[e.action]??`•`}),(0,R.jsx)(`span`,{className:`browser-activity-label`,children:e.label}),t===0&&(0,R.jsx)(`span`,{className:`browser-activity-dot`,"aria-label":`助手正在操作`})]},e.id))}),(0,R.jsxs)(`div`,{className:`browser-viewport`,ref:h,children:[o===void 0&&(0,R.jsx)(`div`,{className:`browser-empty`,children:`当前项目还没有运行中的任务,启动任务后浏览器面板会跟随该任务。`}),o!==void 0&&(o.tabs.length===0||y?.url===``)&&(0,R.jsx)(`div`,{className:`browser-empty`,children:`浏览器已就绪。助手打开页面,或你在上方输入网址,页面会显示在这里。`})]})]})]})}function Zd(e,t,n=Date.now()){return{task:e,framework:t,startedAt:n,updatedAt:n,phase:`analyzing`,comparisonCycle:0,activity:[{id:`import`,label:`HTML 设计稿已导入`,state:`completed`,startedAt:n,completedAt:n}]}}function Qd(e,t,n=Date.now()){if(t.type===`model-start`){let r=e.phase===`analyzing`?`分析设计并规划实现`:e.phase===`building`?`检查实现并规划下一步`:`分析评测结果`;return nf(e,{id:`model:${t.id}`,label:r,state:`running`,startedAt:n},n)}if(t.type===`model-end`)return rf(e,`model:${t.id}`,`completed`,n);if(t.type===`tool-start`){let r=ef(t.name,e.phase),i=tf(t.name,t.label,t.hint);return nf({...e,phase:r},{id:`tool:${t.id}`,label:i,state:`running`,startedAt:n,...t.hint===void 0||t.hint===t.label?{}:{detail:af(t.hint,72)}},n)}if(t.type===`tool-end`){let r=t.result.ok?`completed`:`failed`,i=e.activity.find(e=>e.id===`tool:${t.id}`);return i===void 0?nf(e,{id:`tool:${t.id}`,label:tf(t.name,t.label,t.hint),state:r,startedAt:n,completedAt:n},n):rf(e,i.id,r,n)}return t.type===`model-retry`?nf(e,{id:`retry:${t.attempt}`,label:`模型请求重试 ${t.attempt}/${t.maxAttempts}`,detail:`${Math.ceil(t.delayMs/1e3)} 秒后继续`,state:`info`,startedAt:n,completedAt:n},n):t.type===`warning`?nf(e,{id:`warning:${n}`,label:af(t.message,96),state:`info`,startedAt:n,completedAt:n},n):t.type===`error`?nf(e,{id:`error:${n}`,label:af(t.error.message,96),state:`failed`,startedAt:n,completedAt:n},n):e}function $d(e,t,n=Date.now()){if(t.task!==e.task)return e;let r=`engine:${t.cycle}:${t.stage}`,i=e.activity.find(e=>e.id===r);return nf({...e,phase:`evaluating`,comparisonCycle:t.cycle},{id:r,label:t.message,state:t.state,startedAt:i?.startedAt??n,...t.state===`running`?{}:{completedAt:n},...t.cached===!0?{detail:`已复用缓存`}:{}},n)}function ef(e,t){return e===`D2cCompare`?`evaluating`:[`Write`,`Edit`,`ApplyPatch`,`Mkdir`,`Copy`,`Move`,`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`building`:t}function tf(e,t,n){let r=af(t??n??``,60),i=r===``?``:` ${r}`;return[`Read`,`Glob`,`Grep`,`Search`,`List`].includes(e)?`读取${i||`设计与项目文件`}`:e===`Write`?`创建${i||`前端文件`}`:e===`Edit`||e===`ApplyPatch`?`调整${i||`前端实现`}`:e===`Mkdir`?`创建${i||`项目目录`}`:[`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`运行${i||`项目命令`}`:e===`D2cCompare`?`启动视觉评测`:`${e}${i}`}function nf(e,t,n){let r=e.activity.findIndex(e=>e.id===t.id),i=[...e.activity];return r<0?i.push(t):i[r]=t,{...e,updatedAt:n,activity:i.slice(-12)}}function rf(e,t,n,r){let i=e.activity.find(e=>e.id===t);return i===void 0?e:nf(e,{...i,state:n,completedAt:r},r)}function af(e,t){let n=e.replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}var of={sessions:[],diagnostics:[],models:[],jobs:[]},sf=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`],cf=tu.map(e=>({name:e,description:nu[e]})),lf=5,uf=5*1024*1024,df=20*1024*1024,ff=new Set([`image/png`,`image/jpeg`,`image/webp`]),pf=50;function mf(e){let t=[];for(let n of e){let e=t.at(-1);n.type===`session-output`&&e?.type===`session-output`&&n.sessionId===e.sessionId&&n.workspace===e.workspace&&(n.event.type===`text`||n.event.type===`thinking`)&&e.event.type===n.event.type?t[t.length-1]={...n,event:{type:n.event.type,text:e.event.text+n.event.text}}:t.push(n)}return t}function hf(e,t){return[e.trim(),...t.map((e,t)=>`[Image #${t+1}]`)].filter(Boolean).join(`
152
152
  `)}function gf({attachments:e,onRemove:t}){return(0,R.jsx)(`div`,{className:`image-attachment-strip`,"aria-label":`待发送图片`,children:e.map((e,n)=>(0,R.jsxs)(`figure`,{className:`image-attachment-chip`,children:[(0,R.jsx)(`img`,{src:e.previewUrl,alt:e.name}),(0,R.jsxs)(`figcaption`,{children:[(0,R.jsxs)(`strong`,{children:[`[Image #`,n+1,`]`]}),(0,R.jsx)(`span`,{children:e.name})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`移除 ${e.name}`,title:`移除图片`,children:`×`})]},e.id))})}function _f(){let[e,t]=(0,_.useState)(of),[n,r]=(0,_.useState)(E),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(0),[T,te]=(0,_.useState)(),[ne,re]=(0,_.useState)([]),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)(0),[ce,D]=(0,_.useState)(),[O,le]=(0,_.useState)(),[ue,de]=(0,_.useState)(0),[k,A]=(0,_.useState)(`conversation`),[j,fe]=(0,_.useState)(!1),[pe,me]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(void 0),[_e,ve]=(0,_.useState)(),ye=(0,_.useCallback)(e=>{fe(e),e||me(!1)},[]),be=(0,_.useCallback)(()=>{ye(!1);let e=`内嵌浏览器已关闭,相关任务已中断。`;ve(e),r(t=>ee(t,{type:`session`,event:{type:`notice`,message:e}})),window.flavorDesktop.interrupt().catch(e=>{d(e instanceof Error?e.message:`中断任务失败`)})},[ye]),[xe,Se]=(0,_.useState)(!1),[Ce,we]=(0,_.useState)(``),[Te,Ee]=(0,_.useState)(`active`),[De,Oe]=(0,_.useState)(),[ke,Ne]=(0,_.useState)(),[Fe,Ie]=(0,_.useState)(``),[Le,Re]=(0,_.useState)([]),[M,ze]=(0,_.useState)(-1),[N,Be]=(0,_.useState)(0),[Ve,He]=(0,_.useState)(),[Ue,We]=(0,_.useState)(()=>new Map),Ge=(0,_.useRef)(null),Ke=(0,_.useRef)(null),qe=(0,_.useRef)(void 0),Je=(0,_.useRef)(void 0),Ye=(0,_.useRef)(n),Xe=(0,_.useRef)(new Map),Ze=(0,_.useRef)(new Map),Qe=(0,_.useRef)(new Map),$e=(0,_.useRef)(new Set),et=(0,_.useRef)(!1),tt=(0,_.useCallback)(e=>{a(e),te(void 0),D(void 0)},[]);(0,_.useEffect)(()=>{Ye.current=n},[n]);let nt=(0,_.useCallback)(()=>{let e=Je.current;e!==void 0&&(Xe.current.set(e,{sessionId:qe.current,transcript:Ye.current}),qe.current!==void 0&&Ze.current.set(`${e}\u0000${qe.current}`,Ye.current))},[]),rt=(0,_.useCallback)(e=>{e!==void 0&&We(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),it=(0,_.useCallback)(e=>{let n=e.workspace;Je.current=n,qe.current=e.activeSession?.sessionId,t(e);let i=n===void 0?void 0:Xe.current.get(n);r(i!==void 0&&i.sessionId===e.activeSession?.sessionId?i.transcript:E()),rt(n),A(`conversation`),p(!1)},[rt]);(0,_.useEffect)(()=>()=>{for(let e of $e.current)URL.revokeObjectURL(e);$e.current.clear()},[]);let at=(0,_.useCallback)(e=>{s(t=>{let n=t.find(t=>t.id===e);return n!==void 0&&(URL.revokeObjectURL(n.previewUrl),$e.current.delete(n.previewUrl)),t.filter(t=>t.id!==e)})},[]),ot=(0,_.useCallback)(()=>{s(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl),$e.current.delete(t.previewUrl);return[]})},[]),st=(0,_.useCallback)(async e=>{if(e.length===0)return;let t=lf-o.length;if(t<=0||e.length>t){d(`每条消息最多添加 ${lf} 张图片。`);return}if(o.reduce((e,t)=>e+Math.floor(t.dataBase64.length*3/4),0)+e.reduce((e,t)=>e+t.size,0)>df){d(`单条消息的图片总大小不能超过 20 MiB。`);return}try{let t=await Promise.all(e.map(Pf));for(let e of t)$e.current.add(e.previewUrl);s(e=>[...e,...t].slice(0,lf)),d(void 0)}catch(e){d(Xf(e))}},[o]);(0,_.useEffect)(()=>{let e=Ge.current;if(!e)return;let t=e=>{e.deltaY<0?et.current=!0:requestAnimationFrame(()=>{let e=Ge.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<8&&(et.current=!1)})};return e.addEventListener(`wheel`,t,{passive:!0}),()=>e.removeEventListener(`wheel`,t)},[]),(0,_.useEffect)(()=>{let e=[],n,i=e=>{if(e.type===`snapshot`&&e.workspace!==void 0&&e.snapshot.workspace===e.workspace){let t=Je.current;if(t!==void 0&&t!==e.workspace){Xe.current.set(t,{sessionId:qe.current,transcript:Ye.current});let n=Xe.current.get(e.workspace);r(n!==void 0&&n.sessionId===e.snapshot.activeSession?.sessionId?n.transcript:E()),A(`conversation`),rt(e.workspace)}Je.current=e.workspace}else if(e.workspace!==void 0&&(e.workspace!==Je.current||e.type===`session-output`&&e.sessionId!==qe.current||e.type===`session-started`&&e.payload.sessionId!==qe.current)){let t=Xe.current.get(e.workspace)??{sessionId:void 0,transcript:E()};if(e.type===`session-started`){let t=ee(E(),{type:`restore`,state:e.payload.restoredTranscript});Ze.current.set(`${e.workspace}\u0000${e.payload.sessionId}`,t),Xe.current.set(e.workspace,{sessionId:e.payload.sessionId,transcript:t})}else if(e.type===`session-output`){let n=`${e.workspace}\u0000${e.sessionId}`,r=Pe(Ze.current.get(n)??E(),e.sessionId,e);Ze.current.set(n,r),t.sessionId===e.sessionId&&Xe.current.set(e.workspace,{...t,transcript:r})}return}if(e.type===`d2c-report`){Be(e=>e+1),He(t=>t!==void 0&&t.task===e.payload.task?void 0:t),A(`e2e`);return}if(e.type===`d2c-progress`){He(t=>t===void 0?t:$d(t,e.payload));return}e.type===`session-output`&&e.sessionId===qe.current&&He(t=>t===void 0?t:Qd(t,e.event)),(e.type===`session-output`&&e.sessionId===qe.current&&[`done`,`error`,`exit`].includes(e.event.type)||e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===qe.current))&&He(void 0),Sf(e,qe,t,r,d)},a=()=>{n!==void 0&&(clearTimeout(n),n=void 0);let t=mf(e.splice(0));for(let e of t)i(e)},o=window.flavorDesktop.onEvent(t=>{if(e.push(t),!(t.type===`session-output`&&(t.event.type===`text`||t.event.type===`thinking`))){a();return}n??=setTimeout(a,pf)});return window.flavorDesktop.bootstrap().then(e=>{Je.current=e.workspace,qe.current=e.activeSession?.sessionId,t(e)}).catch(e=>d(Xf(e))).finally(()=>l(!1)),()=>{n!==void 0&&clearTimeout(n),o()}},[]),(0,_.useEffect)(()=>{et.current||Ge.current?.scrollTo({top:Ge.current.scrollHeight,behavior:`smooth`})},[n]),(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listFiles().then(t=>{e||ae(On(t))}).catch(()=>{}),()=>{e=!0}},[e.workspace]),(0,_.useEffect)(()=>{let t=!1;return e.workspace===void 0?(re([]),()=>{t=!0}):(window.flavorDesktop.listSkills().then(e=>{t||re(e)}).catch(()=>{t||re([])}),()=>{t=!0})},[e.workspace,k]);let ct=e.activeSession?.busy??!1,lt=(0,_.useMemo)(()=>e.projects??(e.workspace===void 0?[]:[{workspace:e.workspace,sessions:e.sessions,...e.activeSession===void 0?{}:{activeSession:{sessionId:e.activeSession.sessionId,busy:e.activeSession.busy}},running:ct||e.jobs.some(e=>e.state===`running`)}]),[e.projects,e.workspace,e.sessions,e.activeSession,e.jobs,ct]);(0,_.useEffect)(()=>{We(e=>{let t=Me(lt,Qe.current,e);return Qe.current=t.activity,t.notices})},[lt]);let ut=(0,_.useMemo)(()=>mn(cf,[],ne.filter(e=>e.enabled),e.managedTools??[]),[ne,e.managedTools]),P=(0,_.useMemo)(()=>ct||e.approval!==void 0||e.questions!==void 0||T===i?null:gn(i,ue,ut,C),[i,ue,C,T,ct,e.approval,e.questions,ut]),dt=(0,_.useMemo)(()=>ct||e.approval!==void 0||e.questions!==void 0||ce===i||P!==null?null:kn(i,ue,ie,oe),[i,ue,oe,ce,ct,e.approval,e.questions,ie,P]),ft=P===null?hn(i,ut,!1):0,pt=(0,_.useCallback)(e=>{let t=vn(i,ue,e);a(t.text),te(t.text),w(0),de(t.cursor),setTimeout(()=>{let e=Ke.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,ue]),mt=(0,_.useCallback)(()=>{te(i)},[i]),ht=(0,_.useCallback)(e=>{w(t=>_n(t,e,P?.items.length??0))},[P]),gt=(0,_.useCallback)(e=>{let t=jn(i,ue,e);a(t.text),D(t.text),se(0),le(t.span===void 0?void 0:{...t.span,text:t.text.slice(t.span.start,t.span.end)}),de(t.cursor),setTimeout(()=>{let e=Ke.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,ue]),_t=(0,_.useCallback)(()=>{D(i)},[i]),vt=(0,_.useCallback)(e=>{se(t=>An(t,e,dt?.items.length??0))},[dt]),yt=async()=>{d(void 0);try{nt();let e=await window.flavorDesktop.chooseWorkspace();e!==void 0&&(ot(),it(e))}catch(e){d(Xf(e))}},bt=async n=>{if(n===e.workspace)return rt(n),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),A(`conversation`),p(!1),e;d(void 0),nt();try{let e=await window.flavorDesktop.openWorkspace(n);return ot(),it(e),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),e}catch(e){d(Xf(e));return}},xt=async(e,t)=>{let n=await bt(e);if(n!==void 0){if(n.activeSession?.sessionId===t.sessionId){A(`conversation`),p(!1);return}await F(t)}},F=async e=>{d(void 0);try{nt();let n=await window.flavorDesktop.selectSession(e.sessionId),i=n.snapshot.workspace===void 0?void 0:Ze.current.get(`${n.snapshot.workspace}\u0000${n.sessionId}`);t(n.snapshot),Je.current=n.snapshot.workspace,qe.current=n.sessionId,r(i??ee(E(),{type:`restore`,state:n.restoredTranscript})),A(`conversation`),p(!1)}catch(e){d(Xf(e))}},St=async(e,n)=>{d(void 0);try{let i=await window.flavorDesktop.startSession(e?.sessionId,n);ot(),t(i.snapshot),Je.current=i.snapshot.workspace,qe.current=i.sessionId,r(ee(E(),{type:`restore`,state:i.restoredTranscript})),i.snapshot.workspace!==void 0&&Ze.current.set(`${i.snapshot.workspace}\u0000${i.sessionId}`,ee(E(),{type:`restore`,state:i.restoredTranscript})),p(!1),A(`conversation`),setTimeout(()=>Ke.current?.focus(),0)}catch(e){d(Xf(e))}},I=async(n,s,c)=>{let l=(n??i).trim(),u=n===void 0?o:[];if(!l&&u.length===0)return!1;d(void 0);try{let i=e;if(i.activeSession===void 0){let e=await window.flavorDesktop.startSession();i=e.snapshot,t(i),r(ee(E(),{type:`restore`,state:e.restoredTranscript}))}let o=s??(ct?`steer`:`prompt`);if(u.length>0&&o!==`prompt`)throw Error(`图片只能随新消息发送,不能作为运行中的引导或后续消息。`);return o===`prompt`&&r(e=>ee(e,{type:`submit`,prompt:hf(l,u)})),n===void 0&&a(``),await window.flavorDesktop.submit(l,o,u.map(({name:e,mediaType:t,dataBase64:n})=>({name:e,mediaType:t,dataBase64:n})),c),u.length>0&&ot(),!0}catch(e){let t=Xf(e);return d(t),r(e=>ee(e,{type:`submit-error`,message:t})),!1}},Ct=e=>void I(`/permissions ${e}`),wt=async e=>{d(void 0);try{t(await window.flavorDesktop.switchModel(e))}catch(e){d(Xf(e))}},Tt=async()=>{if(!(ct||e.activeSession===void 0)){d(void 0);try{await window.flavorDesktop.finishTask()}catch(e){d(Xf(e))}}},Et=async e=>{d(void 0);try{let n=await window.flavorDesktop.addModel(e);t(n.snapshot)}catch(e){throw d(Xf(e)),e}},Dt=(e,t)=>{let n=t.currentTarget.getBoundingClientRect();window.flavorDesktop.showAppMenu(e,Math.round(n.left),Math.round(n.bottom))},Ot=async()=>{if(!(y===void 0||x)){S(!0),d(void 0);try{let n=y.sessionId===e.activeSession?.sessionId,i=await window.flavorDesktop.deleteSession(y.sessionId);t(i),n&&r(E()),b(void 0),v(void 0)}catch(e){d(Xf(e))}finally{S(!1)}}},kt=async(e,n)=>{try{t(await window.flavorDesktop.updateSession(e.sessionId,n)),v(void 0)}catch(e){d(Xf(e))}},At=e=>{let t=window.prompt(`任务名称`,e.title??Ae(e));t!==null&&kt(e,{title:t.trim()})},jt=async(e,n)=>{try{t(await window.flavorDesktop.updateProject(e,n)),Oe(void 0)}catch(e){d(Xf(e))}},Mt=(e,t)=>{let n=window.prompt(`项目显示名称`,t??je(e));n!==null&&jt(e,{label:n.trim()})},Nt=async(e,t)=>{if(!(t&&!window.confirm(`项目中有任务正在运行。停止任务并关闭项目?`)))try{it(await window.flavorDesktop.closeProject(e,t)),Oe(void 0)}catch(e){d(Xf(e))}},Pt=async(e,t)=>{let n=await bt(e);if(n!==void 0&&t!==void 0){let e=n.sessions.find(e=>e.sessionId===t);e!==void 0&&await F(e)}};(0,_.useEffect)(()=>{let t={...e.workspace===void 0?{}:{workspace:e.workspace},...e.activeSession===void 0?{}:{sessionId:e.activeSession.sessionId},view:k};Re(e=>{let n=e[M];if(n?.workspace===t.workspace&&n?.sessionId===t.sessionId&&n?.view===t.view)return e;let r=[...e.slice(0,M+1),t].slice(-50);return ze(r.length-1),r})},[e.workspace,e.activeSession?.sessionId,k]);let Ft=async e=>{let n=M+e,i=Le[n];if(i!==void 0){if(ze(n),i.workspace!==void 0){let e=await window.flavorDesktop.openWorkspace(i.workspace);if(it(e),i.sessionId!==void 0){let e=await window.flavorDesktop.selectSession(i.sessionId);t(e.snapshot),qe.current=e.sessionId,r(Ze.current.get(`${i.workspace}\u0000${i.sessionId}`)??ee(E(),{type:`restore`,state:e.restoredTranscript}))}}A(i.view)}};return(0,_.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();t===`n`&&(e.preventDefault(),Se(!0)),t===`p`&&(e.preventDefault(),Ne(`projects`),Ie(``)),t===`k`&&(e.preventDefault(),Ne(`commands`),Ie(``)),t===`[`&&(e.preventDefault(),Ft(-1)),t===`]`&&(e.preventDefault(),Ft(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[e.workspace,Le,M]),(0,R.jsxs)(`div`,{className:`app-frame`,children:[(0,R.jsx)(xf,{railCollapsed:m,onToggleRail:()=>h(e=>!e),onMenu:Dt,canBack:M>0,canForward:M<Le.length-1,onBack:()=>void Ft(-1),onForward:()=>void Ft(1)}),(0,R.jsxs)(`div`,{className:`desktop-shell`,"data-rail-collapsed":m,children:[(0,R.jsx)(`button`,{className:`rail-scrim`,"data-open":f,onClick:()=>p(!1),"aria-label":`关闭项目栏`}),(0,R.jsxs)(`aside`,{className:`project-rail`,"data-open":f,children:[(0,R.jsxs)(`div`,{className:`brand-row`,children:[(0,R.jsx)(Yf,{}),(0,R.jsx)(`strong`,{children:`Flavor Code`})]}),(0,R.jsxs)(`nav`,{className:`primary-actions`,"aria-label":`主要操作`,children:[(0,R.jsxs)(`button`,{className:`rail-action rail-action-primary`,disabled:e.workspace===void 0,onClick:()=>Se(!0),children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`plus`})}),(0,R.jsx)(`span`,{children:`新建任务`}),(0,R.jsx)(`kbd`,{children:`Ctrl N`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,onClick:()=>void yt(),children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`folder`})}),(0,R.jsx)(`span`,{children:`打开项目`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`skills`,onClick:()=>{A(`skills`),p(!1)},disabled:e.workspace===void 0,children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`sparkles`})}),(0,R.jsx)(`span`,{children:`技能`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`memory`,onClick:()=>{A(`memory`),p(!1)},disabled:e.workspace===void 0,children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`database`})}),(0,R.jsx)(`span`,{children:`长期记忆`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`mcp`,onClick:()=>{A(`mcp`),p(!1)},disabled:e.workspace===void 0,children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`server`})}),(0,R.jsx)(`span`,{children:`MCP 服务`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`e2e`,onClick:()=>{A(`e2e`),p(!1)},disabled:e.workspace===void 0,children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`checklist`})}),(0,R.jsx)(`span`,{children:`E2E`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`activity`,onClick:()=>{A(`activity`),p(!1)},children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`bell`})}),(0,R.jsx)(`span`,{children:`活动`}),(e.activities?.filter(e=>e.unread).length??0)>0&&(0,R.jsx)(`em`,{className:`rail-badge`,children:e.activities.filter(e=>e.unread).length})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`git`,onClick:()=>{A(`git`),p(!1)},disabled:e.workspace===void 0,children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`git`})}),(0,R.jsx)(`span`,{children:`Git 变更`})]}),(0,R.jsxs)(`button`,{className:`rail-action`,"data-active":k===`workbench`,onClick:()=>{A(`workbench`),p(!1)},disabled:e.workspace===void 0||e.activeSession===void 0,children:[(0,R.jsx)(`span`,{className:`action-icon`,children:(0,R.jsx)(Jf,{name:`checklist`})}),(0,R.jsx)(`span`,{children:`Agent 工作台`})]})]}),(0,R.jsxs)(`div`,{className:`sessions-scroll`,children:[(0,R.jsxs)(`div`,{className:`rail-section-heading`,children:[(0,R.jsx)(`span`,{children:`项目`}),(0,R.jsx)(`button`,{onClick:()=>void yt(),"aria-label":`打开新项目`,title:`打开新项目`,children:(0,R.jsx)(Jf,{name:`plus`})})]}),lt.length>0&&(0,R.jsxs)(`div`,{className:`session-filter`,children:[(0,R.jsxs)(`div`,{className:`session-search`,children:[(0,R.jsx)(Jf,{name:`search`}),(0,R.jsx)(`input`,{value:Ce,onChange:e=>we(e.target.value),placeholder:`搜索任务`,"aria-label":`搜索任务`}),Ce.length>0&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>we(``),"aria-label":`清除搜索`,title:`清除搜索`,children:`×`})]}),(0,R.jsxs)(`div`,{className:`session-group-filter`,children:[(0,R.jsxs)(`select`,{value:Te,onChange:e=>Ee(e.target.value),"aria-label":`按状态筛选`,children:[(0,R.jsx)(`option`,{value:`active`,children:`任务`}),(0,R.jsx)(`option`,{value:`running`,children:`运行`}),(0,R.jsx)(`option`,{value:`unread`,children:`未读`}),(0,R.jsx)(`option`,{value:`archived`,children:`归档`})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`})]})]}),lt.length===0?(0,R.jsx)(`button`,{className:`empty-project`,onClick:()=>void yt(),children:`选择一个本地文件夹开始`}):lt.map(t=>{let n=t.workspace===e.workspace,r=Ue.has(t.workspace);Ue.get(t.workspace);let i=n||t.running||r;return(0,R.jsxs)(`section`,{className:`project-entry`,"data-active":n,children:[(0,R.jsxs)(`div`,{className:`project-heading-shell`,children:[(0,R.jsxs)(`button`,{className:`project-heading`,onClick:()=>void bt(t.workspace),title:t.workspace,children:[(0,R.jsx)(`span`,{className:`folder-icon`,"aria-hidden":`true`,children:(0,R.jsx)(Jf,{name:`folder`})}),(0,R.jsx)(`span`,{children:t.label||je(t.workspace)}),t.running?(0,R.jsx)(`span`,{className:`project-running-dot`,title:`项目中有任务正在执行`}):(t.unreadCount??0)>0&&(0,R.jsx)(`span`,{className:`project-complete-dot`,role:`status`,"aria-label":`项目有未读活动`})]}),(0,R.jsx)(`button`,{className:`project-more`,onClick:()=>Oe(e=>e===t.workspace?void 0:t.workspace),"aria-label":`管理项目`,children:`•••`}),De===t.workspace&&(0,R.jsxs)(`div`,{className:`project-menu`,role:`menu`,children:[(0,R.jsx)(`button`,{onClick:()=>Mt(t.workspace,t.label),children:`修改显示名称`}),(0,R.jsx)(`button`,{onClick:()=>void jt(t.workspace,{pinned:!t.pinned}),children:t.pinned?`取消置顶`:`置顶项目`}),(0,R.jsx)(`button`,{onClick:()=>void window.flavorDesktop.revealProject(t.workspace),children:`在资源管理器中打开`}),(0,R.jsx)(`button`,{onClick:()=>void window.flavorDesktop.copyProjectPath(t.workspace),children:`复制路径`}),(0,R.jsx)(`button`,{className:`danger-item`,onClick:()=>void Nt(t.workspace,t.running),children:`关闭项目`})]})]}),i&&t.sessions.length===0&&(0,R.jsx)(`p`,{className:`no-sessions`,children:`还没有任务`}),i&&t.sessions.filter(e=>(Te===`archived`?e.archived:!e.archived)&&(Te!==`running`||t.runningSessions?.includes(e.sessionId))&&(Te!==`unread`||e.unread)&&(!Ce.trim()||Ae(e).toLowerCase().includes(Ce.trim().toLowerCase()))).map(r=>{let i=n&&r.sessionId===e.activeSession?.sessionId,a=t.runningSessions?.includes(r.sessionId)??(t.running&&r.sessionId===t.activeSession?.sessionId),o=r.unread&&r.activity===`completed`;return(0,R.jsxs)(`div`,{className:`session-item-shell`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},children:[(0,R.jsxs)(`button`,{className:`session-item`,"data-active":i,"data-running":a,disabled:n&&ct&&!i,onClick:()=>void xt(t.workspace,r),children:[(0,R.jsxs)(`span`,{children:[r.pinned&&(0,R.jsx)(`i`,{className:`pin-mark`,children:`◆`}),Ae(r)]}),a?(0,R.jsx)(`span`,{className:`session-spinner`,role:`status`,"aria-label":`任务正在执行`}):o?(0,R.jsx)(`span`,{className:`session-complete-dot`,role:`status`,"aria-label":`任务已完成,点击查看`}):(0,R.jsx)(`time`,{children:ep(r.updatedAt)})]}),n&&(0,R.jsx)(`button`,{className:`session-more`,"aria-label":`管理会话:${Ae(r)}`,"aria-expanded":g===r.sessionId,onClick:()=>v(e=>e===r.sessionId?void 0:r.sessionId),children:`•••`}),n&&g===r.sessionId&&(0,R.jsxs)(`div`,{className:`session-menu`,role:`menu`,children:[(0,R.jsx)(`button`,{role:`menuitem`,onClick:()=>At(r),children:`重命名`}),(0,R.jsx)(`button`,{role:`menuitem`,onClick:()=>void kt(r,{pinned:!r.pinned}),children:r.pinned?`取消置顶`:`置顶`}),(0,R.jsx)(`button`,{role:`menuitem`,onClick:()=>void kt(r,{archived:!r.archived}),children:r.archived?`取消归档`:`归档`}),(0,R.jsx)(`button`,{role:`menuitem`,className:`danger-item`,disabled:ct&&r.sessionId===e.activeSession?.sessionId,onClick:()=>{b(r),v(void 0)},children:`删除会话`})]})]},r.sessionId)})]},t.workspace)})]}),(0,R.jsxs)(`div`,{className:`rail-footer`,children:[(0,R.jsx)(`span`,{className:`avatar`,children:`F`}),(0,R.jsx)(`span`,{children:`本地工作区`}),(0,R.jsx)(`button`,{title:`帮助`,children:`?`})]})]}),(0,R.jsxs)(`main`,{className:`workspace-panel`,"data-browser-open":j,"data-browser-full":j&&pe,style:he===void 0?void 0:{"--browser-w":`${he}px`},children:[k===`workbench`&&e.workspace!==void 0&&e.activeSession!==void 0?(0,R.jsx)(Md,{snapshot:e,onClose:()=>A(`conversation`),onError:d,onCompose:e=>{tt(e),A(`conversation`),setTimeout(()=>Ke.current?.focus(),0)}}):k===`skills`&&e.workspace!==void 0?(0,R.jsx)(iu,{onClose:()=>A(`conversation`),onError:d}):k===`memory`&&e.workspace!==void 0?(0,R.jsx)(lu,{onClose:()=>A(`conversation`),onError:d}):k===`mcp`&&e.workspace!==void 0?(0,R.jsx)(du,{onClose:()=>A(`conversation`),onError:d}):k===`activity`?(0,R.jsx)(vf,{activities:e.activities??[],onClose:()=>A(`conversation`),onOpen:(e,t)=>void Pt(e,t),onClear:()=>void window.flavorDesktop.acknowledgeSession().then(t)}):k===`git`&&e.workspace!==void 0?(0,R.jsx)(gd,{onClose:()=>A(`conversation`),onError:d,onReview:()=>{A(`conversation`),I(`/review`,`prompt`)}}):k===`e2e`&&e.workspace!==void 0?(0,R.jsx)(pd,{onClose:()=>A(`conversation`),onInterrupt:()=>void window.flavorDesktop.interrupt(),onError:d,refreshKey:N,pending:Ve,disabled:ct,onLaunch:(e,t)=>He(Zd(e,t)),onStartTask:e=>I(e,`prompt`,`d2c`)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:`workspace-header`,children:[(0,R.jsx)(`button`,{className:`mobile-rail-toggle`,onClick:()=>p(!0),"aria-label":`打开项目栏`,children:`☰`}),(0,R.jsx)(`div`,{className:`workspace-breadcrumb`,children:(0,R.jsx)(`span`,{children:je(e.workspace)})}),(0,R.jsxs)(`div`,{className:`header-actions`,children:[e.jobs.some(e=>e.state===`running`)&&(0,R.jsxs)(`div`,{className:`job-strip`,title:`后台任务`,children:[(0,R.jsx)(`span`,{className:`job-pulse`}),e.jobs.filter(e=>e.state===`running`).length,` 个后台任务`]}),(0,R.jsx)(`button`,{className:`finish-task-button`,onClick:()=>void Tt(),disabled:ct||e.activeSession===void 0,title:`评估并完成当前任务`,children:`完成任务`}),(0,R.jsx)(`button`,{title:`更多选项`,children:`•••`})]})]}),(e.recoveryItems?.filter(t=>t.workspace===e.workspace).length??0)>0&&(0,R.jsxs)(`div`,{className:`recovery-banner`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:`检测到上次未完成的任务`}),(0,R.jsx)(`span`,{children:`应用异常退出时,这些任务仍在运行。`})]}),e.recoveryItems.filter(t=>t.workspace===e.workspace).map(n=>(0,R.jsxs)(`div`,{className:`recovery-action`,children:[(0,R.jsx)(`code`,{children:Zf(n.sessionId)}),(0,R.jsx)(`button`,{onClick:()=>{let t=e.sessions.find(e=>e.sessionId===n.sessionId);t!==void 0&&F(t)},children:`恢复 / 查看`}),(0,R.jsx)(`button`,{onClick:()=>void window.flavorDesktop.dismissRecovery(n.sessionId).then(t),children:`忽略`})]},n.sessionId))]}),(0,R.jsxs)(`div`,{className:`conversation-row`,children:[(0,R.jsxs)(`div`,{className:`conversation-scroll`,ref:Ge,children:[_e!==void 0&&(0,R.jsxs)(`div`,{className:`browser-close-notice`,role:`status`,children:[(0,R.jsx)(`span`,{children:_e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`关闭提示`,onClick:()=>ve(void 0),children:`×`})]}),c?(0,R.jsx)(Wf,{}):e.workspace===void 0?(0,R.jsx)(Uf,{onOpen:yt}):n.completed.length===0&&n.active===void 0?(0,R.jsx)(Hf,{project:je(e.workspace),onStart:e=>void I(e)}):(0,R.jsxs)(`div`,{className:`conversation-column`,children:[n.completed.length>60&&(0,R.jsxs)(`div`,{className:`transcript-window-notice`,children:[`更早的 `,n.completed.length-60,` 轮仍保存在会话中,已从实时渲染窗口隐藏`]}),n.completed.slice(-60).map(e=>(0,R.jsx)(wf,{turn:e},e.id)),n.active!==void 0&&(0,R.jsx)(wf,{turn:n.active,active:!0})]})]}),(0,R.jsx)(Xd,{open:j,setOpen:ye,onClose:be,fullscreen:pe,setFullscreen:me,onWidth:ge})]}),(0,R.jsx)(jf,{input:i,setInput:tt,onSend:e=>void I(void 0,e),busy:ct,onInterrupt:()=>{He(void 0),window.flavorDesktop.interrupt()},inputRef:Ke,snapshot:e,attachments:o,onAddImages:e=>void st(e),onRemoveImage:at,setModel:wt,addModel:Et,setPermission:Ct,slashCompletion:P,onSlashSelect:pt,onSlashDismiss:mt,onSlashMove:ht,mentionCompletion:dt,onMentionSelect:gt,onMentionDismiss:_t,onMentionMove:vt,mentionSpan:O,setMentionSpan:le,completedTokenLen:ft,cursorPos:ue,setCursorPos:de})]}),u!==void 0&&(0,R.jsxs)(`div`,{className:`error-toast`,role:`alert`,children:[(0,R.jsx)(`span`,{children:`!`}),(0,R.jsx)(`p`,{children:u}),(0,R.jsx)(`button`,{onClick:()=>d(void 0),children:`×`})]})]})]}),e.approval!==void 0&&(0,R.jsx)(Rf,{approval:e.approval,onResolve:e=>void window.flavorDesktop.resolveApproval(e)}),e.questions!==void 0&&(0,R.jsx)(zf,{questions:e.questions,onAnswer:e=>void window.flavorDesktop.answerQuestions(e)}),e.memoryReviews!==void 0&&e.memoryReviews.length>0&&(0,R.jsx)(Bf,{reviews:e.memoryReviews,autoDismissSeconds:e.memoryAutoDismissSeconds??0,onResolve:(e,t)=>{window.flavorDesktop.resolveMemoryReview(e,t).catch(e=>d(Xf(e)))}}),y!==void 0&&(0,R.jsx)(If,{session:y,deleting:x,onCancel:()=>b(void 0),onDelete:()=>void Ot()}),xe&&(0,R.jsx)(yf,{onCancel:()=>Se(!1),onChoose:e=>{Se(!1),St(void 0,e)}}),ke!==void 0&&(0,R.jsx)(bf,{mode:ke,query:Fe,setQuery:Ie,projects:lt,onClose:()=>Ne(void 0),onProject:e=>{Ne(void 0),bt(e)},onCommand:e=>{Ne(void 0),e===`new`?Se(!0):e===`open`?yt():e===`activity`?A(`activity`):e===`git`?A(`git`):e===`skills`&&A(`skills`)}})]})}function vf({activities:e,onClose:t,onOpen:n,onClear:r}){return(0,R.jsxs)(`section`,{className:`manager-view activity-center`,children:[(0,R.jsxs)(`header`,{className:`manager-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{onClick:t,children:`←`}),(0,R.jsx)(`h2`,{children:`活动`})]}),(0,R.jsx)(`button`,{onClick:r,children:`全部标为已读`})]}),(0,R.jsx)(`div`,{className:`activity-list`,children:e.length===0?(0,R.jsx)(`p`,{className:`manager-empty`,children:`还没有任务活动`}):e.map(e=>(0,R.jsxs)(`button`,{className:`activity-row`,"data-kind":e.kind,"data-unread":e.unread,onClick:()=>n(e.workspace,e.sessionId),children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:e.title}),(0,R.jsxs)(`span`,{children:[je(e.workspace),e.detail?` · ${e.detail}`:``]})]}),(0,R.jsx)(`time`,{children:ep(e.createdAt)})]},e.id))})]})}function yf({onCancel:e,onChoose:t}){return(0,R.jsx)(`div`,{className:`modal-layer`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,R.jsxs)(`section`,{className:`new-task-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-task-title`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`p`,{children:`NEW TASK`}),(0,R.jsx)(`h2`,{id:`new-task-title`,children:`选择任务运行环境`}),(0,R.jsx)(`span`,{children:`隔离只影响 Electron 任务,不改变 CLI 默认行为。`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{onClick:()=>t(`worktree`),children:[(0,R.jsx)(`i`,{children:`◇`}),(0,R.jsx)(`strong`,{children:`隔离工作树`}),(0,R.jsx)(`span`,{children:`新建 flavor/desktop-* 分支,在应用目录中独立运行。`}),(0,R.jsx)(`em`,{children:`推荐`})]}),(0,R.jsxs)(`button`,{onClick:()=>t(`local`),children:[(0,R.jsx)(`i`,{children:`⌂`}),(0,R.jsx)(`strong`,{children:`当前检出`}),(0,R.jsx)(`span`,{children:`直接使用项目当前目录,适合快速查看和轻量操作。`})]})]}),(0,R.jsx)(`footer`,{children:(0,R.jsx)(`button`,{onClick:e,children:`取消`})})]})})}function bf({mode:e,query:t,setQuery:n,projects:r,onClose:i,onProject:a,onCommand:o}){let s=[{id:`new`,label:`新建任务`,hint:`Ctrl N`},{id:`open`,label:`打开项目`,hint:`Ctrl O`},{id:`activity`,label:`查看活动`,hint:``},{id:`git`,label:`打开 Git 变更`,hint:``},{id:`skills`,label:`管理技能`,hint:``}].filter(e=>e.label.toLowerCase().includes(t.toLowerCase())),c=r.filter(e=>`${e.label??``} ${je(e.workspace)} ${e.workspace}`.toLowerCase().includes(t.toLowerCase()));return(0,R.jsx)(`div`,{className:`palette-layer`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,R.jsxs)(`section`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,children:[(0,R.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i()},placeholder:e===`projects`?`切换到项目…`:`键入命令…`}),(0,R.jsx)(`div`,{children:e===`projects`?c.map(e=>(0,R.jsxs)(`button`,{onClick:()=>a(e.workspace),children:[(0,R.jsx)(Jf,{name:`folder`}),(0,R.jsx)(`span`,{children:e.label||je(e.workspace)}),(0,R.jsx)(`small`,{children:e.workspace})]},e.workspace)):s.map(e=>(0,R.jsxs)(`button`,{onClick:()=>o(e.id),children:[(0,R.jsx)(`span`,{children:e.label}),(0,R.jsx)(`kbd`,{children:e.hint})]},e.id))})]})})}function xf({railCollapsed:e,onToggleRail:t,onMenu:n,canBack:r,canForward:i,onBack:a,onForward:o}){return(0,R.jsxs)(`header`,{className:`window-titlebar`,children:[(0,R.jsx)(`button`,{className:`titlebar-icon sidebar-toggle`,"data-collapsed":e,onClick:t,"aria-label":e?`显示项目栏`:`隐藏项目栏`,title:e?`显示项目栏`:`隐藏项目栏`,children:(0,R.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,R.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,R.jsx)(`path`,{d:`M6 3v10`})]})}),(0,R.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!r,onClick:a,"aria-label":`后退`,title:`后退 (Ctrl+[)`,children:(0,R.jsx)(`span`,{children:`‹`})}),(0,R.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!i,onClick:o,"aria-label":`前进`,title:`前进 (Ctrl+])`,children:(0,R.jsx)(`span`,{children:`›`})}),(0,R.jsxs)(`nav`,{className:`titlebar-menus`,"aria-label":`应用菜单`,children:[(0,R.jsx)(`button`,{onClick:e=>n(`file`,e),children:`文件`}),(0,R.jsx)(`button`,{onClick:e=>n(`edit`,e),children:`编辑`}),(0,R.jsx)(`button`,{onClick:e=>n(`view`,e),children:`视图`}),(0,R.jsx)(`button`,{onClick:e=>n(`help`,e),children:`帮助`})]})]})}function Sf(e,t,n,r,i){e.type===`snapshot`?(t.current=e.snapshot.activeSession?.sessionId,n(e.snapshot)):e.type===`session-started`?(t.current=e.payload.sessionId,n(e.payload.snapshot),r(ee(E(),{type:`restore`,state:e.payload.restoredTranscript}))):e.type===`session-output`?r(n=>Pe(n,t.current,e)):e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===t.current)&&i(e.message)}function Cf({turn:e,active:t=!1}){let n=t?e.blocks:e.blocks.filter(e=>e.kind!==`status`||e.task===void 0),r=Math.max(0,n.length-200),i=n.slice(-200);return(0,R.jsxs)(`article`,{className:`turn`,"data-active":t,"data-kind":e.kind??`conversation`,children:[(0,R.jsx)(`div`,{className:`user-message`,children:(0,R.jsx)(`span`,{children:Ef(e.prompt,16e3)})}),(0,R.jsxs)(`div`,{className:`assistant-message`,children:[(0,R.jsx)(`div`,{className:`assistant-avatar`,children:(0,R.jsx)(Yf,{})}),(0,R.jsxs)(`div`,{className:`turn-content`,children:[r>0&&(0,R.jsxs)(`div`,{className:`transcript-window-notice`,children:[`更早的 `,r,` 条任务输出已从实时渲染窗口隐藏`]}),i.map((e,t)=>(0,R.jsx)(Tf,{block:e},e.kind===`status`?e.id:`text-${t}`)),t&&i.length===0&&(0,R.jsxs)(`div`,{className:`thinking-line`,role:`status`,children:[(0,R.jsx)(`i`,{}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:`Flavoring`}),(0,R.jsx)(`small`,{children:`正在理解任务`})]})]})]})]})]})}var wf=_.memo(Cf);function Tf({block:e}){if(e.kind===`text`)return(0,R.jsx)(`div`,{className:`assistant-copy`,children:(0,R.jsx)(on,{text:Ef(e.text)})});let t=e.state===`completed`?`✓`:e.state===`failed`?`×`:e.state===`cancelled`?`–`:e.state===`running`?``:`·`,n=e.activity===`model`,r=n&&e.thinkingText?Df(e.thinkingText):void 0;return(0,R.jsxs)(`div`,{className:`activity-card`,"data-state":e.state,"data-tone":e.tone,"data-activity":e.activity,children:[(0,R.jsx)(`span`,{className:`activity-node`,children:t}),(0,R.jsxs)(`div`,{className:`activity-body`,children:[(0,R.jsxs)(`div`,{className:`activity-title`,children:[(0,R.jsx)(`span`,{children:e.text.replace(/^[·✓×]\s*/,``)}),n&&e.state===`running`&&(0,R.jsx)(`small`,{children:`正在思考`}),e.hint&&(0,R.jsx)(`code`,{children:e.hint})]}),r&&(0,R.jsx)(`div`,{className:`reasoning-preview`,children:r}),e.progress!==void 0&&(0,R.jsx)(`div`,{className:`progress-track`,children:(0,R.jsx)(`i`,{style:{width:`${e.progress}%`}})}),e.presentation?.kind===`file-change`&&(0,R.jsx)(kf,{presentation:e.presentation}),e.presentation?.kind===`generic`&&(0,R.jsxs)(`div`,{className:`tool-presentation`,children:[(0,R.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,R.jsx)(`span`,{children:e.presentation.summary})]}),e.presentation?.kind===`terminal`&&(0,R.jsxs)(`div`,{className:`tool-presentation terminal-presentation`,children:[(0,R.jsx)(`strong`,{children:e.presentation.title}),e.presentation.stdout&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`small`,{children:`OUTPUT`}),(0,R.jsx)(`pre`,{"data-stream":`stdout`,children:Ef(e.presentation.stdout)})]}),e.presentation.stderr&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`small`,{children:`ERROR`}),(0,R.jsx)(`pre`,{"data-stream":`stderr`,children:Ef(e.presentation.stderr)})]}),e.presentation.diagnostic&&(0,R.jsx)(`span`,{className:`terminal-diagnostic`,children:e.presentation.diagnostic})]}),e.presentation?.kind===`web`&&(0,R.jsxs)(`div`,{className:`tool-presentation`,children:[(0,R.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,R.jsx)(`span`,{children:e.presentation.summary})]}),e.tool&&(0,R.jsxs)(`details`,{className:`tool-details`,children:[(0,R.jsx)(`summary`,{children:`调用详情`}),(0,R.jsx)(`label`,{children:`Input`}),(0,R.jsx)(`pre`,{children:Of(e.tool.input)}),e.tool.result===void 0?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`label`,{children:`Result`}),(0,R.jsx)(`pre`,{children:Of(e.tool.result)})]})]}),e.details&&(0,R.jsxs)(`details`,{className:`timeline-details`,children:[(0,R.jsx)(`summary`,{children:`压缩摘要`}),(0,R.jsx)(on,{text:Ef(e.details)})]})]})]})}function Ef(e,t=32e3){if(e.length<=t)return e;let n=Math.floor((t-64)/2);return`${e.slice(0,n)}\n\n… ${e.length-n*2} 个字符已隐藏 …\n\n${e.slice(-n)}`}function Df(e,t=280){let n=e.replace(/\s+/gu,` `).trim(),r=Math.max(1,Math.floor(t)),i=[...n];return i.length<=r?n:`…${i.slice(-r).join(``)}`}function Of(e,t=1e4){let n;try{n=JSON.stringify(e,null,2)??`undefined`}catch{n=String(e)}return n.length<=t?n:`${n.slice(0,t)}…`}function kf({presentation:e}){let t=e.operation===`delete`,n=e.operation===`create`?`新建`:e.operation===`delete`?`删除`:`修改`,r=e.path.replace(/^.*[/\\]/,``),i=t?1:Math.max(1,...e.lines.map(e=>Math.max(e.oldLine??0,e.newLine??0))).toString().length;return(0,R.jsxs)(`details`,{className:`diff-preview`,children:[(0,R.jsxs)(`summary`,{children:[(0,R.jsx)(`span`,{className:`diff-marker ${t?`diff-delete`:`diff-add`}`,children:`●`}),(0,R.jsx)(`span`,{className:`diff-label`,children:n}),(0,R.jsx)(`span`,{className:`diff-path`,children:r}),(0,R.jsxs)(`span`,{className:`diff-counts`,children:[!t&&(0,R.jsxs)(`span`,{className:`diff-added-count`,children:[`+`,e.added]}),!t&&e.removed>0&&(0,R.jsxs)(`span`,{className:`diff-removed-count`,children:[` −`,e.removed]}),t&&(0,R.jsxs)(`span`,{className:`diff-removed-count`,children:[`−`,e.removed]})]})]}),t?null:(0,R.jsx)(`div`,{className:`diff-body`,children:e.lines.map((e,t)=>(0,R.jsx)(Af,{line:e,lineWidth:i},t))})]})}function Af({line:e,lineWidth:t}){let n=e.kind===`removed`||e.kind===`context`?e.oldLine:e.newLine,r=e.kind===`removed`?`-`:e.kind===`added`?`+`:e.kind===`omitted`?`…`:` `;return(0,R.jsxs)(`div`,{className:`diff-row ${e.kind===`added`?`diff-row-added`:e.kind===`removed`?`diff-row-removed`:e.kind===`omitted`?`diff-row-omitted`:`diff-row-context`}`,children:[(0,R.jsx)(`span`,{className:`diff-line-number`,children:String(n??``).padStart(t)}),(0,R.jsx)(`span`,{className:`diff-line-marker`,children:r}),(0,R.jsx)(`span`,{className:`diff-line-text`,children:e.text})]})}function jf(e){let t=e.snapshot.workspace===void 0,[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(null),a=e.slashCompletion!==null,o=e.mentionCompletion!==null,s=a||o,c=e.completedTokenLen>0,l=c?e.input.slice(0,e.completedTokenLen):void 0,u=l?.startsWith(`/`)?l.slice(1).trim():l?.trim(),d=c?void 0:e.mentionSpan,f=d!==void 0&&d.start>=0&&d.end>d.start&&d.start<e.input.length&&d.end<=e.input.length&&e.input.slice(d.start,d.end)===d.text,p=f?e.input.slice(0,d.start):``,m=f?e.input.slice(d.start,d.end):``,h=f?e.input.slice(d.end):``,g=m.startsWith(`@`)?m.slice(1).trim():m,v=c?e.input.slice(e.completedTokenLen):f?h:e.input,y=c?l.length:f?d.start+m.length:0,b=e=>y+e,x=t=>{if(a){if(t.key===`ArrowDown`){t.preventDefault(),e.onSlashMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onSlashMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.slashCompletion?.items[e.slashCompletion?.selectedIndex??0];n!==void 0&&e.onSlashSelect(n.name);return}if(t.key===`Escape`){t.preventDefault(),e.onSlashDismiss();return}}if(o){if(t.key===`ArrowDown`){t.preventDefault(),e.onMentionMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onMentionMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.mentionCompletion?.items[e.mentionCompletion?.selectedIndex??0];n!==void 0&&e.onMentionSelect(n);return}if(t.key===`Escape`){t.preventDefault(),e.onMentionDismiss();return}}let n=t.target,r=n.selectionStart,i=n.selectionEnd;if(t.key===`Backspace`&&r===i&&!s){if(c){let n=yn(e.input,e.completedTokenLen,b(r));if(n!==null){t.preventDefault(),e.setInput(n.text),e.setCursorPos(n.cursor);return}}if(f&&r===0){t.preventDefault();let n=p+h;e.setInput(n),e.setMentionSpan(void 0),e.setCursorPos(p.length);return}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.onSend(t.altKey?`followUp`:e.busy?`steer`:void 0))},S=(t,n)=>{let r;if(r=c?l+t:f?p+m+t:t,f){let t=p+m;r.startsWith(t)||e.setMentionSpan(void 0)}e.setInput(r),e.setCursorPos(b(n))},C=t=>{e.setCursorPos(b(t))},w=(0,R.jsx)(`textarea`,{ref:e.inputRef,className:`composer-textarea`,value:v,onChange:e=>S(e.target.value,e.target.selectionStart),onSelect:e=>C(e.target.selectionStart),onKeyDown:x,onPaste:t=>{let n=Mf(t.clipboardData.files);n.length!==0&&(t.preventDefault(),e.onAddImages(n))},onClick:e=>C(e.target.selectionStart),placeholder:t?`先打开一个项目`:c||f?``:`给 Flavor 一个任务,或输入 / 查看命令`,disabled:t,rows:1}),T=c?(0,R.jsxs)(`div`,{className:`composer-input-row`,children:[(0,R.jsx)(`span`,{className:`slash-tag`,children:u}),w]}):f?(0,R.jsxs)(`div`,{className:`composer-input-row`,children:[p.length>0&&(0,R.jsx)(`span`,{className:`composer-plain-text`,children:p}),(0,R.jsx)(`span`,{className:`mention-tag`,children:g}),w]}):w;return(0,R.jsxs)(`div`,{className:`composer-wrap`,onDragEnter:e=>{Nf(e.dataTransfer)&&(e.preventDefault(),r(!0))},onDragOver:e=>{Nf(e.dataTransfer)&&e.preventDefault()},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||r(!1)},onDrop:t=>{let n=Mf(t.dataTransfer.files);n.length!==0&&(t.preventDefault(),r(!1),e.onAddImages(n))},children:[a&&(0,R.jsx)(Cn,{completion:e.slashCompletion,onSelect:e.onSlashSelect,onDismiss:e.onSlashDismiss}),o&&(0,R.jsx)(En,{completion:e.mentionCompletion,onSelect:e.onMentionSelect,onDismiss:e.onMentionDismiss}),(0,R.jsxs)(`div`,{className:`composer${c||f?` has-tag`:``}`,"data-busy":e.busy,"data-image-drag":n,children:[e.attachments.length>0&&(0,R.jsx)(gf,{attachments:e.attachments,onRemove:e.onRemoveImage}),T,(0,R.jsxs)(`div`,{className:`composer-tools`,children:[(0,R.jsx)(`input`,{ref:i,className:`image-file-input`,type:`file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,onChange:t=>{e.onAddImages(Mf(t.target.files)),t.target.value=``}}),(0,R.jsxs)(`button`,{type:`button`,className:`attach-button attach-button-labeled image-attach-button`,title:`添加图片(也可粘贴或拖入)`,"aria-label":`添加图片`,onClick:()=>i.current?.click(),disabled:t||e.busy||e.attachments.length>=lf,children:[(0,R.jsx)(Jf,{name:`image`}),(0,R.jsx)(`span`,{children:`图片`})]}),(0,R.jsxs)(`button`,{className:`attach-button attach-button-labeled`,title:`在提示中输入 @ 引用项目文件`,onClick:()=>{e.setInput(`${e.input}${e.input?` `:``}@`),setTimeout(()=>{let t=e.inputRef.current;t!==null&&(t.focus(),t.setSelectionRange(t.value.length,t.value.length))},0)},disabled:t,children:[(0,R.jsx)(Jf,{name:`at`}),(0,R.jsx)(`span`,{children:`文件`})]}),(0,R.jsxs)(`div`,{className:`composer-context`,children:[(0,R.jsxs)(`span`,{className:`context-item`,title:e.snapshot.workspace,children:[(0,R.jsx)(Jf,{name:`folder`}),(0,R.jsx)(`span`,{children:je(e.snapshot.workspace)})]}),(0,R.jsxs)(`span`,{className:`context-item`,children:[(0,R.jsx)(Jf,{name:`monitor`}),(0,R.jsx)(`span`,{children:`本地`})]})]}),(0,R.jsxs)(`div`,{className:`composer-controls`,children:[(0,R.jsx)($f,{models:e.snapshot.models,activeModel:e.snapshot.activeSession?.mainModel,busy:e.busy,onSelect:e.setModel,onAdd:e.addModel}),(0,R.jsx)(`select`,{"aria-label":`权限模式`,value:e.snapshot.activeSession?.permissionMode??`default`,disabled:e.busy||e.snapshot.activeSession===void 0,onChange:t=>e.setPermission(t.target.value),children:sf.map(e=>(0,R.jsx)(`option`,{value:e,children:ke(e)},e))}),e.busy&&(0,R.jsxs)(`span`,{className:`queue-count`,title:`引导 + 后续消息`,children:[e.snapshot.activeSession?.queue.steering.length??0,`+`,e.snapshot.activeSession?.queue.followUp.length??0]}),(0,R.jsx)(`button`,{className:`send-button`,onClick:()=>e.onSend(e.busy?`steer`:void 0),disabled:t||!e.input.trim()&&e.attachments.length===0,title:e.busy?`发送引导消息`:`发送`,children:(0,R.jsx)(`span`,{children:`↑`})}),e.busy&&(0,R.jsx)(`button`,{className:`send-button stop-button`,onClick:e.onInterrupt,title:`停止任务`,children:(0,R.jsx)(`span`,{})})]})]})]}),(0,R.jsx)(`p`,{className:`composer-hint`,children:`Enter 发送 · Shift Enter 换行 · 粘贴/拖入图片 · @ 引用文件 · / 调用命令`})]})}function Mf(e){return e===null?[]:Array.from(e).filter(e=>e.type.startsWith(`image/`))}function Nf(e){return Array.from(e.items).some(e=>e.kind===`file`&&e.type.startsWith(`image/`))}async function Pf(e){if(!ff.has(e.type))throw Error(`不支持 ${e.type||`未知格式`};请选择 PNG、JPEG 或 WebP 图片。`);if(e.size<=0)throw Error(`${e.name} 是空文件。`);if(e.size>uf)throw Error(`${e.name} 超过单图 5 MiB 限制。`);let t=Ff(new Uint8Array(await e.arrayBuffer())),n=URL.createObjectURL(e);return{id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,name:e.name,mediaType:e.type,dataBase64:t,previewUrl:n}}function Ff(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function If({session:e,deleting:t,onCancel:n,onDelete:r}){return(0,R.jsx)(`div`,{className:`modal-layer`,children:(0,R.jsxs)(`section`,{className:`decision-sheet delete-session-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`delete-session-title`,children:[(0,R.jsx)(`div`,{className:`sheet-icon danger`,children:`×`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`sheet-kicker`,children:`删除历史会话`}),(0,R.jsxs)(`h2`,{id:`delete-session-title`,children:[`删除“`,Ae(e),`”?`]}),(0,R.jsx)(`p`,{children:`此会话的消息和任务记录将从当前项目中永久删除,此操作无法撤销。`}),(0,R.jsxs)(`div`,{className:`sheet-actions`,children:[(0,R.jsx)(`button`,{disabled:t,onClick:n,children:`取消`}),(0,R.jsx)(`button`,{className:`danger`,disabled:t,onClick:r,children:t?`正在删除…`:`删除会话`})]})]})]})})}var Lf=new Set([`Delete`,`Move`,`RemoveTool`]);function Rf({approval:e,onResolve:t}){let n=Lf.has(e.tool)||e.allowAlways===!1;return(0,R.jsx)(`div`,{className:`modal-layer`,children:(0,R.jsxs)(`section`,{className:`decision-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`approval-title`,children:[(0,R.jsx)(`div`,{className:`sheet-icon warning`,children:`!`}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`p`,{className:`sheet-kicker`,children:[`权限确认 · `,e.agent===`main`?`主 Agent`:`子 Agent`]}),(0,R.jsxs)(`h2`,{id:`approval-title`,children:[`允许执行 `,e.tool,`?`]}),(0,R.jsx)(`p`,{children:e.reason??`这项操作需要你的确认。`}),(e.command||e.paths?.length)&&(0,R.jsxs)(`pre`,{children:[e.command??e.paths?.join(`
153
153
  `),e.args?.length?` ${e.args.join(` `)}`:``]}),(0,R.jsxs)(`div`,{className:`sheet-actions`,children:[(0,R.jsx)(`button`,{onClick:()=>t(`deny`),children:`拒绝`}),!n&&(0,R.jsx)(`button`,{onClick:()=>t(`always`),children:`始终允许同类操作`}),(0,R.jsx)(`button`,{className:`primary`,onClick:()=>t(`allow`),children:`允许一次`})]})]})]})})}function zf({questions:e,onAnswer:t}){let[n,r]=(0,_.useState)({}),[i,a]=(0,_.useState)({}),o=e.every((e,t)=>!!n[t]?.trim());return(0,R.jsx)(`div`,{className:`modal-layer`,children:(0,R.jsxs)(`section`,{className:`question-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,R.jsx)(`p`,{className:`sheet-kicker`,children:`Flavor 需要确认`}),e.map((e,t)=>(0,R.jsxs)(`fieldset`,{children:[(0,R.jsx)(`legend`,{children:e.header}),(0,R.jsx)(`p`,{children:e.question}),(0,R.jsxs)(`div`,{className:`question-options`,children:[e.options.map(e=>(0,R.jsxs)(`button`,{"data-selected":!i[t]&&n[t]===e.label,onClick:()=>{a(e=>({...e,[t]:!1})),r(n=>({...n,[t]:e.label}))},children:[(0,R.jsx)(`strong`,{children:e.label}),(0,R.jsx)(`span`,{children:e.description})]},e.label)),(0,R.jsxs)(`button`,{"data-selected":i[t]===!0,onClick:()=>{a(e=>({...e,[t]:!0})),r(e=>({...e,[t]:``}))},children:[(0,R.jsx)(`strong`,{children:`其他(自定义输入)`}),(0,R.jsx)(`span`,{children:`键入你自己的回答`})]}),i[t]===!0&&(0,R.jsx)(`input`,{className:`question-custom-input`,autoFocus:!0,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),placeholder:`请输入回答`,"aria-label":`${e.header} 自定义回答`})]})]},`${e.header}-${t}`)),(0,R.jsx)(`div`,{className:`sheet-actions`,children:(0,R.jsx)(`button`,{className:`primary`,disabled:!o,onClick:()=>t(n),children:`继续`})})]})})}function Bf({reviews:e,autoDismissSeconds:t,onResolve:n}){return(0,R.jsxs)(`aside`,{className:`memory-review-rail`,"aria-label":`长期记忆写入确认`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:`待确认`}),(0,R.jsx)(`h2`,{children:`长期记忆候选`})]}),(0,R.jsx)(`span`,{children:e.length})]}),(0,R.jsx)(`p`,{className:`memory-review-warning`,children:`以下内容由模型生成,确认前不会写入长期记忆,也不会影响后续会话。`}),(0,R.jsx)(`div`,{className:`memory-review-list`,children:e.map(e=>(0,R.jsxs)(`article`,{children:[(0,R.jsx)(`small`,{children:e.type}),(0,R.jsx)(`p`,{children:e.content}),(0,R.jsx)(Vf,{seconds:t}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{onClick:()=>n(e.id,`dismiss`),children:`忽略`}),(0,R.jsx)(`button`,{className:`primary`,onClick:()=>n(e.id,`accept`),children:`保存`})]})]},e.id))})]})}function Vf({seconds:e}){let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e<=0)return;n(e);let t=setInterval(()=>n(e=>Math.max(0,e-1)),1e3);return()=>clearInterval(t)},[e]),e<=0?null:(0,R.jsxs)(`small`,{className:`memory-review-countdown`,children:[`未操作将在 `,t,`s 后自动忽略`]})}function Hf({project:e,onStart:t}){return(0,R.jsxs)(`section`,{className:`welcome-state`,children:[(0,R.jsx)(`div`,{className:`welcome-mark`,children:(0,R.jsx)(Yf,{})}),(0,R.jsx)(`p`,{children:`已连接本地项目`}),(0,R.jsxs)(`h1`,{children:[`我们应该在 `,(0,R.jsx)(`u`,{children:e}),` 中构建什么?`]}),(0,R.jsx)(`div`,{className:`starter-grid`,children:De.map(e=>(0,R.jsx)(`button`,{onClick:()=>t(e),children:e},e))})]})}function Uf({onOpen:e}){return(0,R.jsxs)(`section`,{className:`open-state`,children:[(0,R.jsx)(`div`,{className:`welcome-mark`,children:(0,R.jsx)(Yf,{})}),(0,R.jsx)(`h1`,{children:`从一个本地项目开始`}),(0,R.jsx)(`p`,{children:`Flavor 会在你选择的文件夹范围内阅读、修改和运行代码。`}),(0,R.jsx)(`button`,{onClick:e,children:`打开项目`})]})}function Wf(){return(0,R.jsxs)(`div`,{className:`loading-state`,children:[(0,R.jsx)(Yf,{}),(0,R.jsx)(`span`,{children:`正在准备桌面工作区…`})]})}var Gf;function Kf(){return Gf??=window.flavorDesktop.appIcon().catch(()=>void 0),Gf}function qf(){let[e,t]=(0,_.useState)(void 0);return(0,_.useEffect)(()=>{let e=!1;return Kf().then(n=>{e||t(n)}),()=>{e=!0}},[]),e}function Jf({name:e}){let t;switch(e){case`plus`:t=(0,R.jsx)(`path`,{d:`M10 4v12M4 10h12`});break;case`folder`:t=(0,R.jsx)(`path`,{d:`M2.75 6.25h5l1.5 1.75h8v7.25a1.5 1.5 0 0 1-1.5 1.5h-12a1.5 1.5 0 0 1-1.5-1.5v-7.5a1.5 1.5 0 0 1 1.5-1.5Z`});break;case`sparkles`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M8.25 3.25c.4 2.4 1.6 3.6 4 4-2.4.4-3.6 1.6-4 4-.4-2.4-1.6-3.6-4-4 2.4-.4 3.6-1.6 4-4Z`}),(0,R.jsx)(`path`,{d:`M14.5 11.5c.25 1.45 1.05 2.25 2.5 2.5-1.45.25-2.25 1.05-2.5 2.5-.25-1.45-1.05-2.25-2.5-2.5 1.45-.25 2.25-1.05 2.5-2.5Z`})]});break;case`database`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ellipse`,{cx:`10`,cy:`5`,rx:`6.25`,ry:`2.5`}),(0,R.jsx)(`path`,{d:`M3.75 5v5c0 1.38 2.8 2.5 6.25 2.5s6.25-1.12 6.25-2.5V5M3.75 10v5c0 1.38 2.8 2.5 6.25 2.5s6.25-1.12 6.25-2.5v-5`})]});break;case`server`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`rect`,{x:`3`,y:`3.5`,width:`14`,height:`5`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`3`,y:`11.5`,width:`14`,height:`5`,rx:`1.5`}),(0,R.jsx)(`path`,{d:`M6 6h.01M6 14h.01M9 6h5M9 14h5`})]});break;case`checklist`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`rect`,{x:`3.25`,y:`2.75`,width:`13.5`,height:`14.5`,rx:`2`}),(0,R.jsx)(`path`,{d:`m6.25 7 1.25 1.25L10 5.75M11.75 7h2M6.25 12h1.5M10 12h4`})]});break;case`image`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`rect`,{x:`2.75`,y:`3.25`,width:`14.5`,height:`13.5`,rx:`2`}),(0,R.jsx)(`circle`,{cx:`7`,cy:`7.25`,r:`1.25`}),(0,R.jsx)(`path`,{d:`m4.75 14 3.5-3.5 2.25 2.25 2.25-2.5 2.5 3.75`})]});break;case`at`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`9.5`,cy:`10`,r:`3`}),(0,R.jsx)(`path`,{d:`M12.5 10v1.25c0 1.15.8 1.75 1.75 1.75 1.4 0 2.25-1.2 2.25-3a6.5 6.5 0 1 0-2.1 4.78`})]});break;case`monitor`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`rect`,{x:`2.75`,y:`3.5`,width:`14.5`,height:`10.5`,rx:`2`}),(0,R.jsx)(`path`,{d:`M7 17h6M10 14v3`})]});break;case`bell`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M5.25 8.5a4.75 4.75 0 0 1 9.5 0c0 5 2 5.5 2 5.5H3.25s2-.5 2-5.5Z`}),(0,R.jsx)(`path`,{d:`M8 16a2.25 2.25 0 0 0 4 0`})]});break;case`git`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`5`,cy:`4`,r:`1.75`}),(0,R.jsx)(`circle`,{cx:`15`,cy:`6.5`,r:`1.75`}),(0,R.jsx)(`circle`,{cx:`5`,cy:`16`,r:`1.75`}),(0,R.jsx)(`path`,{d:`M5 5.75v8.5M6.75 7.5C11 7.5 10.5 6.5 13.25 6.5`})]});break;case`search`:t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`circle`,{cx:`8.75`,cy:`8.75`,r:`5.25`}),(0,R.jsx)(`path`,{d:`m12.5 12.5 4 4`})]});break}return(0,R.jsx)(`svg`,{className:`ui-icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:t})}function Yf(){let e=qf();return e===void 0?(0,R.jsxs)(`svg`,{className:`flavor-mark`,viewBox:`0 0 36 36`,"aria-hidden":`true`,children:[(0,R.jsx)(`path`,{d:`M8 17.5C8 11.7 12.5 7 18 7s10 4.7 10 10.5c0 2.7-1 5.1-2.7 7l1 3.8-4-1.2A9.5 9.5 0 0 1 18 28c-5.5 0-10-4.7-10-10.5Z`}),(0,R.jsx)(`path`,{d:`M16 15l-2 2l2 2`,fill:`none`,stroke:`#1979c9`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,R.jsx)(`path`,{d:`M20 15l2 2l-2 2`,fill:`none`,stroke:`#1979c9`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,R.jsx)(`path`,{className:`mark-smile`,d:`M14 23c2.5 1.5 5.5 1.5 8 0`}),(0,R.jsx)(`ellipse`,{cx:`22`,cy:`24`,rx:`1.2`,ry:`0.9`,fill:`#f472b6`,stroke:`#ec4899`,strokeWidth:`0.3`,transform:`rotate(15 22 24)`})]}):(0,R.jsx)(`img`,{className:`flavor-mark`,src:e,alt:``,"aria-hidden":`true`})}function Xf(e){return e instanceof Error?e.message:String(e)}function Zf(e){return e.replace(/^session-/,``).slice(0,17)}function Qf(e){return e?e.split(`:`).at(-1)??e:`选择模型`}function $f({models:e,activeModel:t,busy:n,onSelect:r,onAdd:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)({provider:``,model:``,baseURL:``,apiKey:``,protocol:`openai-compatible`}),p=t??e[0]?.id,m=e.find(e=>e.id===p),h=m?.label??Qf(p),g=(e,t)=>{f(n=>({...n,[e]:t})),u(void 0)},v=async e=>{if(e.preventDefault(),s)return;let t=e.currentTarget;c(!0),u(void 0);try{await i(d),o(!1),f({provider:``,model:``,baseURL:``,apiKey:``,protocol:`openai-compatible`}),t.closest(`details`)?.removeAttribute(`open`)}catch(e){u(Xf(e))}finally{c(!1)}};return(0,R.jsxs)(`details`,{className:`model-menu`,children:[(0,R.jsxs)(`summary`,{"aria-label":`主模型:${h}`,title:`切换主模型`,children:[(0,R.jsx)(`span`,{className:`model-status-dot`,"data-configured":m!==void 0}),(0,R.jsx)(`span`,{className:`model-summary-label`,children:h}),(0,R.jsx)(`span`,{className:`model-summary-chevron`,"aria-hidden":`true`})]}),(0,R.jsxs)(`div`,{className:`popover model-popover`,children:[(0,R.jsxs)(`div`,{className:`model-popover-heading`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`strong`,{children:a?`添加厂商模型`:`切换主模型`}),(0,R.jsx)(`span`,{children:a?`连接 OpenAI 兼容或 Anthropic 服务`:`DeepSeek 默认可用,也可接入其他厂商`})]}),!a&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!0),disabled:n,children:`+ 新增`})]}),a?(0,R.jsxs)(`form`,{className:`model-provider-form`,onSubmit:e=>void v(e),children:[(0,R.jsxs)(`div`,{className:`model-form-grid`,children:[(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`厂商名称 / ID`}),(0,R.jsx)(`input`,{required:!0,maxLength:64,placeholder:`例如 siliconflow`,value:d.provider,onChange:e=>g(`provider`,e.target.value),pattern:`[A-Za-z0-9][A-Za-z0-9_-]*`})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`模型名称`}),(0,R.jsx)(`input`,{required:!0,maxLength:256,placeholder:`例如 qwen3-coder`,value:d.model,onChange:e=>g(`model`,e.target.value)})]})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`接口协议`}),(0,R.jsxs)(`select`,{value:d.protocol,onChange:e=>g(`protocol`,e.target.value),children:[(0,R.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容 API`}),(0,R.jsx)(`option`,{value:`anthropic`,children:`Anthropic API`})]})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`Base URL`}),(0,R.jsx)(`input`,{required:!0,type:`url`,maxLength:2048,placeholder:`https://api.example.com/v1`,value:d.baseURL,onChange:e=>g(`baseURL`,e.target.value)})]}),(0,R.jsxs)(`label`,{children:[(0,R.jsx)(`span`,{children:`API Key`}),(0,R.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,maxLength:16384,placeholder:`输入服务密钥`,value:d.apiKey,onChange:e=>g(`apiKey`,e.target.value)})]}),(0,R.jsxs)(`p`,{className:`model-security-note`,children:[(0,R.jsx)(`span`,{children:`◆`}),` 配置同步到当前项目,密钥只加密保存在本机。保存后会新建会话。`]}),l!==void 0&&(0,R.jsx)(`p`,{className:`model-form-error`,role:`alert`,children:l}),(0,R.jsxs)(`div`,{className:`model-form-actions`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),u(void 0)},disabled:s,children:`取消`}),(0,R.jsx)(`button`,{type:`submit`,className:`primary`,disabled:s||n,children:s?`正在连接…`:`保存并切换`})]})]}):(0,R.jsx)(`div`,{className:`model-options`,role:`listbox`,"aria-label":`主模型`,children:e.map(e=>{let t=p===e.id;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`model-option`,disabled:n||t,onClick:t=>{r(e.id),t.currentTarget.closest(`details`)?.removeAttribute(`open`)},children:[(0,R.jsxs)(`span`,{className:`model-option-copy`,children:[(0,R.jsx)(`strong`,{children:e.label}),(0,R.jsx)(`small`,{children:e.description})]}),e.source===`custom`&&(0,R.jsx)(`span`,{className:`model-option-badge`,children:`自定义`}),(0,R.jsx)(`span`,{className:`model-option-state`,"aria-hidden":`true`,children:t?`✓`:`→`})]},e.id)})})]})]})}function ep(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})}var tp=document.getElementById(`root`);if(tp===null)throw Error(`Desktop root element was not found`);(0,v.createRoot)(tp).render((0,R.jsx)(_.StrictMode,{children:(0,R.jsx)(_f,{})}));export{c as i,rn as n,u as r,wd as t};