@zonease/aiworker-cli 0.9.5 → 0.9.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
|
@@ -25,6 +25,6 @@ Error generating stack: `+e.message+`
|
|
|
25
25
|
${e.left}px ${e.top}px
|
|
26
26
|
)`}return(0,V.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Yx=B.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Cx(),a=i.useState(`mounted`),o=i.useState(`modal`);return a||n?(0,V.jsx)(Fx.Provider,{value:n,children:(0,V.jsxs)(Fh,{ref:t,...r,children:[a&&o===!0&&(0,V.jsx)(Jx,{ref:i.context.internalBackdropRef,inert:py(!open)}),e.children]})}):null}),Xx={},Zx={},Qx=``;function $x(e){if(typeof document>`u`)return!1;let t=Ym(e);return Hd(t).innerWidth-t.documentElement.clientWidth>0}function eS(e){let t=Ym(e),n=t.documentElement,r=t.body,i=Jd(n)?n:r,a=i.style.overflow;return i.style.overflow=`hidden`,()=>{i.style.overflow=a}}function tS(e){let t=Ym(e),n=t.documentElement,r=t.body,i=Hd(n),a=0,o=0,s=qm.create(),c=typeof CSS<`u`&&CSS.supports?.(`scrollbar-gutter`,`stable`);if(Sf&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let e=i.getComputedStyle(n),t=i.getComputedStyle(r),s=(e.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,Xx={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Qx=n.style.scrollBehavior,Zx={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let l=n.scrollHeight>n.clientHeight,u=n.scrollWidth>n.clientWidth,d=e.overflowY===`scroll`||t.overflowY===`scroll`,f=e.overflowX===`scroll`||t.overflowX===`scroll`,p=Math.max(0,i.innerWidth-n.clientWidth),m=Math.max(0,i.innerHeight-n.clientHeight),h=parseFloat(t.marginTop)+parseFloat(t.marginBottom),g=parseFloat(t.marginLeft)+parseFloat(t.marginRight),_=Jd(n)?n:r;if(c){n.style.scrollbarGutter=s,_.style.overflowY=`hidden`,_.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:s,overflowY:`hidden`,overflowX:`hidden`}),(l||d)&&(n.style.overflowY=`scroll`),(u||f)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:h||m?`calc(100dvh - ${h+m}px)`:`100dvh`,width:g||p?`calc(100vw - ${g+p}px)`:`100vw`,boxSizing:`border-box`,overflow:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,Xx),Object.assign(r.style,Zx),c||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Qx)}function d(){u(),s.request(l)}return l(),i.addEventListener(`resize`,d),()=>{s.cancel(),u(),typeof i.removeEventListener==`function`&&i.removeEventListener(`resize`,d)}}var nS=new class{lockCount=0;restore=null;timeoutLock=Rd.create();timeoutUnlock=Rd.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Ym(e).documentElement,n=Hd(t).getComputedStyle(t).overflowY;if(n===`hidden`||n===`clip`){this.restore=vm;return}let r=Cf||!$x(e);this.restore=r?eS(e):tS(e)}};function rS(e=!0,t=null){kd(()=>{if(e)return nS.acquire(t)},[e,t])}function iS(e){let t=B.useRef(``),n=B.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:B.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n&&e(n,n.pointerType),e(n,t.current),t.current=``},[e]),onPointerDown:n}}function aS(e){let[t,n]=B.useState(null),r=$((t,r)=>{e||n(r)}),i=B.useCallback(()=>{n(null)},[]),{onClick:a,onPointerDown:o}=iS(r);return B.useMemo(()=>({openMethod:t,reset:i,triggerProps:{onClick:a,onPointerDown:o}}),[t,i,a,o])}function oS(e){let{store:t,parentContext:n,actionsRef:r}=e,i=t.useState(`open`),a=t.useState(`disablePointerDismissal`),o=t.useState(`modal`),s=t.useState(`popupElement`),{openMethod:c,triggerProps:l,reset:u}=aS(i);W_(t);let{forceUnmount:d}=G_(i,t,()=>{u()}),f=$(e=>{let n=Mm(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),p=B.useCallback(()=>{t.setOpen(!1,f(jm))},[t,f]);B.useImperativeHandle(r,()=>({unmount:d,close:p}),[d,p]);let m=Q_({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[h,g]=B.useState(0),_=h===0,v=hv(m),y=s_(m,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=Ff(e);if(_&&!a){let e=n;return o&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||Pf(e,s)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:_});rS(i&&o===!0,s);let{getReferenceProps:b,getFloatingProps:x,getTriggerProps:S}=dv([v,y]);t.useContextCallback(`onNestedDialogOpen`,e=>{g(e+1)}),t.useContextCallback(`onNestedDialogClose`,()=>{g(0)}),B.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(h),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,h]);let C=B.useMemo(()=>b(l),[b,l]),w=B.useMemo(()=>S(l),[S,l]),T=B.useMemo(()=>x(),[x]);t.useSyncedValues({openMethod:c,activeTriggerProps:C,inactiveTriggerProps:w,popupProps:T,floatingRootContext:m,nestedOpenDialogCount:h})}var sS={...Y_,modal:k_(e=>e.modal),nested:k_(e=>e.nested),nestedOpenDialogCount:k_(e=>e.nestedOpenDialogCount),disablePointerDismissal:k_(e=>e.disablePointerDismissal),openMethod:k_(e=>e.openMethod),descriptionElementId:k_(e=>e.descriptionElementId),titleElementId:k_(e=>e.titleElementId),viewportElement:k_(e=>e.viewportElement),role:k_(e=>e.role)},cS=class extends I_{constructor(e){super(lS(e),{popupRef:B.createRef(),backdropRef:B.createRef(),internalBackdropRef:B.createRef(),triggerElements:new K_,onOpenChange:void 0,onOpenChangeComplete:void 0},sS)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;let n={open:e,nativeEvent:t.event,reason:t.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit(`openchange`,n);let r={open:e},i=t.trigger?.id??null;(i||e)&&(r.activeTriggerId=i,r.activeTriggerElement=t.trigger??null),this.update(r)}};function lS(e={}){return{...J_(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:`dialog`,...e}}function uS(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=Cx(!0),p=!!f,m=Pd(()=>l?.store??new cS({open:n??r,activeTriggerId:u===void 0?d:u,modal:s,disablePointerDismissal:o,nested:p})).current;m.useControlledProp(`open`,n,r),m.useControlledProp(`activeTriggerId`,u,d),m.useSyncedValues({disablePointerDismissal:o,nested:p,modal:s}),m.useContextCallback(`onOpenChange`,i),m.useContextCallback(`onOpenChangeComplete`,a);let h=m.useState(`payload`);oS({store:m,actionsRef:c,parentContext:f?.store.context,onOpenChange:i,triggerIdProp:u});let g=B.useMemo(()=>({store:m}),[m]);return(0,V.jsx)(Sx.Provider,{value:g,children:typeof t==`function`?t({payload:h}):t})}var dS=B.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,{store:o}=Cx(),s=Iv(i);return o.useSyncedValueWithCleanup(`titleElementId`,s),Dh(`h2`,e,{ref:t,props:[{id:s},a]})}),fS=uS,pS=jx,mS=Yx;function hS({className:e,...t}){return(0,V.jsx)(Tx,{className:Cd(`fixed inset-0 z-50 bg-surface-ink/80 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 transition-opacity duration-150`,e),...t})}function gS({className:e,children:t,showCloseButton:n=!0,...r}){return(0,V.jsxs)(mS,{children:[(0,V.jsx)(hS,{}),(0,V.jsxs)(qx,{className:Cd(`fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-card outline-none sm:rounded-md`,`data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 data-[ending-style]:scale-95 data-[starting-style]:scale-95 transition-[opacity,transform] duration-150`,e),...r,children:[t,n&&(0,V.jsx)(pS,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:text-primary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,"aria-label":`Close dialog`,children:(0,V.jsx)(Xl,{className:`size-4`})})]})]})}function _S({className:e,...t}){return(0,V.jsx)(`div`,{className:Cd(`flex flex-col space-y-1.5 text-left`,e),...t})}function vS({className:e,...t}){return(0,V.jsx)(`div`,{className:Cd(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function yS({className:e,...t}){return(0,V.jsx)(dS,{className:Cd(`text-xl font-bold leading-tight`,e),...t})}function bS({className:e,...t}){return(0,V.jsx)(Mx,{className:Cd(`text-sm text-muted-foreground`,e),...t})}function xS({className:e,...t}){return(0,V.jsx)(`div`,{className:Cd(`animate-pulse rounded-md bg-muted`,e),...t})}function SS(){let e=Nb(),t=Pb(),n=Fb(),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null);async function l(){if(a){c(null);try{await n.mutateAsync(a),o(null)}catch(e){c(e instanceof Ny?e.message:`删除失败。`)}}}return(0,V.jsxs)(`div`,{className:`flex max-w-3xl flex-col gap-6`,children:[(0,V.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Secrets`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`常规 secret 通过配置编辑器管理;这里用于 out-of-band 轮换 / 应急处置。`})]}),(0,V.jsxs)(Od,{onClick:()=>i({kind:`add`}),children:[(0,V.jsx)(Rl,{className:`size-4`}),`添加 secret`]})]}),e.isLoading?(0,V.jsx)(xS,{className:`h-40`}):e.isError?(0,V.jsxs)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[`加载 secrets 失败:`,e.error instanceof Error?e.error.message:`未知错误`]}):e.data?.keys.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:`尚无 secret。`}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.data?.keys.map(e=>(0,V.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-md border bg-card px-4 py-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(kl,{className:`size-4 text-muted-foreground`}),(0,V.jsx)(`code`,{className:`font-mono text-sm`,children:e})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i({kind:`replace`,key:e}),children:`替换`}),(0,V.jsx)(Od,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Delete secret ${e}`,onClick:()=>o(e),children:(0,V.jsx)(ql,{className:`size-4`})})]})]},e))}),s&&(0,V.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),r&&(0,V.jsx)(CS,{existingKeys:e.data?.keys??[],mode:r,submitting:t.isPending,onClose:()=>i(null),onSubmit:async({key:e,value:n})=>{c(null);try{await t.mutateAsync({key:e,value:n}),i(null)}catch(e){c(e instanceof Ny?e.message:`保存失败。`)}}},r.kind===`add`?`__add`:`__replace_${r.key}`),(0,V.jsx)(fS,{open:a!==null,onOpenChange:e=>!e&&o(null),children:(0,V.jsxs)(gS,{className:`sm:max-w-md`,children:[(0,V.jsxs)(_S,{children:[(0,V.jsx)(yS,{children:`删除该 secret?`}),(0,V.jsxs)(bS,{children:[`将从 worker vault 移除`,` `,(0,V.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-xs`,children:a}),`;config 里引用它的字段在替换前会加载失败。`]})]}),(0,V.jsxs)(vS,{children:[(0,V.jsx)(Od,{variant:`outline`,onClick:()=>o(null),children:`取消`}),(0,V.jsx)(Od,{variant:`destructive`,onClick:l,disabled:n.isPending,children:n.isPending?`删除中…`:`删除`})]})]})})]})}function CS({mode:e,existingKeys:t,submitting:n,onClose:r,onSubmit:i}){let a=(0,B.useId)(),o=(0,B.useId)(),[s,c]=(0,B.useState)(e.kind===`replace`?e.key:``),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null);async function h(n){n.preventDefault(),m(null);let r=s.trim();if(r.length===0){m(`key 必填。`);return}if(l.length===0){m(`value 必填。`);return}if(e.kind===`add`&&t.includes(r)){m(`该 key 已存在;改用「替换」。`);return}await i({key:r,value:l}),u(``)}return(0,V.jsx)(fS,{open:!0,onOpenChange:e=>!e&&r(),children:(0,V.jsx)(gS,{className:`sm:max-w-md`,children:(0,V.jsxs)(`form`,{onSubmit:h,children:[(0,V.jsxs)(_S,{children:[(0,V.jsx)(yS,{children:e.kind===`add`?`添加 secret`:`替换 ${e.key}`}),(0,V.jsx)(bS,{children:`value 加密存入 worker vault,之后绝不再回传 UI。`})]}),(0,V.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:a,children:`Key`}),(0,V.jsx)(Cy,{id:a,value:s,onChange:e=>c(e.target.value),disabled:e.kind===`replace`,autoFocus:e.kind===`add`,spellCheck:!1})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:o,children:`Value`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(Cy,{id:o,type:d?`text`:`password`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:e.kind===`replace`}),(0,V.jsx)(Od,{type:`button`,variant:`outline`,size:`icon`,"aria-label":d?`Hide value`:`Show value`,onClick:()=>f(e=>!e),children:d?(0,V.jsx)(Dl,{className:`size-4`}):(0,V.jsx)(Ol,{className:`size-4`})})]})]}),p&&(0,V.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:p})]}),(0,V.jsxs)(vS,{children:[(0,V.jsx)(Od,{type:`button`,variant:`outline`,onClick:r,children:`取消`}),(0,V.jsxs)(Od,{type:`submit`,disabled:n,children:[n?(0,V.jsx)(Al,{className:`size-4 animate-spin`}):null,n?`保存中…`:`保存`]})]})]})})})}var wS=Ri(`/secrets`)({component:SS}),TS=[`web`,`line`,`telegram`,`lark`,`whatsapp`];function ES(){let e=zb(),t=Bb(),n=Vb(),r=Hb(),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null);async function u(e){l(null);try{await n.mutateAsync({id:e.id,patch:{enabled:!e.enabled}})}catch(e){l(e instanceof Ny?e.message:`更新失败。`)}}async function d(){if(o){l(null);try{await r.mutateAsync(o.id),s(null)}catch(e){l(e instanceof Ny?e.message:`删除失败。`)}}}let f=e.data?.jobs??[];return(0,V.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-6`,children:[(0,V.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Cron`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`按 cron 表达式定期触发的 prompt 任务。结果通过指定 channel 发出。`})]}),(0,V.jsxs)(Od,{onClick:()=>a({kind:`add`}),children:[(0,V.jsx)(Rl,{className:`size-4`}),`添加`]})]}),c&&(0,V.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:c}),e.isLoading?(0,V.jsx)(xS,{className:`h-40`}):e.isError?(0,V.jsxs)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[`加载 cron 列表失败:`,e.error instanceof Error?e.error.message:`未知错误`]}):f.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:`尚无 cron。`}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-3`,children:f.map(e=>(0,V.jsx)(`li`,{className:`flex flex-col gap-2 rounded-md border bg-card p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`code`,{className:`font-mono text-sm`,children:e.expression}),(0,V.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-micro uppercase text-muted-foreground`,children:e.channel}),!e.enabled&&(0,V.jsx)(`span`,{className:`rounded bg-warning-soft px-1.5 py-0.5 text-micro font-bold text-warning`,children:`disabled`})]}),(0,V.jsx)(`p`,{className:`mt-1 truncate text-sm text-muted-foreground`,title:e.prompt,children:e.prompt}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`chatId`,(0,V.jsx)(`code`,{className:`ml-1 font-mono`,children:e.chatId}),(0,V.jsx)(`span`,{className:`mx-2`,children:`·`}),`account`,(0,V.jsx)(`code`,{className:`ml-1 font-mono`,children:e.accountId}),(0,V.jsx)(`span`,{className:`mx-2`,children:`·`}),`next`,(0,V.jsx)(`code`,{className:`ml-1 font-mono`,children:e.nextRunAt??`—`}),(0,V.jsx)(`span`,{className:`mx-2`,children:`·`}),`last`,(0,V.jsx)(`code`,{className:`ml-1 font-mono`,children:e.lastRunAt??`—`})]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,V.jsx)(Od,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":e.enabled?`暂停`:`启用`,onClick:()=>void u(e),disabled:n.isPending,children:e.enabled?(0,V.jsx)(Fl,{className:`size-4`}):(0,V.jsx)(Ll,{className:`size-4`})}),(0,V.jsx)(Od,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`编辑`,onClick:()=>a({kind:`edit`,job:e}),children:(0,V.jsx)(Il,{className:`size-4`})}),(0,V.jsx)(Od,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`删除`,onClick:()=>s(e),children:(0,V.jsx)(ql,{className:`size-4`})})]})]})},e.id))}),i&&(0,V.jsx)(DS,{mode:i,submitting:t.isPending||n.isPending,onClose:()=>a(null),onSubmit:async e=>{l(null);try{i.kind===`add`?await t.mutateAsync(e):await n.mutateAsync({id:i.job.id,patch:e}),a(null)}catch(e){l(e instanceof Ny?e.message:`保存失败。`)}}},i.kind===`add`?`__add`:`__edit_${i.job.id}`),(0,V.jsx)(fS,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,V.jsxs)(gS,{className:`sm:max-w-md`,children:[(0,V.jsxs)(_S,{children:[(0,V.jsx)(yS,{children:`删除该 cron?`}),(0,V.jsxs)(bS,{children:[`将立即停止`,` `,(0,V.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-xs`,children:o?.id}),` `,`的调度。`]})]}),(0,V.jsxs)(vS,{children:[(0,V.jsx)(Od,{variant:`outline`,onClick:()=>s(null),children:`取消`}),(0,V.jsx)(Od,{variant:`destructive`,onClick:d,disabled:r.isPending,children:r.isPending?`删除中…`:`删除`})]})]})})]})}function DS({mode:e,submitting:t,onClose:n,onSubmit:r}){let i=(0,B.useId)(),a=(0,B.useId)(),o=(0,B.useId)(),s=(0,B.useId)(),[c,l]=(0,B.useState)((0,B.useMemo)(()=>e.kind===`edit`?{expression:e.job.expression,prompt:e.job.prompt,channel:e.job.channel,chatId:e.job.chatId,accountId:e.job.accountId,enabled:e.job.enabled}:{expression:`0 9 * * *`,prompt:``,channel:`web`,chatId:``,accountId:``,enabled:!0},[e])),[u,d]=(0,B.useState)(null);function f(e,t){l(n=>({...n,[e]:t}))}async function p(e){if(e.preventDefault(),d(null),!c.expression.trim()||!c.prompt.trim()||!c.chatId.trim()){d(`expression / prompt / chatId 必填。`);return}let t={expression:c.expression.trim(),prompt:c.prompt.trim(),channel:c.channel,chatId:c.chatId.trim(),enabled:c.enabled};c.accountId.trim().length>0&&(t.accountId=c.accountId.trim()),await r(t)}return(0,V.jsx)(fS,{open:!0,onOpenChange:e=>!e&&n(),children:(0,V.jsx)(gS,{className:`sm:max-w-lg`,children:(0,V.jsxs)(`form`,{onSubmit:p,children:[(0,V.jsxs)(_S,{children:[(0,V.jsx)(yS,{children:e.kind===`add`?`添加 cron`:`编辑 ${e.job.id}`}),(0,V.jsx)(bS,{children:`cron 表达式遵循 5 字段标准(分 时 日 月 周)。`})]}),(0,V.jsxs)(`div`,{className:`grid gap-3 py-4`,children:[(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:i,children:`Expression`}),(0,V.jsx)(Cy,{id:i,value:c.expression,onChange:e=>f(`expression`,e.target.value),className:`font-mono`})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:a,children:`Prompt`}),(0,V.jsx)(`textarea`,{id:a,className:`min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm`,value:c.prompt,onChange:e=>f(`prompt`,e.target.value)})]}),(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(wy,{children:`Channel`}),(0,V.jsx)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:c.channel,onChange:e=>f(`channel`,e.target.value),children:TS.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:o,children:`chatId`}),(0,V.jsx)(Cy,{id:o,value:c.chatId,onChange:e=>f(`chatId`,e.target.value)})]}),(0,V.jsxs)(`div`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,V.jsx)(wy,{htmlFor:s,children:"accountId(留空 = `sys:cron`)"}),(0,V.jsx)(Cy,{id:s,value:c.accountId,onChange:e=>f(`accountId`,e.target.value)})]}),(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm sm:col-span-2`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:c.enabled,onChange:e=>f(`enabled`,e.target.checked)}),`启用`]})]}),u&&(0,V.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:u})]}),(0,V.jsxs)(vS,{children:[(0,V.jsx)(Od,{type:`button`,variant:`outline`,onClick:n,children:`取消`}),(0,V.jsxs)(Od,{type:`submit`,disabled:t,children:[t?(0,V.jsx)(Al,{className:`size-4 animate-spin`}):null,t?`保存中…`:`保存`]})]})]})})})}var OS=Ri(`/cron`)({component:ES});function kS(e){return{id:`brain-${e}`,type:`filesystem`,priority:100,readOnly:!1,config:{}}}function AS(e){return{id:`brain-${e}`,type:`cloud-gateway`,priority:100,readOnly:!1,config:{url:``,token:``}}}function jS({brains:e,brainWriteTarget:t,brainRetrieval:n,onChange:r}){function i(t,n){let i=e.slice();i[t]=n,r({brains:i})}function a(n){let i=e[n],a=e.filter((e,t)=>t!==n),o={brains:a};i&&t===i.id&&(o.brainWriteTarget=a[0]?.id??``),r(o)}function o(t){let n=t===`filesystem`?kS(e.length+1):AS(e.length+1);r({brains:[...e,n]})}return(0,V.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-md border bg-card p-6`,children:[(0,V.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-lg font-bold`,children:`Brain sources`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`知识与记忆后端。Secret 字段留空表示沿用旧值。`})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(`filesystem`),children:[(0,V.jsx)(Rl,{className:`size-3.5`}),`Filesystem`]}),(0,V.jsxs)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(`cloud-gateway`),children:[(0,V.jsx)(Rl,{className:`size-3.5`}),`Cloud gateway`]})]})]}),e.length===0&&(0,V.jsx)(`p`,{className:`rounded-md border border-dashed p-4 text-center text-sm text-muted-foreground`,children:`尚未配置 brain source。至少加一个才能启用 retrieval。`}),(0,V.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.map((e,t)=>(0,V.jsx)(MS,{source:e,onChange:e=>i(t,e),onRemove:()=>a(t)},e.id))}),e.length>0&&(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`Write target`}),(0,V.jsxs)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:t,onChange:e=>r({brainWriteTarget:e.target.value}),children:[(0,V.jsx)(`option`,{value:``,children:`— none —`}),e.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`接收`,` `,(0,V.jsx)(`code`,{className:`font-mono text-micro`,children:`writeMemory`}),` `,`调用的 source。`]})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`Retrieval mode`}),(0,V.jsxs)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:n,onChange:e=>r({brainRetrieval:e.target.value}),children:[(0,V.jsx)(`option`,{value:`merge-by-priority`,children:`merge-by-priority`}),(0,V.jsx)(`option`,{value:`first-match`,children:`first-match`})]})]})]})]})}function MS({source:e,onChange:t,onRemove:n}){function r(n){t({...e,...n})}function i(n){n!==e.type&&t(n===`filesystem`?{id:e.id,type:`filesystem`,priority:e.priority,readOnly:e.readOnly,config:{}}:{id:e.id,type:`cloud-gateway`,priority:e.priority,readOnly:e.readOnly,config:{url:``,token:``}})}return(0,V.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-md border bg-background p-4`,children:[(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,160px)_minmax(0,120px)_auto]`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`Id`}),(0,V.jsx)(Cy,{value:e.id,onChange:e=>r({id:e.target.value}),"aria-label":`Brain source id`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`Type`}),(0,V.jsxs)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:e.type,onChange:e=>i(e.target.value),"aria-label":`Brain source type`,children:[(0,V.jsx)(`option`,{value:`filesystem`,children:`filesystem`}),(0,V.jsx)(`option`,{value:`cloud-gateway`,children:`cloud-gateway`})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`Priority`}),(0,V.jsx)(Cy,{type:`number`,value:e.priority,onChange:e=>r({priority:Number.parseInt(e.target.value,10)||0})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.readOnly,onChange:e=>r({readOnly:e.target.checked})}),`read-only`]}),(0,V.jsx)(Od,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove brain source`,onClick:n,children:(0,V.jsx)(ql,{className:`size-4`})})]})]}),e.type===`filesystem`?(0,V.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,V.jsx)(NS,{label:`home (optional — 默认 ~/.aiworker/workers/<id>/brain)`,children:(0,V.jsx)(Cy,{value:e.config.home??``,onChange:n=>t({...e,config:{...e.config,home:n.target.value||void 0}})})})}):(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(NS,{label:`url`,children:(0,V.jsx)(Cy,{value:e.config.url,onChange:n=>t({...e,config:{...e.config,url:n.target.value}})})}),(0,V.jsx)(PS,{label:`token`,value:e.config.token,onChange:n=>t({...e,config:{...e.config,token:n}})}),(0,V.jsx)(NS,{label:`defaultCategory (optional)`,children:(0,V.jsx)(Cy,{value:e.config.defaultCategory??``,onChange:n=>t({...e,config:{...e.config,defaultCategory:n.target.value}})})}),(0,V.jsx)(NS,{label:`defaultTypeId (optional)`,children:(0,V.jsx)(Cy,{value:e.config.defaultTypeId??``,onChange:n=>t({...e,config:{...e.config,defaultTypeId:n.target.value}})})})]})]})}function NS({label:e,children:t}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:e}),t]})}function PS({label:e,value:t,onChange:n,placeholder:r=`(unchanged)`}){let[i,a]=(0,B.useState)(!1);return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(Cy,{type:i?`text`:`password`,value:t,onChange:e=>n(e.target.value),placeholder:r,autoComplete:`off`,spellCheck:!1}),(0,V.jsx)(Od,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide ${e}`:`Show ${e}`,onClick:()=>a(e=>!e),children:i?(0,V.jsx)(Dl,{className:`size-4`}):(0,V.jsx)(Ol,{className:`size-4`})})]}),(0,V.jsx)(`p`,{className:`text-micro text-muted-foreground`,children:`留空保留 vault 里旧值。`})]})}var FS=[`web`,`line`,`telegram`,`lark`,`whatsapp`];function IS(){let e=new Uint8Array(24);crypto.getRandomValues(e);let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function LS(e){switch(e){case`web`:return{channel:`web`,inboundToken:``};case`line`:return{channel:`line`,channelSecret:``,channelAccessToken:``};case`telegram`:return{channel:`telegram`,botToken:``};case`lark`:return{channel:`lark`,appId:``,appSecret:``,encryptKey:``,verificationToken:``};case`whatsapp`:return{channel:`whatsapp`,phoneNumberId:``,accessToken:``,appSecret:``,verifyToken:``}}}function RS(e){return{channel:e,enabled:!1,credentials:LS(e)}}function zS(e,t,n){let r=0;for(let i=0;i<n;i+=1)t[i]?.channel===e&&(r+=1);return r===0?e:`${e}#${r}`}function BS({channels:e,info:t,onChange:n}){function r(t,r){let i=e.slice();i[t]=r,n(i)}function i(t){n(e.filter((e,n)=>n!==t))}function a(t){n([...e,RS(t)])}return(0,V.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-md border bg-card p-6`,children:[(0,V.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-lg font-bold`,children:`Channels`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`入站消息源。把卡片里的 webhook URL 粘到对应平台后台。`})]}),(0,V.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:FS.map(e=>(0,V.jsxs)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(e),children:[(0,V.jsx)(Rl,{className:`size-3.5`}),e]},e))})]}),e.length===0&&(0,V.jsx)(`p`,{className:`rounded-md border border-dashed p-4 text-center text-sm text-muted-foreground`,children:`尚未绑定 channel。`}),(0,V.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.map((n,a)=>(0,V.jsx)(VS,{binding:n,webhookUrl:t?.channels.find(e=>e.channel===n.channel)?.webhookUrl,onChange:e=>r(a,e),onRemove:()=>i(a)},zS(n.channel,e,a)))})]})}function VS({binding:e,webhookUrl:t,onChange:n,onRemove:r}){function i(t){n({...e,credentials:t})}function a(t){t!==e.channel&&n({channel:t,enabled:e.enabled,credentials:LS(t)})}return(0,V.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-md border bg-background p-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:e.channel,onChange:e=>a(e.target.value),"aria-label":`Channel type`,children:FS.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}),(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>n({...e,enabled:t.target.checked})}),`enabled`]})]}),(0,V.jsx)(Od,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove ${e.channel} channel`,onClick:r,children:(0,V.jsx)(ql,{className:`size-4`})})]}),t&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(wy,{children:`Webhook URL(只读,粘进平台后台即可)`}),(0,V.jsx)(Cy,{value:t,readOnly:!0,className:`font-mono text-xs`})]}),(0,V.jsx)(HS,{credentials:e.credentials,onChange:i})]})}function HS({credentials:e,onChange:t}){switch(e.channel){case`web`:return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end`,children:[(0,V.jsx)(PS,{label:`inboundToken`,value:e.inboundToken??``,onChange:n=>t({...e,inboundToken:n}),placeholder:`(unchanged — 留空沿用旧 token)`}),(0,V.jsx)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>t({...e,inboundToken:IS()}),children:`Generate`})]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`必填:调用`,` `,(0,V.jsx)(`code`,{className:`font-mono text-micro`,children:`POST /web/webhook`}),` `,`的客户端必须发`,` `,(0,V.jsx)(`code`,{className:`font-mono text-micro`,children:`Authorization: Bearer <inboundToken>`}),`。空 token = 拒绝所有入站(fail-closed)。`]})]});case`line`:return(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(PS,{label:`channelSecret`,value:e.channelSecret,onChange:n=>t({...e,channelSecret:n})}),(0,V.jsx)(PS,{label:`channelAccessToken`,value:e.channelAccessToken,onChange:n=>t({...e,channelAccessToken:n})})]});case`telegram`:return(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(PS,{label:`botToken`,value:e.botToken,onChange:n=>t({...e,botToken:n})}),(0,V.jsx)(PS,{label:`webhookSecretToken (optional)`,value:e.webhookSecretToken??``,onChange:n=>t({...e,webhookSecretToken:n||void 0})})]});case`lark`:return(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`appId`}),(0,V.jsx)(Cy,{value:e.appId,onChange:n=>t({...e,appId:n.target.value})})]}),(0,V.jsx)(PS,{label:`appSecret`,value:e.appSecret,onChange:n=>t({...e,appSecret:n})}),(0,V.jsx)(PS,{label:`encryptKey`,value:e.encryptKey,onChange:n=>t({...e,encryptKey:n})}),(0,V.jsx)(PS,{label:`verificationToken`,value:e.verificationToken,onChange:n=>t({...e,verificationToken:n})})]});case`whatsapp`:return(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`phoneNumberId`}),(0,V.jsx)(Cy,{value:e.phoneNumberId,onChange:n=>t({...e,phoneNumberId:n.target.value})})]}),(0,V.jsx)(PS,{label:`accessToken`,value:e.accessToken,onChange:n=>t({...e,accessToken:n})}),(0,V.jsx)(PS,{label:`appSecret`,value:e.appSecret,onChange:n=>t({...e,appSecret:n})}),(0,V.jsx)(PS,{label:`verifyToken`,value:e.verifyToken,onChange:n=>t({...e,verifyToken:n})})]})}}function US(e){let t=new Map;if(!e)return t;for(let n of e){let e=n.agent?`${n.kind}:${n.agent}`:n.kind;t.set(e,n)}return t}function WS(e,t){let n=e.get(t);if(n)return n.status;let r=[...e.values()].filter(e=>e.kind===t);if(r.length!==0)return r.some(e=>e.status===`ready`)?`ready`:r.every(e=>e.status===`not-found`)?`not-found`:`login-required`}var GS=`__custom__`,KS=[],qS={};function JS({schema:e,value:t,secretFields:n=KS,fieldHints:r=qS,onChange:i}){let a=e.shape,o=new Set(n);function s(e,n){let r={...t};n===void 0?delete r[e]:r[e]=n,i(r)}return(0,V.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:Object.entries(a).map(([e,n])=>(0,V.jsx)(XS,{name:e,schema:n,value:t[e],isSecret:o.has(e),hintValues:r[e],onChange:t=>s(e,t)},e))})}function YS(e){return e instanceof Cs||e instanceof ws?{inner:e._def.innerType,optional:!0}:{inner:e,optional:!1}}function XS({name:e,schema:t,value:n,isSecret:r,hintValues:i,onChange:a}){let{inner:o,optional:s}=YS(t),c=s?` (optional)`:``;if(o instanceof Wo){let t=typeof n==`string`?n:``;return r?(0,V.jsx)(PS,{label:`${e}${c}`,value:t,onChange:e=>a(e||(s?void 0:``))}):i&&i.length>0?(0,V.jsx)(eC,{name:`${e}${c}`,fieldName:e,presets:i,optional:s,value:t,onChange:a}):(0,V.jsx)($S,{label:`${e}${c}`,value:t,onChange:e=>a(e||(s?void 0:``))})}if(o instanceof Ko){let t=typeof n==`number`?n:0;return(0,V.jsx)(tC,{label:`${e}${c}`,value:t,onChange:e=>a(e)})}if(o instanceof Jo)return(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:n===!0,onChange:e=>a(e.target.checked)}),e]});if(o instanceof ys){let t=o._def.values??o.options??[],r=typeof n==`string`?n:s?``:t[0]??``;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`${e}${c}`}),(0,V.jsxs)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:r,onChange:e=>a(e.target.value||(s?void 0:t[0])),children:[s&&(0,V.jsx)(`option`,{value:``,children:`— unset —`}),t.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]})}if(o instanceof rs){let t=Array.isArray(n)?n.filter(e=>typeof e==`string`):[];return(0,V.jsx)($S,{label:`${e}${c} (空白或 , 分隔)`,value:t.join(` `),onChange:e=>{let t=e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean);t.length===0?a(s?void 0:[]):a(t)}})}if(o instanceof fs){let t=typeof n==`object`&&n?Object.fromEntries(Object.entries(n).filter(([,e])=>typeof e==`string`)):{},r=Object.entries(t).map(([e,t])=>`${e}=${t}`).join(`
|
|
27
27
|
`);return(0,V.jsxs)(`div`,{className:`sm:col-span-2 flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`${e}${c} (KEY=value 每行一条)`}),(0,V.jsx)(`textarea`,{className:`min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm font-mono`,value:r,onChange:e=>{let t=[];for(let n of e.target.value.split(`
|
|
28
|
-
`)){let e=n.indexOf(`=`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1);r.length>0&&t.push([r,i])}t.length===0?a(s?void 0:{}):a(Object.fromEntries(t))}})]})}return(0,V.jsxs)(`div`,{className:`sm:col-span-2 flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`${e}${c} (JSON)`}),(0,V.jsx)(QS,{value:n,onChange:a,optional:s})]})}function ZS(e){if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return``}}function QS({value:e,onChange:t,optional:n}){return(0,V.jsx)(`textarea`,{className:`min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm font-mono`,defaultValue:ZS(e),onBlur:e=>{let r=e.target.value.trim();if(r.length===0){t(n?void 0:null);return}try{t(JSON.parse(r))}catch{}}})}function $S({label:e,value:t,onChange:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsx)(Cy,{value:t,onChange:e=>n(e.target.value)})]})}function eC({name:e,fieldName:t,presets:n,optional:r,value:i,onChange:a}){let o=i.length>0&&n.includes(i),[s,c]=(0,B.useState)(()=>i.length===0||o?`preset`:`custom`);function l(e){e.length===0?a(r?void 0:``):a(e)}function u(e){if(e===GS){c(`custom`);return}c(`preset`),l(e)}if(s===`custom`)return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline decoration-dotted underline-offset-2 hover:text-foreground`,onClick:()=>{c(`preset`),n.includes(i)||l(``)},children:`选预设…`})]}),(0,V.jsx)(Cy,{"data-testid":`field-${t}-input`,placeholder:n[0]??``,value:i,onChange:e=>l(e.target.value)})]});let d=o?i:``;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:`field-${t}-select`,children:e}),(0,V.jsxs)(`select`,{id:`field-${t}-select`,"data-testid":`field-${t}-select`,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:d,onChange:e=>u(e.target.value),children:[r&&(0,V.jsx)(`option`,{value:``,children:`— unset —`}),!r&&d===``&&(0,V.jsx)(`option`,{value:``,disabled:!0,children:`— 选 model —`}),n.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e)),(0,V.jsx)(`option`,{value:GS,children:`Custom…`})]})]})}function tC({label:e,value:t,onChange:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsx)(Cy,{type:`number`,value:t,onChange:e=>{let t=Number.parseInt(e.target.value,10);n(Number.isNaN(t)?0:t)}})]})}var nC=X({baseUrl:Y(),apiKey:Y(),model:Y(),timeoutMs:js().int().positive()}),rC={secretFields:[`apiKey`]},iC=X({url:Y(),token:Y(),defaultModel:Y().optional(),tools:Ps(Y()).optional(),timeoutMs:js().int().positive().optional()}),aC=X({command:Y(),args:Ps(Y()),cwd:Y().optional(),env:Ls(Y()).optional(),timeoutMs:js().int().positive().optional(),sandbox:Ms().optional()}),oC=X({model:Y().optional(),cliVersion:Y().optional(),extraArgs:Ps(Y()).optional(),env:Ls(Y()).optional(),workspaceRoot:Y().optional(),timeoutMs:js().int().positive().optional(),permissionPolicy:zs([`auto`,`supervised`,`plan`]).optional()}),sC=X({agent:zs([`gemini`,`qwen`]),model:Y().optional(),cliVersion:Y().optional(),extraArgs:Ps(Y()).optional(),env:Ls(Y()).optional(),timeoutMs:js().int().positive().optional()}),cC=X({model:Y().optional(),timeoutMs:js().int().positive().optional()}),lC=X({model:Y().optional(),timeoutMs:js().int().positive().optional()}),uC=[`gpt-4o-mini`,`gpt-4o`,`gpt-5`,`gpt-5-mini`,`o3-mini`],dC=[`gemini-2.5-flash`,`gemini-2.5-pro`,`gemini-2.0-flash`],fC=[`deepseek-chat`,`deepseek-reasoner`],pC=[`Qwen/Qwen2.5-7B-Instruct`,`Qwen/Qwen2.5-72B-Instruct`,`deepseek-ai/DeepSeek-V3`],mC=[`anthropic/claude-sonnet-4.5`,`openai/gpt-5`,`openai/gpt-4o-mini`,`google/gemini-2.5-flash`],hC=[`sonnet`,`opus`,`haiku`],gC=[`gemini-2.5-pro`,`gemini-2.5-flash`,`gemini-2.0-flash`],_C=[`qwen3-coder-plus`,`qwen3-max`,`qwen3-72b`],vC=[`gpt-5.5`,`gpt-5.4`,`gpt-5.4-mini`,`gpt-5.3-codex`,`gpt-5.2`],yC=[`auto`,`claude-sonnet-4.5`,`gpt-5`,`gemini-2.5-pro`],bC={http:{label:`HTTP (OpenAI-compatible)`,description:`Generic chat-completions endpoint that speaks the OpenAI wire format.`,variants:{default:{label:`Default`,description:`Empty preset — fill in baseUrl, apiKey, model.`,schema:nC,...rC,fieldHints:{model:uC}},"gemini-openai-compat":{label:`Gemini (OpenAI-compat)`,description:`generativelanguage.googleapis.com OpenAI compatibility endpoint.`,schema:nC,...rC,fieldHints:{model:dC}},deepseek:{label:`DeepSeek`,description:`api.deepseek.com — model defaults to deepseek-chat.`,schema:nC,...rC,fieldHints:{model:fC}},siliconflow:{label:`SiliconFlow`,description:`api.siliconflow.cn/v1 — Chinese OpenAI-compatible aggregator.`,schema:nC,...rC,fieldHints:{model:pC}},openrouter:{label:`OpenRouter`,description:`openrouter.ai/api/v1 — fanout to 100+ provider models.`,schema:nC,...rC,fieldHints:{model:mC}}}},mcp:{label:`MCP (tool source)`,description:`Model Context Protocol streamable-http server. Exposes tools, not chat.`,variants:{default:{label:`Default`,description:`MCP server with bearer auth.`,schema:iC,secretFields:[`token`]}}},cli:{label:`Generic CLI`,description:`Spawn an arbitrary CLI per turn. Reserved for stub / debug use.`,variants:{default:{label:`Default`,description:`Manual command + args.`,schema:aC}}},"claude-code":{label:`Claude Code`,description:`Anthropic Claude Code CLI in stream-json mode (FEAT-012).`,variants:{default:{label:`Default (sonnet)`,description:`Auto-approve, sonnet model, 120s turn timeout.`,schema:oC,fieldHints:{model:hC}},"opus-plan":{label:`Opus + Plan policy`,description:`Opus model with plan-mode permission policy, 180s turn timeout.`,schema:oC,fieldHints:{model:hC}}}},acp:{label:`ACP (Gemini / Qwen)`,description:`Agent Client Protocol harness — variant key selects the CLI agent.`,variants:{gemini:{label:`Gemini CLI`,description:`google-gemini/gemini-cli with --experimental-acp + --yolo.`,schema:sC,fieldHints:{model:gC}},qwen:{label:`Qwen Code`,description:`qwenlm/qwen-code with --acp + --yolo.`,schema:sC,fieldHints:{model:_C}}}},codex:{label:`Codex`,description:`OpenAI @openai/codex app-server via JSON-RPC over stdio (FEAT-016).`,variants:{default:{label:`Default (gpt-5.5)`,description:`Codex app-server, 120s turn timeout.`,schema:cC,fieldHints:{model:vC}}}},cursor:{label:`Cursor Agent`,description:`Cursor CLI in stream-json mode — no npm fallback (install cursor-agent) (FEAT-016).`,variants:{default:{label:`Default (auto model)`,description:`cursor-agent -p --output-format=stream-json, 120s turn timeout.`,schema:lC,fieldHints:{model:yC}}}}};function xC(){return Object.keys(bC)}function SC(e){return Object.keys(bC[e].variants)}function CC(e){let t=SC(e);return{engine:e,variant:t.includes(`default`)?`default`:t[0]}}var wC={ready:`ready`,"login-required":`login required`,"not-found":`not installed`},TC={ready:`bg-success`,"login-required":`bg-warning`,"not-found":`bg-muted-foreground/40`},EC={ready:`text-success`,"login-required":`text-warning`,"not-found":`text-muted-foreground`};function DC({status:e,label:t,testId:n}){return e?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${EC[e]}`,"data-testid":n,"data-status":e,children:[(0,V.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${TC[e]}`}),t??wC[e]]}):(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,"data-testid":n,children:[(0,V.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30`}),`unknown`]})}function OC({executor:e,onChange:t}){let n=bC[e.engine],r=n.variants[e.variant],[i,a]=(0,B.useState)(!1),o=jb(),s=US(o.data?.engines),c=Mb(),[l,u]=(0,B.useState)(!1);async function d(){u(!0);try{await c()}finally{u(!1)}}function f(n){if(n===e.engine)return;let r=SC(n).includes(e.variant)?e.variant:void 0;t(r?{engine:n,variant:r}:CC(n))}function p(n){n!==e.variant&&t({engine:e.engine,variant:n})}function m(n){if(!n||Object.keys(n).length===0){let{overrides:n,...r}=e;t(r);return}t({...e,overrides:n})}function h(t){let n=e.overrides?.cmd,r={...t};n&&Object.keys(n).length>0&&(r.cmd=n),m(r)}function g(t){let{cmd:n,...r}=e.overrides??{};if(!t||Object.keys(t).length===0){m(r);return}m({...r,cmd:t})}function _(n){let r={...e};n.modelId===void 0||n.modelId===``?delete r.modelId:r.modelId=n.modelId,n.reasoningId===void 0||n.reasoningId===``?delete r.reasoningId:r.reasoningId=n.reasoningId,n.permissionPolicy===void 0?delete r.permissionPolicy:r.permissionPolicy=n.permissionPolicy,t(r)}let{cmd:v,...y}=e.overrides??{},b=WS(s,e.engine),x=e.engine===`acp`?s.get(`acp:${e.variant}`):s.get(e.engine);return(0,V.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-md border bg-card p-6`,children:[(0,V.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-lg font-bold`,children:`Executor`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`选 engine + variant,仅 override 想改的字段。`})]}),(0,V.jsxs)(`button`,{type:`button`,onClick:d,disabled:l||o.isFetching,"aria-label":`Refresh engine availability`,"data-testid":`refresh-engines-btn`,className:`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-60`,children:[(0,V.jsx)(zl,{className:`size-3.5 ${l?`animate-spin`:``}`}),`Refresh`]})]}),s.size>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2 rounded-md border bg-muted/30 p-2 text-xs`,children:xC().map(e=>{let t=WS(s,e);return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded border bg-background px-2 py-0.5`,"data-testid":`engine-availability-${e}`,children:[(0,V.jsx)(`span`,{className:`font-bold`,children:bC[e].label}),(0,V.jsx)(DC,{status:t,testId:`engine-availability-badge-${e}`})]},e)})}),(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(wy,{htmlFor:`executor-engine`,children:`Engine`}),(0,V.jsx)(DC,{status:b,testId:`engine-selected-badge`})]}),(0,V.jsx)(`select`,{id:`executor-engine`,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:e.engine,onChange:e=>f(e.target.value),children:xC().map(e=>{let t=WS(s,e),n=t?` — ${wC[t]}`:``;return(0,V.jsxs)(`option`,{value:e,children:[bC[e].label,n]},e)})}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.description})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(wy,{htmlFor:`executor-variant`,children:`Variant`}),e.engine===`acp`&&(0,V.jsx)(DC,{status:x?.status,testId:`variant-selected-badge`})]}),(0,V.jsx)(`select`,{id:`executor-variant`,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:e.variant,onChange:e=>p(e.target.value),children:SC(e.engine).map(t=>{let r=e.engine===`acp`?s.get(`acp:${t}`)?.status:void 0,i=r?` — ${wC[r]}`:``;return(0,V.jsxs)(`option`,{value:t,children:[n.variants[t].label,i]},t)})}),r?.description&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.description})]})]}),b===`not-found`&&(0,V.jsx)(kC,{engine:e.engine}),b===`login-required`&&(0,V.jsx)(AC,{engine:e.engine}),r&&(0,V.jsx)(JS,{schema:r.schema,value:y,secretFields:r.secretFields,fieldHints:r.fieldHints,onChange:h}),(0,V.jsxs)(`div`,{className:`border-t pt-4`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`text-sm font-bold text-muted-foreground hover:text-foreground`,onClick:()=>a(e=>!e),"aria-expanded":i,children:[i?`▾`:`▸`,` `,`Advanced (per-request + cmd overrides)`]}),i&&(0,V.jsxs)(`div`,{className:`mt-3 flex flex-col gap-4`,children:[(0,V.jsx)(MC,{modelId:e.modelId,reasoningId:e.reasoningId,permissionPolicy:e.permissionPolicy,onChange:_}),(0,V.jsx)(NC,{cmd:v,onChange:g})]})]})]})}function kC({engine:e}){let t=jC(e);return(0,V.jsxs)(`div`,{role:`alert`,"data-testid":`engine-install-callout`,className:`rounded-md border border-warning bg-warning-soft p-3 text-sm`,children:[(0,V.jsx)(`p`,{className:`font-bold`,children:`本 worker 没有该 engine 对应的 CLI。`}),(0,V.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`进 worker 容器装 / 登录后点 Refresh。具体步骤见`,` `,(0,V.jsxs)(`a`,{className:`underline decoration-dotted underline-offset-2 hover:text-foreground`,href:`/docs/executor-engines.md${t}`,target:`_blank`,rel:`noreferrer`,children:[`docs/executor-engines.md`,t]}),`。`]})]})}function AC({engine:e}){let t=jC(e);return(0,V.jsxs)(`div`,{role:`status`,"data-testid":`engine-login-callout`,className:`rounded-md border border-warning bg-warning-soft p-3 text-sm`,children:[(0,V.jsx)(`p`,{className:`font-bold`,children:`CLI 已装但缺登录态。`}),(0,V.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`在 worker 容器跑对应 CLI 的 login 命令(见`,` `,(0,V.jsxs)(`a`,{className:`underline decoration-dotted underline-offset-2 hover:text-foreground`,href:`/docs/executor-engines.md${t}`,target:`_blank`,rel:`noreferrer`,children:[`docs/executor-engines.md`,t]}),`)后 Refresh。`]})]})}function jC(e){switch(e){case`claude-code`:return`#claude-code`;case`acp`:return`#acp`;case`codex`:return`#codex`;case`cursor`:return`#cursor`;default:return``}}function MC({modelId:e,reasoningId:t,permissionPolicy:n,onChange:r}){return(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`modelId (per-request override)`}),(0,V.jsx)(Cy,{value:e??``,onChange:e=>r({modelId:e.target.value,reasoningId:t,permissionPolicy:n})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`reasoningId`}),(0,V.jsx)(Cy,{value:t??``,onChange:t=>r({modelId:e,reasoningId:t.target.value,permissionPolicy:n})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`permissionPolicy`}),(0,V.jsxs)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:n??``,onChange:n=>{let i=n.target.value;r({modelId:e,reasoningId:t,...i?{permissionPolicy:i}:{}})},children:[(0,V.jsx)(`option`,{value:``,children:`— unset —`}),(0,V.jsx)(`option`,{value:`auto`,children:`auto`}),(0,V.jsx)(`option`,{value:`supervised`,children:`supervised`}),(0,V.jsx)(`option`,{value:`plan`,children:`plan`})]})]})]})}function NC({cmd:e,onChange:t}){function n(e){let n={};e.binary&&e.binary.length>0&&(n.binary=e.binary),e.extraArgs&&e.extraArgs.length>0&&(n.extraArgs=e.extraArgs),e.env&&Object.keys(e.env).length>0&&(n.env=e.env),e.cliVersion&&e.cliVersion.length>0&&(n.cliVersion=e.cliVersion),t(Object.keys(n).length>0?n:void 0)}let r=(e?.extraArgs??[]).join(` `),i=Object.entries(e?.env??{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
28
|
+
`)){let e=n.indexOf(`=`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1);r.length>0&&t.push([r,i])}t.length===0?a(s?void 0:{}):a(Object.fromEntries(t))}})]})}return(0,V.jsxs)(`div`,{className:`sm:col-span-2 flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`${e}${c} (JSON)`}),(0,V.jsx)(QS,{value:n,onChange:a,optional:s})]})}function ZS(e){if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return``}}function QS({value:e,onChange:t,optional:n}){return(0,V.jsx)(`textarea`,{className:`min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm font-mono`,defaultValue:ZS(e),onBlur:e=>{let r=e.target.value.trim();if(r.length===0){t(n?void 0:null);return}try{t(JSON.parse(r))}catch{}}})}function $S({label:e,value:t,onChange:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsx)(Cy,{value:t,onChange:e=>n(e.target.value)})]})}function eC({name:e,fieldName:t,presets:n,optional:r,value:i,onChange:a}){let o=i.length>0&&n.includes(i),[s,c]=(0,B.useState)(()=>i.length===0||o?`preset`:`custom`);function l(e){e.length===0?a(r?void 0:``):a(e)}function u(e){if(e===GS){c(`custom`);return}c(`preset`),l(e)}if(s===`custom`)return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline decoration-dotted underline-offset-2 hover:text-foreground`,onClick:()=>{c(`preset`),n.includes(i)||l(``)},children:`选预设…`})]}),(0,V.jsx)(Cy,{"data-testid":`field-${t}-input`,placeholder:n[0]??``,value:i,onChange:e=>l(e.target.value)})]});let d=o?i:``;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{htmlFor:`field-${t}-select`,children:e}),(0,V.jsxs)(`select`,{id:`field-${t}-select`,"data-testid":`field-${t}-select`,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:d,onChange:e=>u(e.target.value),children:[r&&(0,V.jsx)(`option`,{value:``,children:`— unset —`}),!r&&d===``&&(0,V.jsx)(`option`,{value:``,disabled:!0,children:`— 选 model —`}),n.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e)),(0,V.jsx)(`option`,{value:GS,children:`Custom…`})]})]})}function tC({label:e,value:t,onChange:n}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:e}),(0,V.jsx)(Cy,{type:`number`,value:t,onChange:e=>{let t=Number.parseInt(e.target.value,10);n(Number.isNaN(t)?0:t)}})]})}var nC=X({baseUrl:Y(),apiKey:Y(),model:Y(),timeoutMs:js().int().positive()}),rC={secretFields:[`apiKey`]},iC=X({url:Y(),token:Y(),defaultModel:Y().optional(),tools:Ps(Y()).optional(),timeoutMs:js().int().positive().optional()}),aC=X({command:Y(),args:Ps(Y()),cwd:Y().optional(),env:Ls(Y()).optional(),timeoutMs:js().int().positive().optional(),sandbox:Ms().optional()}),oC=X({model:Y().optional(),cliVersion:Y().optional(),extraArgs:Ps(Y()).optional(),env:Ls(Y()).optional(),workspaceRoot:Y().optional(),timeoutMs:js().int().positive().optional(),permissionPolicy:zs([`auto`,`supervised`,`plan`]).optional()}),sC=X({agent:zs([`gemini`,`qwen`]),model:Y().optional(),cliVersion:Y().optional(),extraArgs:Ps(Y()).optional(),env:Ls(Y()).optional(),timeoutMs:js().int().positive().optional()}),cC=X({model:Y().optional(),timeoutMs:js().int().positive().optional()}),lC=X({model:Y().optional(),timeoutMs:js().int().positive().optional()}),uC=[`gpt-4o-mini`,`gpt-4o`,`gpt-5`,`gpt-5-mini`,`o3-mini`],dC=[`gemini-2.5-flash`,`gemini-2.5-pro`,`gemini-2.0-flash`],fC=[`deepseek-chat`,`deepseek-reasoner`],pC=[`Qwen/Qwen2.5-7B-Instruct`,`Qwen/Qwen2.5-72B-Instruct`,`deepseek-ai/DeepSeek-V3`],mC=[`anthropic/claude-sonnet-4.5`,`openai/gpt-5`,`openai/gpt-4o-mini`,`google/gemini-2.5-flash`],hC=[`sonnet`,`opus`,`haiku`],gC=[`gemini-2.5-pro`,`gemini-2.5-flash`,`gemini-2.0-flash`],_C=[`qwen3-coder-plus`,`qwen3-max`,`qwen3-72b`],vC=[`gpt-5.5`,`gpt-5.4`,`gpt-5.4-mini`,`gpt-5.3-codex`,`gpt-5.2`],yC=[`auto`,`claude-sonnet-4.5`,`gpt-5`,`gemini-2.5-pro`],bC={http:{label:`HTTP (OpenAI-compatible)`,description:`Generic chat-completions endpoint that speaks the OpenAI wire format.`,variants:{default:{label:`Default`,description:`Empty preset — fill in baseUrl, apiKey, model.`,schema:nC,...rC,fieldHints:{model:uC}},"gemini-openai-compat":{label:`Gemini (OpenAI-compat)`,description:`generativelanguage.googleapis.com OpenAI compatibility endpoint.`,schema:nC,...rC,fieldHints:{model:dC}},deepseek:{label:`DeepSeek`,description:`api.deepseek.com — model defaults to deepseek-chat.`,schema:nC,...rC,fieldHints:{model:fC}},siliconflow:{label:`SiliconFlow`,description:`api.siliconflow.cn/v1 — Chinese OpenAI-compatible aggregator.`,schema:nC,...rC,fieldHints:{model:pC}},openrouter:{label:`OpenRouter`,description:`openrouter.ai/api/v1 — fanout to 100+ provider models.`,schema:nC,...rC,fieldHints:{model:mC}}}},mcp:{label:`MCP (tool source)`,description:`Model Context Protocol streamable-http server. Exposes tools, not chat.`,variants:{default:{label:`Default`,description:`MCP server with bearer auth.`,schema:iC,secretFields:[`token`]}}},cli:{label:`Generic CLI`,description:`Spawn an arbitrary CLI per turn. Reserved for stub / debug use.`,variants:{default:{label:`Default`,description:`Manual command + args.`,schema:aC}}},"claude-code":{label:`Claude Code`,description:`Anthropic Claude Code CLI in stream-json mode (FEAT-012).`,variants:{default:{label:`Default`,description:`Auto-approve, CLI default model, 120s turn timeout.`,schema:oC,fieldHints:{model:hC}},"opus-plan":{label:`Opus + Plan policy`,description:`Opus model with plan-mode permission policy, 180s turn timeout.`,schema:oC,fieldHints:{model:hC}}}},acp:{label:`ACP (Gemini / Qwen)`,description:`Agent Client Protocol harness — variant key selects the CLI agent.`,variants:{gemini:{label:`Gemini CLI`,description:`google-gemini/gemini-cli with --experimental-acp + --yolo.`,schema:sC,fieldHints:{model:gC}},qwen:{label:`Qwen Code`,description:`qwenlm/qwen-code with --acp + --yolo.`,schema:sC,fieldHints:{model:_C}}}},codex:{label:`Codex`,description:`OpenAI @openai/codex app-server via JSON-RPC over stdio (FEAT-016).`,variants:{default:{label:`Default (gpt-5.5)`,description:`Codex app-server, 120s turn timeout.`,schema:cC,fieldHints:{model:vC}}}},cursor:{label:`Cursor Agent`,description:`Cursor CLI in stream-json mode — no npm fallback (install cursor-agent) (FEAT-016).`,variants:{default:{label:`Default (auto model)`,description:`cursor-agent -p --output-format=stream-json, 120s turn timeout.`,schema:lC,fieldHints:{model:yC}}}}};function xC(){return Object.keys(bC)}function SC(e){return Object.keys(bC[e].variants)}function CC(e){let t=SC(e);return{engine:e,variant:t.includes(`default`)?`default`:t[0]}}var wC={ready:`ready`,"login-required":`login required`,"not-found":`not installed`},TC={ready:`bg-success`,"login-required":`bg-warning`,"not-found":`bg-muted-foreground/40`},EC={ready:`text-success`,"login-required":`text-warning`,"not-found":`text-muted-foreground`};function DC({status:e,label:t,testId:n}){return e?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${EC[e]}`,"data-testid":n,"data-status":e,children:[(0,V.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${TC[e]}`}),t??wC[e]]}):(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,"data-testid":n,children:[(0,V.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30`}),`unknown`]})}function OC({executor:e,onChange:t}){let n=bC[e.engine],r=n.variants[e.variant],[i,a]=(0,B.useState)(!1),o=jb(),s=US(o.data?.engines),c=Mb(),[l,u]=(0,B.useState)(!1);async function d(){u(!0);try{await c()}finally{u(!1)}}function f(n){if(n===e.engine)return;let r=SC(n).includes(e.variant)?e.variant:void 0;t(r?{engine:n,variant:r}:CC(n))}function p(n){n!==e.variant&&t({engine:e.engine,variant:n})}function m(n){if(!n||Object.keys(n).length===0){let{overrides:n,...r}=e;t(r);return}t({...e,overrides:n})}function h(t){let n=e.overrides?.cmd,r={...t};n&&Object.keys(n).length>0&&(r.cmd=n),m(r)}function g(t){let{cmd:n,...r}=e.overrides??{};if(!t||Object.keys(t).length===0){m(r);return}m({...r,cmd:t})}function _(n){let r={...e};n.modelId===void 0||n.modelId===``?delete r.modelId:r.modelId=n.modelId,n.reasoningId===void 0||n.reasoningId===``?delete r.reasoningId:r.reasoningId=n.reasoningId,n.permissionPolicy===void 0?delete r.permissionPolicy:r.permissionPolicy=n.permissionPolicy,t(r)}let{cmd:v,...y}=e.overrides??{},b=WS(s,e.engine),x=e.engine===`acp`?s.get(`acp:${e.variant}`):s.get(e.engine);return(0,V.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-md border bg-card p-6`,children:[(0,V.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-lg font-bold`,children:`Executor`}),(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`选 engine + variant,仅 override 想改的字段。`})]}),(0,V.jsxs)(`button`,{type:`button`,onClick:d,disabled:l||o.isFetching,"aria-label":`Refresh engine availability`,"data-testid":`refresh-engines-btn`,className:`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-60`,children:[(0,V.jsx)(zl,{className:`size-3.5 ${l?`animate-spin`:``}`}),`Refresh`]})]}),s.size>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2 rounded-md border bg-muted/30 p-2 text-xs`,children:xC().map(e=>{let t=WS(s,e);return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded border bg-background px-2 py-0.5`,"data-testid":`engine-availability-${e}`,children:[(0,V.jsx)(`span`,{className:`font-bold`,children:bC[e].label}),(0,V.jsx)(DC,{status:t,testId:`engine-availability-badge-${e}`})]},e)})}),(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(wy,{htmlFor:`executor-engine`,children:`Engine`}),(0,V.jsx)(DC,{status:b,testId:`engine-selected-badge`})]}),(0,V.jsx)(`select`,{id:`executor-engine`,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:e.engine,onChange:e=>f(e.target.value),children:xC().map(e=>{let t=WS(s,e),n=t?` — ${wC[t]}`:``;return(0,V.jsxs)(`option`,{value:e,children:[bC[e].label,n]},e)})}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.description})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(wy,{htmlFor:`executor-variant`,children:`Variant`}),e.engine===`acp`&&(0,V.jsx)(DC,{status:x?.status,testId:`variant-selected-badge`})]}),(0,V.jsx)(`select`,{id:`executor-variant`,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:e.variant,onChange:e=>p(e.target.value),children:SC(e.engine).map(t=>{let r=e.engine===`acp`?s.get(`acp:${t}`)?.status:void 0,i=r?` — ${wC[r]}`:``;return(0,V.jsxs)(`option`,{value:t,children:[n.variants[t].label,i]},t)})}),r?.description&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.description})]})]}),b===`not-found`&&(0,V.jsx)(kC,{engine:e.engine}),b===`login-required`&&(0,V.jsx)(AC,{engine:e.engine}),r&&(0,V.jsx)(JS,{schema:r.schema,value:y,secretFields:r.secretFields,fieldHints:r.fieldHints,onChange:h}),(0,V.jsxs)(`div`,{className:`border-t pt-4`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`text-sm font-bold text-muted-foreground hover:text-foreground`,onClick:()=>a(e=>!e),"aria-expanded":i,children:[i?`▾`:`▸`,` `,`Advanced (per-request + cmd overrides)`]}),i&&(0,V.jsxs)(`div`,{className:`mt-3 flex flex-col gap-4`,children:[(0,V.jsx)(MC,{modelId:e.modelId,reasoningId:e.reasoningId,permissionPolicy:e.permissionPolicy,onChange:_}),(0,V.jsx)(NC,{cmd:v,onChange:g})]})]})]})}function kC({engine:e}){let t=jC(e);return(0,V.jsxs)(`div`,{role:`alert`,"data-testid":`engine-install-callout`,className:`rounded-md border border-warning bg-warning-soft p-3 text-sm`,children:[(0,V.jsx)(`p`,{className:`font-bold`,children:`本 worker 没有该 engine 对应的 CLI。`}),(0,V.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`进 worker 容器装 / 登录后点 Refresh。具体步骤见`,` `,(0,V.jsxs)(`a`,{className:`underline decoration-dotted underline-offset-2 hover:text-foreground`,href:`/docs/executor-engines.md${t}`,target:`_blank`,rel:`noreferrer`,children:[`docs/executor-engines.md`,t]}),`。`]})]})}function AC({engine:e}){let t=jC(e);return(0,V.jsxs)(`div`,{role:`status`,"data-testid":`engine-login-callout`,className:`rounded-md border border-warning bg-warning-soft p-3 text-sm`,children:[(0,V.jsx)(`p`,{className:`font-bold`,children:`CLI 已装但缺登录态。`}),(0,V.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`在 worker 容器跑对应 CLI 的 login 命令(见`,` `,(0,V.jsxs)(`a`,{className:`underline decoration-dotted underline-offset-2 hover:text-foreground`,href:`/docs/executor-engines.md${t}`,target:`_blank`,rel:`noreferrer`,children:[`docs/executor-engines.md`,t]}),`)后 Refresh。`]})]})}function jC(e){switch(e){case`claude-code`:return`#claude-code`;case`acp`:return`#acp`;case`codex`:return`#codex`;case`cursor`:return`#cursor`;default:return``}}function MC({modelId:e,reasoningId:t,permissionPolicy:n,onChange:r}){return(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`modelId (per-request override)`}),(0,V.jsx)(Cy,{value:e??``,onChange:e=>r({modelId:e.target.value,reasoningId:t,permissionPolicy:n})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`reasoningId`}),(0,V.jsx)(Cy,{value:t??``,onChange:t=>r({modelId:e,reasoningId:t.target.value,permissionPolicy:n})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`permissionPolicy`}),(0,V.jsxs)(`select`,{className:`h-9 rounded-md border bg-background px-3 text-sm`,value:n??``,onChange:n=>{let i=n.target.value;r({modelId:e,reasoningId:t,...i?{permissionPolicy:i}:{}})},children:[(0,V.jsx)(`option`,{value:``,children:`— unset —`}),(0,V.jsx)(`option`,{value:`auto`,children:`auto`}),(0,V.jsx)(`option`,{value:`supervised`,children:`supervised`}),(0,V.jsx)(`option`,{value:`plan`,children:`plan`})]})]})]})}function NC({cmd:e,onChange:t}){function n(e){let n={};e.binary&&e.binary.length>0&&(n.binary=e.binary),e.extraArgs&&e.extraArgs.length>0&&(n.extraArgs=e.extraArgs),e.env&&Object.keys(e.env).length>0&&(n.env=e.env),e.cliVersion&&e.cliVersion.length>0&&(n.cliVersion=e.cliVersion),t(Object.keys(n).length>0?n:void 0)}let r=(e?.extraArgs??[]).join(` `),i=Object.entries(e?.env??{}).map(([e,t])=>`${e}=${t}`).join(`
|
|
29
29
|
`);return(0,V.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border bg-muted/30 p-3`,children:[(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`cmd overrides 仅对 spawn 二进制的 engine(cli / claude-code / acp)生效。`}),(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`cmd.binary`}),(0,V.jsx)(Cy,{value:e?.binary??``,onChange:t=>n({...e,binary:t.target.value})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(wy,{children:`cmd.cliVersion`}),(0,V.jsx)(Cy,{value:e?.cliVersion??``,onChange:t=>n({...e,cliVersion:t.target.value})})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,V.jsx)(wy,{children:`cmd.extraArgs (空白分隔)`}),(0,V.jsx)(Cy,{value:r,onChange:t=>{let r=t.target.value.split(/\s+/).filter(Boolean);n({...e,extraArgs:r})}})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,V.jsx)(wy,{children:`cmd.env (KEY=value 每行)`}),(0,V.jsx)(`textarea`,{className:`min-h-[80px] rounded-md border bg-background px-3 py-2 text-sm font-mono`,value:i,onChange:t=>{let r=[];for(let e of t.target.value.split(`
|
|
30
30
|
`)){let t=e.indexOf(`=`);if(t<=0)continue;let n=e.slice(0,t).trim(),i=e.slice(t+1);n.length>0&&r.push([n,i])}n({...e,env:Object.fromEntries(r)})}})]})]})]})}function PC(){let e=kb(),t=Ob(),[n,r]=(0,B.useState)(0);return e.isLoading?(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(xS,{className:`h-8 w-48`}),(0,V.jsx)(xS,{className:`h-40`}),(0,V.jsx)(xS,{className:`h-40`})]}):e.isError||!e.data?(0,V.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-4 text-sm text-destructive`,children:[`加载 worker config 失败:`,` `,e.error instanceof Error?e.error.message:`未知错误`,` `,(0,V.jsx)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void e.refetch(),children:`重试`})]}):(0,V.jsx)(FC,{initial:e.data.config,initialVersion:e.data.version,info:t.data,onReload:()=>{r(e=>e+1),e.refetch()}},n)}function FC({initial:e,initialVersion:t,info:n,onReload:r}){let[i,a]=(0,B.useState)(e),[o,s]=(0,B.useState)(t),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),m=Ab();function h(e){a(t=>({...t,...e}))}function g(e){a(t=>({...t,executor:e}))}function _(e){a(t=>({...t,channels:e}))}function v(e){a(t=>({...t,evolution:e}))}function y(){if(i.brains.length>0&&i.brainWriteTarget.length===0)return`配置了 brain source 后必须选 write target,或者删光所有 brain。`;if(i.brains.length>0&&!i.brains.some(e=>e.id===i.brainWriteTarget))return`brainWriteTarget "${i.brainWriteTarget}" 不在已配置的 brain id 列表里。`;let e=new Set;for(let t of i.brains){if(t.id.length===0)return`每个 brain source 必须有 id。`;if(e.has(t.id))return`重复的 brain id:${t.id}`;e.add(t.id)}return null}async function b(){l(null),d(null);let e=y();if(e){l(e);return}try{let e=await m.mutateAsync({config:i,ifMatchVersion:o});p(e.runtimeReload===`ok`?`已保存(version ${e.version})。`:`已保存(version ${e.version}),但 runtime reload 失败——重启 worker 才能让新 config 真正生效。`),a(e.config),s(e.version)}catch(e){if(e instanceof Ny&&e.code===`version-conflict`){d({expected:e.expectedVersion,actual:e.actualVersion});return}if(e instanceof Ny&&e.code===`invalid-config`){l(`worker 拒绝了 config:${e.message}`);return}l(e instanceof Error?e.message:`保存失败。`)}}return(0,V.jsxs)(`form`,{className:`flex flex-col gap-6 pb-24`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Configuration`}),(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version`,` `,(0,V.jsx)(`span`,{className:`font-mono`,children:o}),`。Secret 字段渲染为占位,留空保留旧值。`]})]}),u&&(0,V.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-md border border-warning bg-warning-soft p-4 text-sm`,children:[(0,V.jsx)(Jl,{className:`mt-0.5 size-4 text-warning`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsx)(`p`,{className:`font-bold`,children:`Version 冲突`}),(0,V.jsxs)(`p`,{className:`text-muted-foreground`,children:[`你基于 version`,` `,(0,V.jsx)(`code`,{className:`font-mono`,children:u.expected??o}),` `,`做了改动,但当前 stored version 是`,` `,(0,V.jsx)(`code`,{className:`font-mono`,children:u.actual??`?`}),`。期间另一方已经保存了新版本。`]})]}),(0,V.jsx)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Reload 重新编辑`})]}),c&&(0,V.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:c}),f&&(0,V.jsx)(`p`,{role:`status`,className:`rounded-md border border-success bg-success-soft p-3 text-sm`,children:f}),(0,V.jsx)(jS,{brains:i.brains,brainWriteTarget:i.brainWriteTarget,brainRetrieval:i.brainRetrieval,onChange:h}),(0,V.jsx)(OC,{executor:i.executor,onChange:g}),(0,V.jsx)(BS,{channels:i.channels,info:n,onChange:_}),(0,V.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border bg-card p-6`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-bold`,children:`Evolution (L3)`}),(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:i.evolution.enabled,onChange:e=>v({...i.evolution,enabled:e.target.checked})}),`启用 evolution observer`]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[240px]`,children:[(0,V.jsx)(`label`,{className:`text-sm font-bold`,children:`Observation 保留天数`}),(0,V.jsx)(`input`,{type:`number`,min:0,className:`h-9 rounded-md border bg-background px-3 text-sm`,value:i.evolution.observationRetentionDays,onChange:e=>v({...i.evolution,observationRetentionDays:Number.parseInt(e.target.value,10)||0})})]})]}),(0,V.jsx)(`div`,{className:`sticky bottom-0 -mx-6 border-t bg-background/95 px-6 py-3 backdrop-blur`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`保存使用`,` `,(0,V.jsx)(`code`,{className:`font-mono`,children:`If-Match: ${o}`}),`——若 stored version 已前移则返 409。`]}),(0,V.jsxs)(Od,{type:`submit`,disabled:m.isPending,children:[m.isPending?(0,V.jsx)(Al,{className:`size-4 animate-spin`}):(0,V.jsx)(Bl,{className:`size-4`}),m.isPending?`保存中…`:`保存配置`]})]})})]})}var IC=Ri(`/config`)({component:PC});function LC(){let e=qb(),[t,n]=(0,B.useState)(null),r=t,i=Jb(r??void 0),a=Gb(),o=Kb(),s=Yb(),c=Xb(),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(null),h=(0,B.useId)(),g=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>{g.current?.abort()},[]);async function _(){let e=l.trim(),r=t,i=a.isPending||o.isPending;if(!(e.length===0||i)){f(null);try{let t=r?await o.mutateAsync({conversationId:r,prompt:e}):await a.mutateAsync(e);u(``),g.current?.abort();let i=new AbortController;g.current=i,m({taskId:t.id,conversationId:r,text:``,done:!1}),RC(i,t.id,{onConversation:e=>{n(e),m(n=>!n||n.taskId!==t.id?n:{...n,conversationId:e})},onDelta:e=>{m(n=>!n||n.taskId!==t.id?n:{...n,text:n.text+e})},onDone:e=>{m(e=>e&&e.taskId===t.id?{...e,done:!0}:e),c(),e&&s(e)},onError:e=>{f(e),m(null)}})}catch(e){f(e instanceof Ny?e.message:`提交失败。`)}}}return(0,V.jsxs)(`div`,{"data-testid":`worker-chat-panel`,className:`grid min-w-0 grid-cols-1 gap-4 lg:h-[calc(100vh-200px)] lg:min-h-[420px] lg:grid-cols-[280px_1fr]`,children:[(0,V.jsxs)(`aside`,{className:`flex max-h-56 min-h-0 min-w-0 flex-col gap-2 overflow-y-auto rounded-md border bg-card p-3 lg:max-h-none`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(`h2`,{className:`px-1 text-sm font-bold`,children:`Conversations`}),(0,V.jsxs)(Od,{type:`button`,variant:t===null?`secondary`:`outline`,size:`sm`,className:`min-h-8 px-2 py-1 text-xs`,onClick:()=>n(null),children:[(0,V.jsx)(Rl,{className:`size-3.5`}),`新会话`]})]}),e.isLoading?(0,V.jsx)(xS,{className:`h-20`}):(e.data?.conversations??[]).length===0?(0,V.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`尚无会话。`}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.data?.conversations.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`flex w-full flex-col rounded-md px-2 py-1.5 text-left text-xs transition-colors ${r===e.id?`bg-accent text-accent-foreground`:`hover:bg-accent/50`}`,children:[(0,V.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-micro`,children:[e.channel,`:`,e.chatId]}),(0,V.jsx)(`span`,{className:`truncate text-micro-label text-muted-foreground`,children:new Date(e.lastActiveAt).toLocaleString()})]})},e.id))})]}),(0,V.jsxs)(`section`,{className:`flex min-h-[420px] min-w-0 flex-col gap-3 rounded-md border bg-card p-3 sm:p-4 lg:min-h-0`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2 overflow-y-auto`,children:[r?i.isLoading?(0,V.jsx)(xS,{className:`h-40`}):i.isError?(0,V.jsxs)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[`加载消息失败:`,i.error instanceof Error?i.error.message:`未知错误`]}):(i.data?.messages??[]).map(e=>(0,V.jsxs)(`div`,{className:`max-w-[90%] rounded-md p-3 text-sm sm:max-w-[80%] ${e.role===`user`?`self-end border-2 border-primary bg-background text-foreground`:`self-start bg-muted`}`,children:[(0,V.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.content}),(0,V.jsxs)(`p`,{className:`mt-1 text-micro-label opacity-70`,children:[e.role,` · `,new Date(e.createdAt).toLocaleString()]})]},e.id)):(0,V.jsx)(`p`,{className:`rounded-md border border-dashed p-4 text-center text-sm text-muted-foreground sm:p-6`,children:`新会话`}),p&&p.text.length>0&&(0,V.jsxs)(`div`,{className:`max-w-[90%] self-start rounded-md bg-muted p-3 text-sm sm:max-w-[80%]`,children:[(0,V.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:p.text}),!p.done&&(0,V.jsxs)(`p`,{className:`mt-1 text-micro-label text-muted-foreground`,children:[(0,V.jsx)(Al,{className:`inline size-3 animate-spin`}),` streaming…`]})]})]}),d&&(0,V.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:d}),(0,V.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,V.jsx)(`label`,{htmlFor:h,className:`sr-only`,children:`Prompt`}),(0,V.jsx)(`textarea`,{id:h,className:`min-h-[60px] min-w-0 flex-1 resize-none rounded-md border bg-background px-3 py-2 text-sm`,placeholder:`给 worker 发一条消息(Cmd/Ctrl + Enter 发送)`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),_())}}),(0,V.jsxs)(Od,{type:`submit`,className:`w-full sm:w-auto`,disabled:a.isPending||o.isPending||l.trim().length===0,children:[a.isPending||o.isPending?(0,V.jsx)(Al,{className:`size-4 animate-spin`}):(0,V.jsx)(Vl,{className:`size-4`}),`发送`]})]})]})]})}async function RC(e,t,n){let r=null,i=`task:${t}`;function a(e){r!==e&&(r=e,n.onConversation(e))}try{await ab(e.signal,o=>{let s=o.data,c=typeof s.taskId==`string`?s.taskId:null;if(o.type===`conversation.created`&&(!c||c===t)&&(s.chatId===i||c===t)&&typeof s.conversationId==`string`){a(s.conversationId);return}let l=typeof s.conversationId==`string`?s.conversationId:null;if(!(c&&c!==t)&&!(!r&&c!==t)&&!(r&&l&&l!==r)){if(!r&&l&&o.type.startsWith(`orchestrator.`)&&a(l),o.type===`orchestrator.text`){let e=typeof s.delta==`string`?s.delta:``;e.length>0&&n.onDelta(e)}else if(o.type===`orchestrator.finished`)n.onDone(r),e.abort();else if(o.type===`orchestrator.error`){let t=typeof s.error==`string`?s.error:`事件流返回执行错误。`;n.onError(t),e.abort()}}})}catch(t){if(e.signal.aborted)return;n.onError(t instanceof Error?t.message:`事件流中断。`)}}var zC=Ri(`/chat`)({component:LC});function BC(){return(0,V.jsxs)(`section`,{className:`flex w-full max-w-5xl min-w-0 flex-col gap-6`,children:[(0,V.jsxs)(`header`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Brain`}),(0,V.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Project Brain 摘要 + admission 审批 + brain artifact 注册表。 Brief 是 canonical brain(`,(0,V.jsx)(`code`,{className:`font-mono text-xs`,children:`.aiworker/`}),`)的投影;这里展示的内容默认 redact secret-like 字段。`]})]}),(0,V.jsx)(VC,{}),(0,V.jsx)(UC,{}),(0,V.jsx)(WC,{})]})}function VC(){let e=Zb();if(e.isLoading)return(0,V.jsx)(`section`,{className:`rounded-lg border p-4`,children:(0,V.jsx)(xS,{className:`h-24 w-full`})});if(e.error||e.data===void 0)return(0,V.jsxs)(`section`,{className:`rounded-lg border p-4 text-sm text-destructive`,children:[`无法加载 brain summary:`,e.error?.message??`unknown error`]});let{brainSummary:t,checkedAt:n}=e.data;return(0,V.jsxs)(`section`,{className:`grid gap-4 rounded-lg border p-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`mb-2 text-sm font-semibold uppercase text-muted-foreground`,children:`Scope manifest`}),t.scopeManifest.status===`ok`?(0,V.jsxs)(`ul`,{className:`space-y-1 text-sm`,children:[(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`kind: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.scopeManifest.kind})]}),(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`primary soul: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.scopeManifest.primarySoul})]}),t.scopeManifest.privacy&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`privacy: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.scopeManifest.privacy})]}),t.scopeManifest.approval&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`approval: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.scopeManifest.approval})]})]}):(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:`状态:`}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.scopeManifest.status}),t.scopeManifest.error&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`br`,{}),(0,V.jsx)(`span`,{className:`text-destructive`,children:t.scopeManifest.error})]})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`mb-2 text-sm font-semibold uppercase text-muted-foreground`,children:`Aggregates`}),(0,V.jsxs)(`ul`,{className:`space-y-1 text-sm`,children:[(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`artifacts: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.artifacts.total}),(0,V.jsx)(`span`,{children:` total, by status: ${Object.entries(t.artifacts.byStatus).map(([e,t])=>`${e}=${t}`).join(`, `)||`<none>`}`})]}),(0,V.jsx)(`li`,{children:(0,V.jsx)(`span`,{children:`admissions by status: ${Object.entries(t.admissions.byStatus).map(([e,t])=>`${e}=${t}`).join(`, `)||`<none>`}`})}),t.admissions.lastUpdatedAt&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{children:`last updated: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:t.admissions.lastUpdatedAt})]})]}),(0,V.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:`checked at: `}),(0,V.jsx)(`span`,{className:`font-mono`,children:n})]})]})]})}function HC(e){return e===`pending`?`secondary`:e===`approved`||e===`applied`?`default`:e===`rejected`||e===`failed`?`destructive`:`outline`}function UC(){let[e,t]=(0,B.useState)(``),n=Zb(),r=Qb({status:`pending`}),i=$b(),a=ex(),o=tx(),s=e.trim().length>0,c=r.data?.proposals??[];return(0,V.jsxs)(`section`,{className:`rounded-lg border p-4`,children:[(0,V.jsxs)(`header`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:`Admission proposals (pending)`}),(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,V.jsx)(Cy,{className:`h-8 w-48`,placeholder:`--decided-by name`,value:e,onChange:e=>t(e.target.value)})})]}),r.isLoading&&(0,V.jsx)(xS,{className:`h-24 w-full`}),r.error&&(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`加载失败:`,r.error.message]}),!r.isLoading&&c.length===0&&(0,V.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(`p`,{children:`暂无 pending 的 admission proposal。`}),n.data?.brainSummary.admissions.bypassRisk.status===`suspected`&&(0,V.jsx)(`p`,{className:`text-warning`,children:`最近有回复声称已提交 admission 或已写入长期记忆,但 AIWorker admission 数据库没有新增记录;外部 executor 可能写入了自己的 native memory。`})]}),(0,V.jsx)(`ul`,{className:`space-y-3`,children:c.map(t=>(0,V.jsxs)(`li`,{className:`rounded border p-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-mono`,children:t.id}),(0,V.jsx)(dx,{variant:HC(t.status),children:t.status}),(0,V.jsx)(dx,{variant:`outline`,children:t.kind}),(0,V.jsxs)(dx,{variant:`outline`,children:[`soul:`,t.soulId]}),(0,V.jsxs)(dx,{variant:`outline`,children:[`risk:`,t.risk]})]}),(0,V.jsx)(`p`,{className:`mt-1 text-sm`,children:t.summary}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`target:`,` `,(0,V.jsx)(`code`,{className:`font-mono`,children:t.target})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,V.jsx)(Od,{size:`sm`,disabled:!s||i.isPending,onClick:()=>i.mutate({decidedBy:e,id:t.id}),children:`Approve`}),(0,V.jsx)(Od,{size:`sm`,variant:`destructive`,disabled:!s||a.isPending,onClick:()=>a.mutate({decidedBy:e,id:t.id}),children:`Reject`}),(0,V.jsx)(Od,{size:`sm`,variant:`outline`,disabled:!s||o.isPending,onClick:()=>o.mutate({decidedBy:e,id:t.id}),children:`Apply (dry-run)`}),(0,V.jsx)(Od,{size:`sm`,variant:`outline`,disabled:!s||o.isPending,onClick:()=>o.mutate({commit:!0,decidedBy:e,id:t.id}),children:`Apply --commit`})]})]},t.id))}),(i.error||a.error||o.error)&&(0,V.jsxs)(`p`,{className:`mt-3 text-sm text-destructive`,children:[`操作失败:`,(i.error??a.error??o.error)?.message]})]})}function WC(){let e=nx({limit:50});return(0,V.jsxs)(`section`,{className:`rounded-lg border p-4`,children:[(0,V.jsxs)(`header`,{className:`mb-4`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:`Brain artifacts (read-only, redacted)`}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Confidential / secret artifact 的 ref 与 hash 默认替换为`,(0,V.jsx)(`code`,{className:`font-mono`,children:`<redacted>`}),`。`]})]}),e.isLoading&&(0,V.jsx)(xS,{className:`h-24 w-full`}),e.error&&(0,V.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`加载失败:`,e.error.message]}),!e.isLoading&&(e.data?.artifacts.length??0)===0&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无登记的 brain artifact。`}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:(e.data?.artifacts??[]).map(e=>(0,V.jsxs)(`li`,{className:`rounded border p-2 text-sm`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`font-mono`,children:e.id}),(0,V.jsx)(dx,{variant:`outline`,children:e.type}),(0,V.jsx)(dx,{variant:`outline`,children:e.status}),(0,V.jsxs)(dx,{variant:`outline`,children:[`sensitivity:`,e.sensitivity]}),e.scopeId&&(0,V.jsxs)(dx,{variant:`outline`,children:[`scope:`,e.scopeId]})]}),e.summary&&(0,V.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.summary}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`ref:`,` `,(0,V.jsx)(`code`,{className:`font-mono`,children:e.ref})]})]},e.id))})]})}var GC=Ri(`/brain`)({component:BC});function KC(){let e=Ub(),t=Wb(),[n,r]=(0,B.useState)(null),i=(0,B.useMemo)(()=>e.data?.approvals??[],[e.data]);async function a(e,n){r(null);try{await t.mutateAsync({taskId:e.taskId,toolCallId:e.toolCallId,decision:n})}catch(e){r(e instanceof Ny?e.message:`提交失败。`)}}return(0,V.jsxs)(`div`,{className:`flex max-w-4xl flex-col gap-6`,children:[(0,V.jsxs)(`header`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Approvals`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:"orchestrator 命中 toolPolicy `ask` 规则时挂起的工具调用。批准前 60s 内未处理视同 deny。"})]}),i.length>0&&(0,V.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-md border border-warning bg-warning-soft p-3 text-sm`,children:[(0,V.jsx)(Hl,{className:`mt-0.5 size-4 text-warning`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`p`,{className:`font-bold`,children:[i.length,` `,`个 pending approval`]}),(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`超时(默认 60s)未处理 = deny。`})]})]}),n&&(0,V.jsx)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:n}),e.isLoading?(0,V.jsx)(xS,{className:`h-40`}):e.isError?(0,V.jsxs)(`p`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[`加载失败:`,e.error instanceof Error?e.error.message:`未知错误`]}):i.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:`当前没有 pending approval。`}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-3`,children:i.map(e=>(0,V.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-md border bg-card p-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`code`,{className:`font-mono text-sm`,children:e.toolName}),(0,V.jsx)(qC,{at:e.expiresAt})]}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`task`,(0,V.jsx)(`code`,{className:`ml-1 font-mono`,children:e.taskId}),(0,V.jsx)(`span`,{className:`mx-2`,children:`·`}),`tool call`,(0,V.jsx)(`code`,{className:`ml-1 font-mono`,children:e.toolCallId})]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,V.jsxs)(Od,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void a(e,`deny`),disabled:t.isPending,children:[(0,V.jsx)(Xl,{className:`size-4`}),`Deny`]}),(0,V.jsxs)(Od,{type:`button`,size:`sm`,onClick:()=>void a(e,`allow`),disabled:t.isPending,children:[t.isPending?(0,V.jsx)(Al,{className:`size-4 animate-spin`}):(0,V.jsx)(Cl,{className:`size-4`}),`Allow`]})]})]}),(0,V.jsxs)(`details`,{className:`text-xs`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`查看 params`}),(0,V.jsx)(`pre`,{className:`mt-1 overflow-x-auto rounded bg-muted p-2 text-foreground`,children:JSON.stringify(e.params,null,2)})]})]},`${e.taskId}:${e.toolCallId}`))})]})}function qC({at:e}){let t=e-Date.now();if(t<=0)return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-micro text-destructive`,children:[(0,V.jsx)(Tl,{className:`size-3`}),`expired`]});let n=Math.max(0,Math.round(t/1e3));return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-micro text-muted-foreground`,children:[(0,V.jsx)(Tl,{className:`size-3`}),`剩`,n,`s`]})}var JC=Ri(`/approvals`)({component:KC});function YC(){let e=Db(),t=Ob(),n=zb(),r=Ub();return(0,V.jsxs)(`section`,{className:`flex w-full max-w-5xl min-w-0 flex-col gap-6`,children:[(0,V.jsxs)(`header`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold`,children:`概览`}),(0,V.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`单 worker 自管面板。所有数据通道走当前入口的`,` `,(0,V.jsx)(`code`,{className:`font-mono text-xs`,children:`/api/worker/*`}),`兼容管理 API。`]})]}),(0,V.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,V.jsx)(XC,{title:`Worker 健康`,icon:xl,loading:e.isLoading,error:e.error,children:e.data&&(0,V.jsxs)(`ul`,{className:`space-y-1 text-sm`,children:[(0,V.jsx)(ZC,{label:`status`,value:e.data.status}),(0,V.jsx)(ZC,{label:`config`,value:`v${e.data.configVersion}`}),(0,V.jsx)(ZC,{label:`brain`,value:e.data.brain?e.data.brain.status:`unknown`}),(0,V.jsx)(ZC,{label:`executor`,value:e.data.executor?e.data.executor.status:`unknown`})]})}),(0,V.jsx)(XC,{title:`Brain`,icon:Sl,loading:t.isLoading,error:t.error,actionTo:`/config`,actionLabel:`改配置`,children:t.data&&(0,V.jsx)(`ul`,{className:`space-y-1 text-sm`,children:t.data.brains.length===0?(0,V.jsx)(`li`,{className:`text-muted-foreground`,children:`未配置 brain。`}):t.data.brains.map(e=>(0,V.jsxs)(`li`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`code`,{className:`font-mono text-xs`,children:e.id}),(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.type,` · `,e.status]})]},e.id))})}),(0,V.jsx)(XC,{title:`Executor`,icon:El,loading:t.isLoading,error:t.error,actionTo:`/test`,actionLabel:`探测`,children:t.data&&(0,V.jsxs)(`ul`,{className:`space-y-1 text-sm`,children:[(0,V.jsx)(ZC,{label:`type`,value:t.data.executor.type}),t.data.executor.model&&(0,V.jsx)(ZC,{label:`model`,value:t.data.executor.model}),(0,V.jsx)(ZC,{label:`status`,value:t.data.executor.status})]})}),(0,V.jsx)(XC,{title:`Cron 调度`,icon:Kl,loading:n.isLoading,error:n.error,actionTo:`/cron`,actionLabel:`管理`,children:n.data&&(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`共`,` `,(0,V.jsx)(`span`,{className:`font-bold text-foreground`,children:n.data.jobs.length}),` `,`个;`,` `,(0,V.jsx)(`span`,{className:`font-bold text-foreground`,children:n.data.jobs.filter(e=>e.enabled).length}),` `,`启用中。`]})}),(0,V.jsx)(XC,{title:`Approvals`,icon:Ul,loading:r.isLoading,error:r.error,actionTo:`/approvals`,actionLabel:r.data?.approvals.length?`处理`:`查看`,children:r.data&&(0,V.jsx)(`p`,{className:`text-sm`,children:(0,V.jsxs)(`span`,{className:r.data.approvals.length>0?`font-bold text-warning`:`text-muted-foreground`,children:[r.data.approvals.length,` `,`pending`]})})}),(0,V.jsx)(XC,{title:`Chat`,icon:Ml,loading:!1,actionTo:`/chat`,actionLabel:`打开`,children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`发条消息给 worker,检查 orchestrator 端到端通路。`})})]})]})}function XC({title:e,icon:t,loading:n,error:r,actionTo:i,actionLabel:a,children:o}){return(0,V.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-md border bg-card p-4`,children:[(0,V.jsxs)(`header`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`}),(0,V.jsx)(`h3`,{className:`truncate text-sm font-bold`,children:e})]}),i&&(0,V.jsx)(rx,{to:i,className:`shrink-0 text-xs text-muted-foreground underline decoration-dotted underline-offset-2 hover:text-foreground`,children:a??`前往`})]}),n?(0,V.jsx)(xS,{className:`h-16`}):r?(0,V.jsx)(`p`,{className:`text-xs text-destructive`,children:r instanceof Error?r.message:`加载失败`}):o]})}function ZC({label:e,value:t}){return(0,V.jsxs)(`li`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,V.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs`,children:t})]})}var QC=Ri(`/`)({component:YC}),$C=xx.update({id:`/test`,path:`/test`,getParentRoute:()=>lx}),ew=wS.update({id:`/secrets`,path:`/secrets`,getParentRoute:()=>lx}),tw=OS.update({id:`/cron`,path:`/cron`,getParentRoute:()=>lx}),nw=IC.update({id:`/config`,path:`/config`,getParentRoute:()=>lx}),rw=zC.update({id:`/chat`,path:`/chat`,getParentRoute:()=>lx}),iw=GC.update({id:`/brain`,path:`/brain`,getParentRoute:()=>lx}),aw=JC.update({id:`/approvals`,path:`/approvals`,getParentRoute:()=>lx}),ow={IndexRoute:QC.update({id:`/`,path:`/`,getParentRoute:()=>lx}),ApprovalsRoute:aw,BrainRoute:iw,ChatRoute:rw,ConfigRoute:nw,CronRoute:tw,SecretsRoute:ew,TestRoute:$C},sw=lx._addFileChildren(ow)._addFileTypes();Za(`worker`),ol();var cw=$i({routeTree:sw,basepath:el(`worker`),defaultPreload:`intent`,defaultPreloadStaleTime:0,scrollRestoration:!0}),lw=document.getElementById(`root`);if(!lw)throw Error(`Root element not found`);(0,oa.createRoot)(lw).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsxs)(Re,{client:eo,children:[(0,V.jsx)(Qa,{scope:`worker`}),(0,V.jsx)(na,{router:cw}),(0,V.jsx)($a,{})]})}));
|
package/web/worker/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>AIWorker · Worker</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-vVrwOLC8.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-COGrC65e.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|