adam-agent-server 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/App-5QZKMPRM.js +13 -0
- package/dist/adam-tools-FSI5XKDL.js +1 -0
- package/dist/{approval-handler-PB7PSLUS.js → approval-handler-JYCGXQUE.js} +1 -1
- package/dist/audit-manager-CLKTJPLM.js +1 -0
- package/dist/bree-engine-XJR5TKVC.js +1 -0
- package/dist/channels-DY2OW7YQ.js +1 -0
- package/dist/{channels-ULFUCUUZ.js → channels-ZNMTMMCY.js} +1 -1
- package/dist/{chunk-BQ3ZAYHC.js → chunk-3HZE5DQZ.js} +1 -1
- package/dist/chunk-3IQADR6L.js +144 -0
- package/dist/{chunk-NASJH4NT.js → chunk-3N7MGASP.js} +1 -1
- package/dist/{chunk-TAF2DBBC.js → chunk-56QP5ZHF.js} +7 -7
- package/dist/{chunk-PG6LMSX6.js → chunk-5AUQIK3Q.js} +1 -1
- package/dist/{chunk-NUITL62I.js → chunk-6M2QCKAS.js} +1 -1
- package/dist/{chunk-WMB7P64J.js → chunk-6XVWIRR2.js} +1 -1
- package/dist/{chunk-5EPG2US5.js → chunk-7F4SZXI2.js} +39 -10
- package/dist/{chunk-JJH2RCVC.js → chunk-7WJF65TQ.js} +1 -1
- package/dist/{chunk-RZ7LCZVK.js → chunk-ARQF52V6.js} +1 -1
- package/dist/{chunk-NWMOV23A.js → chunk-C2SD2NMZ.js} +1 -1
- package/dist/{chunk-2L2347UQ.js → chunk-DKMF4B33.js} +1 -1
- package/dist/{chunk-EQZFOBAJ.js → chunk-EJBGJLA2.js} +1 -1
- package/dist/{chunk-T33BLZV2.js → chunk-HSEP6LNQ.js} +1 -1
- package/dist/{chunk-GSFLLRS7.js → chunk-IZ3WZHCM.js} +1 -1
- package/dist/chunk-J4Y54LIC.js +50 -0
- package/dist/{chunk-AQ3ASS4B.js → chunk-KO7XBNPV.js} +1 -1
- package/dist/{chunk-RI3V72RP.js → chunk-KUJFQDT5.js} +2 -2
- package/dist/{chunk-DVN3BFPP.js → chunk-LV4XLPCD.js} +1 -1
- package/dist/chunk-MYVYH4PQ.js +77 -0
- package/dist/chunk-OFTIPZTH.js +1 -0
- package/dist/{chunk-K4C43YDD.js → chunk-OY2KVSIX.js} +1 -1
- package/dist/{chunk-IKPYPZ64.js → chunk-PFYYS7CI.js} +1 -1
- package/dist/chunk-QMW7VEPC.js +0 -0
- package/dist/{chunk-A5OCDYTW.js → chunk-QPIWPQWM.js} +1 -1
- package/dist/chunk-S6OV7Z6K.js +1 -0
- package/dist/{chunk-2YTDCR6A.js → chunk-TTP7QRAQ.js} +1 -1
- package/dist/{chunk-B6LOT5CG.js → chunk-UQDC3X6O.js} +1 -1
- package/dist/{chunk-M4YI4WVX.js → chunk-UYOLAFUR.js} +1 -1
- package/dist/chunk-VPZSOYE5.js +6 -0
- package/dist/{chunk-5QZXYKMS.js → chunk-W7U3ASGR.js} +1 -1
- package/dist/chunk-XIQVXRZH.js +27 -0
- package/dist/{chunk-FPZEZYUB.js → chunk-XTOOD44S.js} +1 -1
- package/dist/{chunk-6KF7OO2B.js → chunk-YKMWAVUH.js} +1 -1
- package/dist/{chunk-UQJZU3R5.js → chunk-YVVKUPGL.js} +1 -1
- package/dist/{chunk-HQRUJQN7.js → chunk-YWUX3ZTO.js} +4 -4
- package/dist/cli.js +2 -2
- package/dist/{config-HBQPBIWL.js → config-CILWJYZB.js} +1 -1
- package/dist/config-W2OD7PXZ.js +1 -0
- package/dist/{db-QEWTZGU3.js → db-JO24ZLIN.js} +1 -1
- package/dist/{delivery-log-AC476GX7.js → delivery-log-QPQM5YU7.js} +1 -1
- package/dist/engine-ZAPYG7G4.js +1 -0
- package/dist/{evolution-audit-XMBDUN3T.js → evolution-audit-ZLYQ3ZYV.js} +1 -1
- package/dist/{external-api-V74YTLBY.js → external-api-QKRNGSYS.js} +1 -1
- package/dist/index.js +20 -16
- package/dist/{learner-VCS3Q7BR.js → learner-ACHENH6R.js} +1 -1
- package/dist/{memories-VMOGFVPU.js → memories-LXH4VHCH.js} +1 -1
- package/dist/{memory-extractor-4WJNHYWR.js → memory-extractor-URH4YHK3.js} +2 -2
- package/dist/memory-service-23P6VNKZ.js +1 -0
- package/dist/outbound-gateway-Y3P3T3VH.js +1 -0
- package/dist/presets-XR2OBXUP.js +1 -0
- package/dist/role-presets-DYWDEQYU.js +1 -0
- package/dist/role-workspace-LHW7AWPF.js +1 -0
- package/dist/{roles-ZYCFQMAY.js → roles-DRPLO4LY.js} +1 -1
- package/dist/{runtime-VDBZZ4KG.js → runtime-YPBWWMXW.js} +1 -1
- package/dist/session-manager-Z6K4U5X7.js +1 -0
- package/dist/{task-templates-4KCZOUN5.js → task-templates-4DWXHLFZ.js} +1 -1
- package/dist/workflow-executor-6ZMNL34C.js +1 -0
- package/package.json +2 -1
- package/web/dist/assets/{AlertDialog-B1zj0Qs3.js → AlertDialog-DhA65f_0.js} +1 -1
- package/web/dist/assets/{Button-BehrGSvy.js → Button-CYDgoTTo.js} +1 -1
- package/web/dist/assets/{Card-B5E56u94.js → Card-DDGXsHus.js} +1 -1
- package/web/dist/assets/{ChannelDetail-BaSlX2yb.js → ChannelDetail-Bb8P8It_.js} +1 -1
- package/web/dist/assets/{Channels-CLhgGEmS.js → Channels-8j28oydE.js} +2 -2
- package/web/dist/assets/{Chat-BZpf1DSF.js → Chat-BZwLDoYO.js} +2 -2
- package/web/dist/assets/{Dashboard-HR4Qmdwg.js → Dashboard-Cv0AtO-o.js} +1 -1
- package/web/dist/assets/{EmptyState-tTclFq_B.js → EmptyState-EuQHAv5Y.js} +1 -1
- package/web/dist/assets/{EnvVarEditor-BzJNsDt0.js → EnvVarEditor-r-l-u4V7.js} +1 -1
- package/web/dist/assets/{EventDefDetail-CjoqsH0e.js → EventDefDetail-asUFrbQE.js} +1 -1
- package/web/dist/assets/Events-DtkHL-r2.js +1 -0
- package/web/dist/assets/{Evolution-CUn8g34X.js → Evolution-DIqYOSb8.js} +1 -1
- package/web/dist/assets/FeatureRequests-BxPqLR1x.js +1 -0
- package/web/dist/assets/{GoalDetail-DgPvXb6z.js → GoalDetail-Bkvgg6uI.js} +1 -1
- package/web/dist/assets/Goals-CkKJDCiU.js +1 -0
- package/web/dist/assets/{Logs-CvFC-GbD.js → Logs-DnaaHV0Y.js} +1 -1
- package/web/dist/assets/{Memories-B5pvI6Oj.js → Memories-Dq9S-Tsi.js} +1 -1
- package/web/dist/assets/Mistakes-D5lW31Co.js +1 -0
- package/web/dist/assets/{NotFound-D-OII_Lp.js → NotFound-gJVrOtER.js} +1 -1
- package/web/dist/assets/{PageHeader-B2CgcZ-t.js → PageHeader-CugYeCci.js} +1 -1
- package/web/dist/assets/Plugins-CoRmK2UG.js +1 -0
- package/web/dist/assets/{RoleDetail-BBJxaZip.js → RoleDetail-BHJA_PAn.js} +2 -2
- package/web/dist/assets/Roles-EBUueS_P.js +1 -0
- package/web/dist/assets/{SectionHeader-CmXz6PM3.js → SectionHeader-DihC0CnO.js} +1 -1
- package/web/dist/assets/Settings-DZHAGazz.js +1 -0
- package/web/dist/assets/{Strategies-Ddb5HiUS.js → Strategies-3IV9eueQ.js} +1 -1
- package/web/dist/assets/{Switch-yrTepsdl.js → Switch-B3w5KMMc.js} +1 -1
- package/web/dist/assets/{Table-CXAcZ8Ru.js → Table-Cf6m8zLu.js} +1 -1
- package/web/dist/assets/{TaskDetail-CHwHgfZq.js → TaskDetail-BmXaH3sx.js} +2 -2
- package/web/dist/assets/Work-CvQrOKtL.js +1 -0
- package/web/dist/assets/api-D-UzHSDq.js +1 -0
- package/web/dist/assets/index-BsKlGx3x.js +2 -0
- package/web/dist/assets/index-EqsPGp9a.css +2 -0
- package/web/dist/assets/{useIsMobileLayout-dYzXP1EC.js → useIsMobileLayout-2GbB90oO.js} +1 -1
- package/web/dist/assets/{vendor-icons-Dk0hMuJz.js → vendor-icons-PF9RcPJx.js} +1 -1
- package/web/dist/assets/{vendor-react-C6faO6LO.js → vendor-react-Cxy4EVtR.js} +1 -1
- package/web/dist/assets/{vendor-state-DahK0J-G.js → vendor-state-aQJ7d4tA.js} +1 -1
- package/web/dist/index.html +8 -8
- package/dist/App-ZRCRM7WR.js +0 -13
- package/dist/adam-automator-skills-EZGBICHT.js +0 -18
- package/dist/adam-tools-V5LPU47X.js +0 -1
- package/dist/audit-manager-BSBBDUER.js +0 -1
- package/dist/bree-engine-7S33CWS7.js +0 -1
- package/dist/channels-SITUUC4J.js +0 -1
- package/dist/chunk-4PQHGLZH.js +0 -99
- package/dist/chunk-5XOTPEAK.js +0 -6
- package/dist/chunk-BCH2HAIM.js +0 -23
- package/dist/chunk-GSMC3VUM.js +0 -1
- package/dist/chunk-IZNEOYRP.js +0 -1
- package/dist/chunk-QGYDGZSC.js +0 -49
- package/dist/chunk-ULTK7RD6.js +0 -27
- package/dist/config-ZBNGRASI.js +0 -1
- package/dist/engine-6K4RG644.js +0 -1
- package/dist/memory-service-ZS6MBUIC.js +0 -1
- package/dist/outbound-gateway-H7RFG6D2.js +0 -1
- package/dist/role-presets-XAEOYEAW.js +0 -1
- package/dist/role-workspace-NKGAH6J6.js +0 -1
- package/dist/session-manager-COLCNIB7.js +0 -1
- package/dist/workflow-executor-Z7JFMR56.js +0 -1
- package/web/dist/assets/Events-IeznRpCj.js +0 -1
- package/web/dist/assets/Goals-DYrggK-M.js +0 -1
- package/web/dist/assets/Plugins-BuE7GImW.js +0 -1
- package/web/dist/assets/Roles-C5eVA6LM.js +0 -1
- package/web/dist/assets/Settings-BblOdOih.js +0 -1
- package/web/dist/assets/Work-Corw0ITh.js +0 -1
- package/web/dist/assets/api-Bux34u4-.js +0 -1
- package/web/dist/assets/index-B3_4_qY6.js +0 -2
- package/web/dist/assets/index-Cu5neZGw.css +0 -2
package/README.md
CHANGED
|
@@ -469,3 +469,11 @@ curl -X POST http://localhost:7100/tasks \
|
|
|
469
469
|
| FS | 1 个 | 文件操作 |
|
|
470
470
|
| 健康检查 | 3 个 | 存活、就绪、指标 |
|
|
471
471
|
| WebSocket | 3 个 | 任务流 + 全局事件 + Chat 流 |
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Contact
|
|
476
|
+
|
|
477
|
+
- X (Twitter): [@norvynzhang](https://x.com/norvynzhang)
|
|
478
|
+
- GitHub: [n0rvyn](https://github.com/n0rvyn)
|
|
479
|
+
- Email: [norvynzhang@gmail.com](mailto:norvynzhang@gmail.com)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{b as v,d as so,e as er}from"./chunk-PHT24MOV.js";import{a as no,f as Zo,h as Jo}from"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";import{Box as to,Text as Ut,useInput as di}from"ink";import{useState as ui,useEffect as Co,useRef as Go}from"react";import{createContext as xn,useContext as Tn,useReducer as hn}from"react";import{jsx as vn}from"react/jsx-runtime";var yn={connected:!1,serverInfo:null,activeTasks:0,queuedTasks:0,costToday:0,activeTaskId:null,activeTaskSubmitted:!1,pendingApproval:null,pendingPlanApproval:null,planTimeoutNotice:null,serverUnreachable:!1,view:"chat",configVersion:0,session:null,version:null};function bn(e,t){switch(t.type){case"SET_CONNECTED":return{...e,connected:t.connected};case"SET_SERVER_INFO":return{...e,serverInfo:t.info};case"UPDATE_STATS":return{...e,activeTasks:t.activeTasks,queuedTasks:t.queuedTasks,costToday:t.costToday};case"SET_ACTIVE_TASK":return{...e,activeTaskId:t.taskId,activeTaskSubmitted:!1};case"TASK_SUBMITTED":return{...e,activeTaskSubmitted:!0};case"SET_PENDING_APPROVAL":return{...e,pendingApproval:t.approval};case"SET_SERVER_UNREACHABLE":return{...e,serverUnreachable:t.unreachable};case"SET_VIEW":return{...e,view:t.view};case"CONFIG_CHANGED":return{...e,configVersion:e.configVersion+1};case"SET_SESSION":return{...e,session:t.session};case"SET_PENDING_PLAN_APPROVAL":return{...e,pendingPlanApproval:t.approval};case"SET_PLAN_TIMEOUT_NOTICE":return{...e,pendingPlanApproval:null,planTimeoutNotice:t.planId?{planId:t.planId}:null};case"SET_VERSION":return{...e,version:t.version};default:return e}}var tr=xn(null);function or({children:e}){let[t,o]=hn(bn,yn);return vn(tr.Provider,{value:{state:t,dispatch:o},children:e})}function Je(){let e=Tn(tr);if(!e)throw new Error("useTuiState must be used within TuiProvider");return e}import{useEffect as rr,useRef as nr}from"react";var Cn=15e3;function sr(){let{state:e,dispatch:t}=Je(),o=nr(null),x=nr(null);rr(()=>{x.current=e.session?.id??null},[e.session?.id]),rr(()=>{let m=!0,u=null,l=()=>{o.current&&(clearTimeout(o.current),o.current=null)},i=()=>{l(),o.current=setTimeout(()=>{m&&t({type:"SET_SERVER_UNREACHABLE",unreachable:!0})},Cn)};return(()=>{try{u=new so("/events"),u.on("task_status_change",()=>{}),u.on("approval_request",n=>{if(!m)return;let d=n;t({type:"SET_PENDING_APPROVAL",approval:{taskId:d.taskId,approvalId:d.approvalId,toolName:d.toolName,toolInput:d.toolInput,matchedPattern:d.matchedPattern}})}),u.on("plan_approval_request",n=>{if(!m)return;let d=n;t({type:"SET_PENDING_PLAN_APPROVAL",approval:{taskId:d.taskId,planId:d.planId,roleId:d.roleId,plan:d.plan}})}),u.on("plan_approval_decision",()=>{m&&t({type:"SET_PENDING_PLAN_APPROVAL",approval:null})}),u.on("config_changed",()=>{m&&t({type:"CONFIG_CHANGED"})}),u.on("execution_task_start",n=>{if(!m)return;let d=n,g=x.current;g&&(async()=>{try{let k=await v(`/tasks/${d.taskId}`);m&&k.sourceSessionId===g&&t({type:"SET_ACTIVE_TASK",taskId:d.taskId})}catch{}})()}),u.on("stats_update",n=>{if(!m)return;let d=n;t({type:"UPDATE_STATS",activeTasks:d.activeTasks,queuedTasks:d.queuedTasks,costToday:d.totalCostToday})}),u.connect().then(async()=>{if(m){l(),t({type:"SET_CONNECTED",connected:!0}),t({type:"SET_SERVER_UNREACHABLE",unreachable:!1});try{let n=await v("/version");t({type:"SET_VERSION",version:n.version})}catch{t({type:"SET_VERSION",version:null})}}}).catch(()=>{m&&(t({type:"SET_CONNECTED",connected:!1}),i())})}catch{m&&(t({type:"SET_CONNECTED",connected:!1}),i())}})(),()=>{m=!1,l(),u?.close()}},[t])}import{useEffect as wn,useRef as Sn,useState as ir,useCallback as kn}from"react";function ar(e){let[t,o]=ir([]),[x,m]=ir(!1),u=Sn(null),l=kn(()=>{o([]),m(!1)},[]);return wn(()=>{if(!e)return;let i=!0;o([]),m(!0);try{let a=new er(e);return u.current=a,a.on("reasoning",n=>{if(!i)return;let g=n.content??"";o(k=>{let T=k[k.length-1];if(T?.type==="reasoning"){let S=[...k];return S[S.length-1]={...T,content:T.content+g},S}return[...k,{type:"reasoning",content:g,timestamp:Date.now()}]})}),a.on("tool_call",n=>{if(!i)return;let d=n;o(g=>[...g,{type:"tool_call",content:d.toolName??"unknown tool",timestamp:Date.now(),metadata:{toolName:d.toolName}}])}),a.on("tool_result",n=>{if(!i)return;let d=n;o(g=>[...g,{type:"tool_result",content:d.content??"",timestamp:Date.now()}])}),a.on("error",n=>{if(!i)return;let d=n;o(g=>[...g,{type:"error",content:d.error??"unknown error",timestamp:Date.now()}])}),a.on("complete",n=>{if(!i)return;let d=n;o(g=>[...g,{type:"complete",content:d.result??"",timestamp:Date.now(),metadata:{cost:d.costUsd,turns:d.numTurns,duration:d.totalDurationMs}}]),m(!1)}),a.connect().catch(()=>{i&&(o(n=>[...n,{type:"error",content:"Failed to connect to task stream",timestamp:Date.now()}]),m(!1))}),()=>{i=!1,a.close()}}catch{m(!1)}},[e]),{events:t,isStreaming:x,clearEvents:l}}import{useState as Bo,useEffect as Bn,useCallback as Ht}from"react";function Eo(e){return{id:e.id,status:e.status,messageCount:e.messageCount,createdAt:e.createdAt,lastActiveAt:e.lastActiveAt,title:e.title}}function lr(){let[e,t]=Bo(null),[o,x]=Bo(!0),[m,u]=Bo(null),l=Ht(async()=>{try{let k=(await v("/chat/sessions?status=active")).sessions.find(T=>T.source.type==="tui");return k?Eo(k):null}catch{return null}},[]),i=Ht(async()=>{try{let g=await v("/chat/sessions",{method:"POST",body:{source:{type:"tui"}}}),k=Eo(g.session);return t(k),k}catch{return u("Failed to create session"),null}},[]),a=Ht(async g=>{try{let k=await v("/chat/messages",{method:"POST",body:{content:g,source:{type:"tui"}}});return t(T=>T&&{...T,messageCount:T.messageCount+1,lastActiveAt:Date.now()}),k}catch{return null}},[]),n=Ht(async()=>{if(!e)return!1;try{return await v(`/chat/sessions/${e.id}/archive`,{method:"POST"}),t(null),!0}catch{return!1}},[e]),d=Ht(async()=>{if(e)try{let g=await v(`/chat/sessions/${e.id}`);t(Eo(g.session))}catch{t(null)}},[e]);return Bn(()=>{let g=!1;async function k(){x(!0);let T=await l();g||(T?t(T):await i(),g||x(!1))}return k(),()=>{g=!0}},[]),{session:e,loading:o,error:m,sendMessage:a,createNewSession:i,archiveCurrentSession:n,refreshSession:d,setSession:t}}import{useEffect as cr,useRef as En,useState as In}from"react";function dr(e){let[t,o]=In(null),x=En(new Set);return cr(()=>{if(!e)return;let m=!0,u=null;try{u=new so("/chat/stream"),u.on("chat_message",l=>{if(!m)return;let a=l.message;a&&a.sessionId===e&&a.role==="assistant"&&(x.current.has(a.id)||(x.current.add(a.id),o(a)))}),u.connect().catch(()=>{})}catch{}return()=>{m=!1,u?.close()}},[e]),cr(()=>{x.current.clear(),o(null)},[e]),{latestMessage:t}}import{Box as Io,Text as De}from"ink";import{Fragment as io,jsx as pe,jsxs as Pt}from"react/jsx-runtime";var An=90;function ur({children:e}){return pe(Io,{children:e})}function mr(){let{state:e}=Je(),t=e.session,x=(t?Math.floor((Date.now()-t.lastActiveAt)/6e4):1/0)>=25,m=e.connected?"up":"down",u=e.view==="chat"?"Chat":e.view.charAt(0).toUpperCase()+e.view.slice(1),l=t?t.messageCount===0?"new session":`${t.id.slice(0,8)} \xB7 ${t.messageCount}t`:null,a=(process.stdout.columns??100)<An,n=Pt(io,{children:[pe(De,{bold:!0,children:e.version?`Adam v${e.version}`:"Adam"}),pe(De,{dimColor:!0,children:" | "}),pe(De,{color:e.connected?"green":"red",children:(e.connected,"\u25CF")}),pe(De,{children:` ${m}`}),pe(De,{dimColor:!0,children:" | "}),pe(De,{children:u.toLowerCase()})]}),d=Pt(io,{children:[pe(De,{children:`${e.activeTasks} run / ${e.queuedTasks} q`}),pe(De,{dimColor:!0,children:" | "}),pe(De,{children:`$${e.costToday.toFixed(2)}`}),e.view==="chat"&&t&&Pt(io,{children:[pe(De,{dimColor:!0,children:" | "}),pe(De,{children:l}),x&&Pt(io,{children:[pe(De,{dimColor:!0,children:" | "}),pe(De,{color:"yellow",children:"timeout"})]})]})]});return a?Pt(Io,{flexDirection:"column",borderStyle:"round",borderDimColor:!0,paddingX:1,children:[pe(ur,{children:n}),pe(ur,{children:d})]}):Pt(Io,{borderStyle:"round",borderDimColor:!0,paddingX:1,children:[n,pe(De,{dimColor:!0,children:" | "}),d]})}import{Box as ao,Text as lo,useInput as Dn}from"ink";import{useState as Po,useMemo as Rn}from"react";import Mn from"ink-text-input";var Pn=[{name:"work",description:"Tasks, Automations & Goals"},{name:"config",description:"Configuration"},{name:"evolution",description:"Evolution audit"},{name:"webhooks",description:"Webhook triggers"},{name:"memories",description:"Memory browser"},{name:"strategies",description:"Strategy lab"},{name:"plugins",description:"Plugin management"},{name:"roles",description:"Role management"},{name:"settings",description:"Runtime settings"},{name:"back",description:"Return to chat"},{name:"quit",description:"Exit TUI"}];function Ao(e){let t=e.toLowerCase();return Pn.filter(o=>o.name.startsWith(t))}function gr(e){let t=Ao(e.toLowerCase());return t.length===1?t[0]:void 0}import{jsx as co,jsxs as jt}from"react/jsx-runtime";function fr({onSubmit:e}){let[t,o]=Po(""),[x,m]=Po(0),[u,l]=Po(!1),i=t.startsWith("/")&&t.length>=1,a=t.slice(1),n=Rn(()=>i?Ao(a):[],[i,a]),d=T=>{o(T),T.startsWith("/")?(l(!0),m(0)):l(!1)},g=()=>{let T=t.trim();if(T){if(T.startsWith("/")){let S=T.slice(1),r=gr(S);e(r?`/${r.name}`:T)}else e(T);o(""),l(!1)}},k=T=>{e(`/${T.name}`),o(""),l(!1)};return Dn((T,S)=>{if(!(!u||!i||n.length===0)){if(S.upArrow){m(r=>r<=0?n.length-1:r-1);return}if(S.downArrow){m(r=>r>=n.length-1?0:r+1);return}if(S.tab){let r=n[x];r&&k(r);return}if(S.escape){l(!1),o("");return}}},{isActive:u&&i&&n.length>0}),jt(ao,{flexDirection:"column",children:[u&&i&&n.length>0&&co(ao,{flexDirection:"column",marginBottom:0,paddingX:1,children:n.map((T,S)=>{let r=S===x;return jt(ao,{children:[co(lo,{color:r?"cyan":"gray",bold:r,children:r?"\u25B8 ":" "}),jt(lo,{color:r?"cyan":"white",bold:r,children:["/",T.name]}),jt(lo,{dimColor:!0,children:[" \u2014 ",T.description]})]},T.name)})}),jt(ao,{borderStyle:"round",borderDimColor:!0,children:[co(lo,{bold:!0,children:"\u25B8 "}),co(Mn,{value:t,onChange:d,onSubmit:g,placeholder:"Type a message or / for commands..."})]})]})}import{Box as Dt,Text as Be,useInput as $n}from"ink";import{useState as Nn}from"react";import{jsx as Le,jsxs as et}from"react/jsx-runtime";function _n({content:e,expanded:t}){let o=e.split(`
|
|
2
|
+
`);return o.length<=5?Le(Be,{color:"green",children:e}):t?Le(Be,{color:"green",children:e}):et(Be,{color:"green",children:[o.slice(0,3).join(`
|
|
3
|
+
`),`
|
|
4
|
+
`,et(Be,{dimColor:!0,children:["(",o.length," lines) [Ctrl+O] expand"]})]})}function Ln({event:e,expanded:t}){switch(e.type){case"reasoning":return Le(Dt,{children:Le(Be,{color:"gray",children:e.content})});case"tool_call":return Le(Dt,{children:et(Be,{color:"blue",children:["[tool] ",e.metadata?.toolName??e.content]})});case"tool_result":return et(Dt,{flexDirection:"column",children:[Le(Be,{color:"blue",dimColor:!0,children:"[result]"}),Le(_n,{content:e.content,expanded:t})]});case"error":return Le(Dt,{children:et(Be,{color:"red",children:["[error] ",e.content]})});case"complete":return et(Dt,{flexDirection:"column",marginTop:1,children:[e.content&&Le(Be,{children:e.content}),Le(Be,{dimColor:!0,children:"\u2500\u2500\u2500 Task complete \u2500\u2500\u2500"}),e.metadata?.cost!==void 0&&et(Be,{dimColor:!0,children:["Cost: $",e.metadata.cost.toFixed(4)]}),e.metadata?.turns!==void 0&&et(Be,{dimColor:!0,children:["Turns: ",e.metadata.turns]}),e.metadata?.duration!==void 0&&et(Be,{dimColor:!0,children:["Duration: ",(e.metadata.duration/1e3).toFixed(1),"s"]})]});default:return null}}function pr({events:e,isStreaming:t}){let[o,x]=Nn(!1),m=e.some(u=>u.type==="tool_result"&&u.content.split(`
|
|
5
|
+
`).length>5);return $n((u,l)=>{l.ctrl&&u==="o"&&x(i=>!i)},{isActive:m}),e.length===0&&!t?null:et(Dt,{flexDirection:"column",children:[t&&e.length===0&&Le(Be,{dimColor:!0,children:"Waiting for response..."}),e.map((u,l)=>Le(Ln,{event:u,expanded:o},l)),m&&Le(Be,{dimColor:!0,children:o?"[Ctrl+O] collapse full output":"[Ctrl+O] expand full output"})]})}import{Box as xr,Text as Tr}from"ink";import{jsx as Do,jsxs as On}from"react/jsx-runtime";function hr({messages:e}){return e.length===0?null:Do(xr,{flexDirection:"column",children:e.map((t,o)=>On(xr,{flexDirection:"column",marginBottom:1,children:[Do(Tr,{dimColor:!0,bold:!0,children:t.role==="user"?"You:":"Adam:"}),Do(Tr,{children:t.content})]},o))})}import{Box as Kt,Text as tt,useInput as Vn}from"ink";import{jsx as ot,jsxs as zt}from"react/jsx-runtime";function yr({approval:e,onResolved:t}){return Vn(o=>{o==="a"?v(`/tasks/${e.taskId}/approve`,{method:"POST",body:{approvalId:e.approvalId}}).then(()=>t()).catch(()=>t()):o==="r"&&v(`/tasks/${e.taskId}/reject`,{method:"POST",body:{approvalId:e.approvalId,reason:"rejected by user"}}).then(()=>t()).catch(()=>t())}),zt(Kt,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,children:[ot(tt,{bold:!0,color:"yellow",children:"\u26A0 APPROVAL REQUIRED"}),zt(Kt,{marginTop:1,children:[ot(tt,{children:"Tool: "}),ot(tt,{bold:!0,children:e.toolName})]}),zt(Kt,{children:[ot(tt,{children:"Input: "}),ot(tt,{children:JSON.stringify(e.toolInput)})]}),zt(Kt,{children:[ot(tt,{children:"Pattern: "}),ot(tt,{dimColor:!0,children:e.matchedPattern})]}),zt(Kt,{marginTop:1,children:[ot(tt,{color:"green",children:"[a] Approve"}),ot(tt,{children:" "}),ot(tt,{color:"red",children:"[r] Reject"})]})]})}import{Box as Xt,Text as Ee,useInput as qn}from"ink";import{useState as Fn,useEffect as Un}from"react";import{jsx as ct,jsxs as ze}from"react/jsx-runtime";var Wn=300;function br({approval:e,onResolved:t,onTimeout:o}){let[x,m]=Fn(Wn);Un(()=>{let l=setInterval(()=>{m(i=>i<=1?(clearInterval(l),o(),0):i-1)},1e3);return()=>clearInterval(l)},[o]),qn(l=>{l==="a"?v(`/tasks/${e.taskId}/approve-plan`,{method:"POST",body:{planId:e.planId,decision:"allow",approvalType:"once"}}).then(()=>t()).catch(()=>t()):l==="r"?v(`/tasks/${e.taskId}/approve-plan`,{method:"POST",body:{planId:e.planId,decision:"deny",reason:"rejected by user"}}).then(()=>t()).catch(()=>t()):l==="p"&&v(`/tasks/${e.taskId}/approve-plan`,{method:"POST",body:{planId:e.planId,decision:"allow",approvalType:"permanent"}}).then(()=>t()).catch(()=>t())});let u=e.plan.overallRisk==="high"?"red":e.plan.overallRisk==="medium"?"yellow":"green";return ze(Xt,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[ct(Ee,{bold:!0,color:"cyan",children:"EXECUTION PLAN \u2014 APPROVAL REQUIRED"}),ze(Ee,{dimColor:!0,children:["Plan ID: ",e.planId]}),ze(Ee,{dimColor:!0,children:["Time remaining: ",x,"s"]}),ze(Xt,{marginTop:1,children:[ct(Ee,{children:"Overall Risk: "}),ct(Ee,{bold:!0,color:u,children:e.plan.overallRisk.toUpperCase()})]}),ze(Ee,{bold:!0,children:["Steps (",e.plan.steps.length,"):"]}),e.plan.steps.map(l=>{let i=l.riskLevel==="high"?"red":l.riskLevel==="medium"?"yellow":"green";return ze(Xt,{paddingLeft:2,children:[ze(Ee,{children:["[",l.index,"] "]}),ct(Ee,{children:l.description}),ze(Ee,{dimColor:!0,children:[" (",l.toolsNeeded.join(", "),")"]}),ze(Ee,{color:i,children:[" [",l.riskLevel,"]"]})]},l.index)}),ze(Xt,{marginTop:1,children:[ct(Ee,{dimColor:!0,children:"Permissions: "}),ct(Ee,{children:Object.keys(e.plan.requiredPermissions).join(", ")||"none"})]}),ze(Xt,{marginTop:1,children:[ct(Ee,{color:"green",children:"[a] Allow once "}),ct(Ee,{color:"green",children:"[p] Allow permanent "}),ct(Ee,{color:"red",children:"[r] Deny"})]})]})}import{Box as xe,Text as j,useInput as Zn}from"ink";import{useEffect as Jn,useState as ht,useCallback as Br}from"react";import{Box as ge,Text as F,useInput as Gn}from"ink";import{useEffect as Hn,useState as Rt}from"react";import{jsx as ie,jsxs as G}from"react/jsx-runtime";var vr={plan:!0,result:!1,routing:!0,error:!0},jn={pending:"gray",queued:"gray",running:"yellow",paused:"yellow",completed:"green",failed:"red",cancelled:"gray",blocked:"yellow"};function kr({taskId:e,onBack:t}){let[o,x]=Rt(null),[m,u]=Rt([]),[l,i]=Rt([]),[a,n]=Rt(null),[d,g]=Rt(vr),[k,T]=Rt(!1);Hn(()=>{let h=!1;return x(null),u([]),i([]),n(null),g(vr),T(!1),v(`/tasks/${e}`).then(({task:B})=>{h||x(B)}).catch(B=>{h||n(B instanceof Error?B.message:String(B))}),v(`/tasks/${e}/plan`).then(({plans:B})=>{h||u(B)}).catch(()=>{h||u([])}),v(`/tasks/${e}/delivery-log?limit=8`).then(({logs:B})=>{h||i(B)}).catch(()=>{h||i([])}),()=>{h=!0}},[e]);let S=h=>{g(B=>({...B,[h]:!B[h]}))};if(Gn((h,B)=>{if(h==="b"||B.escape){t();return}h==="1"&&S("plan"),h==="2"&&S("result"),h==="3"&&S("routing"),h==="4"&&S("error"),h==="5"&&T(H=>!H)}),a)return G(ge,{flexDirection:"column",children:[G(F,{color:"red",children:["Task detail failed: ",a]}),ie(F,{dimColor:!0,children:"[b] Back"})]});if(!o)return G(F,{dimColor:!0,children:["Loading task ",e.slice(0,8),"..."]});let r=m[0],s=Qn(o.deliverTo,o.reportTo),E=l.length>0?`${l.length} delivery event${l.length===1?"":"s"}`:"No delivery events";return G(ge,{flexDirection:"column",children:[G(ge,{children:[G(F,{bold:!0,color:"cyan",children:["Task ",o.id.slice(0,8)]}),ie(F,{dimColor:!0,children:" \u2022 "}),ie(F,{color:jn[o.status]??"white",bold:!0,children:o.status.toUpperCase()})]}),G(F,{dimColor:!0,children:[o.roleId?`role ${o.roleId}`:"no role"," \u2022 ",Sr(o.createdAt)," \u2022 ",Xn(o.totalDurationMs)]}),G(ge,{marginTop:1,flexDirection:"column",children:[ie(F,{bold:!0,children:"Summary"}),ie(F,{children:k?o.prompt:Kn(o.prompt,240)}),o.prompt.length>240&&G(F,{dimColor:!0,children:["[5] ",k?"collapse prompt":"expand prompt"]}),G(ge,{marginTop:1,flexDirection:"column",children:[G(F,{dimColor:!0,children:["Cost: ",zn(o.costUsd)]}),G(F,{dimColor:!0,children:["Turns: ",o.numTurns??"\u2014"]}),G(F,{dimColor:!0,children:["Template: ",o.templateId??"\u2014"]}),G(F,{dimColor:!0,children:["Source Session: ",o.sourceSessionId?.slice(0,8)??"\u2014"]})]})]}),G(ge,{marginTop:1,flexDirection:"column",children:[G(F,{bold:!0,children:["[1] Plan ",d.plan?"hide":"show"]}),ie(F,{dimColor:!0,children:r?`${r.plan.steps.length} planned step${r.plan.steps.length===1?"":"s"} \u2022 ${r.plan.overallRisk} risk \u2022 ${r.status}`:"No execution plan"}),d.plan&&r&&G(ge,{marginTop:1,flexDirection:"column",children:[r.plan.steps.map(h=>G(ge,{flexDirection:"column",marginBottom:1,children:[G(F,{children:[h.index,". ",h.description]}),G(F,{dimColor:!0,children:[h.riskLevel," risk \u2022 ",h.toolsNeeded.join(", ")||"no tools listed"]}),h.expectedOutput?G(F,{dimColor:!0,children:["Expected: ",h.expectedOutput]}):null]},h.index)),r.learnedRules&&r.learnedRules.length>0&&G(ge,{flexDirection:"column",children:[ie(F,{color:"blue",bold:!0,children:"Learned Rules"}),r.learnedRules.map((h,B)=>G(F,{dimColor:!0,children:["\u2022 ",h]},B))]})]})]}),G(ge,{marginTop:1,flexDirection:"column",children:[G(F,{bold:!0,children:["[2] Result ",d.result?"hide":"show"]}),ie(F,{dimColor:!0,children:o.result?"Execution produced output.":"No result captured yet."}),d.result&&ie(ge,{marginTop:1,children:ie(F,{children:o.result?wr(o.result,18):"No result yet."})})]}),G(ge,{marginTop:1,flexDirection:"column",children:[G(F,{bold:!0,children:["[3] Routing ",d.routing?"hide":"show"]}),G(F,{dimColor:!0,children:[s," \u2022 ",E]}),d.routing&&G(ge,{marginTop:1,flexDirection:"column",children:[ie(F,{color:"cyan",children:"Deliver To"}),Cr(o.deliverTo),ie(F,{color:"cyan",children:"Report To"}),Cr(o.reportTo),l.length>0&&G(ge,{marginTop:1,flexDirection:"column",children:[ie(F,{color:"cyan",children:"Recent Delivery"}),l.map(h=>G(F,{dimColor:!0,children:[h.status," \u2022 ",Yn(h)," \u2022 ",Sr(h.createdAt)]},h.id))]})]})]}),G(ge,{marginTop:1,flexDirection:"column",children:[G(F,{bold:!0,children:["[4] Error ",d.error?"hide":"show"]}),ie(F,{dimColor:!0,children:o.error?"Execution returned an error condition.":"No error recorded."}),d.error&&o.error&&ie(ge,{marginTop:1,children:ie(F,{color:"red",children:wr(o.error,16)})})]}),ie(ge,{marginTop:1,children:ie(F,{dimColor:!0,children:"[1] plan [2] result [3] routing [4] error [5] prompt [b] back"})})]})}function Cr(e){return!e||e.length===0?ie(F,{dimColor:!0,children:" none"}):ie(ge,{flexDirection:"column",children:e.map((t,o)=>ie(F,{dimColor:!0,children:t.type==="channel"?` channel ${t.channelId.slice(0,8)}${t.chatId?` / ${t.chatId.slice(0,8)}`:""}`:` session ${t.sessionId.slice(0,8)}`},`${t.type}-${o}`))})}function wr(e,t){let o=e.split(`
|
|
6
|
+
`);return o.length<=t?e:`${o.slice(0,t).join(`
|
|
7
|
+
`)}
|
|
8
|
+
\u2026`}function Kn(e,t){let o=e.replace(/\s+/g," ").trim();return o.length<=t?o:`${o.slice(0,t-1)}\u2026`}function zn(e){return e!==void 0?`$${e.toFixed(4)}`:"\u2014"}function Xn(e){if(!e)return"waiting";let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t}s`;let o=Math.floor(t/60),x=t%60;return x===0?`${o}m`:`${o}m ${x}s`}function Sr(e){return new Date(e).toLocaleString()}function Qn(e,t){let o=e?.length??0,x=t?.length??0;return o===0&&x===0?"No delivery targets":`${o} output target${o===1?"":"s"} \u2022 ${x} report target${x===1?"":"s"}`}function Yn(e){return e.target.type==="webhook"?e.target.webhookUrl??"webhook":e.target.type==="channel"?`channel ${e.target.channelId?.slice(0,8)??"unknown"}`:"unknown target"}import{Fragment as ts,jsx as ee,jsxs as te}from"react/jsx-runtime";var Er={pending:"gray",queued:"gray",running:"yellow",paused:"yellow",completed:"green",failed:"red",cancelled:"gray",blocked:"yellow"},uo=["all","pending","queued","running","completed","failed","cancelled","blocked"],Ro=15;function go({onBack:e}){let[t,o]=ht([]),[x,m]=ht(!0),[u,l]=ht("list"),[i,a]=ht(0),[n,d]=ht("all"),[g,k]=ht(0),[T,S]=ht(0),[r,s]=ht(null),E=Br(async()=>{m(!0);try{let D=new URLSearchParams({limit:"100"});n!=="all"&&D.set("status",n);let L=await v(`/tasks?${D}`);o(L.tasks)}catch{o([])}finally{m(!1)}},[n]);Jn(()=>{E()},[E]);let h=Math.max(1,Math.ceil(t.length/Ro)),B=t.slice(T*Ro,(T+1)*Ro),H=Br(async()=>{let D=B[i];if(D)try{await v(`/tasks/${D.id}/cancel`,{method:"POST"}),s(`Cancelled: ${D.id.slice(0,8)}`),l("list"),E()}catch(L){s(`Failed: ${L instanceof Error?L.message:String(L)}`),l("list")}},[B,i,E]);if(Zn((D,L)=>{if(u==="detail"){(L.escape||L.return||D==="q")&&l("list");return}if(u==="cancelling"){D==="y"?H():l("list");return}if(u==="filter"){if(L.escape){l("list");return}L.upArrow&&g>0&&k(N=>N-1),L.downArrow&&g<uo.length-1&&k(N=>N+1),L.return&&(d(uo[g]),S(0),a(0),l("list"));return}if(L.escape||D==="q"){e();return}if(L.upArrow&&i>0&&a(N=>N-1),L.downArrow&&i<B.length-1&&a(N=>N+1),L.return&&B[i]&&l("detail"),D==="x"&&B[i]){let N=B[i];["running","pending","queued","paused"].includes(N.status)?(l("cancelling"),s(null)):s(`Cannot cancel task in status: ${N.status}`)}D==="f"&&(k(uo.indexOf(n)),l("filter")),D==="r"&&E(),(L.pageDown||D==="n")&&T<h-1&&(S(N=>N+1),a(0)),(L.pageUp||D==="p")&&T>0&&(S(N=>N-1),a(0))}),x)return ee(j,{dimColor:!0,children:"Loading tasks..."});if(u==="filter")return te(xe,{flexDirection:"column",children:[ee(j,{bold:!0,children:"Filter by status:"}),uo.map((D,L)=>ee(xe,{children:te(j,{color:L===g?"cyan":"white",children:[L===g?"> ":" ",D,D===n?" (current)":""]})},D)),ee(j,{dimColor:!0,children:"Enter: select Esc: cancel"})]});if(u==="detail"&&B[i])return ee(kr,{taskId:B[i].id,onBack:()=>l("list")});if(u==="cancelling"&&B[i])return te(xe,{flexDirection:"column",children:[te(j,{color:"red",children:['Cancel task "',B[i].id.slice(0,8),'"? (y/n)']}),r&&ee(j,{color:"red",children:r})]});let Y=B[i]??null;return te(xe,{flexDirection:"column",children:[te(xe,{children:[te(j,{bold:!0,children:["Tasks (",t.length,")"]}),n!=="all"&&te(j,{dimColor:!0,children:[" [filter: ",n,"]"]}),te(j,{dimColor:!0,children:[" \u2022 Page ",T+1,"/",h]})]}),r&&ee(j,{color:r.startsWith("Failed")||r.startsWith("Cannot")?"red":"green",children:r}),t.length===0?te(j,{dimColor:!0,children:["No tasks found",n!=="all"?` with status "${n}"`:"","."]}):te(xe,{marginTop:1,flexDirection:"row",gap:2,children:[ee(xe,{flexDirection:"column",flexGrow:3,children:B.map((D,L)=>{let N=L===i,M=Er[D.status]??"white";return te(xe,{flexDirection:"column",marginBottom:1,children:[te(xe,{children:[ee(j,{color:N?"cyan":"gray",bold:N,children:N?"\u276F ":" "}),ee(j,{color:M,bold:!0,children:D.status.toUpperCase()}),ee(j,{dimColor:!0,children:` ${D.id.slice(0,8)}`})]}),ee(xe,{paddingLeft:2,children:ee(j,{color:N?"white":void 0,children:mo(D.prompt,N?72:56)})}),ee(xe,{paddingLeft:2,children:te(j,{dimColor:!0,children:[Pr(D.createdAt)," \u2022 ",Ir(D)," \u2022 ",Ar(D.costUsd)]})})]},D.id)})}),ee(xe,{flexDirection:"column",flexGrow:2,borderStyle:"round",borderDimColor:!0,paddingX:1,children:Y?te(ts,{children:[ee(j,{bold:!0,children:"Preview"}),te(xe,{marginTop:1,children:[ee(j,{color:Er[Y.status]??"white",bold:!0,children:Y.status.toUpperCase()}),ee(j,{dimColor:!0,children:` ${Y.id.slice(0,8)}`})]}),ee(j,{children:mo(Y.prompt,220)}),te(xe,{marginTop:1,flexDirection:"column",children:[te(j,{dimColor:!0,children:["Role: ",Y.roleId??Y.agentId??"\u2014"]}),te(j,{dimColor:!0,children:["Created: ",Pr(Y.createdAt)]}),te(j,{dimColor:!0,children:["Duration: ",Ir(Y)]}),te(j,{dimColor:!0,children:["Cost: ",Ar(Y.costUsd)]}),te(j,{dimColor:!0,children:["Turns: ",Y.numTurns??"\u2014"]})]}),Y.error?te(xe,{marginTop:1,flexDirection:"column",children:[ee(j,{color:"red",bold:!0,children:"Error"}),ee(j,{color:"red",children:mo(Y.error,180)})]}):Y.result?te(xe,{marginTop:1,flexDirection:"column",children:[ee(j,{color:"green",bold:!0,children:"Latest Result"}),ee(j,{children:mo(Y.result,180)})]}):null,ee(xe,{marginTop:1,children:ee(j,{dimColor:!0,children:"Enter opens full detail"})})]}):ee(j,{dimColor:!0,children:"Select a task to inspect it."})})]})]})}function es(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}function mo(e,t){return es(e.replace(/\s+/g," ").trim(),t)}function Ir(e){let t=e.totalDurationMs??(e.startedAt?Date.now()-e.startedAt:void 0);if(!t)return"waiting";let o=Math.max(1,Math.round(t/1e3));if(o<60)return`${o}s`;let x=Math.floor(o/60),m=o%60;return m===0?`${x}m`:`${x}m ${m}s`}function Ar(e){return e!==void 0?`$${e.toFixed(4)}`:"no cost"}function Pr(e){let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;let o=Math.floor(t/60);if(o<60)return`${o}m ago`;let x=Math.floor(o/60);return x<24?`${x}h ago`:`${Math.floor(x/24)}d ago`}Jo();import{Box as St,Text as Re,useInput as os}from"ink";import{useEffect as rs,useState as Dr}from"react";import{readFileSync as ns,existsSync as ss}from"fs";import{parse as is}from"yaml";import{Fragment as ls,jsx as Ie,jsxs as Oe}from"react/jsx-runtime";function Rr({onBack:e}){let[t,o]=Dr(null),[x,m]=Dr(null);return os((u,l)=>{(l.escape||u==="q")&&e()}),rs(()=>{try{let u=Zo;if(!ss(u)){m(`Config file not found: ${u}`);return}let l=ns(u,"utf-8");o(is(l))}catch(u){m(u.message)}},[]),x?Oe(St,{flexDirection:"column",children:[Ie(Re,{color:"red",children:x}),Ie(Re,{dimColor:!0,children:"Press Esc to go back"})]}):t?Oe(St,{flexDirection:"column",children:[Ie(Re,{bold:!0,children:"Configuration (Esc to go back)"}),Ie(St,{marginTop:1,flexDirection:"column",children:Ie(Mo,{obj:t,indent:0})})]}):Ie(Re,{dimColor:!0,children:"Loading config..."})}function Mo({obj:e,indent:t}){let o=" ".repeat(t);return Ie(ls,{children:Object.entries(e).map(([x,m])=>Ie(as,{label:x,value:m,indent:t,parentKey:x},x))})}function as({label:e,value:t,indent:o,parentKey:x}){let m=" ".repeat(o);return Array.isArray(t)?Oe(St,{flexDirection:"column",children:[Oe(Re,{children:[m,Ie(Re,{color:"cyan",children:e}),":"]}),t.length===0?Oe(Re,{dimColor:!0,children:[m," []"]}):t.map((u,l)=>Ie(Mr,{value:u,indent:o+1,parentKey:x,index:l},`${e}-${l}`))]}):t&&typeof t=="object"?Oe(St,{flexDirection:"column",children:[Oe(Re,{children:[m,Ie(Re,{color:"cyan",children:e}),":"]}),Ie(Mo,{obj:t,indent:o+1})]}):Oe(Re,{children:[m,Ie(Re,{color:"cyan",children:e}),": ",$r(x,Nr(t))]})}function Mr({value:e,indent:t,parentKey:o,index:x}){let m=" ".repeat(t);return Array.isArray(e)?Oe(St,{flexDirection:"column",children:[Oe(Re,{children:[m,"- [",x,"]"]}),e.map((u,l)=>Ie(Mr,{value:u,indent:t+1,parentKey:o,index:l},`${x}-${l}`))]}):e&&typeof e=="object"?Oe(St,{flexDirection:"column",children:[Oe(Re,{children:[m,"-"]}),Ie(Mo,{obj:e,indent:t+1})]}):Oe(Re,{children:[m,"- ",$r(o,Nr(e))]})}function $r(e,t){let o=e.toLowerCase();return o.includes("key")||o.includes("token")||o.includes("secret")||o.includes("password")?!t||t.length<8?"****":t.slice(0,4)+"****":t}function Nr(e){return e===null?"null":e===void 0?"undefined":typeof e=="string"?e:String(e)}import{Box as fo,Text as Xe,useInput as cs}from"ink";import{useEffect as ds,useState as $o}from"react";import{jsx as Qt,jsxs as rt}from"react/jsx-runtime";function _r({onBack:e}){let[t,o]=$o([]),[x,m]=$o(!0),[u,l]=$o(null);return cs((i,a)=>{(a.escape||i==="q")&&e()}),ds(()=>{v("/evolution-audit?limit=20").then(i=>{o(i),m(!1)}).catch(i=>{l(i.message),m(!1)})},[]),x?Qt(Xe,{dimColor:!0,children:"Loading evolution log..."}):u?rt(fo,{flexDirection:"column",children:[Qt(Xe,{color:"red",children:u}),Qt(Xe,{dimColor:!0,children:"Press Esc to go back"})]}):t.length===0?rt(fo,{flexDirection:"column",children:[Qt(Xe,{dimColor:!0,children:"No evolution records yet"}),Qt(Xe,{dimColor:!0,children:"Press Esc to go back"})]}):rt(fo,{flexDirection:"column",children:[rt(Xe,{bold:!0,children:["Evolution Audit Log (",t.length," records) \u2014 Esc to go back"]}),t.map(i=>rt(fo,{flexDirection:"column",marginTop:1,children:[rt(Xe,{bold:!0,children:["[",new Date(i.timestamp).toLocaleString(),"]"]}),i.triggerTaskId&&rt(Xe,{dimColor:!0,children:[" Task: ",i.triggerTaskId.slice(0,8)]}),i.diff.split(`
|
|
9
|
+
`).map((a,n)=>a.startsWith("+")?rt(Xe,{color:"green",children:[" ",a]},n):a.startsWith("-")?rt(Xe,{color:"red",children:[" ",a]},n):rt(Xe,{dimColor:!0,children:[" ",a]},n))]},i.id))]})}import{Box as dt,Text as ae,useInput as us}from"ink";import ms from"ink-text-input";import{useEffect as gs,useState as Mt}from"react";import{jsx as Me,jsxs as Te}from"react/jsx-runtime";var fs={pending:"gray",planning:"cyan",executing:"yellow",evaluating:"blue",replanning:"magenta",completed:"green",failed:"red",paused:"gray"};function ps(e,t=20){let o=Math.round(e*t),x=t-o;return"\u2588".repeat(o)+"\u2591".repeat(x)}function xs(e){let t=Math.max(0,Math.floor((e-Date.now())/864e5));return t===0?"< 1d":`${t}d`}function po({onBack:e}){let[t,o]=Mt([]),[x,m]=Mt(null),[u,l]=Mt("list"),[i,a]=Mt(""),[n,d]=Mt(!1),[g,k]=Mt(null);us((r,s)=>{if(u==="create"){s.escape&&(l("list"),a(""),k(null));return}(s.escape||r==="q")&&e(),r==="c"&&(l("create"),k(null)),r==="r"&&T()});let T=()=>{v("/goals?limit=20").then(({goals:r})=>o(r)).catch(r=>m(r.message))};gs(()=>{T()},[]);let S=async r=>{if(r.trim()){d(!0),k(null);try{let s=await v("/goals",{method:"POST",body:{input:r.trim()}});k(`Goal created: ${s.goal.name}`),a(""),l("list"),T()}catch(s){k(`Failed: ${s instanceof Error?s.message:String(s)}`)}finally{d(!1)}}};return x?Te(dt,{flexDirection:"column",children:[Te(ae,{color:"red",children:["Failed to load goals: ",x]}),Me(ae,{dimColor:!0,children:"Press Esc or q to return"})]}):u==="create"?Te(dt,{flexDirection:"column",children:[Me(ae,{bold:!0,children:"Create Goal"}),Me(ae,{dimColor:!0,children:"Describe your SMART goal in natural language:"}),Te(dt,{marginTop:1,children:[Me(ae,{color:"cyan",children:"> "}),Me(ms,{value:i,onChange:a,onSubmit:S})]}),n&&Me(ae,{color:"yellow",children:"Creating goal..."}),g&&Me(ae,{color:g.startsWith("Failed")?"red":"green",children:g}),Me(ae,{dimColor:!0,children:"Press Esc to cancel"})]}):Te(dt,{flexDirection:"column",children:[Te(ae,{bold:!0,children:["Goal Dashboard (",t.length,")"]}),t.length===0?Me(ae,{dimColor:!0,children:"No goals found. Press c to create one."}):Me(dt,{marginTop:1,flexDirection:"column",children:t.map(r=>{let s=r.targetValue>0?r.currentValue/r.targetValue:0,E=fs[r.status]??"white";return Te(dt,{marginBottom:1,flexDirection:"column",children:[Te(dt,{children:[Me(ae,{bold:!0,color:E,children:r.name}),Te(ae,{dimColor:!0,children:[" (",r.role,")"]}),Me(ae,{dimColor:!0,children:" \u2014 "}),Me(ae,{color:E,children:r.status})]}),Te(dt,{children:[Te(ae,{dimColor:!0,children:[" ",ps(s)," "]}),Te(ae,{color:s>=1?"green":"white",children:[Math.round(s*100),"%"]}),Te(ae,{dimColor:!0,children:[" (",r.currentValue,"/",r.targetValue," ",r.metricType,")"]})]}),Te(dt,{children:[Te(ae,{dimColor:!0,children:[" \u23F0 ",xs(r.deadline)," left"]}),Te(ae,{dimColor:!0,children:[" | \u{1F4B0} $",r.budgetUsd]}),Te(ae,{dimColor:!0,children:[" | ID: ",r.id.slice(0,8)]})]})]},r.id)})}),Me(ae,{dimColor:!0,children:"c:create r:refresh Esc/q:back"})]})}import{Box as $t,Text as Fe,useInput as Ts}from"ink";import{useEffect as hs,useState as Lr}from"react";import{jsx as mt,jsxs as ut}from"react/jsx-runtime";function ys(e,t,o=15){let x=e/(e+t),m=Math.round(x*o);return"\u2593".repeat(m)+"\u2591".repeat(o-m)}function Or({onBack:e}){let[t,o]=Lr([]),[x,m]=Lr(null);if(Ts((l,i)=>{(i.escape||l==="q")&&e()}),hs(()=>{v("/strategies?limit=50").then(l=>o(l.strategies??[])).catch(l=>m(l.message))},[]),x)return ut($t,{flexDirection:"column",children:[ut(Fe,{color:"red",children:["Failed to load strategies: ",x]}),mt(Fe,{dimColor:!0,children:"Press Esc or q to return"})]});if(t.length===0)return ut($t,{flexDirection:"column",children:[mt(Fe,{dimColor:!0,children:"No strategies yet. Strategies are created when goals are executed."}),mt(Fe,{dimColor:!0,children:"Press Esc or q to return"})]});let u=new Map;for(let l of t){let i=`${l.role}/${l.taskType}`,a=u.get(i)??[];a.push(l),u.set(i,a)}return ut($t,{flexDirection:"column",children:[mt(Fe,{bold:!0,children:"Strategy Lab"}),mt(Fe,{dimColor:!0,children:"Thompson Sampling populations \u2014 higher bar = higher selection probability"}),mt($t,{marginTop:1,flexDirection:"column",children:Array.from(u.entries()).map(([l,i])=>ut($t,{marginBottom:1,flexDirection:"column",children:[mt(Fe,{bold:!0,color:"cyan",children:l}),i.sort((a,n)=>{let d=a.alpha/(a.alpha+a.beta);return n.alpha/(n.alpha+n.beta)-d}).map(a=>{let n=a.alpha/(a.alpha+a.beta);return ut($t,{children:[mt(Fe,{dimColor:!0,children:" "}),ut(Fe,{children:[ys(a.alpha,a.beta)," "]}),ut(Fe,{color:n>.6?"green":n>.4?"yellow":"red",children:[(n*100).toFixed(0),"%"]}),ut(Fe,{dimColor:!0,children:[" ",a.name," (\u03B1=",a.alpha.toFixed(1)," \u03B2=",a.beta.toFixed(1)," trials=",a.totalTrials,")"]})]},a.id)})]},l))}),mt(Fe,{dimColor:!0,children:"Press Esc or q to return"})]})}import{Box as he,Text as K,useInput as Ss}from"ink";import No from"ink-text-input";import{useEffect as ks,useState as We,useCallback as yt}from"react";import{CronExpressionParser as Bs}from"cron-parser";import{useState as bs,useEffect as vs,useCallback as Vr,useRef as Cs}from"react";var ws=3e3;function Ue(){let[e,t]=bs(null),o=Cs(null),x=Vr(()=>{o.current&&(clearTimeout(o.current),o.current=null),t(null)},[]),m=Vr((u,l)=>{o.current&&(clearTimeout(o.current),o.current=null),t({text:u,type:l}),l==="success"&&(o.current=setTimeout(()=>{t(null),o.current=null},ws))},[]);return vs(()=>()=>{o.current&&clearTimeout(o.current)},[]),{message:e,setMessage:m,clearMessage:x}}import{jsx as J,jsxs as oe}from"react/jsx-runtime";var _o=["manual","cron","once","template_complete"],qr=["cron","once","template_complete"],xo={name:"",triggerType:"manual",cron:"",targetTemplateId:"",stepPrompt:""};function Es(e){try{return Bs.parse(e).next().toDate().toLocaleString()}catch{return"invalid"}}function To({onBack:e}){let[t,o]=We([]),[x,m]=We(!0),[u,l]=We(0),[i,a]=We("list"),[n,d]=We({...xo}),[g,k]=We("name"),[T,S]=We(null),{message:r,setMessage:s,clearMessage:E}=Ue(),[h,B]=We(!1),[H,Y]=We(!1),[D,L]=We({}),[N,M]=We(null),[Z,se]=We(!1),Se=yt(()=>{m(!0),v("/task-templates").then(({templates:f})=>{o(f),new Set(f.flatMap(P=>P.steps?.map(U=>U.roleId).filter(Boolean)??[])).size>0?v("/roles").then(({roles:P})=>{if(!Array.isArray(P)){L({});return}L(Object.fromEntries(P.map(U=>[U.id,U.name])))}).catch(()=>L({})):L({}),m(!1)}).catch(()=>m(!1))},[]);ks(()=>{Se()},[Se]);let Ct=i==="create"||i==="edit",_e=yt(async()=>{let f=t[u];if(!(!f||h)){B(!0),s(`Triggering ${f.name}...`,"loading");try{let C=await v(`/task-templates/${f.id}/run`,{method:"POST"});s(`Triggered: ${f.name} (${C.executionId})`,"success")}catch(C){s(`Trigger failed: ${C instanceof Error?C.message:String(C)}`,"error")}finally{B(!1)}}},[t,u,h,s]),ve=yt(async()=>{let f=t[u];if(!f||H)return;if(!qr.includes(f.trigger?.type??"manual")){s("Toggle not applicable for manual triggers","error");return}let C=!f.enabled;Y(!0),s(`${f.name} \u2192 ${C?"enabling":"disabling"}...`,"loading");try{await v(`/task-templates/${f.id}`,{method:"PATCH",body:{enabled:C}}),o(P=>P.map(U=>U.id===f.id?{...U,enabled:C}:U)),s(`${f.name} ${C?"enabled":"disabled"}`,"success")}catch(P){s(`Toggle failed: ${P instanceof Error?P.message:String(P)}`,"error")}finally{Y(!1)}},[t,u,H,s]),It=yt(async()=>{if(Z)return;let f=t[u];if(f){se(!0);try{let C=await v(`/task-templates/${f.id}/dependents`,{method:"GET"});M({templateId:f.id,templateName:f.name,executionCount:C.dependents.executionCount,taskCount:C.dependents.taskCount}),C.dependents.taskCount===0&&C.dependents.executionCount===0?s(`Delete "${f.name}"? Press d to confirm, Esc to cancel.`,"loading"):s(`"${f.name}" has ${C.dependents.executionCount} execution${C.dependents.executionCount===1?"":"s"}, ${C.dependents.taskCount} task${C.dependents.taskCount===1?"":"s"}. [d] template only (keep tasks) | [D] template + tasks | [Esc] cancel.`,"loading")}catch(C){s(`Failed to inspect dependents: ${C instanceof Error?C.message:String(C)}`,"error")}finally{se(!1)}}},[t,u,s,Z]),Ce=yt(async f=>{let C=N;if(C){M(null);try{let P=await v(`/task-templates/${C.templateId}?mode=${f}`,{method:"DELETE"}),U=[];P.deletedCounts.workflowExecutions>0&&U.push(`${P.deletedCounts.workflowExecutions} exec`),P.deletedCounts.tasks>0&&U.push(`${P.deletedCounts.tasks} task${P.deletedCounts.tasks===1?"":"s"}`);let de=U.length?` (+${U.join(", ")})`:"";s(`Deleted: ${C.templateName}${de}`,"success"),Se(),l(ke=>Math.max(0,Math.min(ke,t.length-2)))}catch(P){s(`Delete failed: ${P instanceof Error?P.message:String(P)}`,"error")}}},[N,Se,s,t.length]),je=yt(()=>{M(null),E()},[E]),Tt=yt(()=>{let f=t[u];f&&(S(f.id),d({name:f.name,triggerType:f.trigger?.type==="workflow_complete"?"template_complete":f.trigger?.type??"manual",cron:f.trigger?.cron??"",targetTemplateId:f.trigger?.type==="template_complete"||f.trigger?.type==="workflow_complete"?f.trigger.event?.split(":")[1]??"":"",stepPrompt:f.steps?.[0]?.prompt??""}),k("name"),a("edit"))},[t,u]),$=yt(async()=>{let f={name:n.name,trigger:{type:n.triggerType,...n.triggerType==="cron"?{cron:n.cron}:{},...n.triggerType==="template_complete"&&n.targetTemplateId?{event:`template_complete:${n.targetTemplateId}`}:{}},steps:[{id:"step-1",prompt:n.stepPrompt}],enabled:!0};try{i==="create"?(await v("/task-templates",{method:"POST",body:f}),s(`Created: ${n.name}`,"success")):i==="edit"&&T&&(await v(`/task-templates/${T}`,{method:"PATCH",body:f}),s(`Updated: ${n.name}`,"success"))}catch(C){s(`Save failed: ${C instanceof Error?C.message:String(C)}`,"error")}a("list"),d({...xo}),S(null),Se()},[n,i,T,Se]);return Ss((f,C)=>{if(Ct){if(C.escape){a("list"),d({...xo}),S(null);return}if(C.return){let P=["name","triggerType","cron","stepPrompt"],de=n.triggerType==="template_complete"?["name","triggerType","targetTemplateId","stepPrompt"]:P.filter(W=>W!=="targetTemplateId"),ke=de.indexOf(g);if(ke<de.length-1){let W=ke+1;if(de[W]==="cron"&&n.triggerType!=="cron"&&W++,W<de.length){k(de[W]);return}}$();return}if(C.tab&&g==="triggerType"){d(P=>{let U=_o.indexOf(P.triggerType);return{...P,triggerType:_o[(U+1)%_o.length]}});return}if(C.tab&&g==="targetTemplateId"){d(P=>{let U=t.filter(W=>W.id!==T),de=U.findIndex(W=>W.id===P.targetTemplateId),ke=U[(de+1)%U.length];return{...P,targetTemplateId:ke?.id??""}});return}return}if(N){if(C.escape){je();return}if(f==="D"&&C.shift){Ce("with_tasks");return}if(f==="d"&&!C.shift){Ce("template_only");return}return}if(C.escape||f==="q"){e();return}if(C.upArrow){l(P=>Math.max(0,P-1));return}if(C.downArrow){l(P=>Math.min(t.length-1,P+1));return}if(f==="t"){_e();return}if(f==="d"&&!C.shift){It();return}if(f==="e"){Tt();return}if(f==="c"){d({...xo}),k("name"),a("create");return}if(f==="s"||f===" "){ve();return}f==="r"&&(Se(),E())}),x?J(K,{dimColor:!0,children:"Loading templates..."}):Ct?oe(he,{flexDirection:"column",children:[oe(K,{bold:!0,children:[i==="create"?"Create Template":"Edit Template"," (Esc to cancel)"]}),oe(he,{marginTop:1,flexDirection:"column",children:[oe(he,{children:[oe(K,{bold:g==="name",color:g==="name"?"cyan":void 0,children:["Name:"," "]}),g==="name"?J(No,{value:n.name,onChange:f=>d(C=>({...C,name:f})),placeholder:"template name"}):J(K,{children:n.name||"(empty)"})]}),oe(he,{children:[oe(K,{bold:g==="triggerType",color:g==="triggerType"?"cyan":void 0,children:["Trigger:"," "]}),J(K,{children:n.triggerType}),g==="triggerType"&&J(K,{dimColor:!0,children:" (Tab to cycle, Enter to continue)"})]}),n.triggerType==="cron"&&oe(he,{children:[oe(K,{bold:g==="cron",color:g==="cron"?"cyan":void 0,children:["Cron:"," "]}),g==="cron"?J(No,{value:n.cron,onChange:f=>d(C=>({...C,cron:f})),placeholder:"*/5 * * * *"}):J(K,{children:n.cron||"(empty)"})]}),(n.triggerType==="template_complete"||n.triggerType==="workflow_complete")&&oe(he,{children:[oe(K,{bold:g==="targetTemplateId",color:g==="targetTemplateId"?"cyan":void 0,children:["Target:"," "]}),J(K,{children:(()=>{let f=t.find(C=>C.id===n.targetTemplateId);return f?f.name:n.targetTemplateId?`(id: ${n.targetTemplateId.slice(0,8)})`:"(Tab to select)"})()}),g==="targetTemplateId"&&J(K,{dimColor:!0,children:" (Tab to cycle)"})]}),oe(he,{children:[oe(K,{bold:g==="stepPrompt",color:g==="stepPrompt"?"cyan":void 0,children:["Step Prompt:"," "]}),g==="stepPrompt"?J(No,{value:n.stepPrompt,onChange:f=>d(C=>({...C,stepPrompt:f})),placeholder:"What should this template do?"}):J(K,{children:n.stepPrompt||"(empty)"})]})]}),J(he,{marginTop:1,children:J(K,{dimColor:!0,children:"Enter: next field / submit | Esc: cancel"})})]}):oe(he,{flexDirection:"column",children:[oe(K,{bold:!0,children:["Automations (",t.length,") (Esc to go back)"]}),r&&J(he,{marginTop:1,children:oe(K,{color:r.type==="success"?"green":r.type==="error"?"red":"gray",children:[r.type==="success"?"\u2713 ":r.type==="error"?"\u2717 ":"\u2192 ",r.text]})}),t.length===0?J(he,{marginTop:1,children:J(K,{dimColor:!0,children:"No templates found. Press c to create one."})}):J(he,{marginTop:1,flexDirection:"column",children:t.map((f,C)=>{let P=C===u,U=f.trigger?.type==="cron"&&f.trigger?.cron?Es(f.trigger.cron):"",de=new Set(f.steps?.filter(W=>W.roleId).map(W=>W.roleId)),ke=f.steps?.length>1?`${f.steps.length} steps${de.size>0?` / ${de.size} roles`:""}`:`${f.steps?.length??0} step`;return oe(he,{flexDirection:"column",children:[oe(he,{children:[J(K,{color:P?"cyan":void 0,bold:P,children:P?"> ":" "}),J(K,{color:P?"cyan":void 0,bold:P,children:Yt(f.name,24)}),J(K,{dimColor:!0,children:Yt(f.trigger?.type,10)}),qr.includes(f.trigger?.type??"manual")?J(K,{color:f.enabled?"green":"gray",children:Yt(f.enabled?"on":"off",6)}):J(K,{dimColor:!0,children:Yt("\u2014",6)}),J(K,{dimColor:!0,children:Yt(ke,18)}),U&&oe(K,{dimColor:!0,children:["next: ",U]})]}),P&&f.steps?.length>1&&J(he,{flexDirection:"column",marginLeft:4,marginTop:0,children:f.steps.map((W,Ze)=>oe(he,{children:[oe(K,{dimColor:!0,children:[" ",Ze+1,". "]}),J(K,{dimColor:!0,children:W.id}),W.roleId&&oe(K,{color:"yellow",children:[" @",D[W.roleId]??W.roleId]}),W.dependsOn&&W.dependsOn.length>0&&oe(K,{dimColor:!0,children:[" (after: ",W.dependsOn.join(", "),")"]}),W.config&&oe(K,{dimColor:!0,children:[" ","[",[W.config.timeout!==void 0?`timeout:${W.config.timeout}s`:"",W.config.maxTurns!==void 0?`turns:${W.config.maxTurns}`:""].filter(Boolean).join(", "),"]"]})]},W.id))})]},f.id)})}),J(he,{marginTop:1,children:J(K,{dimColor:!0,children:"t:trigger s:toggle d:delete e:edit c:create r:refresh"})})]})}function Yt(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}import{Box as bt,Text as Ve,useInput as Is}from"ink";import As from"ink-text-input";import{useEffect as Ps,useState as Nt,useCallback as Fr}from"react";import{jsx as Ae,jsxs as kt}from"react/jsx-runtime";function Ur({onBack:e}){let[t,o]=Nt([]),[x,m]=Nt(""),[u,l]=Nt(!0),[i,a]=Nt(!1),[n,d]=Nt(""),[g,k]=Nt(null),T=Fr(()=>{l(!0),v("/webhooks").then(({webhooks:r,auth:s})=>{o(r),m(s),l(!1)}).catch(()=>l(!1))},[]);Ps(()=>{T()},[T]);let S=Fr(async r=>{if(r.trim())try{let s=await v(`/webhooks/${encodeURIComponent(r.trim())}`,{method:"POST"});k(`Triggered: ${s.executionId}`)}catch(s){k(`Trigger failed: ${s instanceof Error?s.message:String(s)}`)}},[]);return Is((r,s)=>{if(i){if(s.escape){a(!1),d("");return}if(s.return){S(n),a(!1),d("");return}return}if(s.escape||r==="q"){e();return}if(r==="t"){a(!0),d(""),k(null);return}r==="r"&&(T(),k(null))}),u?Ae(Ve,{dimColor:!0,children:"Loading webhooks..."}):kt(bt,{flexDirection:"column",children:[kt(Ve,{bold:!0,children:["Webhooks (",t.length,") (Esc to go back)"]}),kt(Ve,{dimColor:!0,children:["Auth: ",x]}),g&&Ae(bt,{marginTop:1,children:Ae(Ve,{color:"yellow",children:g})}),i&&kt(bt,{marginTop:1,children:[Ae(Ve,{bold:!0,color:"cyan",children:"Trigger webhook: "}),Ae(As,{value:n,onChange:d,placeholder:"webhook name or ID"}),Ae(Ve,{dimColor:!0,children:" (Enter to trigger, Esc to cancel)"})]}),t.length===0?Ae(bt,{marginTop:1,children:Ae(Ve,{dimColor:!0,children:"No webhooks available. Create templates with triggers to expose webhooks."})}):kt(bt,{marginTop:1,flexDirection:"column",children:[Ae(bt,{children:kt(Ve,{bold:!0,children:[_t("NAME",24),_t("DESCRIPTION",36),_t("TRIGGER",28),"TAGS"]})}),t.map(r=>kt(bt,{children:[Ae(Ve,{children:_t(r.displayName,24)}),Ae(Ve,{dimColor:!0,children:_t(Ds(r.description??"",34),36)}),Ae(Ve,{dimColor:!0,children:_t(r.trigger,28)}),Ae(Ve,{dimColor:!0,children:r.tags?.join(", ")??""})]},r.name))]}),Ae(bt,{marginTop:1,children:Ae(Ve,{dimColor:!0,children:"t:trigger r:refresh"})})]})}function _t(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}function Ds(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}import{Box as nt,Text as ue,useInput as Rs}from"ink";import Ms from"ink-text-input";import{useEffect as Wr,useState as gt,useCallback as Lo}from"react";import{jsx as me,jsxs as Qe}from"react/jsx-runtime";function $s(e){return e>=4?"red":e===3?"yellow":"gray"}function Ns(e){return e>=4?"HIGH":e===3?"MED ":"LOW "}function _s(e){return new Date(e).toLocaleDateString()}function Hr({onBack:e}){let[t,o]=gt([]),[x,m]=gt(0),[u,l]=gt([]),[i,a]=gt(!0),[n,d]=gt(!1),[g,k]=gt(""),[T,S]=gt("all"),[r,s]=gt(null),[E,h]=gt(!1),B=Lo(()=>{v("/agents").then(({agents:M})=>{o(M),a(!1)}).catch(()=>a(!1))},[]);Wr(()=>{B()},[B]);let H=t[x],Y=Lo(()=>{H&&(h(!1),v(`/memories/${H.id}`).then(({memories:M})=>{l(M),s(null)}).catch(M=>s(`Failed: ${M instanceof Error?M.message:String(M)}`)))},[H]);Wr(()=>{H&&Y()},[H,Y]);let D=Lo(async M=>{if(!(!H||!M.trim()))try{let Z=await v("/memories/query",{method:"POST",body:{agentId:H.id,prompt:M.trim()}});l(Z.memories),h(!0),s(`Search: ${Z.count} results`)}catch(Z){s(`Search failed: ${Z instanceof Error?Z.message:String(Z)}`)}},[H]),L=n,N=u.filter(M=>T==="all"?!0:T==="high"?M.importance>3:T==="medium"?M.importance===3:M.importance<3);return Rs((M,Z)=>{if(L){if(Z.escape){d(!1),k("");return}if(Z.return){D(g),d(!1),k("");return}return}if(Z.escape||M==="q"){e();return}if(M==="a"){m(se=>(se+1)%Math.max(1,t.length));return}if(Z.leftArrow){m(se=>(se-1+t.length)%Math.max(1,t.length));return}if(Z.rightArrow){m(se=>(se+1)%Math.max(1,t.length));return}if(M==="s"){d(!0),k(""),s(null);return}if(M==="h"){S(se=>se==="high"?"all":"high");return}if(M==="m"){S(se=>se==="medium"?"all":"medium");return}if(M==="l"){S(se=>se==="low"?"all":"low");return}M==="r"&&Y()}),i?me(ue,{dimColor:!0,children:"Loading agents..."}):t.length===0?Qe(nt,{flexDirection:"column",children:[me(ue,{dimColor:!0,children:"No agents found"}),me(ue,{dimColor:!0,children:"Press Esc to go back"})]}):Qe(nt,{flexDirection:"column",children:[me(ue,{bold:!0,children:"Memories (Esc to go back)"}),Qe(nt,{marginTop:1,children:[me(ue,{children:"Agent: "}),me(ue,{bold:!0,color:"cyan",children:H?.name??"?"}),Qe(ue,{dimColor:!0,children:[" (",x+1,"/",t.length,") [a/arrows to switch]"]})]}),me(nt,{children:Qe(ue,{dimColor:!0,children:["Filter: ",T==="all"?"all":T," | ",E?"search results":"all memories"," (",N.length,")"]})}),r&&me(nt,{children:me(ue,{color:"yellow",children:r})}),n&&Qe(nt,{marginTop:1,children:[me(ue,{bold:!0,color:"cyan",children:"Search: "}),me(Ms,{value:g,onChange:k,placeholder:"search query..."}),me(ue,{dimColor:!0,children:" (Enter to search, Esc to cancel)"})]}),N.length===0?me(nt,{marginTop:1,children:Qe(ue,{dimColor:!0,children:["No memories",T!=="all"?` matching filter '${T}'`:""]})}):me(nt,{marginTop:1,flexDirection:"column",children:N.map(M=>Qe(nt,{marginBottom:0,children:[Qe(ue,{color:$s(M.importance),bold:!0,children:[Ns(M.importance)," "]}),me(ue,{dimColor:!0,children:Gr(M.type??"?",12)}),me(ue,{dimColor:!0,children:Gr(`\xD7${M.retrievedCount??0}`,5)}),Qe(ue,{children:[Ls(M.content,55)," "]}),me(ue,{dimColor:!0,children:_s(M.createdAt)}),M.score!==void 0&&Qe(ue,{dimColor:!0,children:[" (",M.score.toFixed(2),")"]})]},M.id))}),me(nt,{marginTop:1,children:me(ue,{dimColor:!0,children:"s:search h:high m:medium l:low a:agent r:refresh"})})]})}function Gr(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}function Ls(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}import{Box as Ye,Text as ce,useInput as Os}from"ink";import ho from"ink-text-input";import{useState as $e,useEffect as jr,useCallback as Oo}from"react";import{jsx as ye,jsxs as fe}from"react/jsx-runtime";var Kr={Anthropic:["anthropic.apiKey","anthropic.baseUrl","anthropic.model","anthropic.defaultOpusModel","anthropic.defaultSonnetModel","anthropic.defaultHaikuModel","anthropic.smallFastModel"],Defaults:["defaults.model","defaults.effort","defaults.maxTurns","defaults.maxBudgetUsd","defaults.timeout","defaults.approvalTimeout"],Server:["server.port","server.host","server.apiKey","server.timezone"],Logging:["logging.level"],Evolution:["roles.evolution.triggerEvery","roles.evolution.reflectionThreshold"],Chat:["chat.sessionTimeoutMinutes","chat.maxSessionTurns","chat.autoTitle","chat.archiveExtractMemory"],Workflow:["watchdog.rules.artifactCleanup.enabled","watchdog.rules.artifactCleanup.ttlDays","watchdog.rules.artifactCleanup.orphanGcMinAgeHours"]},Vs={"anthropic.apiKey":"API Key","anthropic.baseUrl":"Base URL","anthropic.model":"Model","anthropic.defaultOpusModel":"Default Opus","anthropic.defaultSonnetModel":"Default Sonnet","anthropic.defaultHaikuModel":"Default Haiku","anthropic.smallFastModel":"Small Fast","defaults.model":"Default Model","defaults.effort":"Effort","defaults.maxTurns":"Max Turns","defaults.maxBudgetUsd":"Max Budget (USD)","defaults.timeout":"Timeout (sec)","defaults.approvalTimeout":"Approval Timeout (sec)","server.port":"Port","server.host":"Host","server.apiKey":"API Key","server.timezone":"Timezone","logging.level":"Log Level","roles.evolution.triggerEvery":"Evolution Trigger Every","chat.sessionTimeoutMinutes":"Session Timeout (min)","chat.maxSessionTurns":"Max Session Turns","chat.autoTitle":"Auto Title","chat.archiveExtractMemory":"Archive Extract Memory","roles.evolution.reflectionThreshold":"Reflection Threshold","watchdog.rules.artifactCleanup.enabled":"Artifact Cleanup Enabled","watchdog.rules.artifactCleanup.ttlDays":"Artifact Retention (days)","watchdog.rules.artifactCleanup.orphanGcMinAgeHours":"Orphan GC Min Age (hours)"};function zr({onBack:e}){let{state:t}=Je(),[o,x]=$e({}),[m,u]=$e([]),[l,i]=$e(null),[a,n]=$e("view"),[d,g]=$e(0),[k,T]=$e(""),[S,r]=$e(null),[s,E]=$e(!1),[h,B]=$e([]),[H,Y]=$e({}),[D,L]=$e(0),[N,M]=$e(""),[Z,se]=$e(""),[Se,Ct]=$e(""),_e=Object.values(Kr).flat(),ve=Oo(()=>{v("/config").then($=>{x($.config),u($.mutable)}).catch($=>i($.message)),v("/config/env-diff").then($=>{B($.diffs)}).catch(()=>{}),v("/config/env").then($=>Y($.env??{})).catch(()=>{})},[]);jr(()=>{ve()},[ve]),jr(()=>{t.configVersion>0&&ve()},[t.configVersion,ve]);let It=Oo(async()=>{let $=_e[d];if($){E(!0),r(null);try{let f=k,C=o[$];if(C&&typeof C.value=="number"&&(f=Number(k),isNaN(f))){r("Invalid number"),E(!1);return}let P=await v("/config",{method:"PATCH",body:{[$]:f}});P.updated.length>0&&(r(`Updated: ${$}`),ve()),P.errors.length>0&&r(P.errors[0]),n("view")}catch(f){r(`Failed: ${f instanceof Error?f.message:String(f)}`)}finally{E(!1)}}},[_e,d,k,o,ve]),Ce=Object.keys(H),je=Oo(async $=>{try{await v("/config/env",{method:"PUT",body:$}),r("Env vars saved"),ve()}catch(f){r(`Failed: ${f instanceof Error?f.message:String(f)}`)}},[ve]);if(Os(($,f)=>{if(a==="edit"){if(f.escape){n("view");return}return}if(a==="env-list"){if(f.escape){n("view");return}if(f.upArrow&&D>0&&L(C=>C-1),f.downArrow&&D<Ce.length-1&&L(C=>C+1),$==="a"){M(""),n("env-add-key");return}if($==="d"&&Ce.length>0){let C=Ce[D],P={...H};delete P[C],je(P),D>=Ce.length-1&&D>0&&L(U=>U-1);return}if(f.return&&Ce.length>0){Ct(H[Ce[D]]??""),n("env-edit-value");return}return}if(a==="env-add-key"){if(f.escape){n("env-list");return}return}if(a==="env-add-value"){if(f.escape){n("env-list");return}return}if(a==="env-edit-value"){if(f.escape){n("env-list");return}return}if(f.escape||$==="q"){e();return}if(f.upArrow&&d>0&&g(C=>C-1),f.downArrow&&d<_e.length-1&&g(C=>C+1),f.return||$==="e"){let C=_e[d],P=o[C];P&&P.mutable?(T(String(P.value??"")),n("edit"),r(null)):P&&!P.mutable&&r("This setting requires a restart to change")}$==="v"&&(L(0),n("env-list"),r(null)),$==="r"&&(ve(),r("Refreshed")),$==="s"&&h.length>0&&v("/config/sync-to-env",{method:"POST"}).then(()=>{r("Synced to .env"),B([]),ve()}),$==="l"&&h.length>0&&v("/config/load-from-env",{method:"POST"}).then(()=>{r("Loaded from .env"),ve()})}),l)return fe(Ye,{flexDirection:"column",children:[fe(ce,{color:"red",children:["Failed to load config: ",l]}),ye(ce,{dimColor:!0,children:"Press Esc or q to return"})]});let Tt=0;return fe(Ye,{flexDirection:"column",children:[ye(ce,{bold:!0,children:"Settings"}),S&&ye(ce,{color:S.startsWith("Failed")||S.startsWith("This setting")?"yellow":"green",children:S}),h&&h.length>0&&fe(Ye,{flexDirection:"column",marginBottom:1,children:[fe(ce,{color:"yellow",children:[".env differs from DB (",h.length," key(s)): ",h.map($=>$.envKey).join(", ")]}),ye(ce,{dimColor:!0,children:"s:sync DB\u2192.env l:load .env\u2192DB"})]}),ye(Ye,{marginTop:1,flexDirection:"column",children:Object.entries(Kr).map(([$,f])=>fe(Ye,{marginBottom:1,flexDirection:"column",children:[ye(ce,{bold:!0,color:"cyan",children:$}),f.map(C=>{let P=o[C],de=Tt++===d,ke=m.includes(C),W=Vs[C]??C,Ze=P?String(P.value??""):"...";return a==="edit"&&de?fe(Ye,{children:[fe(ce,{color:"cyan",children:["> ",W,": "]}),ye(ho,{value:k,onChange:T,onSubmit:()=>{It()}}),s&&ye(ce,{color:"yellow",children:" saving..."})]},C):fe(Ye,{children:[fe(ce,{color:de?"cyan":"white",children:[de?"> ":" ",ke?" ":"\u{1F512} ",W,": "," "]}),ye(ce,{color:ke?"white":"gray",children:Ze}),!ke&&ye(ce,{dimColor:!0,children:" (restart required)"})]},C)})]},$))}),ye(ce,{dimColor:!0,children:"Enter/e:edit v:env vars r:refresh Esc/q:back"}),a.startsWith("env")&&fe(Ye,{flexDirection:"column",marginTop:1,children:[fe(ce,{bold:!0,color:"cyan",children:["Environment Variables (",Ce.length,")"]}),Ce.length===0&&a==="env-list"&&ye(ce,{dimColor:!0,children:" No env vars. Press a to add."}),Ce.map(($,f)=>{let C=f===D;return a==="env-edit-value"&&C?fe(Ye,{children:[fe(ce,{color:"cyan",children:["> ",$," = "]}),ye(ho,{value:Se,onChange:Ct,onSubmit:()=>{je({...H,[$]:Se}),n("env-list")}})]},$):fe(ce,{color:C&&a==="env-list"?"cyan":"white",children:[C&&a==="env-list"?"> ":" ",$," = ",H[$]]},$)}),a==="env-add-key"&&fe(Ye,{children:[ye(ce,{color:"green",children:" New key: "}),ye(ho,{value:N,onChange:M,onSubmit:()=>{N.trim()&&(se(""),n("env-add-value"))}})]}),a==="env-add-value"&&fe(Ye,{children:[fe(ce,{color:"green",children:[" ",N," = "]}),ye(ho,{value:Z,onChange:se,onSubmit:()=>{je({...H,[N.trim()]:Z}),n("env-list")}})]}),ye(ce,{dimColor:!0,children:"a:add Enter:edit d:delete Esc:back"})]})]})}import{Box as Bt,Text as Pe,useInput as qs}from"ink";import{useEffect as Fs,useState as Vo,useCallback as Us}from"react";import{jsx as we,jsxs as Ot}from"react/jsx-runtime";function Xr({onBack:e}){let[t,o]=Vo([]),[x,m]=Vo(!0),[u,l]=Vo(0),{message:i,setMessage:a,clearMessage:n}=Ue(),d=Us(()=>{m(!0),v("/plugins").then(({plugins:g})=>{o(g),m(!1)}).catch(()=>m(!1))},[]);return Fs(()=>{d()},[d]),qs((g,k)=>{if(k.escape||g==="q"){e();return}if(k.upArrow){l(T=>Math.max(0,T-1));return}if(k.downArrow){l(T=>Math.min(t.length-1,T+1));return}g==="r"&&(d(),n())}),x?we(Pe,{dimColor:!0,children:"Loading plugins..."}):Ot(Bt,{flexDirection:"column",children:[Ot(Pe,{bold:!0,children:["Plugins (",t.length,") (Esc to go back)"]}),i&&we(Bt,{marginTop:1,children:Ot(Pe,{color:i.type==="success"?"green":i.type==="error"?"red":"gray",children:[i.type==="success"?"\u2713 ":i.type==="error"?"\u2717 ":"\u2192 ",i.text]})}),t.length===0?we(Bt,{marginTop:1,children:we(Pe,{dimColor:!0,children:"No plugins installed."})}):Ot(Bt,{marginTop:1,flexDirection:"column",children:[Ot(Bt,{children:[we(Pe,{dimColor:!0,children:" "}),we(Pe,{dimColor:!0,children:Lt("Name",24)}),we(Pe,{dimColor:!0,children:Lt("Scope",8)}),we(Pe,{dimColor:!0,children:Lt("User",6)}),we(Pe,{dimColor:!0,children:"Path"})]}),t.map((g,k)=>{let T=k===u,S=g.id.split("@")[0];return Ot(Bt,{children:[we(Pe,{color:T?"cyan":void 0,bold:T,children:T?"> ":" "}),we(Pe,{color:T?"cyan":void 0,bold:T,children:Lt(S,24)}),we(Pe,{color:T?"cyan":void 0,bold:T,children:Lt(g.scope,8)}),we(Pe,{color:g.globalEnabled?"green":"gray",children:Lt(g.globalEnabled?"on":"off",6)}),we(Pe,{dimColor:!0,children:g.installPath})]},g.id)})]}),we(Bt,{marginTop:1,children:we(Pe,{dimColor:!0,children:"r:refresh"})})]})}function Lt(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}import{Box as qo,Text as Fo,useInput as Ws}from"ink";import{useState as Gs}from"react";import{jsx as Et,jsxs as Qr}from"react/jsx-runtime";var Hs=[{key:"1",id:"tasks",label:"Tasks"},{key:"2",id:"automations",label:"Automations"},{key:"3",id:"goals",label:"Goals"}];function Yr({onBack:e}){let[t,o]=Gs("tasks");return Ws((x,m)=>{if(m.escape||x==="q"){e();return}if(x==="1"){o("tasks");return}if(x==="2"){o("automations");return}if(x==="3"){o("goals");return}}),Qr(qo,{flexDirection:"column",children:[Et(Fo,{bold:!0,children:"Work Surface"}),Et(Fo,{dimColor:!0,children:"Browse tasks, automations, and goals without dropping back into chat mode."}),Et(qo,{gap:3,marginBottom:1,marginTop:1,children:Hs.map(x=>{let m=t===x.id;return Et(qo,{children:Qr(Fo,{color:m?"cyan":"gray",bold:m,children:[m?"\u25CF":"\u25CB"," ",x.key,". ",x.label]})},x.id)})}),t==="tasks"&&Et(go,{onBack:e}),t==="automations"&&Et(To,{onBack:e}),t==="goals"&&Et(po,{onBack:e})]})}import{Box as re,Text as X,useInput as js}from"ink";import{useEffect as Ks,useState as Zt}from"react";import{jsx as V,jsxs as be}from"react/jsx-runtime";var Zr={connected:"green",connecting:"yellow",disconnected:"gray",error:"red"};function Jr({onBack:e}){let[t,o]=Zt([]),[x,m]=Zt(!0),[u,l]=Zt(0),[i,a]=Zt(null),[n,d]=Zt("");Ks(()=>{g()},[]);async function g(){try{let S=await v("/channels");o(S.channels)}catch{}m(!1)}async function k(S){if(t.find(s=>s.id===S)?.platform==="wechat")try{d("Starting WeChat QR login...");let s=await v(`/channels/${S}/wechat/qr-start`,{method:"POST"});if(s.qrcodeUrl){d(`Scan QR: ${s.qrcodeUrl}
|
|
10
|
+
Waiting for scan...`);let E=await v(`/channels/${S}/wechat/qr-wait`,{method:"POST",body:{sessionKey:s.sessionKey,timeoutMs:12e4}});d(E.message)}else d(s.message);g()}catch{d("WeChat connect failed")}else try{await v(`/channels/${S}/connect`,{method:"POST"}),d("Connecting..."),g()}catch{d("Connect failed")}}async function T(S){try{await v(`/channels/${S}/disconnect`,{method:"POST"}),d("Disconnected"),g()}catch{d("Disconnect failed")}}return js((S,r)=>{if(i){if(r.escape||S==="q"){a(null);return}if(S==="c"){k(i.id);return}if(S==="d"){T(i.id);return}return}if(r.escape){e();return}if(r.upArrow){l(s=>Math.max(0,s-1));return}if(r.downArrow){l(s=>Math.min(t.length-1,s+1));return}if(r.return&&t[u]){a(t[u]),d("");return}}),x?V(re,{flexDirection:"column",children:V(X,{dimColor:!0,children:"Loading channels..."})}):i?be(re,{flexDirection:"column",children:[be(re,{marginBottom:1,children:[be(X,{bold:!0,children:["Channel: ",i.name]}),V(X,{dimColor:!0,children:" (Esc to go back)"})]}),be(re,{flexDirection:"column",gap:0,children:[be(X,{children:["ID: ",i.id]}),be(X,{children:["Platform: ",i.platform]}),be(X,{children:["Status: ",V(X,{color:Zr[i.status]??"white",children:i.status})]}),be(X,{children:["Enabled: ",i.enabled?"yes":"no"]}),be(X,{children:["Messages: ",i.messageCount]}),be(X,{children:["Config: ",JSON.stringify(i.config)]})]}),V(re,{marginTop:1,children:V(X,{dimColor:!0,children:"[c] Connect [d] Disconnect [Esc] Back"})}),n&&V(X,{color:"yellow",children:n})]}):be(re,{flexDirection:"column",children:[be(re,{marginBottom:1,children:[V(X,{bold:!0,children:"Channels"}),be(X,{dimColor:!0,children:[" (",t.length," total) "]}),V(X,{dimColor:!0,children:"Arrow keys to select, Enter for detail, Esc to return"})]}),t.length===0?V(X,{dimColor:!0,children:"No channels configured. Add channels via API or config."}):be(re,{flexDirection:"column",children:[be(re,{children:[V(re,{width:3,children:V(X,{dimColor:!0,children:" "})}),V(re,{width:12,children:V(X,{bold:!0,dimColor:!0,children:"ID"})}),V(re,{width:16,children:V(X,{bold:!0,dimColor:!0,children:"Name"})}),V(re,{width:12,children:V(X,{bold:!0,dimColor:!0,children:"Platform"})}),V(re,{width:14,children:V(X,{bold:!0,dimColor:!0,children:"Status"})}),V(re,{width:10,children:V(X,{bold:!0,dimColor:!0,children:"Enabled"})}),V(re,{width:10,children:V(X,{bold:!0,dimColor:!0,children:"Messages"})})]}),t.map((S,r)=>be(re,{children:[V(re,{width:3,children:V(X,{children:r===u?">":" "})}),V(re,{width:12,children:V(X,{inverse:r===u,children:S.id.slice(0,8)})}),V(re,{width:16,children:V(X,{children:S.name})}),V(re,{width:12,children:V(X,{children:S.platform})}),V(re,{width:14,children:be(X,{color:Zr[S.status]??"white",children:[S.status==="connected"?"\u25CF":S.status==="error"?"\u2717":"\u25CB"," ",S.status]})}),V(re,{width:10,children:V(X,{color:S.enabled?"green":"gray",children:S.enabled?"yes":"no"})}),V(re,{width:10,children:V(X,{children:S.messageCount})})]},S.id))]})]})}import{Box as Vt,Text as it,useInput as Qs}from"ink";import{useEffect as Ys,useState as Jt,useCallback as Zs}from"react";import{Box as R,Text as y,useInput as zs}from"ink";import st from"ink-text-input";import{useEffect as en,useState as Q,useCallback as vt}from"react";Jo();import{Fragment as tn,jsx as b,jsxs as I}from"react/jsx-runtime";var Xs=/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;function on({roleId:e,onBack:t}){let[o,x]=Q(null),[m,u]=Q([]),[l,i]=Q(!0),[a,n]=Q("view"),[d,g]=Q(""),[k,T]=Q(0),[S,r]=Q(""),[s,E]=Q([]),[h,B]=Q(0),[H,Y]=Q(new Set),[D,L]=Q("inline"),[N,M]=Q(""),[Z,se]=Q(""),[Se,Ct]=Q([]),[_e,ve]=Q(new Set),[It,Ce]=Q(0),[je,Tt]=Q("default"),[$,f]=Q(""),[C,P]=Q(""),[U,de]=Q("mode"),[ke,W]=Q([]),[Ze,ln]=Q(null),[wo,cn]=Q([]),[At,So]=Q([]),[Ho,ko]=Q(""),[wt,oo]=Q(0),[ro,jo]=Q(""),[Ko,zo]=Q(""),[Xo,Qo]=Q(""),{message:_,setMessage:q}=Ue(),ne=vt(()=>{i(!0),v(`/roles/${e}`).then(({role:p,boundPlugins:w})=>{x(p),u(w??[]),g(p.cagPrompt??""),Y(new Set(p.allowedTools??[])),L(p.executionMode??"inline"),M(p.model??""),se(p.maxBudgetUsd!=null?String(p.maxBudgetUsd):""),i(!1)}).catch(()=>i(!1))},[e]);en(()=>{ne(),v("/config").then(p=>{let w=p.config["defaults.deniedReadPaths"]?.value;Array.isArray(w)&&W(w),ln(p.sandbox),cn(p.osCapabilities?.registry??[])}).catch(()=>{})},[ne]),en(()=>{L(o?.executionMode??"inline"),M(o?.model??""),se(o?.maxBudgetUsd!=null?String(o?.maxBudgetUsd):""),Tt(o?.permissionMode??"default"),f((o?.allowedBashPatterns??[]).join(", ")),P((o?.deniedBashPatterns??[]).join(", ")),So(o?.osCapabilities??[]);let p=o?.osCapabilities?.find(w=>w.id==="automation")?.targets??[];ko(p.join(", "))},[o?.id,o?.executionMode,o?.model,o?.maxBudgetUsd,o?.permissionMode,o?.allowedBashPatterns,o?.deniedBashPatterns,o?.osCapabilities]);let dn=vt(async()=>{if(o)try{await v(`/roles/${o.id}`,{method:"PATCH",body:{cagPrompt:d}}),q("CAG prompt saved","success"),n("view"),ne()}catch(p){q(`Save failed: ${p instanceof Error?p.message:String(p)}`,"error")}},[o,d,ne,q]),un=vt(async()=>{if(o)try{await v(`/roles/${o.id}`,{method:"PATCH",body:{additionalDirectories:Ke}}),q("Directories saved","success"),n("view"),ne()}catch(p){q(`Save failed: ${p instanceof Error?p.message:String(p)}`,"error")}},[o,ne,q]),mn=vt(async()=>{if(o)try{await v(`/roles/${o.id}`,{method:"PATCH",body:{allowedTools:Array.from(H)}}),q("Tool permissions saved","success"),n("view"),ne()}catch(p){q(`Save failed: ${p instanceof Error?p.message:String(p)}`,"error")}},[o,H,ne,q]),gn=vt(async()=>{if(!o)return;let p={executionMode:D};N!==void 0&&(p.model=N);let w=parseFloat(Z);isNaN(w)||(p.maxBudgetUsd=w);try{await v(`/roles/${o.id}`,{method:"PATCH",body:p}),q("Execution config saved","success"),n("view"),ne()}catch(c){q(`Save failed: ${c instanceof Error?c.message:String(c)}`,"error")}},[o,D,N,Z,ne,q]),fn=vt(async()=>{if(!o)return;let p={permissionMode:je},w=$.split(",").map(A=>A.trim()).filter(Boolean),c=C.split(",").map(A=>A.trim()).filter(Boolean);p.allowedBashPatterns=w.length>0?w:[],p.deniedBashPatterns=c.length>0?c:[];try{await v(`/roles/${o.id}`,{method:"PATCH",body:p}),q("Permission config saved","success"),n("view"),ne()}catch(A){q(`Save failed: ${A instanceof Error?A.message:String(A)}`,"error")}},[o,je,$,C,ne,q]),Yo=vt(p=>{let w=new Map;for(let c of p){if(!c.id)continue;let A={id:c.id};c.targets?.length&&(A.targets=Array.from(new Set(c.targets.map(O=>O.trim()).filter(Boolean)))),w.set(c.id,A)}return Array.from(w.values()).sort((c,A)=>c.id.localeCompare(A.id))},[]),pn=vt(async()=>{if(!o)return;let p=Yo(At),w=p.find(c=>c.id==="automation")?.targets??[];if(p.some(c=>c.id==="automation")&&(w.length===0||w.some(c=>!Xs.test(c)))){q("Automation requires valid bundle id targets","error");return}try{await v(`/roles/${o.id}`,{method:"PATCH",body:{osCapabilities:p}}),q("OS capabilities saved","success"),n("view"),ne()}catch(c){q(`Save failed: ${c instanceof Error?c.message:String(c)}`,"error")}},[o,At,Yo,ne,q]),Ke=o?.additionalDirectories??[];if(zs((p,w)=>{if(w.escape){n("view");return}if(p==="r"){ne();return}switch(a){case"view":{if(p==="c"){n("edit-cag");return}if(p==="d"){n("edit-dirs"),T(0),r("");return}if(p==="t"){n("edit-tools");return}if(p==="o"){n("edit-oscaps");return}if(p==="x"){n("edit-exec");return}if(p==="h"){v("/channels?enabled=true").then(({channels:c})=>{Ct(c.map(A=>({name:A.name,id:A.id}))),ve(new Set(o?.allowedChannels??[])),Ce(0),n("edit-channels")}).catch(()=>q("Failed to load channels","error"));return}if(p==="p"){Tt(o?.permissionMode??"default"),f((o?.allowedBashPatterns??[]).join(", ")),P((o?.deniedBashPatterns??[]).join(", ")),de("mode"),n("edit-permissions");return}if(p==="v"){oo(0),n("edit-env");return}if(p==="i"){if(!o)return;let c=!o.inheritUserSettings;v(`/roles/${o.id}`,{method:"PATCH",body:{inheritUserSettings:c}}).then(()=>{q(`Inherit user settings: ${c?"ON":"OFF"}`,"success"),ne()}).catch(()=>q("Failed to toggle","error"));return}if(p==="R"&&o?.presetId){v(`/presets/role/${o.presetId}/restore`,{method:"POST"}).then(()=>{q("Preset restored","success"),ne()}).catch(c=>q(`Restore failed: ${c instanceof Error?c.message:String(c)}`,"error"));return}break}case"edit-cag":{if(w.ctrl&&p==="s"){dn();return}break}case"edit-dirs":{if(p==="s"){un();return}if(p==="a"){n("edit-dirs-add");return}if(p==="m"&&Ke.length>0){let c=Ke[k];if(c){x(O=>O&&{...O,additionalDirectories:O.additionalDirectories?.map((le,lt)=>lt===k?{...typeof le=="string"?{path:le}:le,mode:le.mode==="ro"?"rw":"ro"}:le)});let A=c.mode==="ro"?"rw":"ro";q(`Mode set to ${A.toUpperCase()}`,"success")}return}if(p==="x"&&Ke.length>0){x(c=>c&&{...c,additionalDirectories:Ke.filter((A,O)=>O!==k)}),T(c=>Math.max(0,Math.min(c,Ke.length-2)));return}if(w.upArrow){T(c=>Math.max(0,c-1));return}if(w.downArrow){T(c=>Math.min(Ke.length-1,c+1));return}break}case"edit-dirs-add":{if(w.escape){n("edit-dirs"),r(""),E([]);return}if(w.return&&s.length>0){let c=s[h];c&&(r(c.endsWith("/")?c:c+"/"),E([]));return}if(w.return){let c=S.trim();c&&c.startsWith("/")?(x(A=>A&&{...A,additionalDirectories:[...A.additionalDirectories??[],{path:c,mode:"rw"}]}),r(""),E([]),n("edit-dirs")):q("Path must be absolute (must start with /)","error");return}if(w.tab){let c=S.trim();if(!c||!c.startsWith("/"))return;v(`/fs/suggest-dirs?prefix=${encodeURIComponent(c)}`).then(({suggestions:A})=>{A.length===1?(r(A[0]+"/"),E([])):A.length>1&&(E(A),B(0))}).catch(()=>{E([])});return}if(w.upArrow&&s.length>0){B(c=>Math.max(0,c-1));return}if(w.downArrow&&s.length>0){B(c=>Math.min(s.length-1,c+1));return}break}case"edit-tools":{if(p==="s"){mn();return}let c=parseInt(p,10)-1;if(!isNaN(c)&&c>=0&&c<no.length){let A=no[c];Y(O=>{let le=new Set(O);return le.has(A)?le.delete(A):le.add(A),le});return}break}case"edit-oscaps":{if(p==="s"){pn();return}if(p==="a"&&At.some(O=>O.id==="automation")){let O=At.find(le=>le.id==="automation")?.targets??[];ko(O.join(", ")),n("edit-oscaps-targets");return}let c=wo.filter(O=>O.editable),A=parseInt(p,10)-1;if(!isNaN(A)&&A>=0&&A<c.length){let O=c[A];So(le=>le.some(Gt=>Gt.id===O.id)?le.filter(Gt=>Gt.id!==O.id):[...le,{id:O.id,targets:O.id==="automation"?[]:void 0}]);return}break}case"edit-oscaps-targets":{if(w.return){let c=Ho.split(",").map(A=>A.trim()).filter(Boolean);So(A=>A.map(O=>O.id==="automation"?{...O,targets:c}:O)),n("edit-oscaps");return}break}case"edit-exec":{if(p==="s"){gn();return}if(w.tab){L(c=>c==="inline"?"isolated":"inline");return}break}case"edit-permissions":{if(p==="s"){fn();return}if(w.tab){de(c=>c==="mode"?"allowed":c==="allowed"?"denied":"mode");return}if(U==="mode"&&(w.upArrow||w.downArrow)){let c=["default","acceptEdits","dontAsk","bypassPermissions"],A=c.indexOf(je);w.upArrow&&Tt(c[Math.max(0,A-1)]),w.downArrow&&Tt(c[Math.min(c.length-1,A+1)]);return}break}case"edit-channels":{if(p==="s"){if(!o)return;let c=_e.size>0?Array.from(_e):[];v(`/roles/${o.id}`,{method:"PATCH",body:{allowedChannels:c}}).then(()=>{q("Channels saved","success"),n("view"),ne()}).catch(()=>q("Save failed","error"));return}if(p==="u"){if(!o)return;v(`/roles/${o.id}`,{method:"PATCH",body:{allowedChannels:null}}).then(()=>{q("Channels: unrestricted","success"),n("view"),ne()}).catch(()=>q("Save failed","error"));return}if(p===" "){let c=Se[It];c&&ve(A=>{let O=new Set(A);return O.has(c.name)?O.delete(c.name):O.add(c.name),O});return}if(w.upArrow){Ce(c=>Math.max(0,c-1));return}if(w.downArrow){Ce(c=>Math.min(Se.length-1,c+1));return}break}case"edit-env":{let c=Object.keys(o?.envVars??{});if(p==="a"){jo(""),n("edit-env-add-key");return}if(p==="d"&&c.length>0){let A=c[wt],O={...o?.envVars??{}};delete O[A],v(`/roles/${o.id}`,{method:"PATCH",body:{envVars:O}}).then(()=>{q("Deleted","success"),ne()}).catch(()=>q("Delete failed","error")),wt>=c.length-1&&wt>0&&oo(le=>le-1);return}if(w.return&&c.length>0){Qo((o?.envVars??{})[c[wt]]??""),n("edit-env-edit-value");return}w.upArrow&&wt>0&&oo(A=>A-1),w.downArrow&&wt<c.length-1&&oo(A=>A+1);break}case"edit-env-add-key":case"edit-env-add-value":case"edit-env-edit-value":break}}),l)return b(y,{dimColor:!0,children:"Loading role..."});if(!o)return b(y,{dimColor:!0,children:"Role not found."});if(a==="edit-cag")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"CAG Prompt \u2014 Edit (Esc cancel, Ctrl+S save)"}),b(st,{value:d,onChange:g,placeholder:"Character And Guidance prompt..."}),_&&b(R,{marginTop:1,children:b(y,{color:_.type==="error"?"red":"green",children:_.text})})]});if(a==="edit-dirs-add")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Add Directory (Enter confirm, Esc cancel, Tab:complete)"}),b(st,{value:S,onChange:p=>{r(p),E([])},placeholder:"/absolute/path/to/directory"}),s.length>0&&I(R,{flexDirection:"column",marginTop:1,children:[s.map((p,w)=>I(y,{color:w===h?"cyan":void 0,dimColor:w!==h,children:[w===h?"> ":" ",p,"/"]},p)),b(y,{dimColor:!0,children:"\u2191\u2193 navigate, Enter select, Tab:confirm"})]}),_&&b(R,{marginTop:1,children:b(y,{color:_.type==="error"?"red":"green",children:_.text})})]});if(a==="edit-dirs")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Additional Directories (\u2191\u2193 navigate, a:add m:mode x:remove s:save Esc:cancel)"}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})}),Ke.length===0?b(y,{dimColor:!0,children:"No directories. Press a to add one."}):Ke.map((p,w)=>{let c=typeof p=="string"?{path:p,mode:"rw"}:p,A=c.mode!=="ro";return I(R,{children:[b(y,{color:w===k?"cyan":void 0,bold:w===k,children:w===k?"> ":" "}),I(y,{color:A?"green":"yellow",children:["[",A?"RW":"RO","]"," "]}),b(y,{color:w===k?"cyan":void 0,children:c.path})]},c.path)})]});if(a==="edit-tools")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Tool Permissions \u2014 toggle with number key (s:save Esc:cancel)"}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})}),no.map((p,w)=>{let c=H.has(p);return I(R,{children:[I(y,{dimColor:!0,children:[w+1,". "]}),b(y,{color:c?"green":"red",children:c?"[ON] ":"[OFF] "}),b(y,{children:p})]},p)})]});if(a==="edit-oscaps"){let p=wo.filter(w=>w.editable);return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"OS Capabilities \u2014 toggle with number key (a:automation targets s:save Esc:cancel)"}),Ze&&I(y,{dimColor:!0,children:["Platform: ",Ze.platform," ",Ze.available?"(sandbox active)":"(sandbox unavailable)"]}),wo.map(w=>{let c=p.findIndex(lt=>lt.id===w.id),A=At.some(lt=>lt.id===w.id),O=c>=0?`${c+1}.`:" -",le=w.id==="automation"?(()=>{let lt=At.find(Gt=>Gt.id===w.id)?.targets??[];return lt.length>0?` targets: ${lt.join(", ")}`:" targets: (none)"})():"";return I(R,{flexDirection:"column",marginBottom:1,children:[I(y,{color:A?"green":w.editable?"red":"gray",children:[O," ",A?"[ON]":"[OFF]"," ",w.label," [",w.availability,"]"]}),I(y,{dimColor:!0,children:[" ",w.description,le]}),w.effectiveDisabledReason&&!w.editable&&I(y,{dimColor:!0,children:[" ",w.effectiveDisabledReason]})]},w.id)}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})})]})}if(a==="edit-oscaps-targets")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Automation Targets (comma-separated bundle ids; Enter confirm, Esc cancel)"}),b(st,{value:Ho,onChange:ko,placeholder:"com.apple.mail, com.apple.systemevents"}),b(y,{dimColor:!0,children:"Example: com.apple.mail, com.apple.systemevents"}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})})]});if(a==="edit-exec")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Execution Config (Tab:cycle mode, Enter on field, s:save Esc:cancel)"}),I(R,{children:[b(y,{bold:!0,children:" Mode: "}),b(y,{color:"cyan",children:D}),b(y,{dimColor:!0,children:" (Tab to toggle)"})]}),I(R,{children:[b(y,{bold:!0,children:" Model: "}),b(st,{value:N,onChange:M,placeholder:"sonnet, opus, haiku, or blank"})]}),I(R,{children:[b(y,{bold:!0,children:" Max Budget (USD): "}),b(st,{value:Z,onChange:se,placeholder:"0 = unlimited"})]}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})})]});if(a==="edit-permissions")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Permission Config (Tab:cycle field, \u2191\u2193:mode, s:save, Esc:cancel)"}),I(R,{children:[b(y,{bold:!0,color:U==="mode"?"cyan":void 0,children:" Mode: "}),["default","acceptEdits","dontAsk","bypassPermissions"].map(w=>I(y,{color:w===je?"green":"gray",children:[w===je?`[${w}]`:` ${w} `," "]},w))]}),I(R,{children:[b(y,{bold:!0,color:U==="allowed"?"cyan":void 0,children:" Allowed Bash: "}),U==="allowed"?b(st,{value:$,onChange:f,placeholder:"git add *, pnpm test*"}):b(y,{children:$||"(none)"})]}),I(R,{children:[b(y,{bold:!0,color:U==="denied"?"cyan":void 0,children:" Denied Bash: "}),U==="denied"?b(st,{value:C,onChange:P,placeholder:"rm -rf *, ssh *"}):b(y,{children:C||"(none)"})]}),b(y,{dimColor:!0,children:"Patterns: comma-separated, glob syntax (* = wildcard)"}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})})]});if(a==="edit-channels")return I(R,{flexDirection:"column",children:[b(y,{bold:!0,children:"Allowed Channels (Space:toggle, u:unrestricted, s:save, Esc:cancel)"}),Se.length===0?b(y,{dimColor:!0,children:"No channels available"}):Se.map((p,w)=>I(R,{children:[I(y,{children:[w===It?">":" "," "]}),I(y,{color:_e.has(p.name)?"green":"gray",children:["[",_e.has(p.name)?"x":" ","] ",p.name]})]},p.id)),I(y,{dimColor:!0,children:["Selected: ",_e.size>0?Array.from(_e).join(", "):"none (= block all)"]}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})})]});if(a.startsWith("edit-env")){let p=Object.keys(o.envVars??{});return I(R,{flexDirection:"column",children:[I(y,{bold:!0,children:["Environment Variables (",p.length,")"]}),p.length===0&&a==="edit-env"&&b(y,{dimColor:!0,children:" No env vars. Press a to add."}),p.map((w,c)=>{let A=c===wt;return a==="edit-env-edit-value"&&A?I(R,{children:[I(y,{color:"cyan",children:["> ",w," = "]}),b(st,{value:Xo,onChange:Qo,onSubmit:()=>{let O={...o.envVars??{},[w]:Xo};v(`/roles/${o.id}`,{method:"PATCH",body:{envVars:O}}).then(()=>{q("Saved","success"),ne(),n("edit-env")}).catch(()=>q("Save failed","error"))}})]},w):I(y,{color:A&&a==="edit-env"?"cyan":"white",children:[A&&a==="edit-env"?"> ":" ",w," = ",(o.envVars??{})[w]]},w)}),a==="edit-env-add-key"&&I(R,{children:[b(y,{color:"green",children:" New key: "}),b(st,{value:ro,onChange:jo,onSubmit:()=>{ro.trim()&&(zo(""),n("edit-env-add-value"))}})]}),a==="edit-env-add-value"&&I(R,{children:[I(y,{color:"green",children:[" ",ro," = "]}),b(st,{value:Ko,onChange:zo,onSubmit:()=>{let w={...o.envVars??{},[ro.trim()]:Ko};v(`/roles/${o.id}`,{method:"PATCH",body:{envVars:w}}).then(()=>{q("Added","success"),ne(),n("edit-env")}).catch(()=>q("Add failed","error"))}})]}),b(y,{dimColor:!0,children:"a:add Enter:edit d:delete Esc:back"}),_&&b(y,{color:_.type==="error"?"red":"green",children:_.text})]})}return I(R,{flexDirection:"column",children:[I(y,{bold:!0,children:["Role: ",o.name]}),I(R,{children:[b(y,{dimColor:!0,children:"ID: "}),b(y,{children:o.id})]}),I(R,{children:[b(y,{dimColor:!0,children:"Status: "}),b(y,{color:o.status==="active"?"green":o.status==="probation"?"yellow":"red",children:o.status})]}),o.performanceScore!=null&&I(R,{children:[b(y,{dimColor:!0,children:"Score: "}),I(y,{children:[(o.performanceScore*100).toFixed(0),"%"]})]}),I(R,{children:[b(y,{dimColor:!0,children:"Created: "}),b(y,{children:new Date(o.createdAt).toLocaleString()})]}),I(R,{children:[b(y,{dimColor:!0,children:"Execution: "}),I(y,{children:[o.executionMode??"inline"," / ",o.model??"inherit"," / ",o.maxBudgetUsd!=null?`$${o.maxBudgetUsd}`:"no limit"]})]}),I(R,{children:[b(y,{dimColor:!0,children:"OS Capabilities: "}),b(y,{children:(o.osCapabilities?.length??0)>0?o.osCapabilities.map(p=>p.id==="automation"&&p.targets?.length?`automation(${p.targets.join(",")})`:p.id).join(", "):"None"})]}),Ze&&I(R,{children:[b(y,{dimColor:!0,children:"Sandbox Platform: "}),I(y,{children:[Ze.platform," ",Ze.available?"(active)":"(unavailable)"]})]}),Ke.length>0&&I(tn,{children:[b(y,{bold:!0,children:"Additional Directories:"}),Ke.map(p=>I(y,{dimColor:!0,children:[" ",p.path]},p.path))]}),I(R,{children:[b(y,{dimColor:!0,children:"Permission: "}),b(y,{children:o.permissionMode??"default"})]}),(o.allowedBashPatterns?.length??0)>0&&I(R,{children:[b(y,{dimColor:!0,children:" Bash Allow: "}),b(y,{children:o.allowedBashPatterns.join(", ")})]}),(o.deniedBashPatterns?.length??0)>0&&I(R,{children:[b(y,{dimColor:!0,children:" Bash Deny: "}),b(y,{children:o.deniedBashPatterns.join(", ")})]}),ke.length>0&&I(R,{flexDirection:"column",children:[b(y,{dimColor:!0,children:"Denied Read Paths (global):"}),ke.map(p=>I(y,{dimColor:!0,children:[" ",p]},p)),I(y,{dimColor:!0,italic:!0,children:[" (Settings ",">"," Advanced)"]})]}),I(R,{children:[b(y,{dimColor:!0,children:"Channels: "}),b(y,{children:o.allowedChannels===void 0?"Unrestricted":o.allowedChannels.length===0?"Blocked":o.allowedChannels.join(", ")})]}),I(R,{children:[b(y,{dimColor:!0,children:"Inherit User Settings: "}),b(y,{color:o.inheritUserSettings?"green":"gray",children:o.inheritUserSettings?"Yes":"No"})]}),o.learnedRules.length>0&&I(tn,{children:[b(y,{bold:!0,children:"Learned Rules:"}),o.learnedRules.map(p=>I(y,{dimColor:!0,children:[" - ",p]},p))]}),_&&b(R,{children:b(y,{color:_.type==="error"?"red":_.type==="success"?"green":"gray",children:_.text})}),b(R,{marginTop:1,children:I(y,{dimColor:!0,children:["c:CAG d:dirs t:tools o:oscaps x:exec p:perms h:channels v:env i:inherit"," ",o?.presetId?"R:restore-preset ":"","r:refresh Esc:back"]})})]})}import{jsx as Ge,jsxs as eo}from"react/jsx-runtime";function rn({onBack:e}){let[t,o]=Jt([]),[x,m]=Jt(!0),[u,l]=Jt(0),[i,a]=Jt("list"),[n,d]=Jt(null),{message:g,setMessage:k,clearMessage:T}=Ue(),S=Zs(()=>{m(!0),v("/roles").then(({roles:r})=>{o(r.map(s=>({id:s.id,name:s.name,status:s.status,performanceScore:s.performanceScore,createdAt:s.createdAt,presetId:s.presetId}))),m(!1)}).catch(()=>m(!1))},[]);return Ys(()=>{S()},[S]),Qs((r,s)=>{if(s.escape||r==="q"){e();return}if(s.upArrow){l(E=>Math.max(0,E-1));return}if(s.downArrow){l(E=>Math.min(t.length-1,E+1));return}if(r==="r"&&(S(),T()),r===`
|
|
11
|
+
`||r==="o"||r==="e"){t.length>0&&(d(t[u].id),a("detail"));return}}),x?Ge(it,{dimColor:!0,children:"Loading roles..."}):i==="detail"&&n?Ge(on,{roleId:n,onBack:()=>a("list")}):eo(Vt,{flexDirection:"column",children:[eo(it,{bold:!0,children:["Roles (",t.length,") (Esc to go back)"]}),g&&Ge(Vt,{marginTop:1,children:eo(it,{color:g.type==="success"?"green":g.type==="error"?"red":"gray",children:[g.type==="success"?"\u2713 ":g.type==="error"?"\u2717 ":"\u2192 ",g.text]})}),t.length===0?Ge(Vt,{marginTop:1,children:Ge(it,{dimColor:!0,children:"No roles found. Roles define agent behavior and bind plugins."})}):Ge(Vt,{marginTop:1,flexDirection:"column",children:t.map((r,s)=>{let E=s===u,h=r.performanceScore!=null?`${(r.performanceScore*100).toFixed(0)}%`:"\u2014";return eo(Vt,{children:[Ge(it,{color:E?"cyan":void 0,bold:E,children:E?"> ":" "}),Ge(it,{color:E?"cyan":void 0,bold:E,children:Uo(r.name,24)}),r.presetId&&eo(it,{dimColor:!0,children:["[",r.presetId,"]"]}),Ge(it,{color:Js(r.status),children:Uo(r.status,12)}),Ge(it,{dimColor:!0,children:Uo(h,8)})]},r.id)})}),Ge(Vt,{marginTop:1,children:Ge(it,{dimColor:!0,children:"Enter/O/E:open Esc:back r:refresh"})})]})}function Js(e){return e==="active"?"green":e==="probation"?"yellow":e==="retired"||e==="dead"?"red":"gray"}function Uo(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}import{Box as ei,Text as Wo}from"ink";import ti from"react";import{jsx as yo,jsxs as ri}from"react/jsx-runtime";var Ne={key:"Esc",label:"back"},oi={work:[{key:"1",label:"tasks"},{key:"2",label:"automations"},{key:"3",label:"goals"},Ne],tasks:[{key:"\u2191\u2193",label:"move"},{key:"Enter",label:"detail"},{key:"x",label:"cancel"},{key:"f",label:"filter"},{key:"r",label:"refresh"},Ne],config:[Ne],evolution:[Ne],goals:[{key:"c",label:"create"},{key:"r",label:"refresh"},Ne],strategies:[Ne],templates:[{key:"\u2191\u2193",label:"move"},{key:"t",label:"run"},{key:"s",label:"toggle"},{key:"e",label:"edit"},{key:"c",label:"create"},{key:"d",label:"delete"},{key:"r",label:"refresh"},Ne],webhooks:[Ne],memories:[Ne],plugins:[{key:"\u2191\u2193",label:"move"},{key:"r",label:"refresh"},Ne],roles:[Ne],settings:[Ne],channels:[Ne]};function nn(){let{state:e}=Je(),t=oi[e.view]??[Ne];return yo(ei,{borderStyle:"round",borderDimColor:!0,paddingX:1,children:t.map((o,x)=>ri(ti.Fragment,{children:[x>0&&yo(Wo,{dimColor:!0,children:" "}),yo(Wo,{color:"cyan",children:o.key}),yo(Wo,{dimColor:!0,children:` ${o.label}`})]},`${o.key}-${o.label}`))})}import{Box as qt,Text as He,useInput as ni}from"ink";import{useEffect as si,useState as bo,useCallback as ii}from"react";import{jsx as pt,jsxs as ft}from"react/jsx-runtime";function sn({onBack:e}){let[t,o]=bo([]),[x,m]=bo(!0),[u,l]=bo(0),[i,a]=bo("all"),{message:n,setMessage:d}=Ue(),g=ii(()=>{m(!0);let s=i!=="all"?`?status=${i}`:"";v(`/feature-requests${s}`).then(({featureRequests:E})=>{o(E),l(0),m(!1)}).catch(()=>m(!1))},[i]);si(()=>{g()},[g]);let k=async(s,E)=>{try{await v(`/feature-requests/${s}/status`,{method:"PATCH",body:{status:E}}),d(`Marked as ${E}`,"success"),await g()}catch(h){d(`Failed: ${h instanceof Error?h.message:String(h)}`,"error")}},T=t;ni((s,E)=>{if(E.escape||s==="q"){e();return}if(E.upArrow){l(B=>Math.max(0,B-1));return}if(E.downArrow){l(B=>Math.min(T.length-1,B+1));return}if(s==="r"){g();return}let h={0:"all",1:"new",2:"reviewed",3:"dismissed",4:"converted"};if(h[s]){a(h[s]);return}if(s==="s"&&T.length>0){let B=T[u];if(B&&B.status==="new"){k(B.id,"reviewed");return}}if(s==="d"&&T.length>0){let B=T[u];if(B){k(B.id,"dismissed");return}}if(s==="c"&&T.length>0){let B=T[u];if(B){k(B.id,"converted");return}}});let S=s=>s==="new"?"cyan":s==="reviewed"?"green":s==="dismissed"?"gray":s==="converted"?"yellow":"white",r=s=>{let E=Date.now()-s;if(Math.floor(E/6e4)<1)return"now";let B=Math.floor(E/36e5);return B<24?`${B}h ago`:`${Math.floor(B/24)}d ago`};return ft(qt,{flexDirection:"column",children:[ft(He,{bold:!0,children:["Feature Requests (",T.length,") (Esc:back q:quit r:refresh)"]}),n&&pt(qt,{marginTop:1,children:ft(He,{color:n.type==="error"?"red":"green",children:[n.type==="success"?"\u2713 ":"\u2717 ",n.text]})}),pt(He,{dimColor:!0,children:"Filters: 0=all 1=new 2=reviewed 3=dismissed 4=converted"}),pt(He,{dimColor:!0,children:"Actions: s=reviewed d=dismissed c=converted"}),x?pt(He,{dimColor:!0,children:"Loading..."}):T.length===0?pt(He,{dimColor:!0,children:"No feature requests found."}):pt(qt,{marginTop:1,flexDirection:"column",children:T.map((s,E)=>{let h=E===u,B=s.content.length>80?s.content.slice(0,80)+"...":s.content;return ft(qt,{flexDirection:"column",children:[ft(qt,{children:[pt(He,{color:h?"cyan":void 0,bold:h,children:h?"> ":" "}),ft(He,{color:S(s.status),children:["[",s.status,"]"]}),ft(He,{dimColor:!0,children:[" ",r(s.extractedAt)]}),s.tags&&s.tags.length>0&&ft(He,{dimColor:!0,children:[" ",s.tags.slice(0,3).join(", ")]})]}),ft(qt,{paddingLeft:4,flexDirection:"column",children:[s.summary&&pt(He,{color:h?"cyan":"white",children:s.summary}),pt(He,{dimColor:!0,children:B})]})]},s.id)})})]})}import{Box as Ft,Text as qe,useInput as ai}from"ink";import{useEffect as li,useState as vo,useCallback as ci}from"react";import{jsx as xt,jsxs as at}from"react/jsx-runtime";function an({onBack:e}){let[t,o]=vo([]),[x,m]=vo(!0),[u,l]=vo(0),[i,a]=vo("all"),{message:n,setMessage:d}=Ue(),g=ci(()=>{m(!0);let r=i!=="all"?`?status=${i}`:"";v(`/mistake-patterns${r}`).then(({mistakePatterns:s})=>{o(s),l(0),m(!1)}).catch(()=>m(!1))},[i]);li(()=>{g()},[g]);let k=async(r,s)=>{try{await v(`/mistake-patterns/${r}`,{method:"PATCH",body:{status:s}}),d(`Marked as ${s}`,"success"),await g()}catch(E){d(`Failed: ${E instanceof Error?E.message:String(E)}`,"error")}};ai((r,s)=>{if(s.escape||r==="q"){e();return}if(s.upArrow){l(h=>Math.max(0,h-1));return}if(s.downArrow){l(h=>Math.min(t.length-1,h+1));return}if(r==="r"){g();return}let E={0:"all",1:"new",2:"acknowledged",3:"dismissed"};if(E[r]){a(E[r]);return}if(r==="a"&&t.length>0){let h=t[u];if(h&&h.status!=="acknowledged"){k(h.id,"acknowledged");return}}if(r==="d"&&t.length>0){let h=t[u];if(h&&h.status!=="dismissed"){k(h.id,"dismissed");return}}if(r==="n"&&t.length>0){let h=t[u];if(h&&h.status!=="new"){k(h.id,"new");return}}});let T=r=>r==="new"?"cyan":r==="acknowledged"?"green":r==="dismissed"?"gray":"white",S=r=>{let s=Date.now()-r;if(Math.floor(s/6e4)<1)return"now";let h=Math.floor(s/36e5);return h<24?`${h}h ago`:`${Math.floor(h/24)}d ago`};return at(Ft,{flexDirection:"column",children:[at(qe,{bold:!0,children:["Mistake Patterns (",t.length,") (Esc:back q:quit r:refresh)"]}),n&&xt(Ft,{marginTop:1,children:at(qe,{color:n.type==="error"?"red":"green",children:[n.type==="success"?"\u2713 ":"\u2717 ",n.text]})}),xt(qe,{dimColor:!0,children:"Filters: 0=all 1=new 2=acknowledged 3=dismissed"}),xt(qe,{dimColor:!0,children:"Actions: a=acknowledge d=dismiss n=mark new"}),x?xt(qe,{dimColor:!0,children:"Loading..."}):t.length===0?xt(qe,{dimColor:!0,children:"No mistake patterns found."}):xt(Ft,{marginTop:1,flexDirection:"column",children:t.map((r,s)=>{let E=s===u,h=r.dimensionValue.length>80?r.dimensionValue.slice(0,80)+"...":r.dimensionValue;return at(Ft,{flexDirection:"column",children:[at(Ft,{children:[xt(qe,{color:E?"cyan":void 0,bold:E,children:E?"> ":" "}),at(qe,{color:T(r.status),children:["[",r.status,"]"]}),at(qe,{dimColor:!0,children:[" ",S(r.lastSeen)]}),at(qe,{dimColor:!0,children:[" [",r.dimensionType,"]"]}),at(qe,{dimColor:!0,children:[" ",r.roleIds.length," role(s)"]}),at(qe,{dimColor:!0,children:[" x",r.count]})]}),xt(Ft,{paddingLeft:4,flexDirection:"column",children:xt(qe,{color:E?"cyan":"white",children:h})})]},r.id)})})]})}import{Fragment as pi,jsx as z,jsxs as Wt}from"react/jsx-runtime";function mi(){let{state:e,dispatch:t}=Je(),{session:o,sendMessage:x,createNewSession:m,archiveCurrentSession:u}=lr(),[l,i]=ui([]);Co(()=>{t({type:"SET_SESSION",session:o})},[o,t]),sr();let{latestMessage:a}=dr(o?.id??null),n=Go(null);Co(()=>{a&&a.id!==n.current&&(n.current=a.id,i(B=>[...B,{role:"assistant",content:a.content}]))},[a]);let{events:d,isStreaming:g,clearEvents:k}=ar(e.activeTaskId),T=d[d.length-1],S=T?.type==="complete"&&!g,r=Go(null),s=Go("");Co(()=>{s.current=d.filter(B=>B.type==="reasoning").map(B=>B.content).join("")},[d]),Co(()=>{if(S&&e.activeTaskId!==r.current){r.current=e.activeTaskId;let B=T?.content||s.current;B&&i(H=>[...H,{role:"assistant",content:B}])}},[S,T,e.activeTaskId]);let E=async B=>{let H=B.trim().toLowerCase();if(["quit","exit","/quit","/exit"].includes(H)&&process.exit(0),B.startsWith("/")){let D=B.slice(1),N={work:"work",tasks:"tasks",config:"config",evolution:"evolution",templates:"templates",memories:"memories",goals:"goals",strategies:"strategies",roles:"roles",settings:"settings",channels:"channels",plugins:"plugins","feature-requests":"featureRequests",mistakes:"mistakes",back:"chat"}[D];if(N){t({type:"SET_VIEW",view:N});return}if(D==="new"){if(await u()){let Z=await m();i([]),k(),Z&&i([{role:"assistant",content:`Session archived. New session started: ${Z.id.slice(0,8)}`}])}return}if(D==="session"){let M=o?`Session: ${o.id}
|
|
12
|
+
Turns: ${o.messageCount}
|
|
13
|
+
Last active: ${new Date(o.lastActiveAt).toLocaleString()}`:"No active session";i(Z=>[...Z,{role:"assistant",content:M}]);return}}if(i(D=>[...D,{role:"user",content:B}]),k(),!await x(B)){i(D=>[...D,{role:"assistant",content:"Failed to send message. Server may be disconnected."}]);return}},h=e.view==="chat"&&!e.pendingPlanApproval&&!e.pendingApproval;return Wt(to,{flexDirection:"column",paddingX:1,children:[z(mr,{}),Wt(to,{flexGrow:1,flexDirection:"column",paddingY:1,children:[e.view==="chat"&&Wt(pi,{children:[z(hr,{messages:l}),z(pr,{events:d,isStreaming:g}),!e.connected&&!e.serverUnreachable&&z(to,{children:z(Ut,{color:"red",children:"Server disconnected. Attempting to reconnect..."})}),e.serverUnreachable&&Wt(to,{flexDirection:"column",children:[z(Ut,{color:"red",bold:!0,children:"Server unreachable after 15s."}),z(Ut,{dimColor:!0,children:"Check: adam server logs"}),z(Ut,{dimColor:!0,children:"Type /quit to exit."})]})]}),e.view==="work"&&z(Yr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="tasks"&&z(go,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="config"&&z(Rr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="evolution"&&z(_r,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="goals"&&z(po,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="strategies"&&z(Or,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="templates"&&z(To,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="webhooks"&&z(Ur,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="memories"&&z(Hr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="plugins"&&z(Xr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="roles"&&z(rn,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="featureRequests"&&z(sn,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="mistakes"&&z(an,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="settings"&&z(zr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="channels"&&z(Jr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})})]}),e.pendingPlanApproval?z(br,{approval:e.pendingPlanApproval,onResolved:()=>t({type:"SET_PENDING_PLAN_APPROVAL",approval:null}),onTimeout:()=>t({type:"SET_PLAN_TIMEOUT_NOTICE",planId:e.pendingPlanApproval.planId})}):e.pendingApproval?z(yr,{approval:e.pendingApproval,onResolved:()=>t({type:"SET_PENDING_APPROVAL",approval:null})}):h?z(fr,{onSubmit:E}):z(nn,{}),e.planTimeoutNotice&&z(gi,{planId:e.planTimeoutNotice.planId,onDismiss:()=>t({type:"SET_PLAN_TIMEOUT_NOTICE",planId:null})})]})}function gi({planId:e,onDismiss:t}){return di(o=>{o==="d"&&t()}),Wt(to,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:[Wt(Ut,{color:"yellow",children:["Plan ",e," was auto-denied after 300s timeout."]}),z(Ut,{dimColor:!0,children:" [d] Dismiss"})]})}function fi(){return z(or,{children:z(mi,{})})}export{fi as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as a,B as b,C as c}from"./chunk-56QP5ZHF.js";import"./chunk-UYOLAFUR.js";import"./chunk-KO7XBNPV.js";import"./chunk-6M2QCKAS.js";import"./chunk-W7U3ASGR.js";import"./chunk-PFYYS7CI.js";import"./chunk-SWP2JC54.js";import"./chunk-TTP7QRAQ.js";import"./chunk-LV4XLPCD.js";import"./chunk-UQDC3X6O.js";import"./chunk-YKMWAVUH.js";import"./chunk-C2SD2NMZ.js";import"./chunk-S6OV7Z6K.js";import"./chunk-DKMF4B33.js";import"./chunk-OY2KVSIX.js";import"./chunk-IZ3WZHCM.js";import"./chunk-QMW7VEPC.js";import"./chunk-MYVYH4PQ.js";import"./chunk-6XVWIRR2.js";import"./chunk-L7JP7DUO.js";import"./chunk-VPZSOYE5.js";import"./chunk-5AUQIK3Q.js";import"./chunk-YVVKUPGL.js";import"./chunk-7IFLU3CY.js";import"./chunk-OFTIPZTH.js";import"./chunk-YWUX3ZTO.js";import"./chunk-XTOOD44S.js";import"./chunk-7F4SZXI2.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{c as createAdamTools,b as getToolsFingerprint,a as resolveDeliveryTargets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-3HZE5DQZ.js";import"./chunk-KUJFQDT5.js";import"./chunk-IZ3WZHCM.js";import"./chunk-L7JP7DUO.js";import"./chunk-ARQF52V6.js";import"./chunk-7F4SZXI2.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{b as formatPlanForChannel,e as getPendingApprovalRequestIds,d as handleInboundForApproval,a as parseApprovalReply,c as sendApprovalToChannel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{q as a,r as b,s as c,t as d,u as e}from"./chunk-3IQADR6L.js";import"./chunk-KO7XBNPV.js";import"./chunk-QPIWPQWM.js";import"./chunk-6M2QCKAS.js";import"./chunk-PFYYS7CI.js";import"./chunk-SWP2JC54.js";import"./chunk-LV4XLPCD.js";import"./chunk-UQDC3X6O.js";import"./chunk-N4ES7TCL.js";import"./chunk-C2SD2NMZ.js";import"./chunk-S6OV7Z6K.js";import"./chunk-DKMF4B33.js";import"./chunk-OY2KVSIX.js";import"./chunk-QMW7VEPC.js";import"./chunk-MYVYH4PQ.js";import"./chunk-6XVWIRR2.js";import"./chunk-L7JP7DUO.js";import"./chunk-ARQF52V6.js";import"./chunk-HSEP6LNQ.js";import"./chunk-VPZSOYE5.js";import"./chunk-OFTIPZTH.js";import"./chunk-YWUX3ZTO.js";import"./chunk-XTOOD44S.js";import"./chunk-7F4SZXI2.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as evaluateTaskCompletion,e as getSecurityPosture,d as reportViolation,b as startAuditManager,c as stopAuditManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a,c as b,d as c}from"./chunk-J4Y54LIC.js";import"./chunk-TTP7QRAQ.js";import"./chunk-LV4XLPCD.js";import"./chunk-UQDC3X6O.js";import"./chunk-XIQVXRZH.js";import"./chunk-YKMWAVUH.js";import"./chunk-N4ES7TCL.js";import"./chunk-C2SD2NMZ.js";import"./chunk-S6OV7Z6K.js";import"./chunk-DKMF4B33.js";import"./chunk-OY2KVSIX.js";import"./chunk-KUJFQDT5.js";import"./chunk-IZ3WZHCM.js";import"./chunk-6XVWIRR2.js";import"./chunk-L7JP7DUO.js";import"./chunk-ARQF52V6.js";import"./chunk-VPZSOYE5.js";import"./chunk-5AUQIK3Q.js";import"./chunk-YVVKUPGL.js";import"./chunk-7IFLU3CY.js";import"./chunk-OFTIPZTH.js";import"./chunk-YWUX3ZTO.js";import"./chunk-XTOOD44S.js";import"./chunk-7F4SZXI2.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as BreeEngine,b as getBreeEngine,c as setBreeEngine};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as a,d as b,e as c}from"./chunk-7WJF65TQ.js";import"./chunk-UQDC3X6O.js";import"./chunk-IZ3WZHCM.js";import"./chunk-7F4SZXI2.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{c as channelRoutes,b as getChannelManager,a as setChannelManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f}from"./chunk-IZ3WZHCM.js";import"./chunk-7F4SZXI2.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as createChannel,e as deleteChannel,b as getChannel,d as listChannels,c as updateChannel,f as updateChannelStatus};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as f}from"./chunk-
|
|
1
|
+
import{b as f}from"./chunk-KUJFQDT5.js";import{b as m}from"./chunk-IZ3WZHCM.js";import{c as h,h as v}from"./chunk-MRTJFYPR.js";v();var p=h("channels"),u=new Map,I=3e5,A=new Set(["telegram"]);function w(i){let e=i.trim().toLowerCase().match(/^(yes|y|是|允许|no|n|否|拒绝)\s+(\S+)$/);if(!e)return null;let[,c,l]=e,o=["yes","y","\u662F","\u5141\u8BB8"].includes(c);return{requestId:l,decision:o?"allow":"deny"}}function $(i){let n=m(i);return n?A.has(n.platform):!1}var T={low:"\u{1F7E2}",medium:"\u{1F7E1}",high:"\u{1F534}"},P={low:"\u4F4E",medium:"\u4E2D",high:"\u9AD8"};function k(i){let n=["\u{1F512} \u9700\u8981\u5BA1\u6279",""];for(let e of i.steps){if(e.description.startsWith("Execute task without OS sandbox"))n.push("\u26A0\uFE0F \u65E0\u6C99\u7BB1\u6267\u884C \u2014 \u6587\u4EF6\u7CFB\u7EDF\u9694\u79BB\u672A\u542F\u7528");else{let o=e.description.indexOf(": "),r=o>0?e.description.slice(0,o):"Operation";if(n.push(`\u64CD\u4F5C: ${r}`),r==="Bash"&&o>0)try{let t=JSON.parse(e.description.slice(o+2));if(t.command){let s=String(t.command).trim();n.push(`\u547D\u4EE4: ${s.length>120?s.slice(0,117)+"...":s}`)}}catch{let t=e.description.slice(o+2,o+122);n.push(`\u8BE6\u60C5: ${t}${e.description.length>o+122?"...":""}`)}else if(o>0){let t=e.description.slice(o+2,o+122);n.push(`\u8BE6\u60C5: ${t}${e.description.length>o+122?"...":""}`)}}let c=T[e.riskLevel]??"\u{1F7E1}",l=P[e.riskLevel]??e.riskLevel;n.push(`\u98CE\u9669: ${c} ${l}`),n.push("")}return n.join(`
|
|
2
2
|
`).trimEnd()}async function C(i,n,e,c,l,o=I){let r=e,t=r.slice(0,8);u.set(t,{planId:e,taskId:c,channelId:i,chatId:n,requestId:r,timestamp:Date.now(),timeoutMs:o});let s=f(),d=$(i);if(d){let a=`${l}
|
|
3
3
|
|
|
4
4
|
`;await s.send({channelId:i,chatId:n,content:a,messageType:"approval",replyMarkup:{inlineKeyboard:[[{text:"\u2705 Allow",callbackData:`yes ${t}`},{text:"\u274C Deny",callbackData:`no ${t}`}]]}})}else{let a=[l,"",`Reply 'yes ${t}' or 'no ${t}'`].join(`
|