adam-agent-server 0.5.0 → 1.0.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 +2 -4
- package/dist/App-SCPYTYGQ.js +9 -0
- package/dist/adam-tools-FNJJT7AA.js +1 -0
- package/dist/{approval-handler-HK7GQPHU.js → approval-handler-UDWAC5MF.js} +2 -2
- package/dist/audit-manager-SCX53YJT.js +1 -0
- package/dist/bree-engine-2DB2QECM.js +1 -0
- package/dist/channels-NAPXRIOX.js +1 -0
- package/dist/channels-PQCV74ZI.js +1 -0
- package/dist/{chunk-2GXYBWLS.js → chunk-2C5U3CNX.js} +1 -1
- package/dist/chunk-2CMR5AG7.js +1 -0
- package/dist/chunk-35DBEYMG.js +49 -0
- package/dist/chunk-3TIHZZMK.js +1 -0
- package/dist/{chunk-VF6GJGD6.js → chunk-42RHY3Q3.js} +1 -1
- package/dist/{chunk-742NWPTQ.js → chunk-4TBGFHYX.js} +1 -1
- package/dist/chunk-5V36ACKZ.js +1 -0
- package/dist/{chunk-PQ7KPALO.js → chunk-64FIXWFL.js} +1 -1
- package/dist/chunk-6KLG4APZ.js +1 -0
- package/dist/chunk-6VPL5CXB.js +4 -0
- package/dist/{chunk-T7WVM27S.js → chunk-7KCBFM2C.js} +6 -6
- package/dist/chunk-BCELBB5Q.js +3 -0
- package/dist/{chunk-5ASEAZCR.js → chunk-BONI2HUN.js} +1 -1
- package/dist/chunk-CFTWJZVX.js +67 -0
- package/dist/{chunk-PCSZW2PE.js → chunk-CREHL4BN.js} +7 -7
- package/dist/chunk-FXFHGIY6.js +8 -0
- package/dist/{chunk-KICPHTI2.js → chunk-GA7GEIXB.js} +1 -1
- package/dist/{chunk-HAWA62R2.js → chunk-I5RUEOSQ.js} +1 -1
- package/dist/chunk-INNDBLZE.js +1 -0
- package/dist/chunk-IZQI6QQ7.js +1 -0
- package/dist/{chunk-WXN3PSVX.js → chunk-KHPXEUSY.js} +1 -1
- package/dist/{chunk-IXF3XBGX.js → chunk-NFSXJNPD.js} +1 -1
- package/dist/chunk-NQHTOFQP.js +1 -0
- package/dist/{chunk-B6S2AEOD.js → chunk-PT55643Q.js} +1 -1
- package/dist/chunk-QC6QVNKP.js +83 -0
- package/dist/chunk-QMKQBU3R.js +2 -0
- package/dist/chunk-REKCZ3GY.js +1 -0
- package/dist/{chunk-L7426WNY.js → chunk-ROSOI75V.js} +1 -1
- package/dist/{chunk-FDWW245P.js → chunk-TEMWI6U5.js} +1 -1
- package/dist/{chunk-U36NBCR3.js → chunk-U3XVAAXA.js} +1 -1
- package/dist/chunk-VRP4LTHY.js +1 -0
- package/dist/chunk-WBAPIPST.js +1 -0
- package/dist/{chunk-AXMXXUPO.js → chunk-X26NKAXY.js} +1 -1
- package/dist/{chunk-TN6H2WM2.js → chunk-XFTRKHH2.js} +3 -3
- package/dist/{chunk-FUGJMHY4.js → chunk-YEV5YTS3.js} +1 -1
- package/dist/cli.js +4 -4
- package/dist/config-L4R273R3.js +1 -0
- package/dist/config-N2GMLTPU.js +1 -0
- package/dist/db-S6HDMJ3B.js +1 -0
- package/dist/delivery-log-VAI35G5V.js +1 -0
- package/dist/engine-E67UAI3G.js +1 -0
- package/dist/evolution-audit-KCFDGNSM.js +1 -0
- package/dist/external-api-I6CENLIS.js +1 -0
- package/dist/index.js +12 -57
- package/dist/learner-ABYVK33T.js +1 -0
- package/dist/logger-QCJUU7GV.js +1 -0
- package/dist/memories-3ZAV55YZ.js +1 -0
- package/dist/{memory-extractor-GOISDQTO.js → memory-extractor-BHHKD7X7.js} +2 -2
- package/dist/memory-service-5QHTKIUU.js +1 -0
- package/dist/outbound-gateway-ZFKSN2UT.js +1 -0
- package/dist/role-presets-OTU2M37Y.js +1 -0
- package/dist/roles-LXRHEVUK.js +1 -0
- package/dist/{runtime-6UTYEONR.js → runtime-UCOE6LNN.js} +1 -1
- package/dist/session-manager-RPXFZKMY.js +1 -0
- package/dist/task-templates-XQNKAA4U.js +1 -0
- package/package.json +1 -1
- package/web/dist/assets/{ChannelDetail-dZfZlLgQ.js → ChannelDetail-BajTUEU0.js} +1 -1
- package/web/dist/assets/{Channels-Cw04c7YJ.js → Channels-Bhy6rP_t.js} +1 -1
- package/web/dist/assets/{Chat-D4PHqHPE.js → Chat-Dvt_Oo7d.js} +1 -1
- package/web/dist/assets/{Dashboard-BFewwmAg.js → Dashboard-DlrAor-C.js} +1 -1
- package/web/dist/assets/{Evolution-DY1OC6Oc.js → Evolution-Dlsnnr4G.js} +1 -1
- package/web/dist/assets/{GoalDetail-DZIEpHs2.js → GoalDetail-BuUxwYdd.js} +1 -1
- package/web/dist/assets/{Goals-COCCVLnp.js → Goals-CkPQOev6.js} +1 -1
- package/web/dist/assets/{Logs-DsDeimLt.js → Logs-D33PqDAd.js} +1 -1
- package/web/dist/assets/{Memories-D5IEEI1u.js → Memories-D31dbUM6.js} +1 -1
- package/web/dist/assets/{Plugins-DUwZVjPc.js → Plugins-XlBr07x8.js} +1 -1
- package/web/dist/assets/RoleDetail-rZFlgXzh.js +33 -0
- package/web/dist/assets/{Roles-JeVjD0Ew.js → Roles-d29AC6Kh.js} +1 -1
- package/web/dist/assets/Settings-Bjh_RXYf.js +1 -0
- package/web/dist/assets/{Strategies-KAmpqrcQ.js → Strategies-Cf4ghknk.js} +1 -1
- package/web/dist/assets/{Switch-Jpdn6Yux.js → Switch-CxzUYL49.js} +1 -1
- package/web/dist/assets/{TaskDetail-C4NpqwNT.js → TaskDetail-jMBJbaRU.js} +1 -1
- package/web/dist/assets/{Work-DhaxNYnd.js → Work-CCLTkitf.js} +1 -1
- package/web/dist/assets/index-CVubgAlC.css +2 -0
- package/web/dist/assets/{index-CfKqiQIe.js → index-Ds41VvOC.js} +2 -2
- package/web/dist/index.html +2 -2
- package/dist/App-XZABZ2AF.js +0 -9
- package/dist/adam-tools-BB7WQGVT.js +0 -1
- package/dist/bree-engine-25VACELK.js +0 -1
- package/dist/channels-JEBBMFUQ.js +0 -1
- package/dist/channels-VEUBY2NZ.js +0 -1
- package/dist/chunk-3DAK2XWP.js +0 -1
- package/dist/chunk-5JLMSNIW.js +0 -1
- package/dist/chunk-7SPKRIMZ.js +0 -15
- package/dist/chunk-BREBCBG4.js +0 -49
- package/dist/chunk-D6WM2OQS.js +0 -86
- package/dist/chunk-DWMMWYLD.js +0 -1
- package/dist/chunk-ETQ7KC73.js +0 -1
- package/dist/chunk-FYDFMYUP.js +0 -1
- package/dist/chunk-JXD6ZPV7.js +0 -2
- package/dist/chunk-NSJAV7IH.js +0 -1
- package/dist/chunk-NXTTKAQX.js +0 -3
- package/dist/chunk-SFUS33SO.js +0 -1
- package/dist/chunk-T25NLVMY.js +0 -1
- package/dist/chunk-URW2DJQF.js +0 -1
- package/dist/chunk-WZOMGJSY.js +0 -1
- package/dist/chunk-XNWZZYAV.js +0 -7
- package/dist/config-WHXCZCI4.js +0 -1
- package/dist/config-Y4QWELO3.js +0 -1
- package/dist/db-PNZ3UJOE.js +0 -1
- package/dist/delivery-log-VYTYUFCK.js +0 -1
- package/dist/engine-3PNNEZNK.js +0 -1
- package/dist/evolution-audit-B7WKMOVR.js +0 -1
- package/dist/external-api-XGEOKAWR.js +0 -1
- package/dist/learner-VMD5NQCD.js +0 -1
- package/dist/logger-BEG4WFIM.js +0 -1
- package/dist/memories-EFQ4SFZG.js +0 -1
- package/dist/memory-service-BKLZIRK6.js +0 -1
- package/dist/monitor-K7CGTLA6.js +0 -1
- package/dist/outbound-gateway-DZTXBUTP.js +0 -1
- package/dist/role-presets-FN2RWUCP.js +0 -1
- package/dist/roles-SG2YAR64.js +0 -1
- package/dist/session-manager-45LFTPBA.js +0 -1
- package/dist/task-templates-7LSQ6OST.js +0 -1
- package/web/dist/assets/RoleDetail-B-GKMfMG.js +0 -33
- package/web/dist/assets/Settings-CvEyZp5t.js +0 -1
- package/web/dist/assets/index-LDFr0VVR.css +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as l,e as D,f as S,g as $}from"./chunk-NFSXJNPD.js";import{b as h}from"./chunk-X26NKAXY.js";import{b as u}from"./chunk-ROSOI75V.js";import{a as R,c as T,f as C}from"./chunk-U3XVAAXA.js";import{e as k,g as x,k as N}from"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import{c as d,h as y}from"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";y();var w=d("agent");function I(n){let o=l(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=h(n,1e3),s=o.plan.steps,a=i.filter(e=>e.type==="tool_result"||e.type==="permission_denied").map(e=>({toolName:e.toolName??"unknown",output:e.content,planStepIndex:e.planStepIndex,permissionDenied:e.type==="permission_denied"})),t=[],r=new Set(a.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of s)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let c=a.filter(e=>e.planStepIndex===void 0);for(let e of c)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let b=a.filter(e=>e.permissionDenied);for(let e of b)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?s.find(E=>E.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let p=s.length,m=a.length,g=p>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/p):1,v={stepsPlanned:p,stepsExecuted:m,deviations:t,overallAccuracy:g};return S(o.id,v),w.info({taskId:n,planId:o.id,stepsPlanned:p,stepsExecuted:m,deviationCount:t.length,accuracy:g},"Deviation report generated"),v}function P(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}N();C();y();var f=d("agent");function L(n,o){let i=[],a=u(n)?.prompt.slice(0,100)??"unknown task";P(o)&&i.push(`[+] Task "${a}" completed successfully with ${o.overallAccuracy*100}% plan accuracy (${o.stepsExecuted} steps). [sourceTaskId:${n}]`);for(let t of o.deviations)switch(t.deviationType){case"skipped":i.push(`[-] Planned step "${t.planned}" was skipped during "${a}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${a}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${a}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${a}". [sourceTaskId:${n}]`);break}return i}async function z(n){let o=l(n);if(!o){f.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let s=L(n,i);if(s.length===0)return;$(o.id,s);let a=u(n);if(a?.roleId){let t=k(a.roleId);if(t){let r=[...t.learnedRules,...s];x(a.roleId,{learnedRules:r});let c=R(t.name);T(c,{...t,learnedRules:r}),f.info({roleId:a.roleId,newRulesCount:s.length},"Role learnedRules updated and CLAUDE.md written")}}D(o.id,"completed"),f.info({taskId:n,planId:o.id,rulesExtracted:s.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{L as extractRulesFromDeviation,z as processTaskReview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";h();export{g as getComponentFilter,e as getLogLevel,c as getLogger,b as logger,a as onLogEvent,f as setComponentFilter,d as setLogLevel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-I5RUEOSQ.js";import"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";export{o as DEFAULT_HYBRID_CONFIG,k as DEFAULT_SCORING_WEIGHTS,l as calculateRecency,m as calculateSmallvilleScore,p as cleanupMemories,f as countMemoriesByRole,a as createMemory,j as deleteMemory,b as getMemory,n as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,i as searchByBM25,h as searchByVector,q as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as v}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-PT55643Q.js";import{a as w}from"./chunk-5V36ACKZ.js";import{b as g}from"./chunk-X26NKAXY.js";import{a as p}from"./chunk-2CMR5AG7.js";import{a as l,g as h}from"./chunk-I5RUEOSQ.js";import"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import{b as u,d as M}from"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import{c as y,h as b}from"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";b();M();import{v4 as $}from"uuid";var x=y("manager"),d=150,C=50;function N(e){return u().prepare("SELECT importance_trigger_curr FROM roles WHERE id = ?").get(e)?.importance_trigger_curr??d}function f(e,t){u().prepare("UPDATE roles SET importance_trigger_curr = ? WHERE id = ?").run(t,e)}function _(e,t){let r=N(e)-t;return f(e,r),r<=0}async function S(e){let t=h(e,C,0);if(t.length===0){f(e,d);return}let r=`Based on these recent experiences, what are the key insights and patterns?
|
|
2
2
|
|
|
3
3
|
${t.slice(0,20).map((c,m)=>`${m+1}. [${c.type}] (importance: ${c.importance}) ${c.content}`).join(`
|
|
4
4
|
`)}
|
|
5
5
|
|
|
6
|
-
Provide 1-3 high-level insights.`,o;try{o=(await w(r,"You are an agent self-reflection system. Analyze the experiences and produce concise, actionable insights. Respond with 1-3 high-level insights, each on its own line.")).trim()||E(t)}catch{o=E(t)}let i;try{i=await p(o)}catch{}let a=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(c=>c.length>2),s={id
|
|
6
|
+
Provide 1-3 high-level insights.`,o;try{o=(await w(r,"You are an agent self-reflection system. Analyze the experiences and produce concise, actionable insights. Respond with 1-3 high-level insights, each on its own line.")).trim()||E(t)}catch{o=E(t)}let i;try{i=await p(o)}catch{}let a=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(c=>c.length>2),s={id:$(),roleId:e,type:"reflection",content:o,embedding:i,keywords:[...new Set(a)].slice(0,20),importance:5,sourceType:"reflection",evidence:t.slice(0,10).map(c=>c.id),createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"semantic"};l(s);try{let{markSuperseded:c}=await import("./memories-3ZAV55YZ.js"),m=t.slice(0,10).map(T=>T.id);c(m,s.id)}catch{}try{v({timestamp:Date.now(),oldRules:"",newRules:o,diff:o,roleId:e,source:"reflection"})}catch{}f(e,d),x.info({roleId:e,preview:o.slice(0,100)},"Generated reflection")}function E(e){let t=e.filter(i=>i.type==="event"),n=t.filter(i=>i.content.includes("Error")||i.content.includes("failed")),r=t.filter(i=>i.content.includes("Modified file")),o=[];return r.length>0&&o.push(`Made ${r.length} file modifications in recent tasks.`),n.length>0&&o.push(`Encountered ${n.length} errors.`),t.length>0&&o.push(`Total ${t.length} significant events observed.`),o.length>0?`Reflection: ${o.join(" ")}`:"Reflection: No significant patterns observed in recent activity."}async function R(e,t){_(e,t)&&await S(e)}import{v4 as A}from"uuid";function L(e){let t=e.toolName,n=e.toolOutput||e.content;if(t==="Write"||t==="Edit")return{content:`Modified file via ${t}: ${n.slice(0,400)}`,importance:4,type:"event"};if(t==="Bash"){let r=e.toolInput?.command?.slice(0,100)||"Bash";return n.includes("FAIL")||n.includes("error:")||n.includes("Error:")?{content:`Command failed: ${r} ${n.slice(0,300)}`,importance:4,type:"event"}:n.includes("success")||n.includes("done")||n.includes("OK")?{content:`Command succeeded: ${r}`,importance:2,type:"event"}:{content:`Executed: ${r}`,importance:1,type:"event"}}return t==="Read"?{content:`Read file: ${e.toolInput?.file_path||e.toolInput?.path||"unknown"}`,importance:1,type:"thought"}:t==="Glob"||t==="Grep"?{content:`Searched: ${t} - ${e.toolInput?.pattern||"query"}`,importance:2,type:"thought"}:null}function F(e){let t=g(e,500,0),n=[];for(let r of t)if((r.type==="tool_result"||r.type==="tool_call")&&r.toolName){let o=L(r);o&&n.push(o)}else r.type==="error"&&n.push({content:`Error occurred: ${r.content.slice(0,400)}`,importance:4,type:"event"});return{facts:n}}function k(e){let t=e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(n=>n.length>2);return[...new Set(t)].slice(0,20)}async function V(e,t){let n=!1;try{let{searchByBM25:i}=await import("./memories-3ZAV55YZ.js");n=i(t,e,5).filter(s=>s.sourceTaskId===e).some(s=>s.type==="thought")}catch{}let{facts:r}=F(e),o=0;for(let i of r){if(n&&i.importance<=2)continue;let a=i.content.slice(0,500),s;try{s=await p(a)}catch{}let c=k(a),m={id:A(),roleId:t,type:i.type,content:a,embedding:s,keywords:c,importance:i.importance,sourceType:"task_complete",sourceTaskId:e,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};l(m),o++,await R(t,i.importance)}return o}export{F as extractKeyFacts,V as processTaskCompletion};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./chunk-2C5U3CNX.js";import"./chunk-2CMR5AG7.js";import"./chunk-I5RUEOSQ.js";import"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";export{b as getRelevantMemoryContext,a as queryMemory,c as queryMemoryByTier};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./chunk-BCELBB5Q.js";import"./chunk-64FIXWFL.js";import"./chunk-TEMWI6U5.js";import"./chunk-L7JP7DUO.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";export{a as OutboundGateway,b as getOutboundGateway,c as isRecentlySent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-XFTRKHH2.js";import"./chunk-U3XVAAXA.js";import"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";export{a as CHAT_MANAGER_ROLE_ID,b as initializeDefaultRoles};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,k as h}from"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";h();export{b as createRole,g as deleteRole,c as getRole,d as getRoleByName,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-REKCZ3GY.js";import"./chunk-FCV2DPZQ.js";export{a as MUTABLE_PATHS,b as RESTART_REQUIRED_PATHS,f as buildSdkAuthEnv,h as getNestedValue,d as getRuntimeConfig,c as initRuntimeConfig,i as isMutablePath,j as isRestartRequiredPath,e as loadPersistedConfig,g as updateMutableConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-YEV5YTS3.js";import"./chunk-BONI2HUN.js";import"./chunk-4TBGFHYX.js";import"./chunk-L7JP7DUO.js";import"./chunk-2CMR5AG7.js";import"./chunk-I5RUEOSQ.js";import"./chunk-3TIHZZMK.js";import"./chunk-6KLG4APZ.js";import"./chunk-REKCZ3GY.js";import"./chunk-FXFHGIY6.js";import"./chunk-QMKQBU3R.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";export{p as _resetForTest,e as archiveSession,b as createSession,g as deleteSession,c as getActiveSession,d as getSession,m as getTimeoutPollerInterval,i as incrementMessageCount,n as initSessionManager,j as listSessions,f as restoreSession,o as shutdownSessionManager,k as startTimeoutPoller,l as stopTimeoutPoller,h as touchSession,a as warmCache};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-42RHY3Q3.js";import"./chunk-CREHL4BN.js";import"./chunk-WBAPIPST.js";import"./chunk-INNDBLZE.js";import"./chunk-FCV2DPZQ.js";export{a as createTaskTemplate,g as deleteTaskTemplate,f as disableTaskTemplate,e as enableTaskTemplate,b as getTaskTemplate,d as listTaskTemplates,c as updateTaskTemplate};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{J as t,L as n,S as r,Z as i,_ as a,j as o}from"./vendor-icons-ZPvC5PUS.js";import{d as s,r as c,t as l}from"./vendor-react--nRVf2Ep.js";import{r as u}from"./dist-HyCSN_hp.js";import{t as d}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{J as t,L as n,S as r,Z as i,_ as a,j as o}from"./vendor-icons-ZPvC5PUS.js";import{d as s,r as c,t as l}from"./vendor-react--nRVf2Ep.js";import{r as u}from"./dist-HyCSN_hp.js";import{t as d}from"./index-Ds41VvOC.js";import{n as f,r as p,t as m}from"./Card-BecEmnPW.js";import{n as h}from"./format-DvtQjPZn.js";var g=e(i(),1),_=l();function v(){let{id:e}=s(),[i,l]=(0,g.useState)(null),[v,b]=(0,g.useState)([]),[x,S]=(0,g.useState)([]),[C,w]=(0,g.useState)(null);if((0,g.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),w(null)}catch(e){w(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>b(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>b([])),u(`/delivery-rules`).then(async t=>{let n=t.filter(t=>t.target.type===`channel`&&t.target.channelId===e),r=[];for(let e of n.slice(0,3))try{let t=await u(`/delivery-rules/${e.id}/log`);r.push(...t.log??[])}catch{}r.sort((e,t)=>t.createdAt-e.createdAt),S(r.slice(0,20))}).catch(()=>S([])))},[e]),C)return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-slate-400 hover:text-slate-200`,children:[(0,_.jsx)(t,{size:14}),` Back to Channels`]}),(0,_.jsx)(m,{className:`text-center text-red-400`,children:C})]});if(!i)return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-slate-400 hover:text-slate-200`,children:[(0,_.jsx)(t,{size:14}),` Back to Channels`]}),(0,_.jsx)(m,{className:`text-center text-slate-500`,children:`Loading...`})]});let T=e=>e===`connected`?`success`:e===`connecting`?`warning`:e===`error`?`destructive`:`secondary`,E=e=>{switch(e){case`wechat`:return`WeChat`;case`telegram`:return`Telegram`;case`slack`:return`Slack`;case`discord`:return`Discord`;default:return e.charAt(0).toUpperCase()+e.slice(1)}},D={...i.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in D&&(D[e]=`********`);return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-slate-400 hover:text-slate-200`,children:[(0,_.jsx)(t,{size:14}),` Back to Channels`]}),(0,_.jsx)(m,{children:(0,_.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,_.jsx)(d,{variant:T(i.status),children:i.status}),(0,_.jsx)(d,{variant:`outline`,children:E(i.platform)}),i.enabled?(0,_.jsx)(d,{variant:`success`,children:`enabled`}):(0,_.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-slate-500`,children:i.id})]}),(0,_.jsx)(`h2`,{className:`text-lg font-semibold text-slate-200`,children:i.name})]})})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,_.jsx)(y,{icon:n,label:`Created`,value:h(i.createdAt),mono:!0}),(0,_.jsx)(y,{icon:r,label:`Messages`,value:String(i.messageCount),mono:!0}),i.lastMessageAt&&(0,_.jsx)(y,{icon:n,label:`Last Message`,value:h(i.lastMessageAt),mono:!0}),i.linkedRoleId&&(0,_.jsx)(y,{icon:a,label:`Linked Role`,value:i.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,_.jsxs)(m,{children:[(0,_.jsx)(f,{children:(0,_.jsx)(p,{children:`Configuration`})}),(0,_.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-slate-800 p-3 font-mono text-xs text-slate-300`,children:JSON.stringify(D,null,2)})]}),v.length>0&&(0,_.jsxs)(m,{children:[(0,_.jsx)(f,{children:(0,_.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,_.jsx)(o,{size:14}),` Delivery Rules (`,v.length,`)`]})}),(0,_.jsx)(`div`,{className:`space-y-2`,children:v.map(e=>(0,_.jsxs)(`div`,{className:`rounded-md border border-slate-700 bg-slate-800/50 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(d,{variant:`outline`,children:e.eventType}),e.enabled?(0,_.jsx)(d,{variant:`success`,children:`active`}):(0,_.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,_.jsxs)(`span`,{className:`text-xs text-slate-500`,children:[`max `,e.maxPerMinute,`/min`]})]}),(0,_.jsxs)(`p`,{className:`mt-1 text-xs text-slate-400 font-mono`,children:[`Rule: `,e.id]})]},e.id))})]}),x.length>0&&(0,_.jsxs)(m,{children:[(0,_.jsx)(f,{children:(0,_.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,_.jsx)(r,{size:14}),` Delivery Log (`,x.length,`)`]})}),(0,_.jsx)(`div`,{className:`space-y-2`,children:x.slice(0,10).map(e=>(0,_.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-slate-800 p-2`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`span`,{className:`text-sm text-slate-300 font-mono`,children:e.taskId.slice(0,8)}),(0,_.jsx)(`span`,{className:`text-xs text-slate-500 ml-2`,children:h(e.createdAt)})]}),(0,_.jsx)(d,{variant:e.status===`delivered`?`default`:e.status===`failed`?`destructive`:`outline`,children:e.status})]},e.id))})]})]})}function y({icon:e,label:t,value:n,mono:r}){return(0,_.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-slate-500`,children:[(0,_.jsx)(e,{size:12}),(0,_.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,_.jsx)(`span`,{className:`text-sm text-slate-200 truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{v as ChannelDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{S as t,Z as n,_ as r,a as i,b as a,g as o,m as s,t as c,v as l}from"./vendor-icons-ZPvC5PUS.js";import{t as u}from"./vendor-react--nRVf2Ep.js";import{r as d}from"./dist-HyCSN_hp.js";import{f,t as p}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{S as t,Z as n,_ as r,a as i,b as a,g as o,m as s,t as c,v as l}from"./vendor-icons-ZPvC5PUS.js";import{t as u}from"./vendor-react--nRVf2Ep.js";import{r as d}from"./dist-HyCSN_hp.js";import{f,t as p}from"./index-Ds41VvOC.js";import{n as m,r as h,t as g}from"./Card-BecEmnPW.js";import{t as _}from"./EmptyState-DBFJc4PL.js";var v=e(n(),1),y=u(),b=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`],x={telegram:`{
|
|
2
2
|
"botToken": ""
|
|
3
3
|
}`,slack:`{
|
|
4
4
|
"botToken": "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,Y as n,Z as r,a as i,f as a,g as o,l as s}from"./vendor-icons-ZPvC5PUS.js";import{t as c}from"./vendor-react--nRVf2Ep.js";import{a as l,r as u}from"./dist-HyCSN_hp.js";import{t as d}from"./vendor-state-CH64feAE.js";import{f}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,Y as n,Z as r,a as i,f as a,g as o,l as s}from"./vendor-icons-ZPvC5PUS.js";import{t as c}from"./vendor-react--nRVf2Ep.js";import{a as l,r as u}from"./dist-HyCSN_hp.js";import{t as d}from"./vendor-state-CH64feAE.js";import{f}from"./index-Ds41VvOC.js";import{a as p}from"./format-DvtQjPZn.js";var m=e(r(),1),h=d((e,t)=>({sessions:[],activeSessionId:null,messages:[],loading:!1,sending:!1,_chatWs:null,_chatWsReconnectDelay:1e3,fetchSessions:async()=>{try{e({sessions:(await u(`/chat/sessions`)).sessions})}catch{}},fetchMessages:async t=>{e({loading:!0});try{e({messages:(await u(`/chat/sessions/${t}`)).messages,loading:!1})}catch{e({messages:[],loading:!1})}},sendMessage:async n=>{if(t().sending)return null;e({sending:!0});try{let r=await u(`/chat/messages`,{method:`POST`,body:JSON.stringify({content:n,source:{type:`web`},sessionId:t().activeSessionId??void 0})});return e({activeSessionId:r.sessionId,sending:!1}),t().fetchSessions(),r}catch{return e({sending:!1}),null}},createSession:async()=>{try{let t=await u(`/chat/sessions`,{method:`POST`,body:JSON.stringify({source:{type:`web`}})});return e(e=>({sessions:[t.session,...e.sessions],activeSessionId:t.session.id,messages:[]})),t.session}catch{return null}},archiveSession:async t=>{try{await u(`/chat/sessions/${t}/archive`,{method:`POST`}),e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,status:`archived`}:e),activeSessionId:e.activeSessionId===t?null:e.activeSessionId,messages:e.activeSessionId===t?[]:e.messages}))}catch{}},restoreSession:async t=>{try{await u(`/chat/sessions/${t}/restore`,{method:`POST`}),e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,status:`active`}:e)}))}catch{}},deleteSession:async t=>{try{await u(`/chat/sessions/${t}`,{method:`DELETE`}),e(e=>({sessions:e.sessions.filter(e=>e.id!==t),activeSessionId:e.activeSessionId===t?null:e.activeSessionId,messages:e.activeSessionId===t?[]:e.messages}))}catch{}},setActiveSession:n=>{e({activeSessionId:n,messages:[]}),n&&t().fetchMessages(n)},connectChatStream:()=>{let n=t()._chatWs;if(n&&n.readyState<=1)return;let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=localStorage.getItem(`adam_api_key`),a=new URL(`${r}//${window.location.host}/chat/stream`);i&&a.searchParams.set(`api_key`,i);let o=new WebSocket(a.toString());o.onopen=()=>{e({_chatWs:o,_chatWsReconnectDelay:1e3})},o.onclose=()=>{let n=t()._chatWsReconnectDelay;e({_chatWs:null,_chatWsReconnectDelay:Math.min(n*2,1e4)}),setTimeout(()=>{t().connectChatStream()},n)},o.onerror=()=>{o.close()},o.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`chat_message`&&r.message){let n=r.message,{activeSessionId:i,messages:a}=t();if(n.sessionId!==i||a.some(e=>e.id===n.id))return;e(e=>({messages:[...e.messages,n]}))}else r.type===`session_created`&&t().fetchSessions()}catch{}},e({_chatWs:o})},disconnectChatStream:()=>{let n=t()._chatWs;n&&(n.onclose=null,n.onerror=null,n.onmessage=null,n.close(),e({_chatWs:null}))}})),g=c();function _({message:e}){let t=e.role===`user`;return(0,g.jsx)(`div`,{className:l(`flex`,t?`justify-end`:`justify-start`),children:(0,g.jsxs)(`div`,{className:l(`max-w-[80%] rounded-lg px-3.5 py-2.5 text-sm leading-relaxed`,t?`bg-blue-600 text-white`:`border border-slate-700 bg-slate-800 text-slate-200`),children:[(0,g.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content}),(0,g.jsx)(`div`,{className:l(`mt-1.5 text-[10px]`,t?`text-blue-200/60`:`text-slate-500`),children:p(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]})})}function v({onSend:e,disabled:t,placeholder:n=`Type a message...`}){let[r,i]=(0,m.useState)(``),a=(0,m.useRef)(null),o=()=>{let n=r.trim();!n||t||(e(n),i(``),a.current&&(a.current.style.height=`auto`))},c=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),o())},l=()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};return(0,g.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-slate-800 bg-slate-950 px-4 py-3`,children:[(0,g.jsx)(`textarea`,{ref:a,value:r,onChange:e=>{i(e.target.value),l()},onKeyDown:c,placeholder:n,disabled:t,rows:1,className:`flex-1 resize-none rounded-md border border-slate-700 bg-slate-800 px-3 py-2 text-sm text-slate-200 placeholder:text-slate-500 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50`}),(0,g.jsx)(f,{onClick:o,disabled:t||!r.trim(),size:`default`,"aria-label":`Send message`,children:(0,g.jsx)(s,{size:16})})]})}function y(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return`just now`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function b({session:e,isActive:t,onSelect:r,onArchive:o,onRestore:s,onDelete:c}){let u=e.status===`archived`;return(0,g.jsxs)(`button`,{onClick:r,className:l(`group flex w-full flex-col gap-1 rounded-md px-2.5 py-2 text-left transition-colors`,t?`bg-slate-800 text-slate-100`:`text-slate-400 hover:bg-slate-800/50 hover:text-slate-300`,u&&`opacity-60`),children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`truncate text-xs font-medium`,children:e.title??e.id.slice(0,8)}),(0,g.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100`,children:[u?(0,g.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),s()},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),s())},className:`rounded p-0.5 text-slate-500 hover:text-emerald-400`,title:`Restore`,children:(0,g.jsx)(a,{size:12})}):(0,g.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),o()},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),o())},className:`rounded p-0.5 text-slate-500 hover:text-amber-400`,title:`Archive`,children:(0,g.jsx)(n,{size:12})}),(0,g.jsx)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),c()},onKeyDown:e=>{e.key===`Enter`&&(e.stopPropagation(),c())},className:`rounded p-0.5 text-slate-500 hover:text-red-400`,title:`Delete`,children:(0,g.jsx)(i,{size:12})})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-slate-500`,children:[(0,g.jsxs)(`span`,{children:[e.messageCount,` turns`]}),(0,g.jsx)(`span`,{children:y(e.lastActiveAt)}),u&&(0,g.jsx)(`span`,{className:`rounded bg-slate-700 px-1 py-0.5 text-[9px]`,children:`archived`})]})]})}function x({sessions:e,activeSessionId:t,onSelectSession:n,onNewSession:r,onArchiveSession:i,onRestoreSession:a,onDeleteSession:s}){let c=e.filter(e=>e.status===`active`),l=e.filter(e=>e.status===`archived`);return(0,g.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-800 px-3 py-2.5`,children:[(0,g.jsx)(`span`,{className:`text-xs font-medium text-slate-400`,children:`Sessions`}),(0,g.jsx)(f,{variant:`ghost`,size:`sm`,onClick:r,children:(0,g.jsx)(o,{size:14})})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-1.5 py-1.5`,children:[c.length===0&&l.length===0&&(0,g.jsx)(`div`,{className:`px-2 py-4 text-center text-xs text-slate-500`,children:`No sessions yet`}),c.length>0&&(0,g.jsx)(`div`,{className:`space-y-0.5`,children:c.map(e=>(0,g.jsx)(b,{session:e,isActive:e.id===t,onSelect:()=>n(e.id),onArchive:()=>i(e.id),onRestore:()=>a(e.id),onDelete:()=>s(e.id)},e.id))}),l.length>0&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`mt-3 mb-1 px-2 text-[10px] font-medium uppercase tracking-wider text-slate-600`,children:`Archived`}),(0,g.jsx)(`div`,{className:`space-y-0.5`,children:l.map(e=>(0,g.jsx)(b,{session:e,isActive:e.id===t,onSelect:()=>n(e.id),onArchive:()=>i(e.id),onRestore:()=>a(e.id),onDelete:()=>s(e.id)},e.id))})]})]})]})}function S(){let e=h(e=>e.sessions),n=h(e=>e.activeSessionId),r=h(e=>e.messages),i=h(e=>e.sending),a=h(e=>e.fetchSessions),o=h(e=>e.sendMessage),s=h(e=>e.createSession),c=h(e=>e.archiveSession),l=h(e=>e.restoreSession),u=h(e=>e.deleteSession),d=h(e=>e.setActiveSession),f=h(e=>e.connectChatStream),p=h(e=>e.disconnectChatStream),y=(0,m.useRef)(null);return(0,m.useEffect)(()=>{a()},[a]),(0,m.useEffect)(()=>(f(),()=>p()),[f,p]),(0,m.useEffect)(()=>{y.current?.scrollIntoView?.({behavior:`smooth`})},[r]),(0,g.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,g.jsx)(`div`,{className:`hidden w-56 flex-shrink-0 border-r border-slate-800 bg-slate-950 lg:block`,children:(0,g.jsx)(x,{sessions:e,activeSessionId:n,onSelectSession:d,onNewSession:()=>void s(),onArchiveSession:e=>void c(e),onRestoreSession:e=>void l(e),onDeleteSession:e=>void u(e)})}),(0,g.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,g.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:r.length===0?(0,g.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-slate-500`,children:[(0,g.jsx)(`div`,{className:`rounded-full bg-slate-800 p-3`,children:(0,g.jsx)(t,{size:24})}),(0,g.jsx)(`div`,{className:`text-sm`,children:`Start a conversation with Adam`}),(0,g.jsx)(`div`,{className:`text-xs text-slate-600`,children:`Type a message below to begin`})]}):(0,g.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-3`,children:[r.map(e=>(0,g.jsx)(_,{message:e},e.id)),(0,g.jsx)(`div`,{ref:y})]})}),(0,g.jsx)(`div`,{className:`mx-auto w-full max-w-3xl`,children:(0,g.jsx)(v,{onSend:async e=>{await o(e)},disabled:i})})]})]})}export{S as Chat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,D as n,H as r,I as i,V as a,X as o,Z as s,s as c,z as l}from"./vendor-icons-ZPvC5PUS.js";import{r as u,t as d}from"./vendor-react--nRVf2Ep.js";import{C as f,n as p,t as m}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,D as n,H as r,I as i,V as a,X as o,Z as s,s as c,z as l}from"./vendor-icons-ZPvC5PUS.js";import{r as u,t as d}from"./vendor-react--nRVf2Ep.js";import{C as f,n as p,t as m}from"./index-Ds41VvOC.js";import{n as h,r as g,t as _}from"./Card-BecEmnPW.js";import{a as v,o as y,t as b}from"./format-DvtQjPZn.js";import{a as x,i as S,n as C,o as w,r as T,t as E}from"./Table-tkJ-cuiE.js";var D=e(s(),1),O=d();function k(){let e=f(e=>e.tasks),s=f(e=>e.goals),d=f(e=>e.stats),k=f(e=>e.readiness),j=f(e=>e.roles),M=f(e=>e.executionPool),N=f(e=>e.fetchTasks),P=f(e=>e.fetchGoals),F=f(e=>e.fetchRoles),I=f(e=>e.fetchExecutionPool);(0,D.useEffect)(()=>{N(),P(),F(),I();let e=setInterval(()=>{N(),I()},5e3);return()=>clearInterval(e)},[N,P,F,I]);let L=e.filter(e=>e.status===`running`).length,R=e.filter(e=>e.status===`completed`).length,z=e.filter(e=>e.status===`failed`).length,B=[...e].sort((e,t)=>t.createdAt-e.createdAt).slice(0,8);return(0,O.jsxs)(`div`,{className:`space-y-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Dashboard`}),k&&(0,O.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:(0,O.jsx)(m,{variant:k.status===`ready`?`success`:`destructive`,children:k.status===`ready`?`Server Ready`:`Not Ready`})})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,role:`region`,"aria-label":`Server statistics`,children:[(0,O.jsx)(A,{icon:n,label:`Active Tasks`,value:d.activeTasks||L,color:`text-blue-400`}),(()=>{let e=j.filter(e=>e.status===`active`).length,t=j.length,n=j.filter(e=>e.status===`probation`).length,r=j.filter(e=>e.status===`retired`).length,i=[n>0?`${n} probation`:``,r>0?`${r} retired`:``].filter(Boolean).join(` · `);return(0,O.jsx)(A,{icon:o,label:`Role Health`,value:i?`${e}/${t} | ${i}`:`${e}/${t}`,color:r>0?`text-red-400`:n>0?`text-amber-400`:`text-emerald-400`})})(),(0,O.jsx)(A,{icon:l,label:`Roles`,value:j.length,color:`text-emerald-400`}),(0,O.jsx)(A,{icon:t,label:`Cost Today`,value:b(d.totalCostToday),color:`text-purple-400`})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,role:`region`,"aria-label":`Additional statistics`,children:[(0,O.jsx)(A,{icon:a,label:`Completed`,value:R,color:`text-emerald-400`}),(0,O.jsx)(A,{icon:r,label:`Failed`,value:z,color:`text-red-400`}),(0,O.jsx)(A,{icon:c,label:`Goals`,value:s.length,color:`text-orange-400`}),(0,O.jsx)(A,{icon:i,label:`Execution Pool`,value:`${M.active}/${M.max} | ${M.queued} queued`,color:`text-blue-400`})]}),(0,O.jsx)(`div`,{className:`grid gap-4 lg:grid-cols-1`,children:(0,O.jsxs)(_,{children:[(0,O.jsx)(h,{children:(0,O.jsx)(g,{children:`System Checks`})}),k?(0,O.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Object.entries(k.checks).map(([e,t])=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-slate-800/30 px-3 py-2`,children:[(0,O.jsx)(`div`,{className:t?`h-2 w-2 rounded-full bg-emerald-500`:`h-2 w-2 rounded-full bg-red-500`}),(0,O.jsx)(`span`,{className:`text-xs capitalize text-slate-300`,children:e})]},e))}):(0,O.jsx)(`span`,{className:`text-xs text-slate-500`,children:`Loading...`})]})}),(0,O.jsxs)(_,{padding:!1,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pt-4`,children:[(0,O.jsx)(g,{children:`Recent Tasks`}),(0,O.jsx)(u,{to:`/work`,className:`text-xs text-blue-400 hover:text-blue-300`,children:`View all`})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsxs)(E,{children:[(0,O.jsx)(x,{children:(0,O.jsxs)(w,{children:[(0,O.jsx)(S,{children:`ID`}),(0,O.jsx)(S,{children:`Prompt`}),(0,O.jsx)(S,{children:`Status`}),(0,O.jsx)(S,{children:`Role`}),(0,O.jsx)(S,{children:`Created`})]})}),(0,O.jsxs)(C,{children:[B.map(e=>(0,O.jsxs)(w,{children:[(0,O.jsx)(T,{children:(0,O.jsx)(u,{to:`/tasks/${e.id}`,className:`font-mono text-xs text-blue-400 hover:text-blue-300`,children:e.id.slice(0,8)})}),(0,O.jsx)(T,{children:y(e.prompt,60)}),(0,O.jsx)(T,{children:(0,O.jsx)(m,{variant:p(e.status),children:e.status})}),(0,O.jsx)(T,{children:(0,O.jsx)(`span`,{className:`font-mono text-xs text-slate-500`,children:e.roleId?e.roleId.slice(0,12):`—`})}),(0,O.jsx)(T,{className:`text-xs text-slate-500`,children:v(e.createdAt)})]},e.id)),B.length===0&&(0,O.jsx)(w,{children:(0,O.jsx)(T,{colSpan:5,className:`text-center text-slate-500`,children:`No tasks yet`})})]})]})})]})]})}function A({icon:e,label:t,value:n,color:r}){return(0,O.jsxs)(_,{className:`flex items-center gap-3`,children:[(0,O.jsx)(`div`,{className:`rounded-md bg-slate-800 p-2 ${r}`,children:(0,O.jsx)(e,{size:16})}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`text-lg font-semibold text-slate-100`,children:n}),(0,O.jsx)(`div`,{className:`text-xs text-slate-500`,children:t})]})]})}export{k as Dashboard};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,Z as n,p as r}from"./vendor-icons-ZPvC5PUS.js";import{t as i}from"./vendor-react--nRVf2Ep.js";import{r as a}from"./dist-HyCSN_hp.js";import{C as o,f as s,t as c}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,Z as n,p as r}from"./vendor-icons-ZPvC5PUS.js";import{t as i}from"./vendor-react--nRVf2Ep.js";import{r as a}from"./dist-HyCSN_hp.js";import{C as o,f as s,t as c}from"./index-Ds41VvOC.js";import{t as l}from"./Card-BecEmnPW.js";import{a as u}from"./format-DvtQjPZn.js";import{t as d}from"./EmptyState-DBFJc4PL.js";var f=e(n(),1),p=i();function m(){let e=o(e=>e.roles),n=o(e=>e.fetchRoles),[i,m]=(0,f.useState)([]),[h,g]=(0,f.useState)(!0),[_,v]=(0,f.useState)(`all`);(0,f.useEffect)(()=>{n()},[n]);let y=(0,f.useCallback)(async()=>{g(!0);try{let e=new URLSearchParams({limit:`50`});_!==`all`&&e.set(`roleId`,_),m(await a(`/evolution-audit?${e}`))}catch{m([])}finally{g(!1)}},[_]);(0,f.useEffect)(()=>{y()},[y]);let b=t=>t?e.find(e=>e.id===t)?.name??t.slice(0,8):`System`;return(0,p.jsxs)(`div`,{className:`space-y-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,p.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Evolution Audit`}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsxs)(`select`,{className:`rounded border border-slate-700 bg-slate-900 px-2 py-1.5 text-sm text-slate-200 focus:border-blue-500 focus:outline-none`,value:_,onChange:e=>v(e.target.value),children:[(0,p.jsx)(`option`,{value:`all`,children:`All roles`}),e.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,p.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void y(),children:(0,p.jsx)(r,{size:14})})]})]}),(0,p.jsx)(l,{children:h?(0,p.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,p.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-slate-700 border-t-blue-500`})}):i.length===0?(0,p.jsx)(d,{icon:(0,p.jsx)(t,{size:32}),title:`No evolution records`,description:`Evolution occurs when roles accumulate enough task experience`}):(0,p.jsxs)(`div`,{className:`space-y-4`,children:[(0,p.jsxs)(`p`,{className:`text-xs text-slate-500`,children:[i.length,` records`]}),i.map(e=>(0,p.jsxs)(`div`,{className:`rounded border border-slate-800 p-3`,children:[(0,p.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,p.jsx)(c,{variant:`info`,children:b(e.roleId)}),(0,p.jsx)(`span`,{className:`text-xs text-slate-500`,children:u(e.timestamp)}),e.triggerTaskId&&(0,p.jsxs)(`span`,{className:`text-[10px] text-slate-600`,children:[`triggered by task `,e.triggerTaskId.slice(0,8)]})]}),e.diff.includes(`--- Diagnostic Report ---`)?(0,p.jsxs)(`div`,{className:`space-y-2`,children:[(0,p.jsxs)(`div`,{className:`rounded bg-slate-950 p-2`,children:[(0,p.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-slate-400`,children:`Diagnostic Report`}),(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-slate-400`,children:e.diff.split(`--- Rules Diff ---`)[0]?.replace(`--- Diagnostic Report ---
|
|
2
2
|
`,``).trim()})]}),(0,p.jsxs)(`div`,{className:`rounded bg-slate-950 p-2`,children:[(0,p.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-slate-400`,children:`Rules Changes`}),(0,p.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs`,children:(e.diff.split(`--- Rules Diff ---`)[1]??``).trim().split(`
|
|
3
3
|
`).map((e,t)=>(0,p.jsxs)(`span`,{className:e.startsWith(`+`)?`text-green-400`:e.startsWith(`-`)?`text-red-400`:`text-slate-400`,children:[e,`
|
|
4
4
|
`]},t))})]})]}):(0,p.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap rounded bg-slate-950 p-2 font-mono text-xs`,children:e.diff.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,F as n,J as r,L as i,Z as a,s as o}from"./vendor-icons-ZPvC5PUS.js";import{d as s,r as c,t as l}from"./vendor-react--nRVf2Ep.js";import{r as u}from"./dist-HyCSN_hp.js";import{t as d}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,F as n,J as r,L as i,Z as a,s as o}from"./vendor-icons-ZPvC5PUS.js";import{d as s,r as c,t as l}from"./vendor-react--nRVf2Ep.js";import{r as u}from"./dist-HyCSN_hp.js";import{t as d}from"./index-Ds41VvOC.js";import{n as f,r as p,t as m}from"./Card-BecEmnPW.js";import{n as h}from"./format-DvtQjPZn.js";var g=e(a(),1),_=l();function v(){let{id:e}=s(),[a,l]=(0,g.useState)(null),[v,b]=(0,g.useState)([]),[x,S]=(0,g.useState)(null);if((0,g.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),S(null);try{b((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){S(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),x)return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-slate-400 hover:text-slate-200`,children:[(0,_.jsx)(r,{size:14}),` Back to Goals`]}),(0,_.jsx)(m,{className:`text-center text-red-400`,children:x})]});if(!a)return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-slate-400 hover:text-slate-200`,children:[(0,_.jsx)(r,{size:14}),` Back to Goals`]}),(0,_.jsx)(m,{className:`text-center text-slate-500`,children:`Loading...`})]});let C=a.targetValue>0?Math.min(100,a.currentValue/a.targetValue*100):0,w=a.deadline>0&&a.deadline<Date.now()&&a.status!==`completed`;return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-slate-400 hover:text-slate-200`,children:[(0,_.jsx)(r,{size:14}),` Back to Goals`]}),(0,_.jsx)(m,{children:(0,_.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,_.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(a.status),children:a.status}),(0,_.jsx)(d,{variant:`outline`,children:a.roleId}),(0,_.jsx)(d,{variant:`outline`,children:a.metricType}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-slate-500`,children:a.id})]}),(0,_.jsx)(`h2`,{className:`text-lg font-semibold text-slate-200`,children:a.name}),a.description&&(0,_.jsx)(`p`,{className:`text-sm text-slate-400 mt-1`,children:a.description})]})})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,_.jsx)(y,{icon:o,label:`Progress`,value:`${a.currentValue} / ${a.targetValue}`}),(0,_.jsx)(y,{icon:i,label:w?`Overdue`:`Deadline`,value:h(a.deadline),mono:!0}),(0,_.jsx)(y,{icon:n,label:`Budget`,value:`$${a.budgetUsd.toFixed(2)}`}),(0,_.jsx)(y,{icon:t,label:`Created`,value:h(a.createdAt),mono:!0})]}),(0,_.jsxs)(m,{children:[(0,_.jsx)(f,{children:(0,_.jsx)(p,{children:`Progress`})}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-slate-700 overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full rounded-full transition-all ${w?`bg-red-500`:`bg-blue-500`}`,style:{width:`${C}%`}})}),(0,_.jsxs)(`span`,{className:`text-sm text-slate-300 font-mono`,children:[C.toFixed(1),`%`]})]}),(0,_.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-slate-500`,children:[(0,_.jsxs)(`span`,{children:[a.currentValue,` current`]}),(0,_.jsxs)(`span`,{children:[a.targetValue,` target`]})]})]}),(a.deliverTo??[]).length>0&&(0,_.jsxs)(m,{children:[(0,_.jsx)(f,{children:(0,_.jsx)(p,{children:`Delivery Targets`})}),(0,_.jsx)(`div`,{className:`space-y-1.5`,children:(a.deliverTo??[]).map((e,t)=>(0,_.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-slate-300`,children:e.type===`channel`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d,{variant:`outline`,children:`Channel`}),(0,_.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,_.jsxs)(`span`,{className:`text-xs text-slate-500`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d,{variant:`outline`,children:`Session`}),(0,_.jsx)(`span`,{className:`text-xs text-slate-400`,children:`Chat session`})]})},t))})]}),v.length>0&&(0,_.jsxs)(m,{children:[(0,_.jsx)(f,{children:(0,_.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,_.jsx)(t,{size:14}),` Strategies (`,v.length,`)`]})}),(0,_.jsx)(`div`,{className:`space-y-2`,children:v.map(e=>(0,_.jsxs)(`div`,{className:`flex items-center justify-between text-sm border-b border-slate-800 pb-2`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`text-slate-200`,children:e.name}),(0,_.jsx)(`span`,{className:`text-xs text-slate-500 ml-2`,children:e.taskType})]}),(0,_.jsxs)(d,{variant:`outline`,children:[e.trialCount,` trials`]})]},e.id))})]})]})}function y({icon:e,label:t,value:n,mono:r}){return(0,_.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-slate-500`,children:[(0,_.jsx)(e,{size:12}),(0,_.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,_.jsx)(`span`,{className:`text-sm text-slate-200 truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{v as GoalDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{Z as t,a as n,b as r,g as i,p as a,s as o,t as s,x as c,y as l}from"./vendor-icons-ZPvC5PUS.js";import{t as u}from"./vendor-react--nRVf2Ep.js";import{r as d}from"./dist-HyCSN_hp.js";import{C as f,a as ee,c as p,d as m,f as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S,u as te,w as C}from"./index-CfKqiQIe.js";import{n as w,r as T,t as E}from"./Card-BecEmnPW.js";import{n as D,t as ne}from"./format-DvtQjPZn.js";import{t as O}from"./EmptyState-DBFJc4PL.js";var k=e(t(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([d(`/channels`).catch(()=>({channels:[]})),d(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-slate-400`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-slate-700 bg-slate-800 px-3 py-1.5 text-left text-sm text-slate-200 hover:border-slate-600 focus:border-blue-500 focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-slate-700 bg-slate-800 py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-500`,children:`No active channel conversations. Start a chat on WeChat/Telegram first.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-slate-500`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-slate-300 hover:bg-slate-700`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-slate-600 bg-slate-700`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-slate-500`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-slate-700 px-3 py-1 text-left text-xs text-red-400 hover:bg-slate-700`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-slate-700 px-3 py-1 text-left text-xs text-slate-500 hover:bg-slate-700`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(c,{size:12}),paused:(0,A.jsx)(l,{size:12}),completed:(0,A.jsx)(a,{size:12}),failed:(0,A.jsx)(a,{size:12})};function P(){let e=f(e=>e.goals),t=f(e=>e.fetchGoals),c=f(e=>e.updateGoal),u=f(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,re]=(0,k.useState)([]),[$,ie]=(0,k.useState)([]);(0,k.useEffect)(()=>{t();let e=setInterval(()=>void t(),1e4);return()=>clearInterval(e)},[t]);let ae=async()=>{if(I.trim()){z(!0),V(null);try{await d(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),t()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Goals`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>void t(),children:(0,A.jsx)(a,{size:14})}),(0,A.jsxs)(h,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(i,{size:14}),`New Goal`]})]})]}),P&&(0,A.jsxs)(E,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-slate-700 bg-slate-800 px-3 py-2 text-sm text-slate-200 placeholder:text-slate-500 focus:border-blue-500 focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:re,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ie,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-red-400`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(h,{onClick:()=>void ae(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(h,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let t=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,i=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,a=H===e.id;return(0,A.jsxs)(E,{children:[(0,A.jsxs)(w,{children:[a?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-slate-700 bg-slate-800 px-2 py-1 text-sm text-slate-200 focus:border-blue-500 focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(T,{className:`text-slate-200 text-sm font-medium truncate max-w-[180px]`,children:e.name}),(0,A.jsx)(S,{variant:v(e.status),children:e.status})]}),a?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-slate-700 bg-slate-800 px-2 py-1 text-xs text-slate-200 placeholder:text-slate-500 focus:border-blue-500 focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-slate-400 mb-3 line-clamp-2`,children:e.description}):null,a&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-slate-500`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-slate-300`,children:[t,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-slate-800`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-all ${t>=100?`bg-emerald-500`:`bg-blue-500`}`,style:{width:`${t}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500`,children:`Role`}),(0,A.jsx)(S,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-slate-300`,children:ne(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500 ${i?`text-red-400`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-slate-300 ${i?`text-red-400`:``}`,children:D(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-slate-400`,children:D(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-slate-800`,children:a?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await c(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),C.success(`Goal updated`)}catch(e){C.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(r,{size:14})}),(0,A.jsxs)(h,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await c(e.id,{status:M[e.status]}),C.success(`Status changed to ${M[e.status]}`)}catch(e){C.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(l,{size:12}),(0,A.jsx)(`span`,{className:`ml-1 text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(b,{children:[(0,A.jsx)(m,{asChild:!0,children:(0,A.jsx)(h,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-red-400 hover:text-red-300`,children:(0,A.jsx)(n,{size:14})})}),(0,A.jsxs)(y,{children:[(0,A.jsxs)(_,{children:[(0,A.jsx)(te,{children:`Delete goal`}),(0,A.jsxs)(x,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(p,{children:[(0,A.jsx)(ee,{children:`Cancel`}),(0,A.jsx)(g,{className:`bg-red-600 hover:bg-red-700`,onClick:async()=>{try{await u(e.id),C.success(`Goal deleted`)}catch(e){C.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{Z as t,a as n,b as r,g as i,p as a,s as o,t as s,x as c,y as l}from"./vendor-icons-ZPvC5PUS.js";import{t as u}from"./vendor-react--nRVf2Ep.js";import{r as d}from"./dist-HyCSN_hp.js";import{C as f,a as ee,c as p,d as m,f as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S,u as te,w as C}from"./index-Ds41VvOC.js";import{n as w,r as T,t as E}from"./Card-BecEmnPW.js";import{n as D,t as ne}from"./format-DvtQjPZn.js";import{t as O}from"./EmptyState-DBFJc4PL.js";var k=e(t(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([d(`/channels`).catch(()=>({channels:[]})),d(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-slate-400`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-slate-700 bg-slate-800 px-3 py-1.5 text-left text-sm text-slate-200 hover:border-slate-600 focus:border-blue-500 focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-slate-700 bg-slate-800 py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-slate-500`,children:`No active channel conversations. Start a chat on WeChat/Telegram first.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-slate-500`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-slate-300 hover:bg-slate-700`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-slate-600 bg-slate-700`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-slate-500`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-slate-700 px-3 py-1 text-left text-xs text-red-400 hover:bg-slate-700`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-slate-700 px-3 py-1 text-left text-xs text-slate-500 hover:bg-slate-700`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(c,{size:12}),paused:(0,A.jsx)(l,{size:12}),completed:(0,A.jsx)(a,{size:12}),failed:(0,A.jsx)(a,{size:12})};function P(){let e=f(e=>e.goals),t=f(e=>e.fetchGoals),c=f(e=>e.updateGoal),u=f(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,re]=(0,k.useState)([]),[$,ie]=(0,k.useState)([]);(0,k.useEffect)(()=>{t();let e=setInterval(()=>void t(),1e4);return()=>clearInterval(e)},[t]);let ae=async()=>{if(I.trim()){z(!0),V(null);try{await d(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),t()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Goals`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>void t(),children:(0,A.jsx)(a,{size:14})}),(0,A.jsxs)(h,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(i,{size:14}),`New Goal`]})]})]}),P&&(0,A.jsxs)(E,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-slate-700 bg-slate-800 px-3 py-2 text-sm text-slate-200 placeholder:text-slate-500 focus:border-blue-500 focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:re,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ie,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-red-400`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(h,{onClick:()=>void ae(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(h,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let t=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,i=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,a=H===e.id;return(0,A.jsxs)(E,{children:[(0,A.jsxs)(w,{children:[a?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-slate-700 bg-slate-800 px-2 py-1 text-sm text-slate-200 focus:border-blue-500 focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(T,{className:`text-slate-200 text-sm font-medium truncate max-w-[180px]`,children:e.name}),(0,A.jsx)(S,{variant:v(e.status),children:e.status})]}),a?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-slate-700 bg-slate-800 px-2 py-1 text-xs text-slate-200 placeholder:text-slate-500 focus:border-blue-500 focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-slate-400 mb-3 line-clamp-2`,children:e.description}):null,a&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-slate-500`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-slate-300`,children:[t,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-slate-800`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-all ${t>=100?`bg-emerald-500`:`bg-blue-500`}`,style:{width:`${t}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500`,children:`Role`}),(0,A.jsx)(S,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-slate-300`,children:ne(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500 ${i?`text-red-400`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-slate-300 ${i?`text-red-400`:``}`,children:D(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-slate-500`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-slate-400`,children:D(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-slate-800`,children:a?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await c(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),C.success(`Goal updated`)}catch(e){C.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(h,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(r,{size:14})}),(0,A.jsxs)(h,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await c(e.id,{status:M[e.status]}),C.success(`Status changed to ${M[e.status]}`)}catch(e){C.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(l,{size:12}),(0,A.jsx)(`span`,{className:`ml-1 text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(b,{children:[(0,A.jsx)(m,{asChild:!0,children:(0,A.jsx)(h,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-red-400 hover:text-red-300`,children:(0,A.jsx)(n,{size:14})})}),(0,A.jsxs)(y,{children:[(0,A.jsxs)(_,{children:[(0,A.jsx)(te,{children:`Delete goal`}),(0,A.jsxs)(x,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(p,{children:[(0,A.jsx)(ee,{children:`Cancel`}),(0,A.jsx)(g,{className:`bg-red-600 hover:bg-red-700`,onClick:async()=>{try{await u(e.id),C.success(`Goal deleted`)}catch(e){C.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{Z as t,a as n,o as r,x as i,y as a}from"./vendor-icons-ZPvC5PUS.js";import{t as o}from"./vendor-react--nRVf2Ep.js";import{C as s,f as c}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{Z as t,a as n,o as r,x as i,y as a}from"./vendor-icons-ZPvC5PUS.js";import{t as o}from"./vendor-react--nRVf2Ep.js";import{C as s,f as c}from"./index-Ds41VvOC.js";import{t as l}from"./Card-BecEmnPW.js";import{t as u}from"./EmptyState-DBFJc4PL.js";var d=e(t(),1),f=o(),p={debug:`text-slate-500`,info:`text-blue-400`,warn:`text-amber-400`,error:`text-red-400`},m={adam:`text-purple-400`,manager:`text-cyan-400`,worker:`text-green-400`,scheduler:`text-orange-400`,api:`text-blue-400`,ws:`text-teal-400`,store:`text-yellow-400`,embedding:`text-pink-400`},h=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],g=[`debug`,`info`,`warn`,`error`];function _(){let e=s(e=>e.logs),t=(0,d.useRef)(null),[o,_]=(0,d.useState)(!0),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),C=(0,d.useMemo)(()=>e.filter(e=>!(y&&e.level!==y||x&&e.component!==x)),[e,y,x]);return(0,d.useEffect)(()=>{o&&t.current&&(t.current.scrollTop=t.current.scrollHeight)},[C,o]),(0,f.jsxs)(`div`,{className:`flex h-full flex-col gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,f.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Logs`}),(0,f.jsxs)(`div`,{className:`flex gap-2`,children:[(0,f.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>_(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,f.jsx)(i,{size:14}):(0,f.jsx)(a,{size:14})}),(0,f.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>{s.setState({logs:[]})},title:`Clear logs`,children:(0,f.jsx)(n,{size:14})})]})]}),(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(`span`,{className:`text-xs text-slate-500`,children:`Level:`}),(0,f.jsxs)(`div`,{className:`flex gap-1`,children:[(0,f.jsx)(v,{active:y===null,onClick:()=>b(null),children:`All`}),g.map(e=>(0,f.jsx)(v,{active:y===e,onClick:()=>b(y===e?null:e),children:e},e))]})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(`span`,{className:`text-xs text-slate-500`,children:`Component:`}),(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,f.jsx)(v,{active:x===null,onClick:()=>S(null),children:`All`}),h.map(e=>(0,f.jsx)(v,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]})]}),(0,f.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:C.length===0?(0,f.jsx)(u,{icon:(0,f.jsx)(r,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket`}):(0,f.jsx)(`div`,{ref:t,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:C.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=p[e.level]??`text-slate-400`,i=m[e.component]??`text-slate-400`;return(0,f.jsxs)(`div`,{className:`flex gap-2 hover:bg-slate-800/30 px-1 rounded`,children:[(0,f.jsx)(`span`,{className:`text-slate-600 shrink-0`,children:n}),(0,f.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,f.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,f.jsx)(`span`,{className:`text-slate-300 break-all`,children:e.msg})]},t)})})}),(0,f.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-slate-500`,children:[(0,f.jsxs)(`span`,{children:[C.length,` entries `,C.length!==e.length&&`(${e.length} total)`]}),(0,f.jsx)(`span`,{children:o?`Auto-scrolling`:`Paused`})]})]})}function v({active:e,onClick:t,children:n}){return(0,f.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-slate-700 text-slate-200`:`text-slate-500 hover:text-slate-300`}`,children:n})}export{_ as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{Z as t,p as n,q as r,u as i}from"./vendor-icons-ZPvC5PUS.js";import{t as a}from"./vendor-react--nRVf2Ep.js";import{r as o}from"./dist-HyCSN_hp.js";import{C as s,f as c,t as l}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{Z as t,p as n,q as r,u as i}from"./vendor-icons-ZPvC5PUS.js";import{t as a}from"./vendor-react--nRVf2Ep.js";import{r as o}from"./dist-HyCSN_hp.js";import{C as s,f as c,t as l}from"./index-Ds41VvOC.js";import{t as u}from"./Card-BecEmnPW.js";import{a as d}from"./format-DvtQjPZn.js";import{t as f}from"./EmptyState-DBFJc4PL.js";var p=e(t(),1),m=a();function h(){let e=s(e=>e.roles),t=s(e=>e.fetchRoles),[a,h]=(0,p.useState)(``),[g,_]=(0,p.useState)([]),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(``),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(`all`),[E,D]=(0,p.useState)(new Set);(0,p.useEffect)(()=>{t()},[t]),(0,p.useEffect)(()=>{!a&&e.length>0&&h(e[0].id)},[e,a]);let O=(0,p.useCallback)(async()=>{if(a){y(!0);try{_((await o(`/memories/${a}?limit=100`)).memories)}catch{_([])}finally{y(!1)}}},[a]);(0,p.useEffect)(()=>{a&&O()},[a,O]);let k=async()=>{if(!(!b.trim()||!a)){C(!0);try{_((await o(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:b.trim(),topK:20})})).memories)}catch{_([])}finally{C(!1)}}},A=()=>{x(``),O()},j=g.filter(e=>w===`high`?e.importance>3:w===`medium`?e.importance===3:w===`low`?e.importance<3:!0),M=e=>e>=4?`text-red-400`:e===3?`text-yellow-400`:`text-slate-500`;return(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,m.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Memories`}),(0,m.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>void O(),children:(0,m.jsx)(n,{size:14})})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsx)(`select`,{className:`rounded border border-slate-700 bg-slate-900 px-2 py-1.5 text-sm text-slate-200 focus:border-blue-500 focus:outline-none`,value:a,onChange:e=>h(e.target.value),children:e.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`input`,{className:`w-64 rounded border border-slate-700 bg-slate-900 px-2 py-1.5 text-sm text-slate-200 placeholder-slate-600 focus:border-blue-500 focus:outline-none`,value:b,onChange:e=>x(e.target.value),onKeyDown:e=>e.key===`Enter`&&void k(),placeholder:`Search memories...`}),(0,m.jsx)(c,{size:`sm`,variant:`ghost`,onClick:()=>void k(),disabled:S,children:(0,m.jsx)(i,{size:14})}),b&&(0,m.jsx)(c,{size:`sm`,variant:`ghost`,onClick:A,children:`Clear`})]}),(0,m.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,m.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${w===e?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>T(e),children:e},e))})]}),(0,m.jsx)(u,{children:v||S?(0,m.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,m.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-slate-700 border-t-blue-500`})}):j.length===0?(0,m.jsx)(f,{icon:(0,m.jsx)(r,{size:32}),title:`No memories`,description:b?`No results for this query`:`This agent has no memories yet`}):(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsxs)(`p`,{className:`text-xs text-slate-500`,children:[j.length,` memories`]}),j.map(e=>(0,m.jsxs)(`div`,{className:`rounded border border-slate-800 p-3`,children:[(0,m.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,m.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,m.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,m.jsx)(`span`,{className:`text-xs font-medium ${M(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,m.jsxs)(`span`,{className:`text-[10px] text-slate-600`,children:[`score: `,e.score.toFixed(3)]})]}),(0,m.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-slate-300`,children:e.content}),(0,m.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,m.jsx)(`span`,{className:`rounded bg-slate-800 px-1.5 py-0.5 text-[10px] text-slate-500`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,m.jsxs)(`div`,{className:`mt-2`,children:[(0,m.jsxs)(`button`,{className:`text-[10px] text-blue-400 hover:text-blue-300`,onClick:()=>D(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[E.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),E.has(e.id)&&(0,m.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-slate-800 pl-2`,children:e.evidence.map(e=>{let t=g.find(t=>t.id===e);return(0,m.jsx)(`div`,{className:`text-xs text-slate-500`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,m.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,m.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-slate-600`,children:[d(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,d(e.lastAccessed)]})]},e.id))]})})]})}export{h as Memories};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{E as t,K as n,M as r,U as i,W as a,Z as o,a as ee,g as te,h as s,p as c,t as l}from"./vendor-icons-ZPvC5PUS.js";import{t as u}from"./vendor-react--nRVf2Ep.js";import{r as d}from"./dist-HyCSN_hp.js";import{f,t as p,w as m}from"./index-CfKqiQIe.js";import{t as h}from"./Card-BecEmnPW.js";import{a as g}from"./format-DvtQjPZn.js";import{t as ne}from"./EmptyState-DBFJc4PL.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./Table-tkJ-cuiE.js";var C=e(o(),1),w=u();function T({manifest:e}){if(!e)return null;let t=[];return e.skills.length>0&&t.push({label:`Skill(${e.skills.length})`,variant:`info`}),e.agents.length>0&&t.push({label:`Agent(${e.agents.length})`,variant:`success`}),e.mcpServers.length>0&&t.push({label:`MCP(${e.mcpServers.length})`,variant:`warning`}),e.hooks.length>0&&t.push({label:`Hook(${e.hooks.length})`,variant:`default`}),e.lspServers.length>0&&t.push({label:`LSP(${e.lspServers.length})`,variant:`default`}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>(0,w.jsx)(p,{variant:e.variant,children:e.label},e.label))})}function E(){let[e,o]=(0,C.useState)([]),[u,E]=(0,C.useState)([]),[,D]=(0,C.useState)([]),[,O]=(0,C.useState)(new Set),[re,k]=(0,C.useState)(!0),[A,j]=(0,C.useState)(!1),[,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(null),[F,I]=(0,C.useState)(!1),[L,R]=(0,C.useState)(``),[z,B]=(0,C.useState)([]),[V,H]=(0,C.useState)(!1),[U,W]=(0,C.useState)(new Set),[G,K]=(0,C.useState)(`all`),[q,J]=(0,C.useState)([]),Y=(0,C.useCallback)(async()=>{k(!0);try{o((await d(`/plugins`)).plugins)}catch(e){m.error(e instanceof Error?e.message:`Failed to load plugins`)}finally{k(!1)}},[]),X=(0,C.useCallback)(async()=>{j(!0),M(null);try{let[e,t]=await Promise.all([d(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),d(`/plugins/marketplaces`)]);D(e.available),O(new Set(e.installed.map(e=>e.id))),E(t.sources)}catch(e){M(e instanceof Error?e.message:`Failed to load marketplace`)}finally{j(!1)}},[]),ie=(0,C.useCallback)(async()=>{try{B((await d(`/plugins/stats?limit=20`)).stats)}catch{}},[]),Z=(0,C.useCallback)(async()=>{try{J((await d(`/roles`)).roles)}catch{}},[]);(0,C.useEffect)(()=>{Y(),X(),Z()},[Y,X,Z]);let ae=async(e,t)=>{P(e);try{await d(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),m.success(`${e} ${t?`enabled`:`disabled`} globally`),o(n=>n.map(n=>n.id===e?{...n,globalEnabled:t}:n))}catch(e){m.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{P(null)}},oe=async e=>{P(e);try{await d(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),m.success(`Plugin uninstalled`),await Promise.all([Y(),X()])}catch(e){m.error(e instanceof Error?e.message:`Uninstall failed`)}finally{P(null)}},se=async(e,t,n)=>{P(e);try{await d(`/plugins/install/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify({scope:`project`,cwd:n})});let r=q.find(e=>e.id===t)?.name??t;m.success(`Installed ${e.split(`@`)[0]} for ${r}`),await Y()}catch(e){m.error(e instanceof Error?e.message:`Install to role failed`)}finally{P(null)}},Q=async()=>{if(L.trim())try{await d(`/plugins/install/${encodeURIComponent(L.trim())}`,{method:`POST`,body:JSON.stringify({})}),m.success(`Source added`),R(``),I(!1),await X()}catch(e){m.error(e instanceof Error?e.message:`Failed to add source`)}},ce=e=>{W(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},$=G===`all`?e:e.filter(e=>e.scope===G);return(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,w.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Plugins`}),(0,w.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>void Y(),children:(0,w.jsx)(c,{size:14})})]}),(0,w.jsxs)(h,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(r,{size:14,className:`text-slate-400 flex-shrink-0`}),(0,w.jsx)(`button`,{className:`rounded-full px-2 py-0.5 text-xs transition-colors ${G===`all`?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>K(`all`),children:`All`}),(0,w.jsx)(`button`,{className:`rounded-full px-2 py-0.5 text-xs transition-colors ${G===`user`?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>K(`user`),children:`User`}),(0,w.jsx)(`button`,{className:`rounded-full px-2 py-0.5 text-xs transition-colors ${G===`project`?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>K(`project`),children:`Project`}),(0,w.jsx)(`span`,{className:`h-4 w-px bg-slate-700 mx-1`}),u.map(e=>(0,w.jsx)(p,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,w.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[A&&(0,w.jsx)(t,{size:12,className:`animate-spin text-slate-500`}),A?null:(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>I(!F),children:F?(0,w.jsx)(l,{size:12}):(0,w.jsx)(te,{size:12})})]})]}),F&&(0,w.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,w.jsx)(`input`,{className:`flex-1 rounded border border-slate-700 bg-slate-900 px-2 py-1.5 text-sm text-slate-200 focus:border-blue-500 focus:outline-none`,value:L,onChange:e=>R(e.target.value),placeholder:`https://github.com/org/marketplace-repo`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,w.jsx)(f,{size:`sm`,onClick:()=>void Q(),disabled:!L.trim(),children:`Add`})]})]}),re?(0,w.jsx)(h,{children:(0,w.jsx)(`div`,{className:`py-8 text-center text-sm text-slate-500`,children:`Loading...`})}):$.length===0?(0,w.jsx)(h,{children:(0,w.jsx)(ne,{icon:(0,w.jsx)(s,{size:32}),title:`No plugins`,description:G===`all`?`No plugins installed. Browse the marketplace or install from a URL.`:`No ${G}-scope plugins installed.`})}):(0,w.jsx)(h,{padding:!1,children:(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{className:`w-8`}),(0,w.jsx)(v,{children:`Name`}),(0,w.jsx)(v,{children:`Version`}),(0,w.jsx)(v,{children:`Scope`}),(0,w.jsx)(v,{children:`Type`}),(0,w.jsx)(v,{children:`Activation`}),(0,w.jsx)(v,{children:`Actions`})]})}),(0,w.jsx)(y,{children:$.map(e=>{let n=U.has(e.id),r=e.id.split(`@`)[0],o=N===e.id;return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(b,{className:`group`,children:[(0,w.jsx)(x,{children:(0,w.jsx)(`button`,{onClick:()=>ce(e.id),className:`text-slate-500 hover:text-slate-300`,children:n?(0,w.jsx)(a,{size:12}):(0,w.jsx)(i,{size:12})})}),(0,w.jsx)(x,{className:`font-medium text-slate-200`,children:r}),(0,w.jsx)(x,{className:`text-xs text-slate-400`,children:e.version?`v${e.version}`:`—`}),(0,w.jsxs)(x,{children:[(0,w.jsx)(p,{variant:e.scope===`user`?`info`:`warning`,children:e.scope}),e.scope===`project`&&e.projectPath&&(0,w.jsx)(`div`,{className:`text-[10px] text-slate-600 truncate max-w-[120px]`,title:e.projectPath,children:e.projectPath.split(`/`).pop()})]}),(0,w.jsx)(x,{children:(0,w.jsx)(T,{manifest:e.manifest})}),(0,w.jsx)(x,{children:(0,w.jsx)(p,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`})}),(0,w.jsx)(x,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:o,onClick:()=>void ae(e.id,!e.globalEnabled),children:o?(0,w.jsx)(t,{size:10,className:`animate-spin`}):e.globalEnabled?`Disable`:`Enable`}),(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs text-red-400`,disabled:o,onClick:()=>void oe(e.id),children:(0,w.jsx)(ee,{size:10})})]})})]},e.id),n&&(0,w.jsx)(b,{className:`bg-slate-900/50`,children:(0,w.jsx)(x,{colSpan:7,className:`px-6 py-3`,children:e.manifest?(0,w.jsxs)(`div`,{className:`space-y-3 text-xs`,children:[e.manifest.description&&(0,w.jsx)(`p`,{className:`text-slate-400`,children:e.manifest.description}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[e.manifest.skills.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`Skills`}),e.manifest.skills.map(e=>(0,w.jsxs)(`div`,{className:`text-slate-400`,children:[(0,w.jsx)(`span`,{className:`text-slate-200`,children:e.name}),e.description&&(0,w.jsxs)(`span`,{className:`ml-1 text-slate-500`,children:[`— `,e.description]})]},e.name))]}),e.manifest.agents.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`Agents`}),e.manifest.agents.map(e=>(0,w.jsxs)(`div`,{className:`text-slate-400`,children:[(0,w.jsx)(`span`,{className:`text-slate-200`,children:e.name}),e.description&&(0,w.jsxs)(`span`,{className:`ml-1 text-slate-500`,children:[`— `,e.description]})]},e.name))]}),e.manifest.mcpServers.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,w.jsx)(`div`,{className:`text-slate-400`,children:e},e))]}),e.manifest.hooks.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,w.jsx)(`div`,{className:`text-slate-400`,children:e},e))]})]}),(0,w.jsx)(`div`,{className:`text-slate-600 font-mono truncate mt-1`,title:e.installPath,children:e.installPath}),q.length>0&&e.scope===`user`&&(0,w.jsxs)(`div`,{className:`mt-3 pt-2 border-t border-slate-800`,children:[(0,w.jsx)(`span`,{className:`text-slate-400 mr-2`,children:`Install to Role:`}),q.map(t=>(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-5 px-2 text-[10px] mr-1`,disabled:N===e.id,onClick:()=>void se(e.id,t.id,t.workspacePath),children:t.name},t.id))]})]}):(0,w.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Loading manifest...`})})},`${e.id}-detail`)]})})})]})}),(0,w.jsxs)(h,{children:[(0,w.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-slate-300`,onClick:()=>{!V&&z.length===0&&ie(),H(!V)},children:[(0,w.jsx)(n,{size:14,className:`text-slate-400`}),`Usage Stats`,V?(0,w.jsx)(a,{size:12,className:`ml-auto`}):(0,w.jsx)(i,{size:12,className:`ml-auto`})]}),V&&(0,w.jsx)(`div`,{className:`mt-3`,children:z.length===0?(0,w.jsx)(`p`,{className:`text-xs text-slate-500 text-center py-2`,children:`No usage data yet`}):(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{children:`Plugin`}),(0,w.jsx)(v,{children:`Usage Count`}),(0,w.jsx)(v,{children:`Last Used`})]})}),(0,w.jsx)(y,{children:z.map(e=>(0,w.jsxs)(b,{children:[(0,w.jsx)(x,{className:`font-medium text-slate-200 text-xs`,children:e.pluginName}),(0,w.jsx)(x,{className:`font-mono text-xs text-slate-400`,children:e.usageCount}),(0,w.jsx)(x,{className:`text-xs text-slate-400`,children:e.lastUsed?g(e.lastUsed):`—`})]},e.pluginPath))})]})})]})]})}export{E as Plugins};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{E as t,K as n,M as r,U as i,W as a,Z as o,a as ee,g as te,h as s,p as c,t as l}from"./vendor-icons-ZPvC5PUS.js";import{t as u}from"./vendor-react--nRVf2Ep.js";import{r as d}from"./dist-HyCSN_hp.js";import{f,t as p,w as m}from"./index-Ds41VvOC.js";import{t as h}from"./Card-BecEmnPW.js";import{a as g}from"./format-DvtQjPZn.js";import{t as ne}from"./EmptyState-DBFJc4PL.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./Table-tkJ-cuiE.js";var C=e(o(),1),w=u();function T({manifest:e}){if(!e)return null;let t=[];return e.skills.length>0&&t.push({label:`Skill(${e.skills.length})`,variant:`info`}),e.agents.length>0&&t.push({label:`Agent(${e.agents.length})`,variant:`success`}),e.mcpServers.length>0&&t.push({label:`MCP(${e.mcpServers.length})`,variant:`warning`}),e.hooks.length>0&&t.push({label:`Hook(${e.hooks.length})`,variant:`default`}),e.lspServers.length>0&&t.push({label:`LSP(${e.lspServers.length})`,variant:`default`}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>(0,w.jsx)(p,{variant:e.variant,children:e.label},e.label))})}function E(){let[e,o]=(0,C.useState)([]),[u,E]=(0,C.useState)([]),[,D]=(0,C.useState)([]),[,O]=(0,C.useState)(new Set),[re,k]=(0,C.useState)(!0),[A,j]=(0,C.useState)(!1),[,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(null),[F,I]=(0,C.useState)(!1),[L,R]=(0,C.useState)(``),[z,B]=(0,C.useState)([]),[V,H]=(0,C.useState)(!1),[U,W]=(0,C.useState)(new Set),[G,K]=(0,C.useState)(`all`),[q,J]=(0,C.useState)([]),Y=(0,C.useCallback)(async()=>{k(!0);try{o((await d(`/plugins`)).plugins)}catch(e){m.error(e instanceof Error?e.message:`Failed to load plugins`)}finally{k(!1)}},[]),X=(0,C.useCallback)(async()=>{j(!0),M(null);try{let[e,t]=await Promise.all([d(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),d(`/plugins/marketplaces`)]);D(e.available),O(new Set(e.installed.map(e=>e.id))),E(t.sources)}catch(e){M(e instanceof Error?e.message:`Failed to load marketplace`)}finally{j(!1)}},[]),ie=(0,C.useCallback)(async()=>{try{B((await d(`/plugins/stats?limit=20`)).stats)}catch{}},[]),Z=(0,C.useCallback)(async()=>{try{J((await d(`/roles`)).roles)}catch{}},[]);(0,C.useEffect)(()=>{Y(),X(),Z()},[Y,X,Z]);let ae=async(e,t)=>{P(e);try{await d(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),m.success(`${e} ${t?`enabled`:`disabled`} globally`),o(n=>n.map(n=>n.id===e?{...n,globalEnabled:t}:n))}catch(e){m.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{P(null)}},oe=async e=>{P(e);try{await d(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),m.success(`Plugin uninstalled`),await Promise.all([Y(),X()])}catch(e){m.error(e instanceof Error?e.message:`Uninstall failed`)}finally{P(null)}},se=async(e,t,n)=>{P(e);try{await d(`/plugins/install/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify({scope:`project`,cwd:n})});let r=q.find(e=>e.id===t)?.name??t;m.success(`Installed ${e.split(`@`)[0]} for ${r}`),await Y()}catch(e){m.error(e instanceof Error?e.message:`Install to role failed`)}finally{P(null)}},Q=async()=>{if(L.trim())try{await d(`/plugins/install/${encodeURIComponent(L.trim())}`,{method:`POST`,body:JSON.stringify({})}),m.success(`Source added`),R(``),I(!1),await X()}catch(e){m.error(e instanceof Error?e.message:`Failed to add source`)}},ce=e=>{W(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},$=G===`all`?e:e.filter(e=>e.scope===G);return(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,w.jsx)(`h1`,{className:`text-lg font-semibold text-slate-100`,children:`Plugins`}),(0,w.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>void Y(),children:(0,w.jsx)(c,{size:14})})]}),(0,w.jsxs)(h,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(r,{size:14,className:`text-slate-400 flex-shrink-0`}),(0,w.jsx)(`button`,{className:`rounded-full px-2 py-0.5 text-xs transition-colors ${G===`all`?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>K(`all`),children:`All`}),(0,w.jsx)(`button`,{className:`rounded-full px-2 py-0.5 text-xs transition-colors ${G===`user`?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>K(`user`),children:`User`}),(0,w.jsx)(`button`,{className:`rounded-full px-2 py-0.5 text-xs transition-colors ${G===`project`?`bg-blue-600 text-white`:`bg-slate-800 text-slate-400 hover:bg-slate-700`}`,onClick:()=>K(`project`),children:`Project`}),(0,w.jsx)(`span`,{className:`h-4 w-px bg-slate-700 mx-1`}),u.map(e=>(0,w.jsx)(p,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,w.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[A&&(0,w.jsx)(t,{size:12,className:`animate-spin text-slate-500`}),A?null:(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>I(!F),children:F?(0,w.jsx)(l,{size:12}):(0,w.jsx)(te,{size:12})})]})]}),F&&(0,w.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,w.jsx)(`input`,{className:`flex-1 rounded border border-slate-700 bg-slate-900 px-2 py-1.5 text-sm text-slate-200 focus:border-blue-500 focus:outline-none`,value:L,onChange:e=>R(e.target.value),placeholder:`https://github.com/org/marketplace-repo`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,w.jsx)(f,{size:`sm`,onClick:()=>void Q(),disabled:!L.trim(),children:`Add`})]})]}),re?(0,w.jsx)(h,{children:(0,w.jsx)(`div`,{className:`py-8 text-center text-sm text-slate-500`,children:`Loading...`})}):$.length===0?(0,w.jsx)(h,{children:(0,w.jsx)(ne,{icon:(0,w.jsx)(s,{size:32}),title:`No plugins`,description:G===`all`?`No plugins installed. Browse the marketplace or install from a URL.`:`No ${G}-scope plugins installed.`})}):(0,w.jsx)(h,{padding:!1,children:(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{className:`w-8`}),(0,w.jsx)(v,{children:`Name`}),(0,w.jsx)(v,{children:`Version`}),(0,w.jsx)(v,{children:`Scope`}),(0,w.jsx)(v,{children:`Type`}),(0,w.jsx)(v,{children:`Activation`}),(0,w.jsx)(v,{children:`Actions`})]})}),(0,w.jsx)(y,{children:$.map(e=>{let n=U.has(e.id),r=e.id.split(`@`)[0],o=N===e.id;return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(b,{className:`group`,children:[(0,w.jsx)(x,{children:(0,w.jsx)(`button`,{onClick:()=>ce(e.id),className:`text-slate-500 hover:text-slate-300`,children:n?(0,w.jsx)(a,{size:12}):(0,w.jsx)(i,{size:12})})}),(0,w.jsx)(x,{className:`font-medium text-slate-200`,children:r}),(0,w.jsx)(x,{className:`text-xs text-slate-400`,children:e.version?`v${e.version}`:`—`}),(0,w.jsxs)(x,{children:[(0,w.jsx)(p,{variant:e.scope===`user`?`info`:`warning`,children:e.scope}),e.scope===`project`&&e.projectPath&&(0,w.jsx)(`div`,{className:`text-[10px] text-slate-600 truncate max-w-[120px]`,title:e.projectPath,children:e.projectPath.split(`/`).pop()})]}),(0,w.jsx)(x,{children:(0,w.jsx)(T,{manifest:e.manifest})}),(0,w.jsx)(x,{children:(0,w.jsx)(p,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`})}),(0,w.jsx)(x,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs`,disabled:o,onClick:()=>void ae(e.id,!e.globalEnabled),children:o?(0,w.jsx)(t,{size:10,className:`animate-spin`}):e.globalEnabled?`Disable`:`Enable`}),(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-xs text-red-400`,disabled:o,onClick:()=>void oe(e.id),children:(0,w.jsx)(ee,{size:10})})]})})]},e.id),n&&(0,w.jsx)(b,{className:`bg-slate-900/50`,children:(0,w.jsx)(x,{colSpan:7,className:`px-6 py-3`,children:e.manifest?(0,w.jsxs)(`div`,{className:`space-y-3 text-xs`,children:[e.manifest.description&&(0,w.jsx)(`p`,{className:`text-slate-400`,children:e.manifest.description}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[e.manifest.skills.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`Skills`}),e.manifest.skills.map(e=>(0,w.jsxs)(`div`,{className:`text-slate-400`,children:[(0,w.jsx)(`span`,{className:`text-slate-200`,children:e.name}),e.description&&(0,w.jsxs)(`span`,{className:`ml-1 text-slate-500`,children:[`— `,e.description]})]},e.name))]}),e.manifest.agents.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`Agents`}),e.manifest.agents.map(e=>(0,w.jsxs)(`div`,{className:`text-slate-400`,children:[(0,w.jsx)(`span`,{className:`text-slate-200`,children:e.name}),e.description&&(0,w.jsxs)(`span`,{className:`ml-1 text-slate-500`,children:[`— `,e.description]})]},e.name))]}),e.manifest.mcpServers.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,w.jsx)(`div`,{className:`text-slate-400`,children:e},e))]}),e.manifest.hooks.length>0&&(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`mb-1 font-semibold text-slate-300`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,w.jsx)(`div`,{className:`text-slate-400`,children:e},e))]})]}),(0,w.jsx)(`div`,{className:`text-slate-600 font-mono truncate mt-1`,title:e.installPath,children:e.installPath}),q.length>0&&e.scope===`user`&&(0,w.jsxs)(`div`,{className:`mt-3 pt-2 border-t border-slate-800`,children:[(0,w.jsx)(`span`,{className:`text-slate-400 mr-2`,children:`Install to Role:`}),q.map(t=>(0,w.jsx)(f,{variant:`ghost`,size:`sm`,className:`h-5 px-2 text-[10px] mr-1`,disabled:N===e.id,onClick:()=>void se(e.id,t.id,t.workspacePath),children:t.name},t.id))]})]}):(0,w.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Loading manifest...`})})},`${e.id}-detail`)]})})})]})}),(0,w.jsxs)(h,{children:[(0,w.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-slate-300`,onClick:()=>{!V&&z.length===0&&ie(),H(!V)},children:[(0,w.jsx)(n,{size:14,className:`text-slate-400`}),`Usage Stats`,V?(0,w.jsx)(a,{size:12,className:`ml-auto`}):(0,w.jsx)(i,{size:12,className:`ml-auto`})]}),V&&(0,w.jsx)(`div`,{className:`mt-3`,children:z.length===0?(0,w.jsx)(`p`,{className:`text-xs text-slate-500 text-center py-2`,children:`No usage data yet`}):(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{children:`Plugin`}),(0,w.jsx)(v,{children:`Usage Count`}),(0,w.jsx)(v,{children:`Last Used`})]})}),(0,w.jsx)(y,{children:z.map(e=>(0,w.jsxs)(b,{children:[(0,w.jsx)(x,{className:`font-medium text-slate-200 text-xs`,children:e.pluginName}),(0,w.jsx)(x,{className:`font-mono text-xs text-slate-400`,children:e.usageCount}),(0,w.jsx)(x,{className:`text-xs text-slate-400`,children:e.lastUsed?g(e.lastUsed):`—`})]},e.pluginPath))})]})})]})]})}export{E as Plugins};
|