UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 4.37 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{It as t,Pt as n,Qt as r,Xt as i}from"./control-ui-connection-Bfj9beF_.js";import{BA as a,Qv as o,dj as s,mj as c,ty as l,zA as u}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as d,F as f,H as p,I as m,O as h,Rt as g,S as _,U as v,d as y,f as b,g as x,j as S,l as C,s as w,u as T,x as E,yt as D}from"./solid-runtime-C416s-HC.js";import{n as O,t as k}from"./en-agent-creation-Cv8MHRu_.js";import{E as A,T as j}from"./route-controls-runtime-Bx6nx3QW.js";import{d as M,g as N,h as P,l as F,r as I,t as L}from"./lobster-pet-identity-Cg5EqPlD.js";import{a as R,i as z,n as B,r as V,t as H}from"./avatar-picker-Cl1TESAF.js";function U(e){let[t,r]=d(``),[a,s]=d(null),[l,v]=m(!1),[w,T]=d(),E=f(()=>w()?.result.then(()=>null),{loadingValue:void 0}),O={mode:`bot`,canGenerate:!1,generated:!1,busy:!1},[k,A]=d(null),M=()=>k()?.footerState()??O,N=()=>M().busy,I=`bot-draft-${p()}`,R=f(()=>c(`agentChip.createDialogTitle`)),B=f(()=>c(`agentChip.createDialogName`)),U=f(()=>({id:I,name:t().trim()||R(),avatar:a()??void 0})),q=()=>e.context.agents.state.agentsList?.defaultId,J=()=>M().mode===`generate`&&!M().generated,Y=f(()=>N()||l()||(J()?!M().canGenerate:!t().trim()));async function X(t){let r=e.context.gateway.snapshot.client,i=q();if(!r||!i||!n(e.context.gateway.snapshot,`agents.avatar.generate`,`operator.admin`))throw Error(c(`agents.identity.avatarPermission`));return await r.request(`agents.avatar.generate`,{agentId:i,prompt:t},{timeoutMs:1e5})}let Z=D(function*(t){v(!0);let n=yield z(t,e.context.config);s(V(n))}),Q=!1;function $(){if(J()){!N()&&!l()&&M().canGenerate&&k()?.generate();return}let n=t().trim();Q||!n||N()||l()||(Q=!0,e.onCreate({name:n,avatar:a()}))}return S(j,{class:`agent-create-modal`,get label(){return R()},"onModal-cancel":()=>e.onCancel(),get children(){var n=W(),d=n.firstChild,f=d.firstChild,p=f.nextSibling,m=d.nextSibling,v=m.firstChild,w=v.nextSibling,D=w.firstChild,O=D.nextSibling,j=w.nextSibling,z=j.nextSibling,V=m.nextSibling,q=V.firstChild,Q=q.nextSibling;return n.addEventListener(`submit`,e=>{e.preventDefault(),$()}),y(f,R),p._$$click=()=>e.onCancel(),y(p,S(u,{name:`x`})),y(v,S(h,{get when(){return a()},get fallback(){var e=G();return y(e,S(P,{get look(){return L(F[0][0])},standalone:!0})),e},get children(){return S(o,{get agent(){return U()}})}})),y(D,()=>c(`agents.identity.name`)),O._$$input=e=>r(e.currentTarget.value),y(m,S(H,{agentId:I,get avatar(){return a()},get disabled(){return l()},onSelect:e=>{s(e),T(void 0)},onUpload:e=>{let t=Z(e);t.catch(()=>void 0),T({result:t})},onGenerate:X,footerGeneration:!0,onActionsReady:A,onReset:()=>{s(null),T(void 0)}}),j),y(m,S(h,{get when(){return!l()},get children(){return S(_,{fallback:e=>(()=>{var t=K();return y(t,()=>i(e())),t})(),get children(){return E()}})}}),z),V._$owner=g(),q._$$click=()=>{M().mode===`generate`&&M().generated?k()?.reset():e.onCancel()},y(q,(()=>{var e=b(()=>!!(M().mode===`generate`&&M().generated));return()=>e()?c(`common.reset`):c(`common.cancel`)})()),y(Q,(()=>{var e=b(()=>!!J());return()=>e()?b(()=>!!N())()?c(`agents.identity.avatarGenerating`):c(`agents.identity.avatarGenerate`):b(()=>M().mode===`generate`)()?c(`common.save`):c(`common.create`)})()),C(()=>({e:c(`common.close`),t:B(),a:t(),o:M().mode===`generate`&&M().generated?`reset`:`cancel`,i:Y()}),({e,t,a:n,o:r,i},a)=>{e!==a?.e&&x(p,`aria-label`,e),t!==a?.t&&x(O,`placeholder`,t),O.value=n??``,r!==a?.o&&x(q,`data-action`,r),i!==a?.i&&x(Q,`disabled`,i)}),n}})}var W,G,K;function q(){return(q=e((()=>{T(),v(),N(),I(),M(),a(),l(),k(),r(),t(),s(),R(),B(),A(),W=E(`<form class=agent-create-dialog><div class=agent-create-dialog__header><h2></h2><button type=button class=agent-create-dialog__close></button></div><div class=agent-create-dialog__body><div class=agent-create-dialog__preview></div><label class=agent-create-dialog__name><span class=sr-only></span><input name=name type=text autocomplete=off maxlength=64 autofocus></label><!><!></div><openclaw-modal-actions class=agent-create-dialog__actions><button type=button class=btn></button><button type=submit class="btn primary">`,1),G=E(`<div class="agent-create-dialog__ghost avatar-picker__ghost avatar-picker__sprite lobster-pet">`),K=E(`<p class=agent-create-dialog__error role=alert>`),O(),w([`click`,`input`])})))()}q();export{U as AgentCreateDialog};