@michael-joseph-miller/ant-bot 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michael-joseph-miller/ant-bot",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Local-first daemon and web UI hosting persistent, named Claude agents.",
5
5
  "license": "MIT",
6
6
  "author": "Michael Miller",
@@ -128,4 +128,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
128
128
 
129
129
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Tn,s=!dn.jitless,c=s&&En.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?Wi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function qi(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=>!Vn(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=>Gn(e,r,fn())))}),t)}var Ji=N(`$ZodUnion`,(e,t)=>{I.init(e,t),P(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),P(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),P(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),P(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=>_n(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=>qi(t,r,e,i)):qi(o,r,e,i)}}),Yi=N(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ji.init(e,t);let n=e._zod.parse;P(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=hn(()=>{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(!Tn(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)}}),Xi=N(`$ZodIntersection`,(e,t)=>{I.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])=>Qi(e,t,n)):Qi(e,i,a)}});function Zi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Dn(e)&&Dn(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=Zi(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=Zi(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 Qi(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}),Vn(e))return e;let o=Zi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var $i=N(`$ZodRecord`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Dn(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=>Gn(e,r,fn())),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(...Un(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Un(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`&&Br.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=>Gn(e,r,fn())),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(...Un(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Un(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ea=N(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=pn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>kn.has(typeof e)).map(e=>typeof e==`string`?An(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}}),ta=N(`$ZodLiteral`,(e,t)=>{if(I.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`?An(e):e?An(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}}),na=N(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new un(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 ln;return n.value=i,n.fallback=!0,n}});function ra(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ia=N(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,P(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${_n(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=>ra(e,r)):ra(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),aa=N(`$ZodExactOptional`,(e,t)=>{ia.init(e,t),P(e._zod,`values`,()=>t.innerType._zod.values),P(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),oa=N(`$ZodNullable`,(e,t)=>{I.init(e,t),P(e._zod,`optin`,()=>t.innerType._zod.optin),P(e._zod,`optout`,()=>t.innerType._zod.optout),P(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${_n(e.source)}|null)$`):void 0}),P(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),sa=N(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,P(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ca(e,t)):ca(r,t)}});function ca(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var la=N(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,P(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))}),ua=N(`$ZodNonOptional`,(e,t)=>{I.init(e,t),P(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=>da(t,e)):da(i,e)}});function da(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 fa=N(`$ZodCatch`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,P(e._zod,`optout`,()=>t.innerType._zod.optout),P(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=>Gn(e,n,fn()))},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=>Gn(e,n,fn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),pa=N(`$ZodPipe`,(e,t)=>{I.init(e,t),P(e._zod,`values`,()=>t.in._zod.values),P(e._zod,`optin`,()=>t.in._zod.optin),P(e._zod,`optout`,()=>t.out._zod.optout),P(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=>ma(e,t.in,n)):ma(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ma(e,t.out,n)):ma(r,t.out,n)}});function ma(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 ha=N(`$ZodReadonly`,(e,t)=>{I.init(e,t),P(e._zod,`propValues`,()=>t.innerType._zod.propValues),P(e._zod,`values`,()=>t.innerType._zod.values),P(e._zod,`optin`,()=>t.innerType?._zod?.optin),P(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(ga):ga(r)}});function ga(e){return e.value=Object.freeze(e.value),e}var _a=N(`$ZodCustom`,(e,t)=>{Wr.init(e,t),I.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=>va(t,n,r,e));va(i,n,r,e)}});function va(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(qn(e))}}var ya,ba=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 xa(){return new ba}(ya=globalThis).__zod_globalRegistry??(ya.__zod_globalRegistry=xa());var Sa=globalThis.__zod_globalRegistry;function Ca(e,t){return new e({type:`string`,...F(t)})}function wa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...F(t)})}function Ta(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...F(t)})}function Ea(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...F(t)})}function Da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...F(t)})}function Oa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...F(t)})}function ka(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...F(t)})}function Aa(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...F(t)})}function ja(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...F(t)})}function Ma(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...F(t)})}function Na(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...F(t)})}function Pa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...F(t)})}function Fa(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...F(t)})}function Ia(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...F(t)})}function La(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...F(t)})}function Ra(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...F(t)})}function za(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...F(t)})}function Ba(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...F(t)})}function Va(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...F(t)})}function Ha(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...F(t)})}function Ua(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...F(t)})}function Wa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...F(t)})}function Ga(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...F(t)})}function Ka(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...F(t)})}function qa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...F(t)})}function Ja(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...F(t)})}function Ya(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...F(t)})}function Xa(e,t){return new e({type:`number`,checks:[],...F(t)})}function Za(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...F(t)})}function Qa(e,t){return new e({type:`boolean`,...F(t)})}function $a(e){return new e({type:`unknown`})}function eo(e,t){return new e({type:`never`,...F(t)})}function to(e,t){return new Kr({check:`less_than`,...F(t),value:e,inclusive:!1})}function no(e,t){return new Kr({check:`less_than`,...F(t),value:e,inclusive:!0})}function ro(e,t){return new qr({check:`greater_than`,...F(t),value:e,inclusive:!1})}function io(e,t){return new qr({check:`greater_than`,...F(t),value:e,inclusive:!0})}function ao(e,t){return new Jr({check:`multiple_of`,...F(t),value:e})}function oo(e,t){return new Xr({check:`max_length`,...F(t),maximum:e})}function so(e,t){return new Zr({check:`min_length`,...F(t),minimum:e})}function co(e,t){return new Qr({check:`length_equals`,...F(t),length:e})}function lo(e,t){return new ei({check:`string_format`,format:`regex`,...F(t),pattern:e})}function uo(e){return new ti({check:`string_format`,format:`lowercase`,...F(e)})}function fo(e){return new ni({check:`string_format`,format:`uppercase`,...F(e)})}function po(e,t){return new ri({check:`string_format`,format:`includes`,...F(t),includes:e})}function mo(e,t){return new ii({check:`string_format`,format:`starts_with`,...F(t),prefix:e})}function z(e,t){return new ai({check:`string_format`,format:`ends_with`,...F(t),suffix:e})}function B(e){return new oi({check:`overwrite`,tx:e})}function ho(e){return B(t=>t.normalize(e))}function go(){return B(e=>e.trim())}function _o(){return B(e=>e.toLowerCase())}function vo(){return B(e=>e.toUpperCase())}function yo(){return B(e=>Cn(e))}function bo(e,t,n){return new e({type:`array`,element:t,...F(n)})}function xo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...F(n)})}function So(e,t){let n=Co(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(qn(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(qn(r))}},e(t.value,t)),t);return n}function Co(e,t){let n=new Wr({check:`custom`,...F(t)});return n._zod.check=e,n}function wo(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??Sa,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 To(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,To(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`&&Oo(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 Eo(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>
130
130
 
131
- 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 Do(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:Ao(t,`input`,e.processors),output:Ao(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Oo(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 Oo(r.element,n);if(r.type===`set`)return Oo(r.valueType,n);if(r.type===`lazy`)return Oo(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 Oo(r.innerType,n);if(r.type===`intersection`)return Oo(r.left,n)||Oo(r.right,n);if(r.type===`record`||r.type===`map`)return Oo(r.keyType,n)||Oo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Oo(r.in,n)||Oo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Oo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Oo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Oo(e,n))return!0;return!!(r.rest&&Oo(r.rest,n))}return!1}var ko=(e,t={})=>n=>{let r=wo({...n,processors:t});return To(e,r),Eo(r,e),Do(r,e)},Ao=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=wo({...i??{},target:a,io:t,processors:n});return To(e,o),Eo(o,e),Do(o,e)},jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Mo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=jo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},No=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`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)},Po=(e,t,n,r)=>{n.type=`boolean`},Fo=(e,t,n,r)=>{n.not={}},Io=(e,t,n,r)=>{let i=e._zod.def,a=pn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Lo=(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}},Ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},zo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Bo=(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=To(a.element,t,{...r,path:[...r.path,`items`]})},Vo=(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]=To(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=To(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ho=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>To(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Uo=(e,t,n,r)=>{let i=e._zod.def,a=To(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=To(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]]},Wo=(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=To(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=To(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=To(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)}},Go=(e,t,n,r)=>{let i=e._zod.def,a=To(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`}]},Ko=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},qo=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Jo=(e,t,n,r)=>{let i=e._zod.def;To(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)))},Yo=(e,t,n,r)=>{let i=e._zod.def;To(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},Xo=(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;To(o,t,r);let s=t.seen.get(e);s.ref=o},Zo=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Qo=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},$o=N(`ZodISODateTime`,(e,t)=>{xi.init(e,t),Ts.init(e,t)});function es(e){return Ka($o,e)}var ts=N(`ZodISODate`,(e,t)=>{Si.init(e,t),Ts.init(e,t)});function ns(e){return qa(ts,e)}var rs=N(`ZodISOTime`,(e,t)=>{Ci.init(e,t),Ts.init(e,t)});function is(e){return Ja(rs,e)}var as=N(`ZodISODuration`,(e,t)=>{wi.init(e,t),Ts.init(e,t)});function os(e){return Ya(as,e)}var ss=N(`ZodError`,(e,t)=>{Yn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Qn(e,t)},flatten:{value:t=>Zn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,mn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,mn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),cs=$n(ss),ls=er(ss),us=tr(ss),ds=rr(ss),fs=ar(ss),ps=or(ss),ms=sr(ss),hs=cr(ss),gs=lr(ss),_s=ur(ss),vs=dr(ss),ys=fr(ss),bs=new WeakMap;function xs(e,t,n){let r=Object.getPrototypeOf(e),i=bs.get(r);if(i||(i=new Set,bs.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 Ss=N(`ZodType`,(e,t)=>(I.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ao(e,`input`),output:Ao(e,`output`)}}),e.toJSONSchema=ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>cs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>us(e,t,n),e.parseAsync=async(t,n)=>ls(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ds(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>fs(e,t,n),e.decode=(t,n)=>ps(e,t,n),e.encodeAsync=async(t,n)=>ms(e,t,n),e.decodeAsync=async(t,n)=>hs(e,t,n),e.safeEncode=(t,n)=>gs(e,t,n),e.safeDecode=(t,n)=>_s(e,t,n),e.safeEncodeAsync=async(t,n)=>vs(e,t,n),e.safeDecodeAsync=async(t,n)=>ys(e,t,n),xs(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 jn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Pc(e,t))},superRefine(e,t){return this.check(Fc(e,t))},overwrite(e){return this.check(B(e))},optional(){return gc(this)},exactOptional(){return vc(this)},nullable(){return bc(this)},nullish(){return gc(bc(this))},nonoptional(e){return Ec(this,e)},array(){return tc(this)},or(e){return ic([this,e])},and(e){return cc(this,e)},transform(e){return Ac(this,mc(e))},default(e){return Sc(this,e)},prefault(e){return wc(this,e)},catch(e){return Oc(this,e)},pipe(e){return Ac(this,e)},readonly(){return Mc(this)},describe(e){let t=this.clone();return Sa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Sa.get(this);let t=this.clone();return Sa.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 Sa.get(e)?.description},configurable:!0}),e)),Cs=N(`_ZodString`,(e,t)=>{li.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,xs(e,`_ZodString`,{regex(...e){return this.check(lo(...e))},includes(...e){return this.check(po(...e))},startsWith(...e){return this.check(mo(...e))},endsWith(...e){return this.check(z(...e))},min(...e){return this.check(so(...e))},max(...e){return this.check(oo(...e))},length(...e){return this.check(co(...e))},nonempty(...e){return this.check(so(1,...e))},lowercase(e){return this.check(uo(e))},uppercase(e){return this.check(fo(e))},trim(){return this.check(go())},normalize(...e){return this.check(ho(...e))},toLowerCase(){return this.check(_o())},toUpperCase(){return this.check(vo())},slugify(){return this.check(yo())}})}),ws=N(`ZodString`,(e,t)=>{li.init(e,t),Cs.init(e,t),e.email=t=>e.check(wa(Es,t)),e.url=t=>e.check(Aa(ks,t)),e.jwt=t=>e.check(Ga(Ws,t)),e.emoji=t=>e.check(ja(As,t)),e.guid=t=>e.check(Ta(Ds,t)),e.uuid=t=>e.check(Ea(Os,t)),e.uuidv4=t=>e.check(Da(Os,t)),e.uuidv6=t=>e.check(Oa(Os,t)),e.uuidv7=t=>e.check(ka(Os,t)),e.nanoid=t=>e.check(Ma(js,t)),e.guid=t=>e.check(Ta(Ds,t)),e.cuid=t=>e.check(Na(Ms,t)),e.cuid2=t=>e.check(Pa(Ns,t)),e.ulid=t=>e.check(Fa(Ps,t)),e.base64=t=>e.check(Ha(Vs,t)),e.base64url=t=>e.check(Ua(Hs,t)),e.xid=t=>e.check(Ia(Fs,t)),e.ksuid=t=>e.check(La(Is,t)),e.ipv4=t=>e.check(Ra(Ls,t)),e.ipv6=t=>e.check(za(Rs,t)),e.cidrv4=t=>e.check(Ba(zs,t)),e.cidrv6=t=>e.check(Va(Bs,t)),e.e164=t=>e.check(Wa(Us,t)),e.datetime=t=>e.check(es(t)),e.date=t=>e.check(ns(t)),e.time=t=>e.check(is(t)),e.duration=t=>e.check(os(t))});function V(e){return Ca(ws,e)}var Ts=N(`ZodStringFormat`,(e,t)=>{L.init(e,t),Cs.init(e,t)}),Es=N(`ZodEmail`,(e,t)=>{fi.init(e,t),Ts.init(e,t)}),Ds=N(`ZodGUID`,(e,t)=>{ui.init(e,t),Ts.init(e,t)}),Os=N(`ZodUUID`,(e,t)=>{di.init(e,t),Ts.init(e,t)}),ks=N(`ZodURL`,(e,t)=>{pi.init(e,t),Ts.init(e,t)}),As=N(`ZodEmoji`,(e,t)=>{mi.init(e,t),Ts.init(e,t)}),js=N(`ZodNanoID`,(e,t)=>{hi.init(e,t),Ts.init(e,t)}),Ms=N(`ZodCUID`,(e,t)=>{gi.init(e,t),Ts.init(e,t)}),Ns=N(`ZodCUID2`,(e,t)=>{_i.init(e,t),Ts.init(e,t)}),Ps=N(`ZodULID`,(e,t)=>{vi.init(e,t),Ts.init(e,t)}),Fs=N(`ZodXID`,(e,t)=>{yi.init(e,t),Ts.init(e,t)}),Is=N(`ZodKSUID`,(e,t)=>{bi.init(e,t),Ts.init(e,t)}),Ls=N(`ZodIPv4`,(e,t)=>{Ti.init(e,t),Ts.init(e,t)}),Rs=N(`ZodIPv6`,(e,t)=>{Ei.init(e,t),Ts.init(e,t)}),zs=N(`ZodCIDRv4`,(e,t)=>{Di.init(e,t),Ts.init(e,t)}),Bs=N(`ZodCIDRv6`,(e,t)=>{Oi.init(e,t),Ts.init(e,t)}),Vs=N(`ZodBase64`,(e,t)=>{Ai.init(e,t),Ts.init(e,t)}),Hs=N(`ZodBase64URL`,(e,t)=>{Mi.init(e,t),Ts.init(e,t)}),Us=N(`ZodE164`,(e,t)=>{Ni.init(e,t),Ts.init(e,t)}),Ws=N(`ZodJWT`,(e,t)=>{Fi.init(e,t),Ts.init(e,t)}),Gs=N(`ZodNumber`,(e,t)=>{R.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),xs(e,`ZodNumber`,{gt(e,t){return this.check(ro(e,t))},gte(e,t){return this.check(io(e,t))},min(e,t){return this.check(io(e,t))},lt(e,t){return this.check(to(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(qs(e))},safe(e){return this.check(qs(e))},positive(e){return this.check(ro(0,e))},nonnegative(e){return this.check(io(0,e))},negative(e){return this.check(to(0,e))},nonpositive(e){return this.check(no(0,e))},multipleOf(e,t){return this.check(ao(e,t))},step(e,t){return this.check(ao(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 H(e){return Xa(Gs,e)}var Ks=N(`ZodNumberFormat`,(e,t)=>{Ii.init(e,t),Gs.init(e,t)});function qs(e){return Za(Ks,e)}var Js=N(`ZodBoolean`,(e,t)=>{Li.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r)});function Ys(e){return Qa(Js,e)}var Xs=N(`ZodUnknown`,(e,t)=>{Ri.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Zs(){return $a(Xs)}var Qs=N(`ZodNever`,(e,t)=>{zi.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r)});function $s(e){return eo(Qs,e)}var ec=N(`ZodArray`,(e,t)=>{Vi.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.element=t.element,xs(e,`ZodArray`,{min(e,t){return this.check(so(e,t))},nonempty(e){return this.check(so(1,e))},max(e,t){return this.check(oo(e,t))},length(e,t){return this.check(co(e,t))},unwrap(){return this.element}})});function tc(e,t){return bo(ec,e,t)}var nc=N(`ZodObject`,(e,t)=>{Ki.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),P(e,`shape`,()=>t.shape),xs(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Zs()})},loose(){return this.clone({...this._zod.def,catchall:Zs()})},strict(){return this.clone({...this._zod.def,catchall:$s()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return In(this,e)},safeExtend(e){return Ln(this,e)},merge(e){return Rn(this,e)},pick(e){return Pn(this,e)},omit(e){return Fn(this,e)},partial(...e){return zn(hc,this,e[0])},required(...e){return Bn(Tc,this,e[0])}})});function U(e,t){return new nc({type:`object`,shape:e??{},...F(t)})}var rc=N(`ZodUnion`,(e,t)=>{Ji.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.options=t.options});function ic(e,t){return new rc({type:`union`,options:e,...F(t)})}var ac=N(`ZodDiscriminatedUnion`,(e,t)=>{rc.init(e,t),Yi.init(e,t)});function oc(e,t,n){return new ac({type:`union`,options:t,discriminator:e,...F(n)})}var sc=N(`ZodIntersection`,(e,t)=>{Xi.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r)});function cc(e,t){return new sc({type:`intersection`,left:e,right:t})}var lc=N(`ZodRecord`,(e,t)=>{$i.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function uc(e,t,n){return!t||!t._zod?new lc({type:`record`,keyType:V(),valueType:e,...F(t)}):new lc({type:`record`,keyType:e,valueType:t,...F(n)})}var dc=N(`ZodEnum`,(e,t)=>{ea.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(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 dc({...t,checks:[],...F(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 dc({...t,checks:[],...F(r),entries:i})}});function W(e,t){return new dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...F(t)})}var fc=N(`ZodLiteral`,(e,t)=>{ta.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new fc({type:`literal`,values:Array.isArray(e)?e:[e],...F(t)})}var pc=N(`ZodTransform`,(e,t)=>{na.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new un(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(qn(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(qn(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 mc(e){return new pc({type:`transform`,transform:e})}var hc=N(`ZodOptional`,(e,t)=>{ia.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new hc({type:`optional`,innerType:e})}var _c=N(`ZodExactOptional`,(e,t)=>{aa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new _c({type:`optional`,innerType:e})}var yc=N(`ZodNullable`,(e,t)=>{oa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new yc({type:`nullable`,innerType:e})}var xc=N(`ZodDefault`,(e,t)=>{sa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sc(e,t){return new xc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():On(t)}})}var Cc=N(`ZodPrefault`,(e,t)=>{la.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wc(e,t){return new Cc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():On(t)}})}var Tc=N(`ZodNonOptional`,(e,t)=>{ua.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Tc({type:`nonoptional`,innerType:e,...F(t)})}var Dc=N(`ZodCatch`,(e,t)=>{fa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Oc(e,t){return new Dc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var kc=N(`ZodPipe`,(e,t)=>{pa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.in=t.in,e.out=t.out});function Ac(e,t){return new kc({type:`pipe`,in:e,out:t})}var jc=N(`ZodReadonly`,(e,t)=>{ha.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e){return new jc({type:`readonly`,innerType:e})}var Nc=N(`ZodCustom`,(e,t)=>{_a.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r)});function Pc(e,t={}){return xo(Nc,e,t)}function Fc(e,t){return So(e,t)}var Ic=W([`idle`,`queued`,`running`,`waiting_approval`,`waiting_input`,`interrupted`]),Lc=W([`none`,`unread`,`needs_attention`]),Rc=[`fable`,`opus`,`sonnet`,`haiku`],zc=W(Rc);U({id:V(),slug:V().regex(/^[a-z0-9][a-z0-9-]*$/),name:V().min(1).max(60),title:V().max(120).default(``),description:V().max(8e3).default(``),avatarEmoji:V().max(8).default(`🤖`),modelTier:zc.default(`sonnet`),pinned:Ys().default(!1),hidden:Ys().default(!1),notifications:Ys().default(!0),sessionId:V().nullable().default(null),state:Ic.default(`idle`),attention:Lc.default(`none`),threadId:V().nullable().default(null),createdAt:H(),deletedAt:H().nullable().default(null)});var Bc=W([`dm`,`group`]);U({id:V(),kind:Bc,title:V().default(``),memberBotIds:tc(V()).default([]),pinned:Ys().default(!1),hidden:Ys().default(!1),lastReadAt:H().default(0),createdAt:H()});var Vc=oc(`type`,[U({type:G(`tool`),toolName:V(),summary:V(),input:Zs().optional(),result:V().optional(),status:W([`running`,`ok`,`error`,`denied`])}),U({type:G(`file`),path:V(),name:V(),mime:V(),bytes:H(),action:W([`created`,`modified`]).default(`created`)}),U({type:G(`approval`),approvalId:V()}),U({type:G(`handoff`),fromBotId:V(),toBotId:V(),note:V()}),U({type:G(`error`),message:V()}),U({type:G(`signin`),serverName:V(),url:V()})]),Hc=W([`user`,`bot`,`system`]),Uc=U({id:V(),threadId:V(),authorKind:Hc,authorBotId:V().nullable().default(null),replyToId:V().nullable().default(null),contentMd:V().default(``),cards:tc(Vc).default([]),streaming:Ys().default(!1),createdAt:H()});U({id:V(),messageId:V().nullable(),path:V(),name:V(),mime:V(),bytes:H(),createdAt:H()});var Wc=W([`pending`,`allowed`,`denied`,`expired`]),Gc=U({id:V(),botId:V(),threadId:V(),toolName:V(),inputSummary:V(),rawInput:Zs(),status:Wc.default(`pending`),decidedBy:W([`user`,`rule`,`auto_review`]).nullable().default(null),reason:V().default(``),ruleId:V().nullable().default(null),createdAt:H(),decidedAt:H().nullable().default(null)}),Kc=W([`require`,`allow`]);U({id:V(),kind:Kc,toolPattern:V().default(`*`),inputPattern:V().default(``),scopeNote:V().default(``),builtin:Ys().default(!1),enabled:Ys().default(!0),createdAt:H()}),U({id:V(),slug:V(),name:V(),description:V().default(``),path:V(),source:W([`user`,`taught`,`imported`]).default(`user`),createdAt:H()});var qc=/^[a-z0-9][a-z0-9-]{0,31}$/,Jc=[`antbot`,`browser`],Yc=oc(`transport`,[U({transport:G(`stdio`),command:V().min(1),args:tc(V()).default([]),env:uc(V(),V()).default({})}),U({transport:G(`http`),url:V().url(),headers:uc(V(),V()).default({}),tools:tc(V()).optional()}),U({transport:G(`sse`),url:V().url(),headers:uc(V(),V()).default({}),tools:tc(V()).optional()})]),Xc=U({id:V(),name:V().regex(qc,`lowercase letters, digits and hyphens only, max 32 characters`).refine(e=>!Jc.includes(e),{message:`"antbot" and "browser" are reserved for the built-in servers`}),description:V().default(``),enabled:Ys().default(!0),kind:W([`custom`,`builtin`]).default(`custom`),config:Yc,lastStatus:V().nullable().default(null),lastError:V().nullable().default(null),checkedAt:H().nullable().default(null),createdAt:H()});U({status:W([`ready`,`needs-sign-in`,`needs-credential`,`unreachable`]),selfRegistration:Ys().optional(),provider:V().optional(),tools:tc(U({name:V(),description:V()})).default([]),detail:V().optional(),alternative:V().optional()}),U({id:V(),botId:V(),name:V().min(1),cronExpr:V(),timezone:V().default(`UTC`),instructionMd:V(),enabled:Ys().default(!0),lastRunAt:H().nullable().default(null),nextRunAt:H().nullable().default(null),createdAt:H()});var Zc=U({id:V(),routineId:V(),startedAt:H(),finishedAt:H().nullable().default(null),status:W([`running`,`ok`,`failed`,`interrupted`]),summary:V().default(``),threadId:V().nullable().default(null),isTest:Ys().default(!1)});U({id:V(),fromBotId:V(),toBotId:V(),contentMd:V(),hops:H().default(1),delivered:Ys().default(!1),createdAt:H()}),U({id:V(),botId:V(),turnId:V(),model:V(),inputTokens:H().default(0),outputTokens:H().default(0),cacheReadTokens:H().default(0),costEstimate:H().default(0),createdAt:H()}),W([`user`,`bot`,`routine`,`system`]);var Qc={seq:H(),threadId:V().nullable(),botId:V().nullable()};oc(`type`,[U({...Qc,type:G(`hello`),epoch:V()}),U({...Qc,type:G(`message.created`),message:Uc}),U({...Qc,type:G(`message.delta`),messageId:V(),delta:V()}),U({...Qc,type:G(`message.done`),messageId:V(),contentMd:V()}),U({...Qc,type:G(`message.card`),messageId:V(),card:Vc,cardIndex:H()}),U({...Qc,type:G(`bot.state`),state:Ic,attention:Lc}),U({...Qc,type:G(`approval.pending`),approval:Gc}),U({...Qc,type:G(`approval.resolved`),approval:Gc}),U({...Qc,type:G(`routine.run`),run:Zc}),U({...Qc,type:G(`usage.tick`),inputTokens:H(),outputTokens:H(),model:V()}),U({...Qc,type:G(`notify`),title:V(),body:V(),level:W([`info`,`warn`,`error`])}),U({...Qc,type:G(`secret.request`),requestId:V(),name:V(),reason:V()}),U({...Qc,type:G(`thread.updated`),threadId2:V()})]);var $c=oc(`kind`,[U({kind:G(`mouse`),action:W([`move`,`down`,`up`,`wheel`]),x:H().min(0).max(1),y:H().min(0).max(1),button:W([`left`,`middle`,`right`]).default(`left`),clickCount:H().int().min(0).max(3).default(1),deltaX:H().default(0),deltaY:H().default(0)}),U({kind:G(`key`),action:W([`down`,`up`]),key:V().min(1).max(32)}),U({kind:G(`text`),text:V().min(1).max(4096)})]);oc(`type`,[U({type:G(`input`),input:$c}),U({type:G(`selection-request`)})]),U({name:V().min(1).max(60),title:V().max(120).optional(),description:V().max(8e3).optional(),avatarEmoji:V().max(8).optional(),modelTier:zc.optional()}).partial().extend({pinned:Ys().optional(),hidden:Ys().optional(),notifications:Ys().optional()}),U({kind:W([`dm`,`group`]),title:V().optional(),memberBotIds:tc(V())}),U({contentMd:V(),attachmentIds:tc(V()).optional(),replyToId:V().nullable().optional(),mentionBotIds:tc(V()).optional(),mentionEveryone:Ys().optional()}),U({decision:W([`allow`,`deny`]),alwaysRule:U({toolPattern:V(),inputPattern:V().default(``),scopeNote:V().default(``)}).optional()}),U({kind:W([`require`,`allow`]),toolPattern:V().min(1),inputPattern:V().default(``),scopeNote:V().default(``)}),U({botId:V(),name:V().min(1),cronExpr:V().min(1),timezone:V().optional(),instructionMd:V().min(1),enabled:Ys().optional()}),U({name:V().min(1),description:V().default(``),bodyMd:V().min(1),source:W([`user`,`taught`,`imported`]).optional()}),U({name:Xc.shape.name,description:V().default(``),config:Yc.optional(),builtin:V().optional(),enabled:Ys().optional(),botIds:tc(V()).optional()}).refine(e=>!!e.config!=!!e.builtin,{message:`Give either config or builtin, not both`}),U({description:V().optional(),config:Yc.optional(),enabled:Ys().optional()});var K={timezone:V(),maxConcurrentSessions:H().min(1).max(8),autoReviewEnabled:Ys(),theme:W([`system`,`light`,`dark`]),localExecution:W([`ask`,`always`,`never`]),dailyTokenBudget:H(),notificationsEnabled:Ys(),billingMode:W([`subscription`,`api`]),computerMode:W([`host`,`container`])};U({timezone:K.timezone.default(`UTC`),maxConcurrentSessions:K.maxConcurrentSessions.default(2),autoReviewEnabled:K.autoReviewEnabled.default(!0),theme:K.theme.default(`system`),localExecution:K.localExecution.default(`ask`),dailyTokenBudget:K.dailyTokenBudget.default(0),notificationsEnabled:K.notificationsEnabled.default(!0),billingMode:K.billingMode.default(`subscription`),computerMode:K.computerMode.default(`host`)}),U(K).partial(),U({kind:W([`message`,`file`,`routine`,`bot`]),id:V(),threadId:V().nullable(),botId:V().nullable(),title:V(),snippet:V(),createdAt:H()});var el=sn.MAX_ATTACHMENTS_PER_MESSAGE;function tl(e,t){let n=e.slice(0,t),r=/(^|\s)([@/])([\w-]*)$/.exec(n);if(!r)return null;let i=r[2];return i===`/`&&n.trim()!==`/${r[3]}`?null:{prefix:i,query:r[3],start:t-r[3].length-1}}function nl({onSend:e,bots:t,skills:n,running:r,onStop:i,uploadFile:a}){let[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),m=(0,_.useRef)(0);(0,_.useEffect)(()=>{m.current=c.length},[c.length]);let h=(0,_.useMemo)(()=>a??(e=>w.attachments.upload(e)),[a]),g=(0,_.useMemo)(()=>{if(!u||u.prefix!==`@`)return[];let e=u.query.toLowerCase();return t.filter(t=>t.bot.name.toLowerCase().includes(e)||t.bot.slug.toLowerCase().includes(e)).slice(0,8)},[u,t]),v=(0,_.useMemo)(()=>{if(!u||u.prefix!==`/`)return[];let e=u.query.toLowerCase();return n.filter(t=>t.slug.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)).slice(0,8)},[u,n]);function y(e){let t=Array.from(e),n=Math.max(0,el-m.current),r=t.slice(0,n);m.current=Math.min(el,m.current+r.length);for(let e of r)h(e).then(e=>{l(t=>t.length>=el?t:[...t,e])}).catch(()=>{m.current=Math.max(0,m.current-1)})}function b(e){l(t=>t.filter(t=>t.id!==e))}function x(){let t=o.trim();t&&(e(t,c.map(e=>e.id)),s(``),l([]),d(null))}function ee(e,t){s(e),d(tl(e,t))}function te(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),x()):e.key===`Escape`&&d(null)}function S(e){if(!u)return;let t=p.current,n=t?t.selectionStart:o.length,r=o.slice(0,u.start),i=o.slice(n),a=u.prefix===`@`?`@${e} `:`/${e} `,c=`${r}${a}${i}`;s(c),d(null),requestAnimationFrame(()=>{t?.focus();let e=r.length+a.length;t?.setSelectionRange(e,e)})}function ne(e){let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e);t.length>0&&(e.preventDefault(),y(t))}function re(e){e.preventDefault(),e.dataTransfer.files.length>0&&y(e.dataTransfer.files)}return(0,O.jsxs)(`div`,{className:`shrink-0 border-t border-(--color-border) bg-(--color-bg-elevated) p-3`,onDrop:re,onDragOver:e=>e.preventDefault(),children:[c.length>0&&(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:c.map(e=>(0,O.jsxs)(`span`,{"data-testid":`attachment-chip`,className:`flex items-center gap-1.5 rounded-full border border-(--color-border) bg-(--color-bg) px-2.5 py-1 text-xs`,children:[e.name,(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,className:`text-(--color-text-muted) hover:text-(--color-red)`,onClick:()=>b(e.id),children:`×`})]},e.id))}),u&&(g.length>0||v.length>0)&&(0,O.jsx)(`div`,{className:`mb-2 max-h-40 overflow-auto rounded border border-(--color-border) bg-(--color-bg) text-sm shadow-lg`,children:u.prefix===`@`?g.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.bot.slug),children:[(0,O.jsx)(`span`,{children:e.bot.avatarEmoji}),(0,O.jsx)(`span`,{children:e.bot.name})]},e.bot.id)):v.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.slug),children:[(0,O.jsxs)(`span`,{className:`shrink-0 font-mono text-(--color-text-muted)`,children:[`/`,e.slug]}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-(--color-text-muted)`,title:e.description,children:e.description})]},e.id))}),(0,O.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`Attach files`,className:`shrink-0 rounded border border-(--color-border) px-2.5 py-2 text-sm hover:bg-(--color-bg-hover)`,onClick:()=>f.current?.click(),children:`+`}),(0,O.jsx)(`input`,{ref:f,"data-testid":`attachment-input`,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&y(e.target.files),e.target.value=``}}),(0,O.jsx)(`textarea`,{ref:p,value:o,rows:1,placeholder:`Message… (@ to mention, / for a skill)`,className:`max-h-40 min-h-[38px] flex-1 resize-none rounded border border-(--color-border) bg-(--color-bg) px-3 py-2 text-sm outline-none focus:border-(--color-accent)`,onChange:e=>ee(e.target.value,e.target.selectionStart),onKeyDown:te,onPaste:ne}),r&&(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 rounded border border-(--color-red) px-3 py-2 text-sm font-medium text-(--color-red) hover:bg-(--color-red)/10`,children:`Stop`}),(0,O.jsx)(`button`,{type:`button`,onClick:x,disabled:!o.trim(),className:`shrink-0 rounded bg-(--color-accent) px-3 py-2 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Send`})]})]})}M.setOptions({breaks:!0});function rl(e){return M.parse(e,{async:!1}).replace(/<script[\s\S]*?<\/script>/gi,``)}function il(e,t){if(e.authorKind===`user`)return{name:`You`,emoji:`🧑`};if(e.authorKind===`system`)return{name:`System`,emoji:`⚙️`};let n=e.authorBotId?t[e.authorBotId]?.bot:void 0;return{name:n?.name??`Bot`,emoji:n?.avatarEmoji??`🤖`}}function al({message:e,botsById:t}){let{name:n,emoji:r}=il(e,t),i=e.authorKind===`user`;return(0,O.jsxs)(`div`,{className:b(`flex gap-3 px-4 py-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`mt-0.5 text-lg leading-none`,children:r}),(0,O.jsxs)(`div`,{className:b(`min-w-0 max-w-[75%]`,i&&`items-end text-right`),children:[(0,O.jsxs)(`div`,{className:b(`mb-0.5 flex items-baseline gap-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:n}),(0,O.jsx)(`span`,{className:`text-[11px] text-(--color-text-faint)`,children:new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),e.contentMd&&(0,O.jsxs)(`div`,{className:b(`markdown-body inline-block rounded-lg px-3 py-2 text-sm`,i?`bg-(--color-accent) text-(--color-accent-fg)`:`bg-(--color-bg-elevated)`),children:[(0,O.jsx)(`span`,{dangerouslySetInnerHTML:{__html:rl(e.contentMd)}}),e.streaming&&(0,O.jsx)(`span`,{className:`ml-0.5 inline-block w-1.5 animate-pulse bg-current align-middle`,children:`\xA0`})]}),(0,O.jsx)(on,{cards:e.cards})]})]})}function ol({thread:e,messages:t,botsById:n,bots:r,skills:i,running:a,onSend:o,onStop:s}){let c=(0,_.useRef)(null),[l,u]=(0,_.useState)(!0);(0,_.useEffect)(()=>{if(!l)return;let e=()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)};e();let t=requestAnimationFrame(()=>{e(),requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[t,l]);function d(){let e=c.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;u(t<80)}return e?(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{ref:c,onScroll:d,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:t.length===0?(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-(--color-text-muted)`,children:`No messages yet — say hello and give this bot a job.`}):t.map(e=>(0,O.jsx)(al,{message:e,botsById:n},e.id))}),(0,O.jsx)(nl,{onSend:o,bots:r,skills:i,running:a,onStop:s})]}):(0,O.jsx)(`div`,{className:`flex h-full flex-1 flex-col items-center justify-center text-(--color-text-muted)`,children:(0,O.jsx)(`p`,{className:`text-sm`,children:`Select a bot to start a conversation, or create a new one.`})})}var sl=`🤖.🧠.🦾.🛰️.🧭.🗂️.📚.🔍.🧮.🧰.🛠️.⚙️.🧪.🧬.📈.📊.💡.🗒️.✍️.📝.📅.⏰.📬.📡.🌐.🔐.🗝️.🧯.🚀.🛎️.🎯.🧵.🧩.🕵️.🧑‍💻.👩‍💻.🧑‍🔬.🐜.🐝.🦉`.split(`.`);function cl({onCreate:e,onClose:t,busy:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(`🤖`),[f,p]=(0,_.useState)(`sonnet`);function m(){i.trim()&&e({name:i.trim(),title:o.trim(),description:c.trim(),avatarEmoji:u,modelTier:f})}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-(--color-border) bg-(--color-bg-elevated) p-5 shadow-xl`,children:[(0,O.jsx)(`h2`,{className:`mb-4 text-base font-semibold`,children:`New bot`}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsx)(`div`,{className:`grid grid-cols-8 gap-1 rounded border border-(--color-border) p-1.5`,children:sl.slice(0,16).map(e=>(0,O.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded p-1 text-lg ${u===e?`bg-(--color-accent)/25`:`hover:bg-(--color-bg-hover)`}`,children:e},e))})}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Name`}),(0,O.jsx)(`input`,{autoFocus:!0,className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value),placeholder:`Scout`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:o,onChange:e=>s(e.target.value),placeholder:`Research assistant`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:3,value:c,onChange:e=>l(e.target.value),placeholder:`What should this bot do?`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Rc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${f===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),(0,O.jsx)(`p`,{className:`rounded border border-(--color-amber)/40 bg-(--color-amber)/10 p-2 text-xs text-(--color-amber)`,children:`Bots share one computer, workspace, browser profile and logins. Bots are not a security boundary.`}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]}),(0,O.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`rounded px-3 py-1.5 text-sm text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,disabled:!i.trim()||n,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create bot`})]})]})})}var ll={running:`text-(--color-blue)`,ok:`text-(--color-green)`,failed:`text-(--color-red)`,interrupted:`text-(--color-amber)`};function ul({botId:e,onCreated:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(`0 9 * * *`),[o,s]=(0,_.useState)(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null);async function m(){if(!(!n.trim()||!i.trim()||!c.trim())){d(!0),p(null);try{t(await w.routines.create({botId:e,name:n,cronExpr:i,timezone:o,instructionMd:c})),r(``),l(``)}catch(e){p(e instanceof ie?e.message:`Failed to create routine`)}finally{d(!1)}}}return(0,O.jsxs)(`div`,{className:`space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:`New routine`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Name`,value:n,onChange:e=>r(e.target.value)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Cron expression (e.g. 0 9 * * *)`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{className:`w-40 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Timezone`,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Instructions for this run…`,rows:3,value:c,onChange:e=>l(e.target.value)}),f&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:f}),(0,O.jsx)(`button`,{type:`button`,disabled:u,onClick:m,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create routine`})]})}function dl({routine:e,onChanged:t,onDeleted:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1);async function d(){let t=await w.routines.runs(e.id);i(t.slice(0,20))}async function f(){let e=!a;o(e),e&&await d()}async function p(){t(await w.routines.update(e.id,{enabled:!e.enabled}))}async function m(){window.confirm(`Delete routine "${e.name}"?`)&&(await w.routines.remove(e.id),n(e.id))}async function h(){u(!0),c(!1);try{await w.routines.testRun(e.id),await d(),o(!0)}finally{u(!1)}}return(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsxs)(`div`,{className:`font-mono text-xs text-(--color-text-muted)`,children:[e.cronExpr,` · `,e.timezone]}),e.nextRunAt&&(0,O.jsxs)(`div`,{className:`text-xs text-(--color-text-faint)`,children:[`Next run: `,new Date(e.nextRunAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:p}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),disabled:l,className:`rounded border border-(--color-border) px-2 py-1 text-xs hover:bg-(--color-bg-hover)`,children:`Test run`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red)`,children:`Delete`})]})]}),s&&(0,O.jsxs)(`div`,{className:`mt-2 rounded border border-(--color-amber)/50 bg-(--color-amber)/10 p-2 text-xs`,children:[(0,O.jsx)(`p`,{className:`text-(--color-amber)`,children:`A test run performs real work — it can navigate websites, change files and call connected tools.`}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-amber) px-2 py-1 font-medium text-(--color-bg)`,children:`Run anyway`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`rounded px-2 py-1 text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`mt-2 text-xs text-(--color-text-muted) hover:underline`,children:a?`Hide run history`:`Show run history`}),a&&(0,O.jsxs)(`ul`,{className:`mt-1 space-y-1`,children:[r.length===0&&(0,O.jsx)(`li`,{className:`text-xs text-(--color-text-faint)`,children:`No runs yet.`}),r.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsx)(`span`,{className:b(`font-medium`,ll[e.status]),children:e.status}),(0,O.jsx)(`span`,{className:`text-(--color-text-faint)`,children:new Date(e.startedAt).toLocaleString()}),e.isTest&&(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px]`,children:`test`}),e.summary&&(0,O.jsx)(`span`,{className:`truncate text-(--color-text-muted)`,children:e.summary})]},e.id))]})]})}function fl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let t=!1;return i(!0),w.routines.list(e).then(e=>{t||n(e)}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(ul,{botId:e,onCreated:e=>n(t=>[e,...t])}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`Loading routines…`}),!r&&t.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No routines yet.`}),t.map(e=>(0,O.jsx)(dl,{routine:e,onChanged:e=>n(t=>t.map(t=>t.id===e.id?e:t)),onDeleted:e=>n(t=>t.filter(t=>t.id!==e))},e.id))]})}function pl({bot:e,onUpdated:t}){let[n,r]=(0,_.useState)(e.name),[i,a]=(0,_.useState)(e.title),[o,s]=(0,_.useState)(e.description),[c,l]=(0,_.useState)(e.avatarEmoji),[u,d]=(0,_.useState)(e.modelTier),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1);async function y(){p(!0),h(null);try{t(await w.bots.update(e.id,{name:n,title:i,description:o,avatarEmoji:c,modelTier:u}))}catch(e){h(e instanceof ie?e.message:`Failed to save`)}finally{p(!1)}}return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex h-12 w-12 items-center justify-center rounded-lg border border-(--color-border) text-2xl hover:bg-(--color-bg-hover)`,children:c}),(0,O.jsx)(`div`,{className:`flex-1`,children:(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm font-medium`,value:n,onChange:e=>r(e.target.value),"aria-label":`Name`})})]}),g&&(0,O.jsx)(`div`,{className:`grid grid-cols-10 gap-1 rounded border border-(--color-border) p-2`,children:sl.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>{l(e),v(!1)},className:`rounded p-1 text-lg hover:bg-(--color-bg-hover)`,children:e},e))}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value)})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description / persona`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:4,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Rc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${u===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),m&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:m}),(0,O.jsx)(`button`,{type:`button`,onClick:y,disabled:f,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Save profile`})]})}function ml({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``);(0,_.useEffect)(()=>{w.bots.memory.list(e).then(n)},[e]);function l(e){i(e),o(t.find(t=>t.name===e)?.content??``)}async function u(){let t=r??s.trim();t&&(await w.bots.memory.save(e,t,a),n(e=>{let n=e.findIndex(e=>e.name===t);return n===-1?[...e,{name:t,content:a}]:e.map((e,r)=>r===n?{name:t,content:a}:e)}),i(t),c(``))}async function d(t){await w.bots.memory.remove(e,t),n(e=>e.filter(e=>e.name!==t)),r===t&&(i(null),o(``))}return(0,O.jsxs)(`div`,{className:`grid grid-cols-[160px_1fr] gap-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[t.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(e.name),className:`flex-1 truncate rounded px-2 py-1 text-left text-xs ${r===e.name?`bg-(--color-accent)/15`:`hover:bg-(--color-bg-hover)`}`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e.name),"aria-label":`Delete ${e.name}`,className:`text-xs text-(--color-text-faint) hover:text-(--color-red)`,children:`×`})]},e.name)),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,placeholder:`new-file.md`,value:s,onChange:e=>{c(e.target.value),i(null),o(``)}})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`textarea`,{className:`h-40 w-full rounded border border-(--color-border) bg-(--color-bg) p-2 font-mono text-xs`,value:a,onChange:e=>o(e.target.value),placeholder:`Durable facts this bot should remember…`}),(0,O.jsx)(`button`,{type:`button`,onClick:u,className:`mt-2 rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save memory file`})]})]})}function hl({skill:e,checked:t,onToggle:n}){let[r,i]=(0,_.useState)(!1),a=`skill-${e.id}`;return(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,O.jsx)(`input`,{id:a,type:`checkbox`,className:`mt-1 shrink-0`,checked:t,onChange:n}),(0,O.jsx)(`label`,{htmlFor:a,className:`shrink-0 cursor-pointer whitespace-nowrap font-medium`,children:e.name}),e.description&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,title:r?`Collapse description`:`Show the full description`,className:`min-w-0 flex-1 cursor-pointer text-left text-xs text-(--color-text-muted) hover:text-(--color-text) ${r?`whitespace-pre-wrap break-words`:`truncate`}`,children:[`— `,e.description]})]})}function gl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{w.connectors.list().then(n)},[]),(0,_.useEffect)(()=>{w.bots.connectors.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);async function s(t){if(!r)return;let n=new Set(r);n.has(t)?n.delete(t):n.add(t),i(n),o(null);try{await w.bots.connectors.set(e,Array.from(n))}catch(e){i(r),o(e instanceof ie?e.message:`Could not save`)}}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No connectors yet. Add one on the Connectors screen.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-start gap-2 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:r?.has(e.id)??!1,disabled:!r,onChange:()=>s(e.id),className:`mt-0.5`}),(0,O.jsxs)(`span`,{className:`min-w-0`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:String(e.config.transport)}),!e.enabled&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:`(disabled)`}),e.missingSecrets.length>0&&(0,O.jsxs)(`span`,{className:`ml-1 text-(--color-amber)`,children:[`missing secret: `,e.missingSecrets.join(`, `)]}),e.lastStatus===`needs-sign-in`&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-amber)`,children:`needs sign-in`}),e.description&&(0,O.jsx)(`span`,{className:`block truncate text-(--color-text-muted)`,title:e.description,children:e.description})]})]},e.id)),a&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:a})]})}function _l({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(new Set),[a,o]=(0,_.useState)(!1);(0,_.useEffect)(()=>{w.skills.list().then(n)},[]),(0,_.useEffect)(()=>{w.bots.skills.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);function s(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),o(!1)}async function c(){await w.bots.skills.set(e,Array.from(r)),o(!0)}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No skills taught yet.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsx)(hl,{skill:e,checked:r.has(e.id),onToggle:()=>s(e.id)},e.id)),(0,O.jsx)(`button`,{type:`button`,onClick:c,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save skills`}),a&&(0,O.jsx)(`span`,{className:`ml-2 text-xs text-(--color-green)`,children:`Saved`})]})}function vl({bot:e,onClose:t,onUpdated:n,onDuplicated:r,onDeleted:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null);async function d(){n(await w.bots.update(e.id,{pinned:!e.pinned}))}async function f(){n(await w.bots.update(e.id,{hidden:!e.hidden}))}async function p(){n(await w.bots.update(e.id,{notifications:!e.notifications}))}async function m(){r(await w.bots.duplicate(e.id))}async function h(){await w.bots.remove(e.id),i(e.id)}return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto p-5`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[e.name,` settings`]}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]}),(0,O.jsx)(`section`,{className:`mb-6`,children:(0,O.jsx)(pl,{bot:e,onUpdated:n})}),(0,O.jsxs)(`section`,{className:`mb-6 flex flex-wrap gap-2 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.pinned?`Unpin`:`Pin`}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.hidden?`Unhide`:`Hide`}),(0,O.jsx)(`button`,{type:`button`,onClick:p,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.notifications?`Mute notifications`:`Unmute notifications`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Duplicate`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`rounded border border-(--color-red)/50 px-3 py-1.5 text-xs text-(--color-red) hover:bg-(--color-red)/10`,children:`Delete`})]}),s&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-border) bg-(--color-bg-elevated) p-3 text-sm`,children:[(0,O.jsx)(`p`,{className:`mb-1`,children:`Clear this conversation and start a fresh session?`}),(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-text-muted)`,children:`Deletes the messages in this thread and drops the model’s accumulated context. Keeps the Bot’s description, memory, skills, connectors, routines and files.`}),l&&(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-red)`,children:l}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{u(null);try{await w.bots.reset(e.id),c(!1),n(e)}catch(e){u(e instanceof ie?e.message:`Could not start fresh`)}},className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{c(!1),u(null)},className:`rounded border border-(--color-border) px-3 py-1.5 text-xs`,children:`Cancel`})]})]}),a&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-red)/50 bg-(--color-red)/10 p-3 text-sm`,children:[(0,O.jsxs)(`p`,{className:`text-(--color-red)`,children:[`Delete `,e.name,`? This removes it from your roster and conversation history, but its workspace files and any browser logins it used survive deletion.`]}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-red) px-3 py-1.5 text-xs font-medium text-white`,children:`Delete permanently`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded px-3 py-1.5 text-xs text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Memory`}),(0,O.jsx)(ml,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Skills`}),(0,O.jsx)(_l,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Connectors`}),(0,O.jsx)(gl,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Routines`}),(0,O.jsx)(fl,{botId:e.id})]})]})}function yl({kind:e}){return(0,O.jsx)(`span`,{className:b(`rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,e===`require`?`bg-(--color-red)/15 text-(--color-red)`:`bg-(--color-green)/15 text-(--color-green)`),children:e===`require`?`Require approval`:`Always allow`})}function bl({onCreated:e}){let[t,n]=(0,_.useState)(`require`),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(null);async function d(){if(r.trim())try{e(await w.rules.create({kind:t,toolPattern:r.trim(),inputPattern:a,scopeNote:s})),i(``),o(``),c(``),u(null)}catch(e){u(e instanceof ie?e.message:`Failed to create rule`)}}return(0,O.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`flex gap-2`,children:[`require`,`allow`].map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:b(`rounded px-3 py-1 text-xs font-medium`,t===e?`bg-(--color-accent) text-(--color-accent-fg)`:`border border-(--color-border) text-(--color-text-muted)`),children:e===`require`?`Require approval`:`Always allow`},e))}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Tool pattern (e.g. Bash, browser_*, *)`,value:r,onChange:e=>i(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Input pattern (optional regex)`,value:a,onChange:e=>o(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Scope note (why this rule exists)`,value:s,onChange:e=>c(e.target.value)}),l&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:l}),(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg)`,children:`Add rule`})]})}function xl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0);(0,_.useEffect)(()=>{w.rules.list().then(t).finally(()=>r(!1))},[]);async function i(e){let n=await w.rules.update(e.id,!e.enabled);t(e=>e.map(e=>e.id===n.id?n:e))}async function a(e){e.builtin||window.confirm(`Delete rule for "${e.toolPattern}"?`)&&(await w.rules.remove(e.id),t(t=>t.filter(t=>t.id!==e.id)))}return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-1 text-lg font-semibold`,children:`Rules`}),(0,O.jsx)(`p`,{className:`mb-4 text-sm text-(--color-text-muted)`,children:`Require Approval always wins over Always Allow.`}),(0,O.jsx)(bl,{onCreated:e=>t(t=>[e,...t])}),n&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Loading…`}),!n&&e.length===0&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No rules yet.`}),(0,O.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(yl,{kind:e.kind}),e.builtin&&(0,O.jsx)(`span`,{title:`Built-in rule`,"aria-label":`Built-in rule`,className:`text-(--color-text-faint)`,children:`🔒`}),(0,O.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e.toolPattern})]}),e.inputPattern&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-(--color-text-muted)`,children:e.inputPattern}),e.scopeNote&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-(--color-text-faint)`,children:e.scopeNote})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>i(e)}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e),disabled:e.builtin,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red) disabled:cursor-not-allowed disabled:opacity-30`,children:`Delete`})]})]},e.id))})]})}function Sl({label:e,value:t,max:n,sublabel:r}){let i=n>0?Math.max(2,Math.round(t/n*100)):0;return(0,O.jsxs)(`div`,{className:`mb-2`,children:[(0,O.jsxs)(`div`,{className:`mb-0.5 flex items-baseline justify-between text-xs`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e}),(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:r??t.toLocaleString()})]}),(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-bg)`,children:(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-accent)`,style:{width:`${i}%`}})})]})}function Cl(){let[e,t]=(0,_.useState)(null);if((0,_.useEffect)(()=>{w.usage().then(t)},[]),!e)return(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading usage…`});let n=e.totals.inputTokens+e.totals.outputTokens,r=Math.max(1,...e.byBot.map(e=>e.inputTokens+e.outputTokens)),i=Math.max(1,...e.byDay.map(e=>e.inputTokens+e.outputTokens)),a=Math.max(1,...e.byModel.map(e=>e.inputTokens+e.outputTokens));return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-4 text-lg font-semibold`,children:`Usage`}),(0,O.jsxs)(`section`,{className:`mb-6 grid grid-cols-3 gap-3`,children:[(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Input tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.inputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Output tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.outputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Cache-read tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.cacheReadTokens.toLocaleString()})]})]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By bot`}),e.byBot.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byBot.map(e=>(0,O.jsx)(Sl,{label:e.botName,value:e.inputTokens+e.outputTokens,max:r},e.botId))]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By day`}),(0,O.jsx)(`div`,{className:`flex items-end gap-1`,style:{height:96},children:e.byDay.map(e=>{let t=e.inputTokens+e.outputTokens,n=Math.max(2,Math.round(t/i*88));return(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-end`,title:`${e.day}: ${t.toLocaleString()} tokens`,children:[(0,O.jsx)(`div`,{className:`w-full rounded-t bg-(--color-accent)`,style:{height:n}}),(0,O.jsx)(`span`,{className:`mt-1 rotate-0 text-[9px] text-(--color-text-faint)`,children:e.day.slice(5)})]},e.day)})}),e.byDay.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By model`}),e.byModel.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byModel.map(e=>(0,O.jsx)(Sl,{label:e.model,value:e.inputTokens+e.outputTokens,max:a,sublabel:n>0?`${Math.round((e.inputTokens+e.outputTokens)/n*100)}%`:`0%`},e.model))]})]})}var wl=`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`;function Tl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);(0,_.useEffect)(()=>{w.secrets.list().then(e=>{t(e.names),r(e.backend)}).catch(()=>d(!0))},[]);async function f(){l(null);try{let e=await w.secrets.set(i.trim(),o);t(e.names),a(``),s(``)}catch(e){l(e instanceof ie?e.message:`Could not store the secret`)}}async function p(e){l(null);try{let n=await w.secrets.remove(e);t(n.names)}catch(e){l(e instanceof ie?e.message:`Could not remove the secret`)}}return u?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets backend is available on this machine.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-text-muted)`,children:[`Stored in your `,n===`file`?`ant-bot data directory`:n??`keychain`,`. Names only are ever shown; a value cannot be read back, by you or by a bot.`]}),e.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets stored.`}):(0,O.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`code`,{className:`flex-1 truncate`,children:e}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded border border-(--color-border) px-2 py-0.5 text-xs text-(--color-red)`,children:`Remove`})]},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:`${wl} w-2/5`,placeholder:`NAME`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:`${wl} flex-1`,placeholder:`value`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,onClick:f,disabled:!i.trim()||!o,className:`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,children:`Store`})]}),c&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:c})]})}function El({label:e,children:t}){return(0,O.jsxs)(`label`,{className:`mb-3 flex items-center justify-between gap-4 border-b border-(--color-border) py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:e}),t]})}function Dl({onSettingsChange:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!1);(0,_.useEffect)(()=>{w.settings.get().then(t=>{n(t),e?.(t)})},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let t=await w.settings.update(r);n(t),e?.(t)}finally{i(!1)}}return t?(0,O.jsxs)(`div`,{className:`mx-auto max-w-xl p-6`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),r&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:`Saving…`})]}),(0,O.jsx)(El,{label:`Timezone`,children:(0,O.jsx)(`input`,{className:`w-48 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.timezone,onChange:e=>a({timezone:e.target.value})})}),(0,O.jsx)(El,{label:`Max concurrent sessions`,children:(0,O.jsx)(`input`,{type:`number`,min:1,max:8,className:`w-20 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.maxConcurrentSessions,onChange:e=>a({maxConcurrentSessions:Math.min(8,Math.max(1,Number(e.target.value)||1))})})}),(0,O.jsx)(El,{label:`Auto-review (Haiku triage of tool calls)`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.autoReviewEnabled,onChange:e=>a({autoReviewEnabled:e.target.checked})})}),(0,O.jsx)(El,{label:`Theme`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.theme,onChange:e=>a({theme:e.target.value}),children:[(0,O.jsx)(`option`,{value:`system`,children:`System`}),(0,O.jsx)(`option`,{value:`light`,children:`Light`}),(0,O.jsx)(`option`,{value:`dark`,children:`Dark`})]})}),(0,O.jsx)(El,{label:`Local execution (run commands on this machine)`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.localExecution,onChange:e=>a({localExecution:e.target.value}),children:[(0,O.jsx)(`option`,{value:`ask`,children:`Ask`}),(0,O.jsx)(`option`,{value:`always`,children:`Always`}),(0,O.jsx)(`option`,{value:`never`,children:`Never`})]})}),(0,O.jsx)(El,{label:`Daily token budget (0 = unlimited)`,children:(0,O.jsx)(`input`,{type:`number`,min:0,className:`w-32 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.dailyTokenBudget,onChange:e=>a({dailyTokenBudget:Math.max(0,Number(e.target.value)||0)})})}),(0,O.jsx)(El,{label:`Desktop notifications`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.notificationsEnabled,onChange:e=>a({notificationsEnabled:e.target.checked})})}),(0,O.jsx)(El,{label:`Billing mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.billingMode,onChange:e=>a({billingMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`subscription`,children:`Subscription`}),(0,O.jsx)(`option`,{value:`api`,children:`API (metered)`})]})}),(0,O.jsx)(El,{label:`Computer mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.computerMode,onChange:e=>a({computerMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`host`,children:`Host`}),(0,O.jsx)(`option`,{value:`container`,children:`Container`})]})}),(0,O.jsx)(`h2`,{className:`mt-8 mb-2 text-sm font-semibold`,children:`Secrets`}),(0,O.jsx)(Tl,{})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading settings…`})}var Ol=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,kl=/\.(md|markdown|txt|json|ya?ml|csv|log|ts|tsx|js|jsx|py|sh|css|html)$/i;function Al(e){return e.startsWith(`.`)}function jl({entry:e,depth:t,showHidden:n,onOpenFile:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1);async function u(){if(!e.dir){r(e.path);return}if(!i&&o===null){l(!0);let t=await w.workspace.tree(e.path);s(t),l(!1)}a(e=>!e)}return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`button`,{type:`button`,onClick:u,className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-sm hover:bg-(--color-bg-hover)`,style:{paddingLeft:`${t*14+6}px`},children:[(0,O.jsx)(`span`,{className:`w-3 shrink-0 text-(--color-text-faint)`,children:e.dir?i?`▾`:`▸`:``}),(0,O.jsx)(`span`,{className:`shrink-0`,children:e.dir?`📁`:`📄`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name}),!e.dir&&(0,O.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-(--color-text-faint)`,children:[e.bytes,`B`]})]}),i&&(0,O.jsxs)(`div`,{children:[c&&(0,O.jsx)(`div`,{style:{paddingLeft:`${(t+1)*14+6}px`},className:`py-1 text-xs text-(--color-text-faint)`,children:`Loading…`}),o?.filter(e=>n||!Al(e.name)).map(e=>(0,O.jsx)(jl,{entry:e,depth:t+1,showHidden:n,onOpenFile:r},e.path))]})]})}function Ml({path:e,onClose:t}){let[n,r]=(0,_.useState)(null),i=e.split(`/`).pop()??e,a=Ol.test(i),o=kl.test(i);return(0,_.useEffect)(()=>{r(null),o&&fetch(w.workspace.fileUrl(e)).then(e=>e.text()).then(r).catch(()=>r(`(failed to load preview)`))},[e,o]),(0,O.jsxs)(`div`,{className:`flex h-full flex-col border-l border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm font-medium`,children:i}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`a`,{href:w.workspace.fileUrl(e),download:i,className:`text-xs text-(--color-accent) hover:underline`,children:`Download`}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[a&&(0,O.jsx)(`img`,{src:w.workspace.fileUrl(e),alt:i,className:`max-w-full`}),o&&(0,O.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs`,children:n??`Loading…`}),!a&&!o&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No inline preview available — use Download.`})]})]})}function Nl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{w.workspace.tree(``).then(t).finally(()=>s(!1))},[]),(0,O.jsxs)(`div`,{className:`flex h-full`,children:[(0,O.jsxs)(`div`,{className:`flex w-80 shrink-0 flex-col border-r border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workspace`}),(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),`Hidden files`]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[o&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Loading…`}),!o&&e.length===0&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Workspace is empty.`}),e.filter(e=>n||!Al(e.name)).map(e=>(0,O.jsx)(jl,{entry:e,depth:0,showHidden:n,onOpenFile:a},e.path))]})]}),i&&(0,O.jsx)(`div`,{className:`w-96 shrink-0`,children:(0,O.jsx)(Ml,{path:i,onClose:()=>a(null)})})]})}function Pl(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null);(0,_.useEffect)(()=>{w.computer.status().then(e=>{t(e),e.pages.length>0&&r(e.pages[0].botId)})},[]);async function g(e){if(!e){h(`Nothing is selected on the remote page.`);return}try{await navigator.clipboard.writeText(e),h(`Copied ${e.length.toLocaleString()} character${e.length===1?``:`s`} from the page.`)}catch{h(`The browser refused clipboard access, so the selection was not copied.`)}}(0,_.useEffect)(()=>{if(a(null),u.current?.close(),!n||!e?.available)return;let t=window.location.protocol===`https:`?`wss`:`ws`,r=new WebSocket(`${t}://${window.location.host}/api/computer/screencast/${n}`);return u.current=r,r.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`frame`?a({data:t.data,w:t.w,h:t.h}):t.type===`selection`?g(t.text??``):t.type===`input-error`&&h(t.message??`Input was rejected.`)}catch{}},()=>r.close()},[n,e?.available]),(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]),(0,_.useEffect)(()=>{o&&d.current?.focus()},[o]);async function v(){if(!n)return;let e=await w.computer.takeover(n);s(e.ok),l(e.message??null)}async function y(){n&&(await w.computer.returnControl(n),s(!1),l(null))}function b(e){let t=u.current;if(!(!o||!t||t.readyState!==WebSocket.OPEN))try{t.send(JSON.stringify(e))}catch{}}function x(e){b({type:`input`,input:e})}function ee(e){let t=e.currentTarget.getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}}let te=[`left`,`middle`,`right`];return e?e.available?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-(--color-border) p-3`,children:[(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:n??``,onChange:e=>r(e.target.value||null),children:[e.pages.length===0&&(0,O.jsx)(`option`,{value:``,children:`No active pages`}),e.pages.map(e=>(0,O.jsx)(`option`,{value:e.botId,children:e.title||e.url},e.botId))]}),(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:o?(0,O.jsx)(`button`,{type:`button`,onClick:y,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Return control`}):(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:!n,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs font-medium hover:bg-(--color-bg-hover) disabled:opacity-40`,children:`Take over`})})]}),(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Never paste passwords or one-time codes into chat — use takeover.`}),c&&(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:c}),(0,O.jsx)(`div`,{ref:d,tabIndex:o?0:-1,onFocus:()=>p(!0),onBlur:()=>p(!1),onKeyDown:e=>{if(o&&!((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`)){if((e.ctrlKey||e.metaKey)&&(e.key.toLowerCase()===`c`||e.key.toLowerCase()===`x`)){e.preventDefault(),b({type:`selection-request`}),e.key.toLowerCase()===`x`&&x({kind:`key`,action:`down`,key:e.key});return}e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey?x({kind:`text`,text:e.key}):x({kind:`key`,action:`down`,key:e.key})}},onKeyUp:e=>{o&&((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`||(e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey||x({kind:`key`,action:`up`,key:e.key})))},onPaste:e=>{if(!o)return;e.preventDefault();let t=e.clipboardData.getData(`text`);t&&x({kind:`text`,text:t.slice(0,4096)})},className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-black/20 p-3 outline-none ${o&&!f?`ring-2 ring-(--color-amber) ring-inset`:``}`,children:i?(0,O.jsx)(`img`,{src:`data:image/jpeg;base64,${i.data}`,width:i.w,height:i.h,alt:`Agent computer screencast`,draggable:!1,onPointerMove:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`move`,...t,button:`left`,clickCount:1,deltaX:0,deltaY:0})},onPointerDown:e=>{let t=ee(e);t&&(d.current?.focus(),x({kind:`mouse`,action:`down`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0}))},onPointerUp:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`up`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0})},onWheel:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`wheel`,...t,button:`left`,clickCount:1,deltaX:e.deltaX,deltaY:e.deltaY})},onContextMenu:e=>{o&&e.preventDefault()},className:`max-h-full max-w-full rounded border border-(--color-border) ${o?`cursor-crosshair`:`pointer-events-none select-none`}`}):(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Waiting for a screencast frame…`})}),o&&!f&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Click the screen to send keystrokes to it.`}),m&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:m})]}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:`The agent computer isn't available right now.`}),(0,O.jsx)(`p`,{className:`max-w-sm text-xs text-(--color-text-muted)`,children:`Bots can still browse the web and use tools — you just won't see a live screencast until the computer service starts.`})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Checking the computer service…`})}var Fl=`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,Il=`mb-1 block text-xs text-(--color-text-muted)`,Ll=`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,q=0,J=()=>({id:q++,k:``,v:``,secret:!1}),Y=(e,t)=>`mcp/${e}/${t}`;function X(e){let t=(e.match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^["'].*["']$/.test(e)?e.slice(1,-1):e);return{command:t[0]??``,args:t.slice(1)}}var Z=e=>/^https?:\/\//i.test(e.trim());function Rl(e){let t=e.trim();if(!t)return``;let n;if(Z(t))try{n=new URL(t).hostname.replace(/^(mcp|www|api)\./,``).split(`.`)[0]??``}catch{n=``}else{let{command:e,args:r}=X(t);n=(r.find(e=>!e.startsWith(`-`))??e).split(`/`).pop()?.replace(/^(mcp-)?server-|-mcp(-server)?$/g,``)??``}return n.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,32)}function zl(e){let t=e.tools.length;switch(e.status){case`ready`:return{text:`ready — ${t} tool${t===1?``:`s`}`,tone:`ok`};case`needs-sign-in`:return e.alternative?{text:e.detail??`use the built-in instead: ${e.alternative}`,tone:`bad`}:{text:`needs sign-in${e.provider?` (${e.provider})`:``}`,tone:`warn`};case`needs-credential`:return{text:e.detail??`needs a credential`,tone:`warn`};case`unreachable`:return{text:`unreachable${e.detail?` — ${e.detail}`:``}`,tone:`bad`}}}var Bl={ok:`text-(--color-green)`,warn:`text-(--color-amber)`,bad:`text-(--color-red)`};function Vl({pairs:e,onChange:t,keyLabel:n}){let r=(n,r)=>t(e.map(e=>e.id===n?{...e,...r}:e));return(0,O.jsxs)(`div`,{className:`space-y-1`,children:[e.map(i=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`input`,{className:b(Fl,`w-2/5`),placeholder:n,value:i.k,onChange:e=>r(i.id,{k:e.target.value})}),(0,O.jsx)(`input`,{className:Fl,type:i.secret?`password`:`text`,placeholder:i.secret?`value (stored in your keychain)`:`value`,value:i.v,onChange:e=>r(i.id,{v:e.target.value})}),(0,O.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1 text-[11px] text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:i.secret,onChange:e=>r(i.id,{secret:e.target.checked}),"aria-label":`${i.k||n} is a secret`}),`secret`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e.id!==i.id)),className:b(Ll,`text-(--color-text-muted)`),children:`×`})]},i.id)),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,J()]),className:b(Ll,`text-(--color-text-muted)`),children:[`+ add `,n.toLowerCase()]})]})}function Hl({entry:e,provider:t,onSubmit:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``);return(0,O.jsxs)(`div`,{className:`mt-2 space-y-1 rounded bg-(--color-bg-elevated) p-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-amber)`,children:[t??`This provider`,` needs an OAuth client you create yourself — a one-time setup that every`,` `,t??`provider`,` connector then shares.`]}),e&&e.setupSteps.length>0&&(0,O.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-5 text-[11px] text-(--color-text-muted)`,children:e.setupSteps.map(e=>(0,O.jsx)(`li`,{children:e},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:Fl,placeholder:`client ID`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:Fl,placeholder:`client secret`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,disabled:!i.trim(),onClick:()=>n({clientId:i.trim(),...o.trim()?{clientSecret:o.trim()}:{}}),className:Ll,children:`Sign in`})]}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]})}function Ul({catalog:e,bots:t,onCreated:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),v=e.find(e=>e.name===r.trim()||e.name===a.trim()&&!r.trim())??null,y=Z(r),b=a.trim()||(v?v.name:Rl(r)),x=e=>{i(e),s||o(Rl(e))};async function ee(){g(null),m(!0);try{let e=b,t;if(v&&!y&&(r.trim()===v.name||!r.trim()))t={name:e,description:v.description,builtin:v.name};else if(y)t={name:e,description:``,config:{transport:`http`,url:r.trim(),headers:await te(e)}};else{let{command:n,args:i}=X(r);if(!n)throw new ie(`Type a command, a URL, or a built-in name.`,400);t={name:e,description:``,config:{transport:`stdio`,command:n,args:i,env:await te(e)}}}d.size&&(t.botIds=Array.from(d));let a=await w.connectors.create(t);i(``),o(``),c(!1),u([]),f(new Set),n(a,a.check)}catch(e){g(e instanceof ie?e.message:`Failed to add connector`)}finally{m(!1)}}async function te(e){let t={};for(let n of l){let r=n.k.trim();if(r){if(n.secret){let i=Y(e,r);await w.secrets.set(i,n.v),t[r]=`{{secret:${i}}}`}else t[r]=n.v}}return t}let S=v&&(r.trim()===v.name||!r.trim())&&(a.trim()===v.name||r.trim()===v.name)?`${v.displayName} is built into ant-bot. ${v.description}`:y?`A remote server. If it needs a sign-in, that starts right after adding.`:r.trim()?`A local command ant-bot runs itself.`:null;return(0,O.jsxs)(`div`,{className:`mb-6 space-y-2 rounded border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Il,children:`Add`}),(0,O.jsx)(`input`,{className:Fl,list:`antbot-catalog`,placeholder:`a built-in (${e.map(e=>e.name).join(`, `)||`gmail`}), a command, or a URL`,value:r,onChange:e=>x(e.target.value)}),(0,O.jsx)(`datalist`,{id:`antbot-catalog`,children:e.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.displayName},e.name))}),S&&(0,O.jsx)(`p`,{className:`mt-1 text-[11px] text-(--color-text-muted)`,children:S})]}),(0,O.jsx)(`div`,{className:`flex gap-2`,children:(0,O.jsxs)(`div`,{className:`w-1/3`,children:[(0,O.jsx)(`span`,{className:Il,children:`Name`}),(0,O.jsx)(`input`,{className:Fl,placeholder:`github`,value:a,onChange:e=>{o(e.target.value),c(!0)}})]})}),r.trim()&&!v&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Il,children:y?`Headers`:`Environment`}),(0,O.jsx)(Vl,{pairs:l,onChange:u,keyLabel:y?`Header`:`VAR`})]}),t.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Il,children:`Give it to`}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:d.has(e.id),onChange:t=>{let n=new Set(d);t.target.checked?n.add(e.id):n.delete(e.id),f(n)}}),e.name]},e.id))})]}),h&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:h}),(0,O.jsx)(`button`,{type:`button`,onClick:ee,disabled:p||!b||!r.trim()&&!v,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg) disabled:opacity-40`,children:p?`Adding…`:`Add`})]})}function Wl({connector:e,catalog:t,assignedTo:n,initialCheck:r,onChanged:i}){let[a,o]=(0,_.useState)(r),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),h=e.kind===`builtin`?t.find(t=>t.name===e.name)??null:null;(0,_.useEffect)(()=>{r&&(o(r),r.status===`needs-sign-in`&&r.selfRegistration===!1&&!r.alternative&&f(!0))},[r]);async function g(t={}){u(null);try{let{authorizeUrl:n}=await w.connectors.login(e.id,t);window.open(n,`_blank`,`noopener`),f(!1)}catch(e){let t=e instanceof ie?e.message:`Could not start sign-in`;u(t),/client ID|client secret/i.test(t)&&f(!0)}}async function v(){c(!0);try{let t=await w.connectors.check(e.id);o(t),t.status===`needs-sign-in`&&t.selfRegistration===!1&&!t.alternative&&f(!0),i()}catch(e){o({status:`unreachable`,tools:[],detail:e instanceof ie?e.message:`Check failed`})}finally{c(!1)}}let y=a?zl(a):e.enabled?e.missingSecrets.length?{text:`missing secret: ${e.missingSecrets.join(`, `)}`,tone:`warn`}:e.signedIn?{text:`signed in`,tone:`ok`}:e.lastStatus===`ready`||e.lastStatus===`connected`?{text:`ready`,tone:`ok`}:e.lastStatus?{text:e.lastStatus.replace(/-/g,` `),tone:`warn`}:{text:`unchecked`,tone:`warn`}:{text:`disabled`,tone:`warn`},x=e.kind===`builtin`||e.config.transport!==`stdio`;return(0,O.jsxs)(`div`,{className:`border-b border-(--color-border) py-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-2 rounded bg-(--color-bg-elevated) px-1.5 py-0.5 text-[11px] text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:e.config.transport}),(0,O.jsx)(`span`,{className:b(`ml-2 text-xs`,Bl[y.tone]),"data-testid":`connector-state`,children:y.text}),e.description&&(0,O.jsx)(`p`,{className:`truncate text-xs text-(--color-text-muted)`,title:e.description,children:e.description}),(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:n.length?`→ ${n.join(`, `)}`:`→ no bots yet — tick it in Bot settings`}),e.lastError&&!a&&y.tone!==`ok`&&(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:e.lastError})]}),x&&(0,O.jsx)(`button`,{type:`button`,onClick:e.signedIn?async()=>{await w.connectors.logout(e.id),i()}:()=>g(),className:Ll,children:e.signedIn?`Sign out`:`Sign in`}),(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:s,className:Ll,children:s?`Checking…`:`Check`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await w.connectors.update(e.id,{enabled:!e.enabled}),i()},className:Ll,children:e.enabled?`Disable`:`Enable`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await w.connectors.remove(e.id),i()},className:b(Ll,`text-(--color-red)`),children:`Delete`})]}),l&&!d&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-(--color-red)`,children:l}),d&&(0,O.jsx)(Hl,{entry:h,provider:a?.provider,onSubmit:g,error:l}),a&&a.tools.length>0&&(0,O.jsxs)(`div`,{className:`mt-1 text-xs`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`text-(--color-text-muted) underline`,children:p?`hide tools`:`show ${a.tools.length} tools`}),p&&(0,O.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:a.tools.map(t=>(0,O.jsxs)(`li`,{className:`truncate`,title:t.description,children:[(0,O.jsx)(`code`,{children:`mcp__${e.name}__${t.name}`}),t.description&&(0,O.jsx)(`span`,{className:`ml-2 text-(--color-text-muted)`,children:t.description})]},t.name))})]})]})}function Gl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)({}),[c,l]=(0,_.useState)({}),u=()=>{w.connectors.list().then(t),w.bots.list().then(async e=>{let t=e.map(e=>({id:e.bot.id,name:e.bot.name}));a(t);let n={};for(let e of t){let t=await w.bots.connectors.get(e.id).catch(()=>[]);for(let r of t)n[r.name]=[...n[r.name]??[],e.name]}s(n)}).catch(()=>a([]))};return(0,_.useEffect)(()=>{u(),w.connectors.catalog().then(r).catch(()=>r([]))},[]),(0,O.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[(0,O.jsx)(`h2`,{className:`mb-1 text-lg font-semibold`,children:`Connectors`}),(0,O.jsxs)(`p`,{className:`mb-4 text-xs text-(--color-text-muted)`,children:[`MCP servers your Bots can use: a built-in like Gmail, a command ant-bot runs, or a URL. Add one here, tick which Bots get it — a Bot without an assignment cannot see its tools at all. Tools reach Bots as`,` `,(0,O.jsx)(`code`,{children:`mcp__<name>__<tool>`}),` and still pass the permission gateway.`]}),(0,O.jsx)(Ul,{catalog:n,bots:i,onCreated:(e,t)=>{l(n=>({...n,[e.id]:t})),u()}}),e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No connectors yet.`}):e.map(e=>(0,O.jsx)(Wl,{connector:e,catalog:n,assignedTo:o[e.name]??[],initialCheck:c[e.id]??null,onChanged:u},e.id))]})}var Kl=[{label:`New bot`,target:{kind:`newBot`}},{label:`Open settings`,target:{kind:`settings`}},{label:`Open rules`,target:{kind:`rules`}},{label:`Open usage`,target:{kind:`usage`}},{label:`Open workspace`,target:{kind:`workspace`}}];function ql({open:e,onClose:t,onNavigate:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)([]);if((0,_.useEffect)(()=>{e||(i(``),o([]))},[e]),(0,_.useEffect)(()=>{if(!r.trim()){o([]);return}let e=!1,t=setTimeout(()=>{w.search(r).then(t=>{e||o(t)})},150);return()=>{e=!0,clearTimeout(t)}},[r]),!e)return null;let s=Kl.filter(e=>e.label.toLowerCase().includes(r.toLowerCase()));function c(e){n(e),t()}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/50 pt-24`,onClick:t,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-(--color-border) bg-(--color-bg-elevated) shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>e.key===`Escape`&&t(),placeholder:`Search bots, threads, messages, files… or run a command`,className:`w-full border-b border-(--color-border) bg-transparent px-4 py-3 text-sm outline-none`}),(0,O.jsxs)(`div`,{className:`max-h-96 overflow-y-auto p-1.5`,children:[s.length>0&&(0,O.jsxs)(`div`,{className:`mb-1`,children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Actions`}),s.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(e.target),className:`flex w-full items-center rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:e.label},e.label))]}),a.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Results`}),a.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>e.threadId&&c({kind:`thread`,id:e.threadId}),className:`flex w-full flex-col items-start rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px] uppercase text-(--color-text-muted)`,children:e.kind}),(0,O.jsx)(`span`,{className:`truncate font-medium`,children:e.title})]}),e.snippet&&(0,O.jsx)(`span`,{className:`truncate text-xs text-(--color-text-muted)`,children:e.snippet})]},`${e.kind}-${e.id}`))]}),r.trim()&&s.length===0&&a.length===0&&(0,O.jsx)(`p`,{className:`px-2.5 py-4 text-center text-sm text-(--color-text-muted)`,children:`No results.`})]})]})})}var Jl=[{view:`thread`,label:`Chats`},{view:`workspace`,label:`Workspace`},{view:`computer`,label:`Computer`},{view:`rules`,label:`Rules`},{view:`connectors`,label:`Connectors`},{view:`usage`,label:`Usage`},{view:`settings`,label:`Settings`}],Yl={connecting:`Connecting…`,open:`Connected`,closed:`Disconnected`},Xl={connecting:`bg-(--color-amber) animate-pulse`,open:`bg-(--color-green)`,closed:`bg-(--color-red)`};function Zl({connection:e,pendingCount:t,view:n,onChangeView:r,onOpenPalette:i,onOpenApproval:a}){return(0,O.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center justify-between border-b border-(--color-border) bg-(--color-bg-elevated) px-3`,children:[(0,O.jsx)(`nav`,{className:`flex items-center gap-1`,children:Jl.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>r(e.view),className:b(`rounded px-2.5 py-1 text-xs font-medium`,n===e.view?`bg-(--color-accent)/15 text-(--color-accent)`:`text-(--color-text-muted) hover:bg-(--color-bg-hover)`),children:[e.label,e.view===`rules`&&t>0&&(0,O.jsx)(`span`,{className:`ml-1.5 rounded-full bg-(--color-amber) px-1.5 py-0.5 text-[10px] font-semibold text-(--color-bg)`,children:t})]},e.view))}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`rounded border border-(--color-border) px-2.5 py-1 text-xs text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:[`Search… `,(0,O.jsx)(`span`,{className:`ml-1 opacity-60`,children:`⌘K`})]}),t>0&&(0,O.jsxs)(`button`,{type:`button`,onClick:a,title:`Go to the thread waiting on you`,className:`flex items-center gap-1 rounded-full bg-(--color-amber)/15 px-2 py-0.5 text-xs font-medium text-(--color-amber) hover:bg-(--color-amber)/25`,children:[t,` pending approval`,t===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`span`,{className:b(`h-1.5 w-1.5 rounded-full`,Xl[e])}),Yl[e]]})]})]})}function Ql({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e})}function $l({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:e})}function eu(){let e=T(e=>e.bots),t=T(e=>e.threads),n=T(e=>e.activeThreadId),r=T(e=>e.messagesByThread),i=T(e=>e.pendingApprovals),a=T(e=>e.connection),o=T(e=>e.notifications),s=T(e=>e.setBots),c=T(e=>e.setThreads),l=T(e=>e.setThreadMessages),u=T(e=>e.setActiveThreadId),d=T(e=>e.appendLocalMessage),f=T(e=>e.dismissNotification),p=T(e=>e.setPendingApprovals),[m,h]=(0,_.useState)(`thread`),[g,v]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(null),[S,ne]=(0,_.useState)(null),[re,ie]=(0,_.useState)(!1),[C,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)(`system`);(0,_.useEffect)(()=>{let e=document.documentElement,t=window.matchMedia(`(prefers-color-scheme: dark)`);function n(){let n=oe===`light`||oe===`system`&&!t.matches;e.classList.toggle(`light`,n)}return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[oe]),(0,_.useEffect)(()=>{let e=E();return()=>e.close()},[]);let ce=T(e=>e.epoch);(0,_.useEffect)(()=>{w.bots.list().then(s),w.threads.list().then(c),w.skills.list().then(ae),w.approvals.list().then(p).catch(()=>{})},[ce,s,c,p]);let le=T(e=>e.threadEpoch);(0,_.useEffect)(()=>{n&&(w.threads.get(n).then(({messages:e})=>{l(n,e)}),w.threads.markRead(n).catch(()=>{}))},[n,le,l]),(0,_.useEffect)(()=>{function e(e){let t=e.metaKey||e.ctrlKey;t&&e.key.toLowerCase()===`n`?(e.preventDefault(),v(!0)):t&&e.key.toLowerCase()===`k`&&(e.preventDefault(),ie(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let D=(0,_.useMemo)(()=>{let t={};for(let n of e)t[n.bot.id]=n;return t},[e]),ue=(0,_.useMemo)(()=>Object.values(t).filter(e=>e.kind===`group`),[t]),de=n?t[n]??null:null,fe=n?r[n]??[]:[],k=de?e.find(e=>e.thread?.id===de.id):void 0,A=S?D[S]?.bot??null:null;async function pe(){s(await w.bots.list())}async function me(e){x(!0),te(null);try{let t=await w.bots.create(e);await pe(),v(!1),t.threadId&&(c(await w.threads.list()),u(t.threadId),h(`thread`))}catch(e){te(e instanceof Error?e.message:`Failed to create bot`)}finally{x(!1)}}async function ge(e,t){if(!n)return;let r=await w.threads.postMessage(n,{contentMd:e,attachmentIds:t});d(n,r)}async function _e(){k&&await w.bots.stop(k.bot.id)}function ve(e){u(e),ne(null),h(`thread`)}function ye(e){e.kind===`thread`?ve(e.id):e.kind===`newBot`?v(!0):h(e.kind)}return(0,O.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,O.jsx)(Zl,{connection:a,pendingCount:i.length,view:m,onChangeView:e=>{ne(null),h(e)},onOpenPalette:()=>ie(!0),onOpenApproval:()=>{let e=i[0];e&&ve(e.threadId)}}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,O.jsx)(he,{entries:e,groupThreads:ue,botsById:D,activeThreadId:n,onSelectThread:ve,onNewBot:()=>v(!0)}),(0,O.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[m===`thread`&&(A?(0,O.jsx)(vl,{bot:A,onClose:()=>ne(null),onUpdated:t=>s(e.map(e=>e.bot.id===t.id?{...e,bot:t}:e)),onDuplicated:e=>{pe(),ne(e.id)},onDeleted:()=>{ne(null),pe()}}):(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[k&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-(--color-border) px-4 py-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-lg leading-none`,children:k.bot.avatarEmoji}),(0,O.jsx)(`span`,{className:`text-sm font-semibold`,children:k.bot.name}),k.bot.title&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:k.bot.title})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>ne(k.bot.id),className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Bot settings`})]}),(0,O.jsx)(ol,{thread:de,messages:fe,botsById:D,bots:e,skills:C,running:k?.bot.state===`running`||k?.bot.state===`queued`,onSend:ge,onStop:_e})]})),m===`rules`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(xl,{})}),m===`connectors`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(Gl,{})}),m===`usage`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(Cl,{})}),m===`settings`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(Dl,{onSettingsChange:e=>se(e.theme)})}),m===`workspace`&&(0,O.jsx)($l,{children:(0,O.jsx)(Nl,{})}),m===`computer`&&(0,O.jsx)($l,{children:(0,O.jsx)(Pl,{})})]})]}),o.length>0&&(0,O.jsx)(`div`,{className:`pointer-events-none fixed bottom-24 right-4 z-50 flex flex-col gap-2`,children:o.slice(-4).map(e=>(0,O.jsxs)(`div`,{className:b(`pointer-events-auto w-72 rounded-md border p-3 text-sm shadow-lg`,e.level===`error`&&`border-(--color-red)/50 bg-(--color-bg-elevated)`,e.level===`warn`&&`border-(--color-amber)/50 bg-(--color-bg-elevated)`,e.level===`info`&&`border-(--color-border) bg-(--color-bg-elevated)`),children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:`text-(--color-text-faint) hover:text-(--color-text)`,children:`×`})]}),e.body&&(0,O.jsx)(`p`,{className:`mt-0.5 text-xs text-(--color-text-muted)`,children:e.body})]},e.id))}),g&&(0,O.jsx)(cl,{onCreate:me,onClose:()=>v(!1),busy:y,error:ee}),(0,O.jsx)(ql,{open:re,onClose:()=>ie(!1),onNavigate:ye})]})}var tu=document.getElementById(`root`);if(!tu)throw Error(`#root not found`);(0,v.createRoot)(tu).render((0,O.jsx)(_.StrictMode,{children:(0,O.jsx)(eu,{})}));
131
+ 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 Do(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:Ao(t,`input`,e.processors),output:Ao(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Oo(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 Oo(r.element,n);if(r.type===`set`)return Oo(r.valueType,n);if(r.type===`lazy`)return Oo(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 Oo(r.innerType,n);if(r.type===`intersection`)return Oo(r.left,n)||Oo(r.right,n);if(r.type===`record`||r.type===`map`)return Oo(r.keyType,n)||Oo(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Oo(r.in,n)||Oo(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Oo(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Oo(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Oo(e,n))return!0;return!!(r.rest&&Oo(r.rest,n))}return!1}var ko=(e,t={})=>n=>{let r=wo({...n,processors:t});return To(e,r),Eo(r,e),Do(r,e)},Ao=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=wo({...i??{},target:a,io:t,processors:n});return To(e,o),Eo(o,e),Do(o,e)},jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Mo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=jo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},No=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`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)},Po=(e,t,n,r)=>{n.type=`boolean`},Fo=(e,t,n,r)=>{n.not={}},Io=(e,t,n,r)=>{let i=e._zod.def,a=pn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Lo=(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}},Ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},zo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Bo=(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=To(a.element,t,{...r,path:[...r.path,`items`]})},Vo=(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]=To(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=To(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ho=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>To(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Uo=(e,t,n,r)=>{let i=e._zod.def,a=To(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=To(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]]},Wo=(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=To(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=To(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=To(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)}},Go=(e,t,n,r)=>{let i=e._zod.def,a=To(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`}]},Ko=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},qo=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Jo=(e,t,n,r)=>{let i=e._zod.def;To(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)))},Yo=(e,t,n,r)=>{let i=e._zod.def;To(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},Xo=(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;To(o,t,r);let s=t.seen.get(e);s.ref=o},Zo=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Qo=(e,t,n,r)=>{let i=e._zod.def;To(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},$o=N(`ZodISODateTime`,(e,t)=>{xi.init(e,t),Ts.init(e,t)});function es(e){return Ka($o,e)}var ts=N(`ZodISODate`,(e,t)=>{Si.init(e,t),Ts.init(e,t)});function ns(e){return qa(ts,e)}var rs=N(`ZodISOTime`,(e,t)=>{Ci.init(e,t),Ts.init(e,t)});function is(e){return Ja(rs,e)}var as=N(`ZodISODuration`,(e,t)=>{wi.init(e,t),Ts.init(e,t)});function os(e){return Ya(as,e)}var ss=N(`ZodError`,(e,t)=>{Yn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Qn(e,t)},flatten:{value:t=>Zn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,mn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,mn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),cs=$n(ss),ls=er(ss),us=tr(ss),ds=rr(ss),fs=ar(ss),ps=or(ss),ms=sr(ss),hs=cr(ss),gs=lr(ss),_s=ur(ss),vs=dr(ss),ys=fr(ss),bs=new WeakMap;function xs(e,t,n){let r=Object.getPrototypeOf(e),i=bs.get(r);if(i||(i=new Set,bs.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 Ss=N(`ZodType`,(e,t)=>(I.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ao(e,`input`),output:Ao(e,`output`)}}),e.toJSONSchema=ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>cs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>us(e,t,n),e.parseAsync=async(t,n)=>ls(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ds(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>fs(e,t,n),e.decode=(t,n)=>ps(e,t,n),e.encodeAsync=async(t,n)=>ms(e,t,n),e.decodeAsync=async(t,n)=>hs(e,t,n),e.safeEncode=(t,n)=>gs(e,t,n),e.safeDecode=(t,n)=>_s(e,t,n),e.safeEncodeAsync=async(t,n)=>vs(e,t,n),e.safeDecodeAsync=async(t,n)=>ys(e,t,n),xs(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 jn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Pc(e,t))},superRefine(e,t){return this.check(Fc(e,t))},overwrite(e){return this.check(B(e))},optional(){return gc(this)},exactOptional(){return vc(this)},nullable(){return bc(this)},nullish(){return gc(bc(this))},nonoptional(e){return Ec(this,e)},array(){return tc(this)},or(e){return ic([this,e])},and(e){return cc(this,e)},transform(e){return Ac(this,mc(e))},default(e){return Sc(this,e)},prefault(e){return wc(this,e)},catch(e){return Oc(this,e)},pipe(e){return Ac(this,e)},readonly(){return Mc(this)},describe(e){let t=this.clone();return Sa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Sa.get(this);let t=this.clone();return Sa.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 Sa.get(e)?.description},configurable:!0}),e)),Cs=N(`_ZodString`,(e,t)=>{li.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,xs(e,`_ZodString`,{regex(...e){return this.check(lo(...e))},includes(...e){return this.check(po(...e))},startsWith(...e){return this.check(mo(...e))},endsWith(...e){return this.check(z(...e))},min(...e){return this.check(so(...e))},max(...e){return this.check(oo(...e))},length(...e){return this.check(co(...e))},nonempty(...e){return this.check(so(1,...e))},lowercase(e){return this.check(uo(e))},uppercase(e){return this.check(fo(e))},trim(){return this.check(go())},normalize(...e){return this.check(ho(...e))},toLowerCase(){return this.check(_o())},toUpperCase(){return this.check(vo())},slugify(){return this.check(yo())}})}),ws=N(`ZodString`,(e,t)=>{li.init(e,t),Cs.init(e,t),e.email=t=>e.check(wa(Es,t)),e.url=t=>e.check(Aa(ks,t)),e.jwt=t=>e.check(Ga(Ws,t)),e.emoji=t=>e.check(ja(As,t)),e.guid=t=>e.check(Ta(Ds,t)),e.uuid=t=>e.check(Ea(Os,t)),e.uuidv4=t=>e.check(Da(Os,t)),e.uuidv6=t=>e.check(Oa(Os,t)),e.uuidv7=t=>e.check(ka(Os,t)),e.nanoid=t=>e.check(Ma(js,t)),e.guid=t=>e.check(Ta(Ds,t)),e.cuid=t=>e.check(Na(Ms,t)),e.cuid2=t=>e.check(Pa(Ns,t)),e.ulid=t=>e.check(Fa(Ps,t)),e.base64=t=>e.check(Ha(Vs,t)),e.base64url=t=>e.check(Ua(Hs,t)),e.xid=t=>e.check(Ia(Fs,t)),e.ksuid=t=>e.check(La(Is,t)),e.ipv4=t=>e.check(Ra(Ls,t)),e.ipv6=t=>e.check(za(Rs,t)),e.cidrv4=t=>e.check(Ba(zs,t)),e.cidrv6=t=>e.check(Va(Bs,t)),e.e164=t=>e.check(Wa(Us,t)),e.datetime=t=>e.check(es(t)),e.date=t=>e.check(ns(t)),e.time=t=>e.check(is(t)),e.duration=t=>e.check(os(t))});function V(e){return Ca(ws,e)}var Ts=N(`ZodStringFormat`,(e,t)=>{L.init(e,t),Cs.init(e,t)}),Es=N(`ZodEmail`,(e,t)=>{fi.init(e,t),Ts.init(e,t)}),Ds=N(`ZodGUID`,(e,t)=>{ui.init(e,t),Ts.init(e,t)}),Os=N(`ZodUUID`,(e,t)=>{di.init(e,t),Ts.init(e,t)}),ks=N(`ZodURL`,(e,t)=>{pi.init(e,t),Ts.init(e,t)}),As=N(`ZodEmoji`,(e,t)=>{mi.init(e,t),Ts.init(e,t)}),js=N(`ZodNanoID`,(e,t)=>{hi.init(e,t),Ts.init(e,t)}),Ms=N(`ZodCUID`,(e,t)=>{gi.init(e,t),Ts.init(e,t)}),Ns=N(`ZodCUID2`,(e,t)=>{_i.init(e,t),Ts.init(e,t)}),Ps=N(`ZodULID`,(e,t)=>{vi.init(e,t),Ts.init(e,t)}),Fs=N(`ZodXID`,(e,t)=>{yi.init(e,t),Ts.init(e,t)}),Is=N(`ZodKSUID`,(e,t)=>{bi.init(e,t),Ts.init(e,t)}),Ls=N(`ZodIPv4`,(e,t)=>{Ti.init(e,t),Ts.init(e,t)}),Rs=N(`ZodIPv6`,(e,t)=>{Ei.init(e,t),Ts.init(e,t)}),zs=N(`ZodCIDRv4`,(e,t)=>{Di.init(e,t),Ts.init(e,t)}),Bs=N(`ZodCIDRv6`,(e,t)=>{Oi.init(e,t),Ts.init(e,t)}),Vs=N(`ZodBase64`,(e,t)=>{Ai.init(e,t),Ts.init(e,t)}),Hs=N(`ZodBase64URL`,(e,t)=>{Mi.init(e,t),Ts.init(e,t)}),Us=N(`ZodE164`,(e,t)=>{Ni.init(e,t),Ts.init(e,t)}),Ws=N(`ZodJWT`,(e,t)=>{Fi.init(e,t),Ts.init(e,t)}),Gs=N(`ZodNumber`,(e,t)=>{R.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),xs(e,`ZodNumber`,{gt(e,t){return this.check(ro(e,t))},gte(e,t){return this.check(io(e,t))},min(e,t){return this.check(io(e,t))},lt(e,t){return this.check(to(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(qs(e))},safe(e){return this.check(qs(e))},positive(e){return this.check(ro(0,e))},nonnegative(e){return this.check(io(0,e))},negative(e){return this.check(to(0,e))},nonpositive(e){return this.check(no(0,e))},multipleOf(e,t){return this.check(ao(e,t))},step(e,t){return this.check(ao(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 H(e){return Xa(Gs,e)}var Ks=N(`ZodNumberFormat`,(e,t)=>{Ii.init(e,t),Gs.init(e,t)});function qs(e){return Za(Ks,e)}var Js=N(`ZodBoolean`,(e,t)=>{Li.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r)});function Ys(e){return Qa(Js,e)}var Xs=N(`ZodUnknown`,(e,t)=>{Ri.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Zs(){return $a(Xs)}var Qs=N(`ZodNever`,(e,t)=>{zi.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r)});function $s(e){return eo(Qs,e)}var ec=N(`ZodArray`,(e,t)=>{Vi.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bo(e,t,n,r),e.element=t.element,xs(e,`ZodArray`,{min(e,t){return this.check(so(e,t))},nonempty(e){return this.check(so(1,e))},max(e,t){return this.check(oo(e,t))},length(e,t){return this.check(co(e,t))},unwrap(){return this.element}})});function tc(e,t){return bo(ec,e,t)}var nc=N(`ZodObject`,(e,t)=>{Ki.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vo(e,t,n,r),P(e,`shape`,()=>t.shape),xs(e,`ZodObject`,{keyof(){return W(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Zs()})},loose(){return this.clone({...this._zod.def,catchall:Zs()})},strict(){return this.clone({...this._zod.def,catchall:$s()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return In(this,e)},safeExtend(e){return Ln(this,e)},merge(e){return Rn(this,e)},pick(e){return Pn(this,e)},omit(e){return Fn(this,e)},partial(...e){return zn(hc,this,e[0])},required(...e){return Bn(Tc,this,e[0])}})});function U(e,t){return new nc({type:`object`,shape:e??{},...F(t)})}var rc=N(`ZodUnion`,(e,t)=>{Ji.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r),e.options=t.options});function ic(e,t){return new rc({type:`union`,options:e,...F(t)})}var ac=N(`ZodDiscriminatedUnion`,(e,t)=>{rc.init(e,t),Yi.init(e,t)});function oc(e,t,n){return new ac({type:`union`,options:t,discriminator:e,...F(n)})}var sc=N(`ZodIntersection`,(e,t)=>{Xi.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r)});function cc(e,t){return new sc({type:`intersection`,left:e,right:t})}var lc=N(`ZodRecord`,(e,t)=>{$i.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function uc(e,t,n){return!t||!t._zod?new lc({type:`record`,keyType:V(),valueType:e,...F(t)}):new lc({type:`record`,keyType:e,valueType:t,...F(n)})}var dc=N(`ZodEnum`,(e,t)=>{ea.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(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 dc({...t,checks:[],...F(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 dc({...t,checks:[],...F(r),entries:i})}});function W(e,t){return new dc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...F(t)})}var fc=N(`ZodLiteral`,(e,t)=>{ta.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function G(e,t){return new fc({type:`literal`,values:Array.isArray(e)?e:[e],...F(t)})}var pc=N(`ZodTransform`,(e,t)=>{na.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new un(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(qn(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(qn(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 mc(e){return new pc({type:`transform`,transform:e})}var hc=N(`ZodOptional`,(e,t)=>{ia.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new hc({type:`optional`,innerType:e})}var _c=N(`ZodExactOptional`,(e,t)=>{aa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new _c({type:`optional`,innerType:e})}var yc=N(`ZodNullable`,(e,t)=>{oa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new yc({type:`nullable`,innerType:e})}var xc=N(`ZodDefault`,(e,t)=>{sa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sc(e,t){return new xc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():On(t)}})}var Cc=N(`ZodPrefault`,(e,t)=>{la.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wc(e,t){return new Cc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():On(t)}})}var Tc=N(`ZodNonOptional`,(e,t)=>{ua.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e,t){return new Tc({type:`nonoptional`,innerType:e,...F(t)})}var Dc=N(`ZodCatch`,(e,t)=>{fa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Oc(e,t){return new Dc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var kc=N(`ZodPipe`,(e,t)=>{pa.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.in=t.in,e.out=t.out});function Ac(e,t){return new kc({type:`pipe`,in:e,out:t})}var jc=N(`ZodReadonly`,(e,t)=>{ha.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mc(e){return new jc({type:`readonly`,innerType:e})}var Nc=N(`ZodCustom`,(e,t)=>{_a.init(e,t),Ss.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r)});function Pc(e,t={}){return xo(Nc,e,t)}function Fc(e,t){return So(e,t)}var Ic=W([`idle`,`queued`,`running`,`waiting_approval`,`waiting_input`,`interrupted`]),Lc=W([`none`,`unread`,`needs_attention`]),Rc=[`fable`,`opus`,`sonnet`,`haiku`],zc=W(Rc);U({id:V(),slug:V().regex(/^[a-z0-9][a-z0-9-]*$/),name:V().min(1).max(60),title:V().max(120).default(``),description:V().max(8e3).default(``),avatarEmoji:V().max(8).default(`🤖`),modelTier:zc.default(`sonnet`),pinned:Ys().default(!1),hidden:Ys().default(!1),notifications:Ys().default(!0),sessionId:V().nullable().default(null),state:Ic.default(`idle`),attention:Lc.default(`none`),threadId:V().nullable().default(null),createdAt:H(),deletedAt:H().nullable().default(null)});var Bc=W([`dm`,`group`]);U({id:V(),kind:Bc,title:V().default(``),memberBotIds:tc(V()).default([]),pinned:Ys().default(!1),hidden:Ys().default(!1),lastReadAt:H().default(0),createdAt:H()});var Vc=oc(`type`,[U({type:G(`tool`),toolName:V(),summary:V(),input:Zs().optional(),result:V().optional(),status:W([`running`,`ok`,`error`,`denied`])}),U({type:G(`file`),path:V(),name:V(),mime:V(),bytes:H(),action:W([`created`,`modified`]).default(`created`)}),U({type:G(`approval`),approvalId:V()}),U({type:G(`handoff`),fromBotId:V(),toBotId:V(),note:V()}),U({type:G(`error`),message:V()}),U({type:G(`signin`),serverName:V(),url:V()})]),Hc=W([`user`,`bot`,`system`]),Uc=U({id:V(),threadId:V(),authorKind:Hc,authorBotId:V().nullable().default(null),replyToId:V().nullable().default(null),contentMd:V().default(``),cards:tc(Vc).default([]),streaming:Ys().default(!1),createdAt:H()});U({id:V(),messageId:V().nullable(),path:V(),name:V(),mime:V(),bytes:H(),createdAt:H()});var Wc=W([`pending`,`allowed`,`denied`,`expired`]),Gc=U({id:V(),botId:V(),threadId:V(),toolName:V(),inputSummary:V(),rawInput:Zs(),status:Wc.default(`pending`),decidedBy:W([`user`,`rule`,`auto_review`]).nullable().default(null),reason:V().default(``),ruleId:V().nullable().default(null),createdAt:H(),decidedAt:H().nullable().default(null)}),Kc=W([`require`,`allow`]);U({id:V(),kind:Kc,toolPattern:V().default(`*`),inputPattern:V().default(``),scopeNote:V().default(``),builtin:Ys().default(!1),enabled:Ys().default(!0),createdAt:H()}),U({id:V(),slug:V(),name:V(),description:V().default(``),path:V(),source:W([`user`,`taught`,`imported`]).default(`user`),createdAt:H()});var qc=/^[a-z0-9][a-z0-9-]{0,31}$/,Jc=[`antbot`,`browser`],Yc=oc(`transport`,[U({transport:G(`stdio`),command:V().min(1),args:tc(V()).default([]),env:uc(V(),V()).default({})}),U({transport:G(`http`),url:V().url(),headers:uc(V(),V()).default({}),tools:tc(V()).optional()}),U({transport:G(`sse`),url:V().url(),headers:uc(V(),V()).default({}),tools:tc(V()).optional()})]),Xc=U({id:V(),name:V().regex(qc,`lowercase letters, digits and hyphens only, max 32 characters`).refine(e=>!Jc.includes(e),{message:`"antbot" and "browser" are reserved for the built-in servers`}),description:V().default(``),enabled:Ys().default(!0),kind:W([`custom`,`builtin`]).default(`custom`),config:Yc,lastStatus:V().nullable().default(null),lastError:V().nullable().default(null),checkedAt:H().nullable().default(null),createdAt:H()});U({status:W([`ready`,`needs-sign-in`,`needs-credential`,`unreachable`]),selfRegistration:Ys().optional(),provider:V().optional(),tools:tc(U({name:V(),description:V()})).default([]),detail:V().optional(),alternative:V().optional()}),U({id:V(),botId:V(),name:V().min(1),cronExpr:V(),timezone:V().default(`UTC`),instructionMd:V(),enabled:Ys().default(!0),lastRunAt:H().nullable().default(null),nextRunAt:H().nullable().default(null),createdAt:H()});var Zc=U({id:V(),routineId:V(),startedAt:H(),finishedAt:H().nullable().default(null),status:W([`running`,`ok`,`failed`,`interrupted`]),summary:V().default(``),threadId:V().nullable().default(null),isTest:Ys().default(!1)});U({id:V(),fromBotId:V(),toBotId:V(),contentMd:V(),hops:H().default(1),delivered:Ys().default(!1),createdAt:H()}),U({id:V(),botId:V(),turnId:V(),model:V(),inputTokens:H().default(0),outputTokens:H().default(0),cacheReadTokens:H().default(0),costEstimate:H().default(0),createdAt:H()}),W([`user`,`bot`,`routine`,`system`]);var Qc={seq:H(),threadId:V().nullable(),botId:V().nullable()};oc(`type`,[U({...Qc,type:G(`hello`),epoch:V()}),U({...Qc,type:G(`message.created`),message:Uc}),U({...Qc,type:G(`message.delta`),messageId:V(),delta:V()}),U({...Qc,type:G(`message.done`),messageId:V(),contentMd:V()}),U({...Qc,type:G(`message.card`),messageId:V(),card:Vc,cardIndex:H()}),U({...Qc,type:G(`bot.state`),state:Ic,attention:Lc}),U({...Qc,type:G(`approval.pending`),approval:Gc}),U({...Qc,type:G(`approval.resolved`),approval:Gc}),U({...Qc,type:G(`routine.run`),run:Zc}),U({...Qc,type:G(`usage.tick`),inputTokens:H(),outputTokens:H(),model:V()}),U({...Qc,type:G(`notify`),title:V(),body:V(),level:W([`info`,`warn`,`error`])}),U({...Qc,type:G(`secret.request`),requestId:V(),name:V(),reason:V()}),U({...Qc,type:G(`thread.updated`),threadId2:V()})]);var $c=oc(`kind`,[U({kind:G(`mouse`),action:W([`move`,`down`,`up`,`wheel`]),x:H().min(0).max(1),y:H().min(0).max(1),button:W([`left`,`middle`,`right`]).default(`left`),clickCount:H().int().min(0).max(3).default(1),deltaX:H().default(0),deltaY:H().default(0)}),U({kind:G(`key`),action:W([`down`,`up`]),key:V().min(1).max(32)}),U({kind:G(`text`),text:V().min(1).max(4096)})]);oc(`type`,[U({type:G(`input`),input:$c}),U({type:G(`selection-request`)})]),U({name:V().min(1).max(60),title:V().max(120).optional(),description:V().max(8e3).optional(),avatarEmoji:V().max(8).optional(),modelTier:zc.optional()}).partial().extend({pinned:Ys().optional(),hidden:Ys().optional(),notifications:Ys().optional()}),U({kind:W([`dm`,`group`]),title:V().optional(),memberBotIds:tc(V())}),U({contentMd:V(),attachmentIds:tc(V()).optional(),replyToId:V().nullable().optional(),mentionBotIds:tc(V()).optional(),mentionEveryone:Ys().optional()}),U({decision:W([`allow`,`deny`]),alwaysRule:U({toolPattern:V(),inputPattern:V().default(``),scopeNote:V().default(``)}).optional()}),U({kind:W([`require`,`allow`]),toolPattern:V().min(1),inputPattern:V().default(``),scopeNote:V().default(``)}),U({botId:V(),name:V().min(1),cronExpr:V().min(1),timezone:V().optional(),instructionMd:V().min(1),enabled:Ys().optional()}),U({name:V().min(1),description:V().default(``),bodyMd:V().min(1),source:W([`user`,`taught`,`imported`]).optional()}),U({name:Xc.shape.name,description:V().default(``),config:Yc.optional(),builtin:V().optional(),enabled:Ys().optional(),botIds:tc(V()).optional()}).refine(e=>!!e.config!=!!e.builtin,{message:`Give either config or builtin, not both`}),U({description:V().optional(),config:Yc.optional(),enabled:Ys().optional()});var K={timezone:V(),maxConcurrentSessions:H().min(1).max(8),autoReviewEnabled:Ys(),theme:W([`system`,`light`,`dark`]),localExecution:W([`ask`,`always`,`never`]),dailyTokenBudget:H(),notificationsEnabled:Ys(),billingMode:W([`subscription`,`api`]),computerMode:W([`host`,`container`])};U({timezone:K.timezone.default(`UTC`),maxConcurrentSessions:K.maxConcurrentSessions.default(2),autoReviewEnabled:K.autoReviewEnabled.default(!0),theme:K.theme.default(`system`),localExecution:K.localExecution.default(`ask`),dailyTokenBudget:K.dailyTokenBudget.default(0),notificationsEnabled:K.notificationsEnabled.default(!0),billingMode:K.billingMode.default(`subscription`),computerMode:K.computerMode.default(`host`)}),U(K).partial(),U({kind:W([`message`,`file`,`routine`,`bot`]),id:V(),threadId:V().nullable(),botId:V().nullable(),title:V(),snippet:V(),createdAt:H()});var el=sn.MAX_ATTACHMENTS_PER_MESSAGE;function tl(e,t){let n=e.slice(0,t),r=/(^|\s)([@/])([\w-]*)$/.exec(n);if(!r)return null;let i=r[2];return i===`/`&&n.trim()!==`/${r[3]}`?null:{prefix:i,query:r[3],start:t-r[3].length-1}}function nl({onSend:e,bots:t,skills:n,running:r,onStop:i,uploadFile:a}){let[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),m=(0,_.useRef)(0);(0,_.useEffect)(()=>{m.current=c.length},[c.length]);let h=(0,_.useMemo)(()=>a??(e=>w.attachments.upload(e)),[a]),g=(0,_.useMemo)(()=>{if(!u||u.prefix!==`@`)return[];let e=u.query.toLowerCase();return t.filter(t=>t.bot.name.toLowerCase().includes(e)||t.bot.slug.toLowerCase().includes(e)).slice(0,8)},[u,t]),v=(0,_.useMemo)(()=>{if(!u||u.prefix!==`/`)return[];let e=u.query.toLowerCase();return n.filter(t=>t.slug.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)).slice(0,8)},[u,n]);function y(e){let t=Array.from(e),n=Math.max(0,el-m.current),r=t.slice(0,n);m.current=Math.min(el,m.current+r.length);for(let e of r)h(e).then(e=>{l(t=>t.length>=el?t:[...t,e])}).catch(()=>{m.current=Math.max(0,m.current-1)})}function b(e){l(t=>t.filter(t=>t.id!==e))}function x(){let t=o.trim();t&&(e(t,c.map(e=>e.id)),s(``),l([]),d(null))}function ee(e,t){s(e),d(tl(e,t))}function te(e){e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),x()):e.key===`Escape`&&d(null)}function S(e){if(!u)return;let t=p.current,n=t?t.selectionStart:o.length,r=o.slice(0,u.start),i=o.slice(n),a=u.prefix===`@`?`@${e} `:`/${e} `,c=`${r}${a}${i}`;s(c),d(null),requestAnimationFrame(()=>{t?.focus();let e=r.length+a.length;t?.setSelectionRange(e,e)})}function ne(e){let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e);t.length>0&&(e.preventDefault(),y(t))}function re(e){e.preventDefault(),e.dataTransfer.files.length>0&&y(e.dataTransfer.files)}return(0,O.jsxs)(`div`,{className:`shrink-0 border-t border-(--color-border) bg-(--color-bg-elevated) p-3`,onDrop:re,onDragOver:e=>e.preventDefault(),children:[c.length>0&&(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:c.map(e=>(0,O.jsxs)(`span`,{"data-testid":`attachment-chip`,className:`flex items-center gap-1.5 rounded-full border border-(--color-border) bg-(--color-bg) px-2.5 py-1 text-xs`,children:[e.name,(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,className:`text-(--color-text-muted) hover:text-(--color-red)`,onClick:()=>b(e.id),children:`×`})]},e.id))}),u&&(g.length>0||v.length>0)&&(0,O.jsx)(`div`,{className:`mb-2 max-h-40 overflow-auto rounded border border-(--color-border) bg-(--color-bg) text-sm shadow-lg`,children:u.prefix===`@`?g.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.bot.slug),children:[(0,O.jsx)(`span`,{children:e.bot.avatarEmoji}),(0,O.jsx)(`span`,{children:e.bot.name})]},e.bot.id)):v.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-(--color-bg-hover)`,onClick:()=>S(e.slug),children:[(0,O.jsxs)(`span`,{className:`shrink-0 font-mono text-(--color-text-muted)`,children:[`/`,e.slug]}),(0,O.jsx)(`span`,{className:`min-w-0 truncate text-(--color-text-muted)`,title:e.description,children:e.description})]},e.id))}),(0,O.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,"aria-label":`Attach files`,className:`shrink-0 rounded border border-(--color-border) px-2.5 py-2 text-sm hover:bg-(--color-bg-hover)`,onClick:()=>f.current?.click(),children:`+`}),(0,O.jsx)(`input`,{ref:f,"data-testid":`attachment-input`,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&y(e.target.files),e.target.value=``}}),(0,O.jsx)(`textarea`,{ref:p,value:o,rows:1,placeholder:`Message… (@ to mention, / for a skill)`,className:`max-h-40 min-h-[38px] flex-1 resize-none rounded border border-(--color-border) bg-(--color-bg) px-3 py-2 text-sm outline-none focus:border-(--color-accent)`,onChange:e=>ee(e.target.value,e.target.selectionStart),onKeyDown:te,onPaste:ne}),r&&(0,O.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 rounded border border-(--color-red) px-3 py-2 text-sm font-medium text-(--color-red) hover:bg-(--color-red)/10`,children:`Stop`}),(0,O.jsx)(`button`,{type:`button`,onClick:x,disabled:!o.trim(),className:`shrink-0 rounded bg-(--color-accent) px-3 py-2 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Send`})]})]})}M.setOptions({breaks:!0});function rl(e){return M.parse(e,{async:!1}).replace(/<script[\s\S]*?<\/script>/gi,``)}function il(e,t){if(e.authorKind===`user`)return{name:`You`,emoji:`🧑`};if(e.authorKind===`system`)return{name:`System`,emoji:`⚙️`};let n=e.authorBotId?t[e.authorBotId]?.bot:void 0;return{name:n?.name??`Bot`,emoji:n?.avatarEmoji??`🤖`}}function al({message:e,botsById:t}){let{name:n,emoji:r}=il(e,t),i=e.authorKind===`user`;return(0,O.jsxs)(`div`,{className:b(`flex gap-3 px-4 py-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`mt-0.5 text-lg leading-none`,children:r}),(0,O.jsxs)(`div`,{className:b(`min-w-0 max-w-[75%]`,i&&`items-end text-right`),children:[(0,O.jsxs)(`div`,{className:b(`mb-0.5 flex items-baseline gap-2`,i&&`flex-row-reverse`),children:[(0,O.jsx)(`span`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:n}),(0,O.jsx)(`span`,{className:`text-[11px] text-(--color-text-faint)`,children:new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),e.contentMd&&(0,O.jsxs)(`div`,{className:b(`markdown-body inline-block rounded-lg px-3 py-2 text-sm`,i?`bg-(--color-accent) text-(--color-accent-fg)`:`bg-(--color-bg-elevated)`),children:[(0,O.jsx)(`span`,{dangerouslySetInnerHTML:{__html:rl(e.contentMd)}}),e.streaming&&(0,O.jsx)(`span`,{className:`ml-0.5 inline-block w-1.5 animate-pulse bg-current align-middle`,children:`\xA0`})]}),(0,O.jsx)(on,{cards:e.cards})]})]})}function ol({thread:e,messages:t,botsById:n,bots:r,skills:i,running:a,onSend:o,onStop:s}){let c=(0,_.useRef)(null),[l,u]=(0,_.useState)(!0);(0,_.useEffect)(()=>{if(!l)return;let e=()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)};e();let t=requestAnimationFrame(()=>{e(),requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[t,l]);function d(){let e=c.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;u(t<80)}return e?(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,O.jsx)(`div`,{ref:c,onScroll:d,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:t.length===0?(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-(--color-text-muted)`,children:`No messages yet — say hello and give this bot a job.`}):t.map(e=>(0,O.jsx)(al,{message:e,botsById:n},e.id))}),(0,O.jsx)(nl,{onSend:o,bots:r,skills:i,running:a,onStop:s})]}):(0,O.jsx)(`div`,{className:`flex h-full flex-1 flex-col items-center justify-center text-(--color-text-muted)`,children:(0,O.jsx)(`p`,{className:`text-sm`,children:`Select a bot to start a conversation, or create a new one.`})})}var sl=`🤖.🧠.🦾.🛰️.🧭.🗂️.📚.🔍.🧮.🧰.🛠️.⚙️.🧪.🧬.📈.📊.💡.🗒️.✍️.📝.📅.⏰.📬.📡.🌐.🔐.🗝️.🧯.🚀.🛎️.🎯.🧵.🧩.🕵️.🧑‍💻.👩‍💻.🧑‍🔬.🐜.🐝.🦉`.split(`.`);function cl({onCreate:e,onClose:t,busy:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(`🤖`),[f,p]=(0,_.useState)(`sonnet`);function m(){i.trim()&&e({name:i.trim(),title:o.trim(),description:c.trim(),avatarEmoji:u,modelTier:f})}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,O.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-(--color-border) bg-(--color-bg-elevated) p-5 shadow-xl`,children:[(0,O.jsx)(`h2`,{className:`mb-4 text-base font-semibold`,children:`New bot`}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,O.jsx)(`div`,{className:`grid grid-cols-8 gap-1 rounded border border-(--color-border) p-1.5`,children:sl.slice(0,16).map(e=>(0,O.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded p-1 text-lg ${u===e?`bg-(--color-accent)/25`:`hover:bg-(--color-bg-hover)`}`,children:e},e))})}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Name`}),(0,O.jsx)(`input`,{autoFocus:!0,className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value),placeholder:`Scout`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:o,onChange:e=>s(e.target.value),placeholder:`Research assistant`})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:3,value:c,onChange:e=>l(e.target.value),placeholder:`What should this bot do?`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Rc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${f===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),(0,O.jsx)(`p`,{className:`rounded border border-(--color-amber)/40 bg-(--color-amber)/10 p-2 text-xs text-(--color-amber)`,children:`Bots share one computer, workspace, browser profile and logins. Bots are not a security boundary.`}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]}),(0,O.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`rounded px-3 py-1.5 text-sm text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,disabled:!i.trim()||n,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create bot`})]})]})})}var ll={running:`text-(--color-blue)`,ok:`text-(--color-green)`,failed:`text-(--color-red)`,interrupted:`text-(--color-amber)`};function ul({botId:e,onCreated:t}){let[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(`0 9 * * *`),[o,s]=(0,_.useState)(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null);async function m(){if(!(!n.trim()||!i.trim()||!c.trim())){d(!0),p(null);try{t(await w.routines.create({botId:e,name:n,cronExpr:i,timezone:o,instructionMd:c})),r(``),l(``)}catch(e){p(e instanceof ie?e.message:`Failed to create routine`)}finally{d(!1)}}}return(0,O.jsxs)(`div`,{className:`space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs font-semibold text-(--color-text-muted)`,children:`New routine`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Name`,value:n,onChange:e=>r(e.target.value)}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Cron expression (e.g. 0 9 * * *)`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{className:`w-40 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Timezone`,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Instructions for this run…`,rows:3,value:c,onChange:e=>l(e.target.value)}),f&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:f}),(0,O.jsx)(`button`,{type:`button`,disabled:u,onClick:m,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Create routine`})]})}function dl({routine:e,onChanged:t,onDeleted:n}){let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1);async function d(){let t=await w.routines.runs(e.id);i(t.slice(0,20))}async function f(){let e=!a;o(e),e&&await d()}async function p(){t(await w.routines.update(e.id,{enabled:!e.enabled}))}async function m(){window.confirm(`Delete routine "${e.name}"?`)&&(await w.routines.remove(e.id),n(e.id))}async function h(){u(!0),c(!1);try{await w.routines.testRun(e.id),await d(),o(!0)}finally{u(!1)}}return(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsxs)(`div`,{className:`font-mono text-xs text-(--color-text-muted)`,children:[e.cronExpr,` · `,e.timezone]}),e.nextRunAt&&(0,O.jsxs)(`div`,{className:`text-xs text-(--color-text-faint)`,children:[`Next run: `,new Date(e.nextRunAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:p}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),disabled:l,className:`rounded border border-(--color-border) px-2 py-1 text-xs hover:bg-(--color-bg-hover)`,children:`Test run`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red)`,children:`Delete`})]})]}),s&&(0,O.jsxs)(`div`,{className:`mt-2 rounded border border-(--color-amber)/50 bg-(--color-amber)/10 p-2 text-xs`,children:[(0,O.jsx)(`p`,{className:`text-(--color-amber)`,children:`A test run performs real work — it can navigate websites, change files and call connected tools.`}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-amber) px-2 py-1 font-medium text-(--color-bg)`,children:`Run anyway`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`rounded px-2 py-1 text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`mt-2 text-xs text-(--color-text-muted) hover:underline`,children:a?`Hide run history`:`Show run history`}),a&&(0,O.jsxs)(`ul`,{className:`mt-1 space-y-1`,children:[r.length===0&&(0,O.jsx)(`li`,{className:`text-xs text-(--color-text-faint)`,children:`No runs yet.`}),r.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsx)(`span`,{className:b(`font-medium`,ll[e.status]),children:e.status}),(0,O.jsx)(`span`,{className:`text-(--color-text-faint)`,children:new Date(e.startedAt).toLocaleString()}),e.isTest&&(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px]`,children:`test`}),e.summary&&(0,O.jsx)(`span`,{className:`truncate text-(--color-text-muted)`,children:e.summary})]},e.id))]})]})}function fl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{let t=!1;return i(!0),w.routines.list(e).then(e=>{t||n(e)}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(ul,{botId:e,onCreated:e=>n(t=>[e,...t])}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`Loading routines…`}),!r&&t.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No routines yet.`}),t.map(e=>(0,O.jsx)(dl,{routine:e,onChanged:e=>n(t=>t.map(t=>t.id===e.id?e:t)),onDeleted:e=>n(t=>t.filter(t=>t.id!==e))},e.id))]})}function pl({bot:e,onUpdated:t}){let[n,r]=(0,_.useState)(e.name),[i,a]=(0,_.useState)(e.title),[o,s]=(0,_.useState)(e.description),[c,l]=(0,_.useState)(e.avatarEmoji),[u,d]=(0,_.useState)(e.modelTier),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1);async function y(){p(!0),h(null);try{t(await w.bots.update(e.id,{name:n,title:i,description:o,avatarEmoji:c,modelTier:u}))}catch(e){h(e instanceof ie?e.message:`Failed to save`)}finally{p(!1)}}return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex h-12 w-12 items-center justify-center rounded-lg border border-(--color-border) text-2xl hover:bg-(--color-bg-hover)`,children:c}),(0,O.jsx)(`div`,{className:`flex-1`,children:(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm font-medium`,value:n,onChange:e=>r(e.target.value),"aria-label":`Name`})})]}),g&&(0,O.jsx)(`div`,{className:`grid grid-cols-10 gap-1 rounded border border-(--color-border) p-2`,children:sl.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>{l(e),v(!1)},className:`rounded p-1 text-lg hover:bg-(--color-bg-hover)`,children:e},e))}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Title`}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,value:i,onChange:e=>a(e.target.value)})]}),(0,O.jsxs)(`label`,{className:`block text-xs`,children:[(0,O.jsx)(`span`,{className:`mb-1 block text-(--color-text-muted)`,children:`Description / persona`}),(0,O.jsx)(`textarea`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1.5 text-sm`,rows:4,value:o,onChange:e=>s(e.target.value)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`mb-1 block text-xs text-(--color-text-muted)`,children:`Model tier`}),(0,O.jsx)(`div`,{className:`inline-flex rounded border border-(--color-border) p-0.5`,children:Rc.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`rounded px-3 py-1 text-xs font-medium capitalize ${u===e?`bg-(--color-accent) text-(--color-accent-fg)`:`text-(--color-text-muted)`}`,children:e},e))})]}),m&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:m}),(0,O.jsx)(`button`,{type:`button`,onClick:y,disabled:f,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg) disabled:opacity-40`,children:`Save profile`})]})}function ml({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``);(0,_.useEffect)(()=>{w.bots.memory.list(e).then(n)},[e]);function l(e){i(e),o(t.find(t=>t.name===e)?.content??``)}async function u(){let t=r??s.trim();t&&(await w.bots.memory.save(e,t,a),n(e=>{let n=e.findIndex(e=>e.name===t);return n===-1?[...e,{name:t,content:a}]:e.map((e,r)=>r===n?{name:t,content:a}:e)}),i(t),c(``))}async function d(t){await w.bots.memory.remove(e,t),n(e=>e.filter(e=>e.name!==t)),r===t&&(i(null),o(``))}return(0,O.jsxs)(`div`,{className:`grid grid-cols-[160px_1fr] gap-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[t.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>l(e.name),className:`flex-1 truncate rounded px-2 py-1 text-left text-xs ${r===e.name?`bg-(--color-accent)/15`:`hover:bg-(--color-bg-hover)`}`,children:e.name}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>d(e.name),"aria-label":`Delete ${e.name}`,className:`text-xs text-(--color-text-faint) hover:text-(--color-red)`,children:`×`})]},e.name)),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,placeholder:`new-file.md`,value:s,onChange:e=>{c(e.target.value),i(null),o(``)}})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`textarea`,{className:`h-40 w-full rounded border border-(--color-border) bg-(--color-bg) p-2 font-mono text-xs`,value:a,onChange:e=>o(e.target.value),placeholder:`Durable facts this bot should remember…`}),(0,O.jsx)(`button`,{type:`button`,onClick:u,className:`mt-2 rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save memory file`})]})]})}function hl({skill:e,checked:t,onToggle:n}){let[r,i]=(0,_.useState)(!1),a=`skill-${e.id}`;return(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,O.jsx)(`input`,{id:a,type:`checkbox`,className:`mt-1 shrink-0`,checked:t,onChange:n}),(0,O.jsx)(`label`,{htmlFor:a,className:`shrink-0 cursor-pointer whitespace-nowrap font-medium`,children:e.name}),e.description&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),"aria-expanded":r,title:r?`Collapse description`:`Show the full description`,className:`min-w-0 flex-1 cursor-pointer text-left text-xs text-(--color-text-muted) hover:text-(--color-text) ${r?`whitespace-pre-wrap break-words`:`truncate`}`,children:[`— `,e.description]})]})}function gl({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{w.connectors.list().then(n)},[]),(0,_.useEffect)(()=>{w.bots.connectors.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);async function s(t){if(!r)return;let n=new Set(r);n.has(t)?n.delete(t):n.add(t),i(n),o(null);try{await w.bots.connectors.set(e,Array.from(n))}catch(e){i(r),o(e instanceof ie?e.message:`Could not save`)}}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No connectors yet. Add one on the Connectors screen.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-start gap-2 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:r?.has(e.id)??!1,disabled:!r,onChange:()=>s(e.id),className:`mt-0.5`}),(0,O.jsxs)(`span`,{className:`min-w-0`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:String(e.config.transport)}),!e.enabled&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-text-muted)`,children:`(disabled)`}),e.missingSecrets.length>0&&(0,O.jsxs)(`span`,{className:`ml-1 text-(--color-amber)`,children:[`missing secret: `,e.missingSecrets.join(`, `)]}),e.lastStatus===`needs-sign-in`&&(0,O.jsx)(`span`,{className:`ml-1 text-(--color-amber)`,children:`needs sign-in`}),e.description&&(0,O.jsx)(`span`,{className:`block truncate text-(--color-text-muted)`,title:e.description,children:e.description})]})]},e.id)),a&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:a})]})}function _l({botId:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(new Set),[a,o]=(0,_.useState)(!1);(0,_.useEffect)(()=>{w.skills.list().then(n)},[]),(0,_.useEffect)(()=>{w.bots.skills.get(e).then(e=>i(new Set(e.map(e=>e.id))))},[e]);function s(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),o(!1)}async function c(){await w.bots.skills.set(e,Array.from(r)),o(!0)}return t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No skills taught yet.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>(0,O.jsx)(hl,{skill:e,checked:r.has(e.id),onToggle:()=>s(e.id)},e.id)),(0,O.jsx)(`button`,{type:`button`,onClick:c,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Save skills`}),a&&(0,O.jsx)(`span`,{className:`ml-2 text-xs text-(--color-green)`,children:`Saved`})]})}function vl({bot:e,onClose:t,onUpdated:n,onDuplicated:r,onDeleted:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null);async function d(){n(await w.bots.update(e.id,{pinned:!e.pinned}))}async function f(){n(await w.bots.update(e.id,{hidden:!e.hidden}))}async function p(){n(await w.bots.update(e.id,{notifications:!e.notifications}))}async function m(){r(await w.bots.duplicate(e.id))}async function h(){await w.bots.remove(e.id),i(e.id)}return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto p-5`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[e.name,` settings`]}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]}),(0,O.jsx)(`section`,{className:`mb-6`,children:(0,O.jsx)(pl,{bot:e,onUpdated:n})}),(0,O.jsxs)(`section`,{className:`mb-6 flex flex-wrap gap-2 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.pinned?`Unpin`:`Pin`}),(0,O.jsx)(`button`,{type:`button`,onClick:f,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.hidden?`Unhide`:`Hide`}),(0,O.jsx)(`button`,{type:`button`,onClick:p,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:e.notifications?`Mute notifications`:`Unmute notifications`}),(0,O.jsx)(`button`,{type:`button`,onClick:m,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Duplicate`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`rounded border border-(--color-border) px-3 py-1.5 text-xs hover:bg-(--color-bg-hover)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`rounded border border-(--color-red)/50 px-3 py-1.5 text-xs text-(--color-red) hover:bg-(--color-red)/10`,children:`Delete`})]}),s&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-border) bg-(--color-bg-elevated) p-3 text-sm`,children:[(0,O.jsx)(`p`,{className:`mb-1`,children:`Clear this conversation and start a fresh session?`}),(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-text-muted)`,children:`Deletes the messages in this thread and drops the model’s accumulated context. Keeps the Bot’s description, memory, skills, connectors, routines and files.`}),l&&(0,O.jsx)(`p`,{className:`mb-2 text-xs text-(--color-red)`,children:l}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{u(null);try{await w.bots.reset(e.id),c(!1),n(e)}catch(e){u(e instanceof ie?e.message:`Could not start fresh`)}},className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Start fresh`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{c(!1),u(null)},className:`rounded border border-(--color-border) px-3 py-1.5 text-xs`,children:`Cancel`})]})]}),a&&(0,O.jsxs)(`div`,{className:`mb-6 rounded border border-(--color-red)/50 bg-(--color-red)/10 p-3 text-sm`,children:[(0,O.jsxs)(`p`,{className:`text-(--color-red)`,children:[`Delete `,e.name,`? This removes it from your roster and conversation history, but its workspace files and any browser logins it used survive deletion.`]}),(0,O.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:h,className:`rounded bg-(--color-red) px-3 py-1.5 text-xs font-medium text-white`,children:`Delete permanently`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded px-3 py-1.5 text-xs text-(--color-text-muted)`,children:`Cancel`})]})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Memory`}),(0,O.jsx)(ml,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Skills`}),(0,O.jsx)(_l,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`mb-6 border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Connectors`}),(0,O.jsx)(gl,{botId:e.id})]}),(0,O.jsxs)(`section`,{className:`border-t border-(--color-border) pt-4`,children:[(0,O.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:`Routines`}),(0,O.jsx)(fl,{botId:e.id})]})]})}function yl({kind:e}){return(0,O.jsx)(`span`,{className:b(`rounded px-1.5 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,e===`require`?`bg-(--color-red)/15 text-(--color-red)`:`bg-(--color-green)/15 text-(--color-green)`),children:e===`require`?`Require approval`:`Always allow`})}function bl({onCreated:e}){let[t,n]=(0,_.useState)(`require`),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(null);async function d(){if(r.trim())try{e(await w.rules.create({kind:t,toolPattern:r.trim(),inputPattern:a,scopeNote:s})),i(``),o(``),c(``),u(null)}catch(e){u(e instanceof ie?e.message:`Failed to create rule`)}}return(0,O.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`flex gap-2`,children:[`require`,`allow`].map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:b(`rounded px-3 py-1 text-xs font-medium`,t===e?`bg-(--color-accent) text-(--color-accent-fg)`:`border border-(--color-border) text-(--color-text-muted)`),children:e===`require`?`Require approval`:`Always allow`},e))}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Tool pattern (e.g. Bash, browser_*, *)`,value:r,onChange:e=>i(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 font-mono text-sm`,placeholder:`Input pattern (optional regex)`,value:a,onChange:e=>o(e.target.value)}),(0,O.jsx)(`input`,{className:`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,placeholder:`Scope note (why this rule exists)`,value:s,onChange:e=>c(e.target.value)}),l&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:l}),(0,O.jsx)(`button`,{type:`button`,onClick:d,className:`rounded bg-(--color-accent) px-3 py-1.5 text-sm font-medium text-(--color-accent-fg)`,children:`Add rule`})]})}function xl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0);(0,_.useEffect)(()=>{w.rules.list().then(t).finally(()=>r(!1))},[]);async function i(e){let n=await w.rules.update(e.id,!e.enabled);t(e=>e.map(e=>e.id===n.id?n:e))}async function a(e){e.builtin||window.confirm(`Delete rule for "${e.toolPattern}"?`)&&(await w.rules.remove(e.id),t(t=>t.filter(t=>t.id!==e.id)))}return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-1 text-lg font-semibold`,children:`Rules`}),(0,O.jsx)(`p`,{className:`mb-4 text-sm text-(--color-text-muted)`,children:`Require Approval always wins over Always Allow.`}),(0,O.jsx)(bl,{onCreated:e=>t(t=>[e,...t])}),n&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Loading…`}),!n&&e.length===0&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No rules yet.`}),(0,O.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(yl,{kind:e.kind}),e.builtin&&(0,O.jsx)(`span`,{title:`Built-in rule`,"aria-label":`Built-in rule`,className:`text-(--color-text-faint)`,children:`🔒`}),(0,O.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e.toolPattern})]}),e.inputPattern&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-(--color-text-muted)`,children:e.inputPattern}),e.scopeNote&&(0,O.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-(--color-text-faint)`,children:e.scopeNote})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>i(e)}),`Enabled`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>a(e),disabled:e.builtin,className:`rounded border border-(--color-red)/50 px-2 py-1 text-xs text-(--color-red) disabled:cursor-not-allowed disabled:opacity-30`,children:`Delete`})]})]},e.id))})]})}function Sl({label:e,value:t,max:n,sublabel:r}){let i=n>0?Math.max(2,Math.round(t/n*100)):0;return(0,O.jsxs)(`div`,{className:`mb-2`,children:[(0,O.jsxs)(`div`,{className:`mb-0.5 flex items-baseline justify-between text-xs`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e}),(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:r??t.toLocaleString()})]}),(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-bg)`,children:(0,O.jsx)(`div`,{className:`h-2 rounded bg-(--color-accent)`,style:{width:`${i}%`}})})]})}function Cl(){let[e,t]=(0,_.useState)(null);if((0,_.useEffect)(()=>{w.usage().then(t)},[]),!e)return(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading usage…`});let n=e.totals.inputTokens+e.totals.outputTokens,r=Math.max(1,...e.byBot.map(e=>e.inputTokens+e.outputTokens)),i=Math.max(1,...e.byDay.map(e=>e.inputTokens+e.outputTokens)),a=Math.max(1,...e.byModel.map(e=>e.inputTokens+e.outputTokens));return(0,O.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,O.jsx)(`h1`,{className:`mb-4 text-lg font-semibold`,children:`Usage`}),(0,O.jsxs)(`section`,{className:`mb-6 grid grid-cols-3 gap-3`,children:[(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Input tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.inputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Output tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.outputTokens.toLocaleString()})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-(--color-border) p-3`,children:[(0,O.jsx)(`div`,{className:`text-xs text-(--color-text-muted)`,children:`Cache-read tokens`}),(0,O.jsx)(`div`,{className:`text-xl font-semibold`,children:e.totals.cacheReadTokens.toLocaleString()})]})]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By bot`}),e.byBot.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byBot.map(e=>(0,O.jsx)(Sl,{label:e.botName,value:e.inputTokens+e.outputTokens,max:r},e.botId))]}),(0,O.jsxs)(`section`,{className:`mb-6`,children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By day`}),(0,O.jsx)(`div`,{className:`flex items-end gap-1`,style:{height:96},children:e.byDay.map(e=>{let t=e.inputTokens+e.outputTokens,n=Math.max(2,Math.round(t/i*88));return(0,O.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-end`,title:`${e.day}: ${t.toLocaleString()} tokens`,children:[(0,O.jsx)(`div`,{className:`w-full rounded-t bg-(--color-accent)`,style:{height:n}}),(0,O.jsx)(`span`,{className:`mt-1 rotate-0 text-[9px] text-(--color-text-faint)`,children:e.day.slice(5)})]},e.day)})}),e.byDay.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`By model`}),e.byModel.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No usage yet.`}),e.byModel.map(e=>(0,O.jsx)(Sl,{label:e.model,value:e.inputTokens+e.outputTokens,max:a,sublabel:n>0?`${Math.round((e.inputTokens+e.outputTokens)/n*100)}%`:`0%`},e.model))]})]})}var wl=`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`;function Tl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);(0,_.useEffect)(()=>{w.secrets.list().then(e=>{t(e.names),r(e.backend)}).catch(()=>d(!0))},[]);async function f(){l(null);try{let e=await w.secrets.set(i.trim(),o);t(e.names),a(``),s(``)}catch(e){l(e instanceof ie?e.message:`Could not store the secret`)}}async function p(e){l(null);try{let n=await w.secrets.remove(e);t(n.names)}catch(e){l(e instanceof ie?e.message:`Could not remove the secret`)}}return u?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets backend is available on this machine.`}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-text-muted)`,children:[`Stored in your `,n===`file`?`ant-bot data directory`:n??`keychain`,`. Names only are ever shown; a value cannot be read back, by you or by a bot.`]}),e.length===0?(0,O.jsx)(`p`,{className:`text-xs text-(--color-text-muted)`,children:`No secrets stored.`}):(0,O.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,O.jsx)(`code`,{className:`flex-1 truncate`,children:e}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>p(e),className:`rounded border border-(--color-border) px-2 py-0.5 text-xs text-(--color-red)`,children:`Remove`})]},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:`${wl} w-2/5`,placeholder:`NAME`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:`${wl} flex-1`,placeholder:`value`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,onClick:f,disabled:!i.trim()||!o,className:`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,children:`Store`})]}),c&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:c})]})}function El({label:e,children:t}){return(0,O.jsxs)(`label`,{className:`mb-3 flex items-center justify-between gap-4 border-b border-(--color-border) py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-(--color-text-muted)`,children:e}),t]})}function Dl({onSettingsChange:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!1);(0,_.useEffect)(()=>{w.settings.get().then(t=>{n(t),e?.(t)})},[]);async function a(r){if(!t)return;let a={...t,...r};n(a),i(!0);try{let t=await w.settings.update(r);n(t),e?.(t)}finally{i(!1)}}return t?(0,O.jsxs)(`div`,{className:`mx-auto max-w-xl p-6`,children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),r&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:`Saving…`})]}),(0,O.jsx)(El,{label:`Timezone`,children:(0,O.jsx)(`input`,{className:`w-48 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.timezone,onChange:e=>a({timezone:e.target.value})})}),(0,O.jsx)(El,{label:`Max concurrent sessions`,children:(0,O.jsx)(`input`,{type:`number`,min:1,max:8,className:`w-20 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.maxConcurrentSessions,onChange:e=>a({maxConcurrentSessions:Math.min(8,Math.max(1,Number(e.target.value)||1))})})}),(0,O.jsx)(El,{label:`Auto-review (Haiku triage of tool calls)`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.autoReviewEnabled,onChange:e=>a({autoReviewEnabled:e.target.checked})})}),(0,O.jsx)(El,{label:`Theme`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.theme,onChange:e=>a({theme:e.target.value}),children:[(0,O.jsx)(`option`,{value:`system`,children:`System`}),(0,O.jsx)(`option`,{value:`light`,children:`Light`}),(0,O.jsx)(`option`,{value:`dark`,children:`Dark`})]})}),(0,O.jsx)(El,{label:`Local execution (run commands on this machine)`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.localExecution,onChange:e=>a({localExecution:e.target.value}),children:[(0,O.jsx)(`option`,{value:`ask`,children:`Ask`}),(0,O.jsx)(`option`,{value:`always`,children:`Always`}),(0,O.jsx)(`option`,{value:`never`,children:`Never`})]})}),(0,O.jsx)(El,{label:`Daily token budget (0 = unlimited)`,children:(0,O.jsx)(`input`,{type:`number`,min:0,className:`w-32 rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.dailyTokenBudget,onChange:e=>a({dailyTokenBudget:Math.max(0,Number(e.target.value)||0)})})}),(0,O.jsx)(El,{label:`Desktop notifications`,children:(0,O.jsx)(`input`,{type:`checkbox`,checked:t.notificationsEnabled,onChange:e=>a({notificationsEnabled:e.target.checked})})}),(0,O.jsx)(El,{label:`Billing mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.billingMode,onChange:e=>a({billingMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`subscription`,children:`Subscription`}),(0,O.jsx)(`option`,{value:`api`,children:`API (metered)`})]})}),(0,O.jsx)(El,{label:`Computer mode`,children:(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:t.computerMode,onChange:e=>a({computerMode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`host`,children:`Host`}),(0,O.jsx)(`option`,{value:`container`,children:`Container`})]})}),(0,O.jsx)(`h2`,{className:`mt-8 mb-2 text-sm font-semibold`,children:`Secrets`}),(0,O.jsx)(Tl,{})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Loading settings…`})}var Ol=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,kl=/\.(md|markdown|txt|json|ya?ml|csv|log|ts|tsx|js|jsx|py|sh|css|html)$/i;function Al(e){return e.startsWith(`.`)}function jl({entry:e,depth:t,showHidden:n,onOpenFile:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(!1);async function u(){if(!e.dir){r(e.path);return}if(!i&&o===null){l(!0);let t=await w.workspace.tree(e.path);s(t),l(!1)}a(e=>!e)}return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`button`,{type:`button`,onClick:u,className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left text-sm hover:bg-(--color-bg-hover)`,style:{paddingLeft:`${t*14+6}px`},children:[(0,O.jsx)(`span`,{className:`w-3 shrink-0 text-(--color-text-faint)`,children:e.dir?i?`▾`:`▸`:``}),(0,O.jsx)(`span`,{className:`shrink-0`,children:e.dir?`📁`:`📄`}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name}),!e.dir&&(0,O.jsxs)(`span`,{className:`ml-auto shrink-0 text-xs text-(--color-text-faint)`,children:[e.bytes,`B`]})]}),i&&(0,O.jsxs)(`div`,{children:[c&&(0,O.jsx)(`div`,{style:{paddingLeft:`${(t+1)*14+6}px`},className:`py-1 text-xs text-(--color-text-faint)`,children:`Loading…`}),o?.filter(e=>n||!Al(e.name)).map(e=>(0,O.jsx)(jl,{entry:e,depth:t+1,showHidden:n,onOpenFile:r},e.path))]})]})}function Ml({path:e,onClose:t}){let[n,r]=(0,_.useState)(null),i=e.split(`/`).pop()??e,a=Ol.test(i),o=kl.test(i);return(0,_.useEffect)(()=>{r(null),o&&fetch(w.workspace.fileUrl(e)).then(e=>e.text()).then(r).catch(()=>r(`(failed to load preview)`))},[e,o]),(0,O.jsxs)(`div`,{className:`flex h-full flex-col border-l border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm font-medium`,children:i}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`a`,{href:w.workspace.fileUrl(e),download:i,className:`text-xs text-(--color-accent) hover:underline`,children:`Download`}),(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Close`})]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[a&&(0,O.jsx)(`img`,{src:w.workspace.fileUrl(e),alt:i,className:`max-w-full`}),o&&(0,O.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs`,children:n??`Loading…`}),!a&&!o&&(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No inline preview available — use Download.`})]})]})}function Nl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0);return(0,_.useEffect)(()=>{w.workspace.tree(``).then(t).finally(()=>s(!1))},[]),(0,O.jsxs)(`div`,{className:`flex h-full`,children:[(0,O.jsxs)(`div`,{className:`flex w-80 shrink-0 flex-col border-r border-(--color-border)`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-b border-(--color-border) p-2`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workspace`}),(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),`Hidden files`]})]}),(0,O.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[o&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Loading…`}),!o&&e.length===0&&(0,O.jsx)(`p`,{className:`p-2 text-xs text-(--color-text-muted)`,children:`Workspace is empty.`}),e.filter(e=>n||!Al(e.name)).map(e=>(0,O.jsx)(jl,{entry:e,depth:0,showHidden:n,onOpenFile:a},e.path))]})]}),i&&(0,O.jsx)(`div`,{className:`w-96 shrink-0`,children:(0,O.jsx)(Ml,{path:i,onClose:()=>a(null)})})]})}function Pl(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=(0,_.useRef)(null),d=(0,_.useRef)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null);(0,_.useEffect)(()=>{w.computer.status().then(e=>{t(e),e.pages.length>0&&r(e.pages[0].botId)})},[]);async function g(e){if(!e){h(`Nothing is selected on the remote page.`);return}try{await navigator.clipboard.writeText(e),h(`Copied ${e.length.toLocaleString()} character${e.length===1?``:`s`} from the page.`)}catch{h(`The browser refused clipboard access, so the selection was not copied.`)}}(0,_.useEffect)(()=>{if(a(null),u.current?.close(),!n||!e?.available)return;let t=window.location.protocol===`https:`?`wss`:`ws`,r=new WebSocket(`${t}://${window.location.host}/api/computer/screencast/${n}`);return u.current=r,r.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`frame`?a({data:t.data,w:t.w,h:t.h}):t.type===`selection`?g(t.text??``):t.type===`input-error`&&h(t.message??`Input was rejected.`)}catch{}},()=>r.close()},[n,e?.available]),(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]),(0,_.useEffect)(()=>{o&&d.current?.focus()},[o]);async function v(){if(!n)return;let e=await w.computer.takeover(n);s(e.ok),l(e.message??null)}async function y(){n&&(await w.computer.returnControl(n),s(!1),l(null))}function b(e){let t=u.current;if(!(!o||!t||t.readyState!==WebSocket.OPEN))try{t.send(JSON.stringify(e))}catch{}}function x(e){b({type:`input`,input:e})}function ee(e){let t=e.currentTarget.getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}}let te=[`left`,`middle`,`right`];return e?e.available?(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-(--color-border) p-3`,children:[(0,O.jsxs)(`select`,{className:`rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-sm`,value:n??``,onChange:e=>r(e.target.value||null),children:[e.pages.length===0&&(0,O.jsx)(`option`,{value:``,children:`No active pages`}),e.pages.map(e=>(0,O.jsx)(`option`,{value:e.botId,children:e.title||e.url},e.botId))]}),(0,O.jsx)(`div`,{className:`flex items-center gap-2`,children:o?(0,O.jsx)(`button`,{type:`button`,onClick:y,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg)`,children:`Return control`}):(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:!n,className:`rounded border border-(--color-border) px-3 py-1.5 text-xs font-medium hover:bg-(--color-bg-hover) disabled:opacity-40`,children:`Take over`})})]}),(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Never paste passwords or one-time codes into chat — use takeover.`}),c&&(0,O.jsx)(`p`,{className:`border-b border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:c}),(0,O.jsx)(`div`,{ref:d,tabIndex:o?0:-1,onFocus:()=>p(!0),onBlur:()=>p(!1),onKeyDown:e=>{if(o&&!((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`)){if((e.ctrlKey||e.metaKey)&&(e.key.toLowerCase()===`c`||e.key.toLowerCase()===`x`)){e.preventDefault(),b({type:`selection-request`}),e.key.toLowerCase()===`x`&&x({kind:`key`,action:`down`,key:e.key});return}e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey?x({kind:`text`,text:e.key}):x({kind:`key`,action:`down`,key:e.key})}},onKeyUp:e=>{o&&((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`v`||(e.preventDefault(),e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey||x({kind:`key`,action:`up`,key:e.key})))},onPaste:e=>{if(!o)return;e.preventDefault();let t=e.clipboardData.getData(`text`);t&&x({kind:`text`,text:t.slice(0,4096)})},className:`flex min-h-0 flex-1 items-center justify-center overflow-auto bg-black/20 p-3 outline-none ${o&&!f?`ring-2 ring-(--color-amber) ring-inset`:``}`,children:i?(0,O.jsx)(`img`,{src:`data:image/jpeg;base64,${i.data}`,width:i.w,height:i.h,alt:`Agent computer screencast`,draggable:!1,onPointerMove:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`move`,...t,button:`left`,clickCount:1,deltaX:0,deltaY:0})},onPointerDown:e=>{let t=ee(e);t&&(d.current?.focus(),x({kind:`mouse`,action:`down`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0}))},onPointerUp:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`up`,...t,button:te[e.button]??`left`,clickCount:e.detail||1,deltaX:0,deltaY:0})},onWheel:e=>{let t=ee(e);t&&x({kind:`mouse`,action:`wheel`,...t,button:`left`,clickCount:1,deltaX:e.deltaX,deltaY:e.deltaY})},onContextMenu:e=>{o&&e.preventDefault()},className:`max-h-full max-w-full rounded border border-(--color-border) ${o?`cursor-crosshair`:`pointer-events-none select-none`}`}):(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`Waiting for a screencast frame…`})}),o&&!f&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-amber)/10 px-3 py-2 text-xs text-(--color-amber)`,children:`Click the screen to send keystrokes to it.`}),m&&(0,O.jsx)(`p`,{className:`border-t border-(--color-border) bg-(--color-bg-elevated) px-3 py-2 text-xs text-(--color-text-muted)`,children:m})]}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:`The agent computer isn't available right now.`}),(0,O.jsx)(`p`,{className:`max-w-sm text-xs text-(--color-text-muted)`,children:`Bots can still browse the web and use tools — you just won't see a live screencast until the computer service starts.`})]}):(0,O.jsx)(`p`,{className:`p-6 text-sm text-(--color-text-muted)`,children:`Checking the computer service…`})}var Fl=`w-full rounded border border-(--color-border) bg-(--color-bg) px-2 py-1 text-xs`,Il=`mb-1 block text-xs text-(--color-text-muted)`,Ll=`rounded border border-(--color-border) px-2 py-1 text-xs disabled:opacity-40`,q=0,J=()=>({id:q++,k:``,v:``,secret:!1}),Y=(e,t)=>`mcp/${e}/${t}`;function X(e){let t=(e.match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^["'].*["']$/.test(e)?e.slice(1,-1):e);return{command:t[0]??``,args:t.slice(1)}}var Z=e=>/^https?:\/\//i.test(e.trim());function Rl(e){let t=e.trim();if(!t)return``;let n;if(Z(t))try{n=new URL(t).hostname.replace(/^(mcp|www|api)\./,``).split(`.`)[0]??``}catch{n=``}else{let{command:e,args:r}=X(t);n=(r.find(e=>!e.startsWith(`-`))??e).split(`/`).pop()?.replace(/^(mcp-)?server-|-mcp(-server)?$/g,``)??``}return n.toLowerCase().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,32)}function zl(e){let t=e.tools.length;switch(e.status){case`ready`:return{text:`ready — ${t} tool${t===1?``:`s`}`,tone:`ok`};case`needs-sign-in`:return e.alternative?{text:e.detail??`use the built-in instead: ${e.alternative}`,tone:`bad`}:{text:e.detail??`needs sign-in${e.provider?` (${e.provider})`:``}`,tone:`warn`};case`needs-credential`:return{text:e.detail??`needs a credential`,tone:`warn`};case`unreachable`:return{text:`unreachable${e.detail?` — ${e.detail}`:``}`,tone:`bad`}}}var Bl={ok:`text-(--color-green)`,warn:`text-(--color-amber)`,bad:`text-(--color-red)`};function Vl({pairs:e,onChange:t,keyLabel:n}){let r=(n,r)=>t(e.map(e=>e.id===n?{...e,...r}:e));return(0,O.jsxs)(`div`,{className:`space-y-1`,children:[e.map(i=>(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`input`,{className:b(Fl,`w-2/5`),placeholder:n,value:i.k,onChange:e=>r(i.id,{k:e.target.value})}),(0,O.jsx)(`input`,{className:Fl,type:i.secret?`password`:`text`,placeholder:i.secret?`value (stored in your keychain)`:`value`,value:i.v,onChange:e=>r(i.id,{v:e.target.value})}),(0,O.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1 text-[11px] text-(--color-text-muted)`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:i.secret,onChange:e=>r(i.id,{secret:e.target.checked}),"aria-label":`${i.k||n} is a secret`}),`secret`]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e.id!==i.id)),className:b(Ll,`text-(--color-text-muted)`),children:`×`})]},i.id)),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,J()]),className:b(Ll,`text-(--color-text-muted)`),children:[`+ add `,n.toLowerCase()]})]})}function Hl({entry:e,provider:t,onSubmit:n,error:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``);return(0,O.jsxs)(`div`,{className:`mt-2 space-y-1 rounded bg-(--color-bg-elevated) p-2`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-(--color-amber)`,children:[t??`This provider`,` needs an OAuth client you create yourself — a one-time setup that every`,` `,t??`provider`,` connector then shares.`]}),e&&e.setupSteps.length>0&&(0,O.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-5 text-[11px] text-(--color-text-muted)`,children:e.setupSteps.map(e=>(0,O.jsx)(`li`,{children:e},e))}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[(0,O.jsx)(`input`,{className:Fl,placeholder:`client ID`,value:i,onChange:e=>a(e.target.value)}),(0,O.jsx)(`input`,{type:`password`,className:Fl,placeholder:`client secret`,value:o,onChange:e=>s(e.target.value)}),(0,O.jsx)(`button`,{type:`button`,disabled:!i.trim(),onClick:()=>n({clientId:i.trim(),...o.trim()?{clientSecret:o.trim()}:{}}),className:Ll,children:`Sign in`})]}),r&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:r})]})}function Ul({catalog:e,bots:t,onCreated:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),v=e.find(e=>e.name===r.trim()||e.name===a.trim()&&!r.trim())??null,y=Z(r),b=a.trim()||(v?v.name:Rl(r)),x=e=>{i(e),s||o(Rl(e))};async function ee(){g(null),m(!0);try{let e=b,t;if(v&&!y&&(r.trim()===v.name||!r.trim()))t={name:e,description:v.description,builtin:v.name};else if(y)t={name:e,description:``,config:{transport:`http`,url:r.trim(),headers:await te(e)}};else{let{command:n,args:i}=X(r);if(!n)throw new ie(`Type a command, a URL, or a built-in name.`,400);t={name:e,description:``,config:{transport:`stdio`,command:n,args:i,env:await te(e)}}}d.size&&(t.botIds=Array.from(d));let a=await w.connectors.create(t);i(``),o(``),c(!1),u([]),f(new Set),n(a,a.check)}catch(e){g(e instanceof ie?e.message:`Failed to add connector`)}finally{m(!1)}}async function te(e){let t={};for(let n of l){let r=n.k.trim();if(r){if(n.secret){let i=Y(e,r);await w.secrets.set(i,n.v),t[r]=`{{secret:${i}}}`}else t[r]=n.v}}return t}let S=v&&(r.trim()===v.name||!r.trim())&&(a.trim()===v.name||r.trim()===v.name)?`${v.displayName} is built into ant-bot. ${v.description}`:y?`A remote server. If it needs a sign-in, that starts right after adding.`:r.trim()?`A local command ant-bot runs itself.`:null;return(0,O.jsxs)(`div`,{className:`mb-6 space-y-2 rounded border border-(--color-border) p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Il,children:`Add`}),(0,O.jsx)(`input`,{className:Fl,list:`antbot-catalog`,placeholder:`a built-in (${e.map(e=>e.name).join(`, `)||`gmail`}), a command, or a URL`,value:r,onChange:e=>x(e.target.value)}),(0,O.jsx)(`datalist`,{id:`antbot-catalog`,children:e.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.displayName},e.name))}),S&&(0,O.jsx)(`p`,{className:`mt-1 text-[11px] text-(--color-text-muted)`,children:S})]}),(0,O.jsx)(`div`,{className:`flex gap-2`,children:(0,O.jsxs)(`div`,{className:`w-1/3`,children:[(0,O.jsx)(`span`,{className:Il,children:`Name`}),(0,O.jsx)(`input`,{className:Fl,placeholder:`github`,value:a,onChange:e=>{o(e.target.value),c(!0)}})]})}),r.trim()&&!v&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Il,children:y?`Headers`:`Environment`}),(0,O.jsx)(Vl,{pairs:l,onChange:u,keyLabel:y?`Header`:`VAR`})]}),t.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:Il,children:`Give it to`}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:t.map(e=>(0,O.jsxs)(`label`,{className:`flex items-center gap-1 text-xs`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:d.has(e.id),onChange:t=>{let n=new Set(d);t.target.checked?n.add(e.id):n.delete(e.id),f(n)}}),e.name]},e.id))})]}),h&&(0,O.jsx)(`p`,{className:`text-xs text-(--color-red)`,children:h}),(0,O.jsx)(`button`,{type:`button`,onClick:ee,disabled:p||!b||!r.trim()&&!v,className:`rounded bg-(--color-accent) px-3 py-1.5 text-xs font-medium text-(--color-accent-fg) disabled:opacity-40`,children:p?`Adding…`:`Add`})]})}function Wl({connector:e,catalog:t,assignedTo:n,initialCheck:r,onChanged:i}){let[a,o]=(0,_.useState)(r),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),h=e.kind===`builtin`?t.find(t=>t.name===e.name)??null:null;(0,_.useEffect)(()=>{r&&(o(r),r.status===`needs-sign-in`&&r.selfRegistration===!1&&!r.alternative&&f(!0))},[r]);async function g(t={}){u(null);try{let{authorizeUrl:n}=await w.connectors.login(e.id,t);window.open(n,`_blank`,`noopener`),f(!1)}catch(e){let t=e instanceof ie?e.message:`Could not start sign-in`;u(t),/client ID|client secret/i.test(t)&&f(!0)}}async function v(){c(!0);try{let t=await w.connectors.check(e.id);o(t),t.status===`needs-sign-in`&&t.selfRegistration===!1&&!t.alternative&&f(!0),i()}catch(e){o({status:`unreachable`,tools:[],detail:e instanceof ie?e.message:`Check failed`})}finally{c(!1)}}let y=a?zl(a):e.enabled?e.missingSecrets.length?{text:`missing secret: ${e.missingSecrets.join(`, `)}`,tone:`warn`}:e.signedIn?{text:`signed in`,tone:`ok`}:e.lastStatus===`ready`||e.lastStatus===`connected`?{text:`ready`,tone:`ok`}:e.lastStatus?{text:e.lastStatus.replace(/-/g,` `),tone:`warn`}:{text:`unchecked`,tone:`warn`}:{text:`disabled`,tone:`warn`},x=e.kind===`builtin`||e.config.transport!==`stdio`;return(0,O.jsxs)(`div`,{className:`border-b border-(--color-border) py-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`span`,{className:`ml-2 rounded bg-(--color-bg-elevated) px-1.5 py-0.5 text-[11px] text-(--color-text-muted)`,children:e.kind===`builtin`?`built-in`:e.config.transport}),(0,O.jsx)(`span`,{className:b(`ml-2 text-xs`,Bl[y.tone]),"data-testid":`connector-state`,children:y.text}),e.description&&(0,O.jsx)(`p`,{className:`truncate text-xs text-(--color-text-muted)`,title:e.description,children:e.description}),(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:n.length?`→ ${n.join(`, `)}`:`→ no bots yet — tick it in Bot settings`}),e.lastError&&!a&&y.tone!==`ok`&&(0,O.jsx)(`p`,{className:`text-[11px] text-(--color-text-muted)`,children:e.lastError})]}),x&&(0,O.jsx)(`button`,{type:`button`,onClick:e.signedIn?async()=>{await w.connectors.logout(e.id),i()}:()=>g(),className:Ll,children:e.signedIn?`Sign out`:`Sign in`}),(0,O.jsx)(`button`,{type:`button`,onClick:v,disabled:s,className:Ll,children:s?`Checking…`:`Check`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await w.connectors.update(e.id,{enabled:!e.enabled}),i()},className:Ll,children:e.enabled?`Disable`:`Enable`}),(0,O.jsx)(`button`,{type:`button`,onClick:async()=>{await w.connectors.remove(e.id),i()},className:b(Ll,`text-(--color-red)`),children:`Delete`})]}),l&&!d&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-(--color-red)`,children:l}),d&&(0,O.jsx)(Hl,{entry:h,provider:a?.provider,onSubmit:g,error:l}),a&&a.tools.length>0&&(0,O.jsxs)(`div`,{className:`mt-1 text-xs`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`text-(--color-text-muted) underline`,children:p?`hide tools`:`show ${a.tools.length} tools`}),p&&(0,O.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:a.tools.map(t=>(0,O.jsxs)(`li`,{className:`truncate`,title:t.description,children:[(0,O.jsx)(`code`,{children:`mcp__${e.name}__${t.name}`}),t.description&&(0,O.jsx)(`span`,{className:`ml-2 text-(--color-text-muted)`,children:t.description})]},t.name))})]})]})}function Gl(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)({}),[c,l]=(0,_.useState)({}),u=()=>{w.connectors.list().then(t),w.bots.list().then(async e=>{let t=e.map(e=>({id:e.bot.id,name:e.bot.name}));a(t);let n={};for(let e of t){let t=await w.bots.connectors.get(e.id).catch(()=>[]);for(let r of t)n[r.name]=[...n[r.name]??[],e.name]}s(n)}).catch(()=>a([]))};return(0,_.useEffect)(()=>{u(),w.connectors.catalog().then(r).catch(()=>r([]))},[]),(0,O.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[(0,O.jsx)(`h2`,{className:`mb-1 text-lg font-semibold`,children:`Connectors`}),(0,O.jsxs)(`p`,{className:`mb-4 text-xs text-(--color-text-muted)`,children:[`MCP servers your Bots can use: a built-in like Gmail, a command ant-bot runs, or a URL. Add one here, tick which Bots get it — a Bot without an assignment cannot see its tools at all. Tools reach Bots as`,` `,(0,O.jsx)(`code`,{children:`mcp__<name>__<tool>`}),` and still pass the permission gateway.`]}),(0,O.jsx)(Ul,{catalog:n,bots:i,onCreated:(e,t)=>{l(n=>({...n,[e.id]:t})),u()}}),e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-(--color-text-muted)`,children:`No connectors yet.`}):e.map(e=>(0,O.jsx)(Wl,{connector:e,catalog:n,assignedTo:o[e.name]??[],initialCheck:c[e.id]??null,onChanged:u},e.id))]})}var Kl=[{label:`New bot`,target:{kind:`newBot`}},{label:`Open settings`,target:{kind:`settings`}},{label:`Open rules`,target:{kind:`rules`}},{label:`Open usage`,target:{kind:`usage`}},{label:`Open workspace`,target:{kind:`workspace`}}];function ql({open:e,onClose:t,onNavigate:n}){let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)([]);if((0,_.useEffect)(()=>{e||(i(``),o([]))},[e]),(0,_.useEffect)(()=>{if(!r.trim()){o([]);return}let e=!1,t=setTimeout(()=>{w.search(r).then(t=>{e||o(t)})},150);return()=>{e=!0,clearTimeout(t)}},[r]),!e)return null;let s=Kl.filter(e=>e.label.toLowerCase().includes(r.toLowerCase()));function c(e){n(e),t()}return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/50 pt-24`,onClick:t,children:(0,O.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-(--color-border) bg-(--color-bg-elevated) shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>e.key===`Escape`&&t(),placeholder:`Search bots, threads, messages, files… or run a command`,className:`w-full border-b border-(--color-border) bg-transparent px-4 py-3 text-sm outline-none`}),(0,O.jsxs)(`div`,{className:`max-h-96 overflow-y-auto p-1.5`,children:[s.length>0&&(0,O.jsxs)(`div`,{className:`mb-1`,children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Actions`}),s.map(e=>(0,O.jsx)(`button`,{type:`button`,onClick:()=>c(e.target),className:`flex w-full items-center rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:e.label},e.label))]}),a.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-semibold uppercase tracking-wide text-(--color-text-faint)`,children:`Results`}),a.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>e.threadId&&c({kind:`thread`,id:e.threadId}),className:`flex w-full flex-col items-start rounded px-2.5 py-1.5 text-left text-sm hover:bg-(--color-bg-hover)`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`rounded bg-(--color-border) px-1 text-[10px] uppercase text-(--color-text-muted)`,children:e.kind}),(0,O.jsx)(`span`,{className:`truncate font-medium`,children:e.title})]}),e.snippet&&(0,O.jsx)(`span`,{className:`truncate text-xs text-(--color-text-muted)`,children:e.snippet})]},`${e.kind}-${e.id}`))]}),r.trim()&&s.length===0&&a.length===0&&(0,O.jsx)(`p`,{className:`px-2.5 py-4 text-center text-sm text-(--color-text-muted)`,children:`No results.`})]})]})})}var Jl=[{view:`thread`,label:`Chats`},{view:`workspace`,label:`Workspace`},{view:`computer`,label:`Computer`},{view:`rules`,label:`Rules`},{view:`connectors`,label:`Connectors`},{view:`usage`,label:`Usage`},{view:`settings`,label:`Settings`}],Yl={connecting:`Connecting…`,open:`Connected`,closed:`Disconnected`},Xl={connecting:`bg-(--color-amber) animate-pulse`,open:`bg-(--color-green)`,closed:`bg-(--color-red)`};function Zl({connection:e,pendingCount:t,view:n,onChangeView:r,onOpenPalette:i,onOpenApproval:a}){return(0,O.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center justify-between border-b border-(--color-border) bg-(--color-bg-elevated) px-3`,children:[(0,O.jsx)(`nav`,{className:`flex items-center gap-1`,children:Jl.map(e=>(0,O.jsxs)(`button`,{type:`button`,onClick:()=>r(e.view),className:b(`rounded px-2.5 py-1 text-xs font-medium`,n===e.view?`bg-(--color-accent)/15 text-(--color-accent)`:`text-(--color-text-muted) hover:bg-(--color-bg-hover)`),children:[e.label,e.view===`rules`&&t>0&&(0,O.jsx)(`span`,{className:`ml-1.5 rounded-full bg-(--color-amber) px-1.5 py-0.5 text-[10px] font-semibold text-(--color-bg)`,children:t})]},e.view))}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsxs)(`button`,{type:`button`,onClick:i,className:`rounded border border-(--color-border) px-2.5 py-1 text-xs text-(--color-text-muted) hover:bg-(--color-bg-hover)`,children:[`Search… `,(0,O.jsx)(`span`,{className:`ml-1 opacity-60`,children:`⌘K`})]}),t>0&&(0,O.jsxs)(`button`,{type:`button`,onClick:a,title:`Go to the thread waiting on you`,className:`flex items-center gap-1 rounded-full bg-(--color-amber)/15 px-2 py-0.5 text-xs font-medium text-(--color-amber) hover:bg-(--color-amber)/25`,children:[t,` pending approval`,t===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-(--color-text-muted)`,children:[(0,O.jsx)(`span`,{className:b(`h-1.5 w-1.5 rounded-full`,Xl[e])}),Yl[e]]})]})]})}function Ql({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e})}function $l({children:e}){return(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:e})}function eu(){let e=T(e=>e.bots),t=T(e=>e.threads),n=T(e=>e.activeThreadId),r=T(e=>e.messagesByThread),i=T(e=>e.pendingApprovals),a=T(e=>e.connection),o=T(e=>e.notifications),s=T(e=>e.setBots),c=T(e=>e.setThreads),l=T(e=>e.setThreadMessages),u=T(e=>e.setActiveThreadId),d=T(e=>e.appendLocalMessage),f=T(e=>e.dismissNotification),p=T(e=>e.setPendingApprovals),[m,h]=(0,_.useState)(`thread`),[g,v]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(null),[S,ne]=(0,_.useState)(null),[re,ie]=(0,_.useState)(!1),[C,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)(`system`);(0,_.useEffect)(()=>{let e=document.documentElement,t=window.matchMedia(`(prefers-color-scheme: dark)`);function n(){let n=oe===`light`||oe===`system`&&!t.matches;e.classList.toggle(`light`,n)}return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[oe]),(0,_.useEffect)(()=>{let e=E();return()=>e.close()},[]);let ce=T(e=>e.epoch);(0,_.useEffect)(()=>{w.bots.list().then(s),w.threads.list().then(c),w.skills.list().then(ae),w.approvals.list().then(p).catch(()=>{})},[ce,s,c,p]);let le=T(e=>e.threadEpoch);(0,_.useEffect)(()=>{n&&(w.threads.get(n).then(({messages:e})=>{l(n,e)}),w.threads.markRead(n).catch(()=>{}))},[n,le,l]),(0,_.useEffect)(()=>{function e(e){let t=e.metaKey||e.ctrlKey;t&&e.key.toLowerCase()===`n`?(e.preventDefault(),v(!0)):t&&e.key.toLowerCase()===`k`&&(e.preventDefault(),ie(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let D=(0,_.useMemo)(()=>{let t={};for(let n of e)t[n.bot.id]=n;return t},[e]),ue=(0,_.useMemo)(()=>Object.values(t).filter(e=>e.kind===`group`),[t]),de=n?t[n]??null:null,fe=n?r[n]??[]:[],k=de?e.find(e=>e.thread?.id===de.id):void 0,A=S?D[S]?.bot??null:null;async function pe(){s(await w.bots.list())}async function me(e){x(!0),te(null);try{let t=await w.bots.create(e);await pe(),v(!1),t.threadId&&(c(await w.threads.list()),u(t.threadId),h(`thread`))}catch(e){te(e instanceof Error?e.message:`Failed to create bot`)}finally{x(!1)}}async function ge(e,t){if(!n)return;let r=await w.threads.postMessage(n,{contentMd:e,attachmentIds:t});d(n,r)}async function _e(){k&&await w.bots.stop(k.bot.id)}function ve(e){u(e),ne(null),h(`thread`)}function ye(e){e.kind===`thread`?ve(e.id):e.kind===`newBot`?v(!0):h(e.kind)}return(0,O.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,O.jsx)(Zl,{connection:a,pendingCount:i.length,view:m,onChangeView:e=>{ne(null),h(e)},onOpenPalette:()=>ie(!0),onOpenApproval:()=>{let e=i[0];e&&ve(e.threadId)}}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,O.jsx)(he,{entries:e,groupThreads:ue,botsById:D,activeThreadId:n,onSelectThread:ve,onNewBot:()=>v(!0)}),(0,O.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[m===`thread`&&(A?(0,O.jsx)(vl,{bot:A,onClose:()=>ne(null),onUpdated:t=>s(e.map(e=>e.bot.id===t.id?{...e,bot:t}:e)),onDuplicated:e=>{pe(),ne(e.id)},onDeleted:()=>{ne(null),pe()}}):(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[k&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-(--color-border) px-4 py-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-lg leading-none`,children:k.bot.avatarEmoji}),(0,O.jsx)(`span`,{className:`text-sm font-semibold`,children:k.bot.name}),k.bot.title&&(0,O.jsx)(`span`,{className:`text-xs text-(--color-text-muted)`,children:k.bot.title})]}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>ne(k.bot.id),className:`text-xs text-(--color-text-muted) hover:text-(--color-text)`,children:`Bot settings`})]}),(0,O.jsx)(ol,{thread:de,messages:fe,botsById:D,bots:e,skills:C,running:k?.bot.state===`running`||k?.bot.state===`queued`,onSend:ge,onStop:_e})]})),m===`rules`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(xl,{})}),m===`connectors`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(Gl,{})}),m===`usage`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(Cl,{})}),m===`settings`&&(0,O.jsx)(Ql,{children:(0,O.jsx)(Dl,{onSettingsChange:e=>se(e.theme)})}),m===`workspace`&&(0,O.jsx)($l,{children:(0,O.jsx)(Nl,{})}),m===`computer`&&(0,O.jsx)($l,{children:(0,O.jsx)(Pl,{})})]})]}),o.length>0&&(0,O.jsx)(`div`,{className:`pointer-events-none fixed bottom-24 right-4 z-50 flex flex-col gap-2`,children:o.slice(-4).map(e=>(0,O.jsxs)(`div`,{className:b(`pointer-events-auto w-72 rounded-md border p-3 text-sm shadow-lg`,e.level===`error`&&`border-(--color-red)/50 bg-(--color-bg-elevated)`,e.level===`warn`&&`border-(--color-amber)/50 bg-(--color-bg-elevated)`,e.level===`info`&&`border-(--color-border) bg-(--color-bg-elevated)`),children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>f(e.id),className:`text-(--color-text-faint) hover:text-(--color-text)`,children:`×`})]}),e.body&&(0,O.jsx)(`p`,{className:`mt-0.5 text-xs text-(--color-text-muted)`,children:e.body})]},e.id))}),g&&(0,O.jsx)(cl,{onCreate:me,onClose:()=>v(!1),busy:y,error:ee}),(0,O.jsx)(ql,{open:re,onClose:()=>ie(!1),onNavigate:ye})]})}var tu=document.getElementById(`root`);if(!tu)throw Error(`#root not found`);(0,v.createRoot)(tu).render((0,O.jsx)(_.StrictMode,{children:(0,O.jsx)(eu,{})}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>ant-bot</title>
7
- <script type="module" crossorigin src="/assets/index-Cfy0hrM2.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-YLvrZXZp.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-BFXK6qyy.css">
9
9
  </head>
10
10
  <body>