adam-agent-server 1.11.0 → 1.12.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/package.json +1 -1
- package/web/dist/assets/{Button-CYDgoTTo.js → Button-VPwTNGpF.js} +1 -1
- package/web/dist/assets/{Card-DDGXsHus.js → Card-C2N6k4gh.js} +1 -1
- package/web/dist/assets/{ChannelDetail-Bb8P8It_.js → ChannelDetail-DktmpO0A.js} +1 -1
- package/web/dist/assets/{Channels-8j28oydE.js → Channels-ozCXdZMq.js} +2 -2
- package/web/dist/assets/{Chat-BZwLDoYO.js → Chat-CggvtidD.js} +1 -1
- package/web/dist/assets/{Dashboard-Cv0AtO-o.js → Dashboard-z37ZVhzH.js} +1 -1
- package/web/dist/assets/{EmptyState-EuQHAv5Y.js → EmptyState-CWS9PJND.js} +1 -1
- package/web/dist/assets/{EnvVarEditor-r-l-u4V7.js → EnvVarEditor-D0kGIBcl.js} +1 -1
- package/web/dist/assets/{EventDefDetail-asUFrbQE.js → EventDefDetail-BiXTA6LF.js} +1 -1
- package/web/dist/assets/Events-C4P3jjZd.js +1 -0
- package/web/dist/assets/{Evolution-DIqYOSb8.js → Evolution-C884p_CE.js} +1 -1
- package/web/dist/assets/{FeatureRequests-BxPqLR1x.js → FeatureRequests-Ck0WQnXX.js} +1 -1
- package/web/dist/assets/{GoalDetail-Bkvgg6uI.js → GoalDetail-DJOyf7By.js} +1 -1
- package/web/dist/assets/Goals-CDZWDuXR.js +1 -0
- package/web/dist/assets/{Logs-DnaaHV0Y.js → Logs-6r7fnBn7.js} +1 -1
- package/web/dist/assets/{Memories-Dq9S-Tsi.js → Memories-CvPaqv5r.js} +1 -1
- package/web/dist/assets/{Mistakes-D5lW31Co.js → Mistakes-aUhkqHDC.js} +1 -1
- package/web/dist/assets/{NotFound-gJVrOtER.js → NotFound-R6tIzhL0.js} +1 -1
- package/web/dist/assets/{PageHeader-CugYeCci.js → PageHeader-D9lLjo0N.js} +1 -1
- package/web/dist/assets/Plugins-CtwoMUoj.js +1 -0
- package/web/dist/assets/RoleDetail-B32225ae.js +33 -0
- package/web/dist/assets/{Roles-EBUueS_P.js → Roles-CGYsxuq8.js} +1 -1
- package/web/dist/assets/{SectionHeader-DihC0CnO.js → SectionHeader-BB3H3F_P.js} +1 -1
- package/web/dist/assets/Settings-D2jrO8-G.js +1 -0
- package/web/dist/assets/{Strategies-3IV9eueQ.js → Strategies-DUps-2I9.js} +1 -1
- package/web/dist/assets/Switch-B_R_EX9s.js +1 -0
- package/web/dist/assets/{Table-Cf6m8zLu.js → Table-D4lT5uHx.js} +1 -1
- package/web/dist/assets/Tabs-CwzWpI-7.js +1 -0
- package/web/dist/assets/{TaskDetail-BmXaH3sx.js → TaskDetail-DKminIM_.js} +1 -1
- package/web/dist/assets/Work-uD_6IieV.js +1 -0
- package/web/dist/assets/es2015-DCW7LI8d.js +41 -0
- package/web/dist/assets/index-6f2jcj0h.css +2 -0
- package/web/dist/assets/index-Bl-2p6d8.js +12 -0
- package/web/dist/assets/{useIsMobileLayout-2GbB90oO.js → useIsMobileLayout-D6Tz5o5h.js} +1 -1
- package/web/dist/assets/usePluginsWithUsage-CSQr03vZ.js +1 -0
- package/web/dist/assets/{vendor-icons-PF9RcPJx.js → vendor-icons-jzPiR6xl.js} +1 -1
- package/web/dist/assets/{vendor-react-Cxy4EVtR.js → vendor-react-CIkiuNDu.js} +1 -1
- package/web/dist/assets/{vendor-state-aQJ7d4tA.js → vendor-state-CEOsUh-T.js} +1 -1
- package/web/dist/index.html +7 -7
- package/web/dist/assets/AlertDialog-DhA65f_0.js +0 -51
- package/web/dist/assets/Events-DtkHL-r2.js +0 -1
- package/web/dist/assets/Goals-CkKJDCiU.js +0 -1
- package/web/dist/assets/Plugins-CoRmK2UG.js +0 -1
- package/web/dist/assets/RoleDetail-BHJA_PAn.js +0 -33
- package/web/dist/assets/Settings-DZHAGazz.js +0 -1
- package/web/dist/assets/Switch-B3w5KMMc.js +0 -1
- package/web/dist/assets/Work-CvQrOKtL.js +0 -1
- package/web/dist/assets/index-BsKlGx3x.js +0 -2
- package/web/dist/assets/index-EqsPGp9a.css +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adam-agent-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Goal-driven AI agent orchestration server with Role+Skill model, real-time streaming, and multi-channel delivery",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "norvyn https://x.com/norvynzhang https://github.com/n0rvyn norvynzhang@gmail.com",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-jzPiR6xl.js";import{t as n}from"./vendor-react-CIkiuNDu.js";import{n as r,t as i}from"./dist-CgGno8kE.js";var a=e(t(),1);function o(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function s(...e){return t=>{let n=!1,r=e.map(e=>{let r=o(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():o(e[t],null)}}}}function c(...e){return a.useCallback(s(...e),e)}var l=n(),u=Symbol.for(`react.lazy`),d=a.use;function f(e){return typeof e==`object`&&!!e&&`then`in e}function p(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===u&&`_payload`in e&&f(e._payload)}function m(e){let t=g(e),n=a.forwardRef((e,n)=>{let{children:r,...i}=e;p(r)&&typeof d==`function`&&(r=d(r._payload));let o=a.Children.toArray(r),s=o.find(v);if(s){let e=s.props.children,r=o.map(t=>t===s?a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null:t);return(0,l.jsx)(t,{...i,ref:n,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return(0,l.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var h=m(`Slot`);function g(e){let t=a.forwardRef((e,t)=>{let{children:n,...r}=e;if(p(n)&&typeof d==`function`&&(n=d(n._payload)),a.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==a.Fragment&&(i.ref=t?s(t,e):e),a.cloneElement(n,i)}return a.Children.count(n)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _=Symbol(`radix.slottable`);function v(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===_}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=i(`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-[background-color,border-color,color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-[var(--app-accent)] text-white shadow-[var(--app-shadow-accent)] hover:bg-[var(--app-accent-strong)] hover:shadow-[var(--app-shadow-lg)]`,secondary:`border border-[var(--app-border)] bg-white/[0.06] text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.1]`,destructive:`bg-[var(--app-danger)] text-white shadow-[var(--app-shadow-danger)] hover:bg-[var(--app-danger-strong)]`,ghost:`text-[var(--app-text-muted)] hover:text-[var(--app-text)] hover:bg-white/[0.06]`,outline:`border border-[var(--app-border)] bg-transparent text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.04]`,link:`text-[var(--app-accent-strong)] underline-offset-4 hover:underline`},size:{default:`px-3.5 py-1.5`,sm:`px-3 py-1.5 text-xs`,lg:`px-5 py-2.5`,icon:`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),S=a.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...a},o)=>(0,l.jsx)(i?h:`button`,{className:r(x({variant:t,size:n,className:e})),ref:o,...a}));S.displayName=`Button`;export{c as i,x as n,s as r,S as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-jzPiR6xl.js";import{t as n}from"./vendor-react-CIkiuNDu.js";import{n as r}from"./dist-CgGno8kE.js";var i=e(t(),1),a=n(),o=i.forwardRef(({className:e,padding:t=!0,...n},i)=>(0,a.jsx)(`div`,{ref:i,className:r(`surface-panel rounded-xl text-[var(--app-text)]`,t&&`p-4`,e),...n}));o.displayName=`Card`;var s=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`mb-4 flex items-start justify-between gap-3`,e),...t}));s.displayName=`CardHeader`;var c=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`h3`,{ref:n,className:r(`text-base font-semibold text-[var(--app-text)]`,e),...t}));c.displayName=`CardTitle`;var l=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`p`,{ref:n,className:r(`text-sm leading-6 text-[var(--app-text-muted)]`,e),...t}));l.displayName=`CardDescription`;var u=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`space-y-3`,e),...t}));u.displayName=`CardContent`;var d=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`flex items-center pt-3`,e),...t}));d.displayName=`CardFooter`;export{c as i,l as n,s as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,J as n,L as r,O as i,lt as a,ot as o}from"./vendor-icons-jzPiR6xl.js";import{f as s,r as c,t as l}from"./vendor-react-CIkiuNDu.js";import{t as u}from"./api-D-UzHSDq.js";import{t as d}from"./index-Bl-2p6d8.js";import{i as f,r as p,t as m}from"./Card-C2N6k4gh.js";import{t as h}from"./PageHeader-D9lLjo0N.js";import{t as g}from"./SectionHeader-BB3H3F_P.js";import{n as _}from"./format-BUYXZqDw.js";var v=e(a(),1),y=l();function b(){let{id:e}=s(),[a,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),E(null)}catch(e){E(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>S(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>S([])),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),w(r.slice(0,20))}).catch(()=>w([])))},[e]),T)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(o,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!a)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(o,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let D=e=>e===`connected`?`success`:e===`connecting`?`warning`:e===`error`?`destructive`:`secondary`,O=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)}},k={...a.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in k&&(k[e]=`********`);return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(o,{size:14}),` Back to Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:a.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(a.status),children:a.status})},{label:`Platform`,value:O(a.platform)},{label:`Enabled`,value:a.enabled?`Yes`:`No`},{label:`Messages`,value:a.messageCount}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Channel ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:a.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Linked role`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:a.linkedRoleId?`${a.linkedRoleId.slice(0,8)}...`:`None`})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Delivery rules`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Recent delivery events`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:C.length})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:n,label:`Created`,value:_(a.createdAt),mono:!0}),(0,y.jsx)(x,{icon:i,label:`Messages`,value:String(a.messageCount),mono:!0}),a.lastMessageAt&&(0,y.jsx)(x,{icon:n,label:`Last Message`,value:_(a.lastMessageAt),mono:!0}),a.linkedRoleId&&(0,y.jsx)(x,{icon:t,label:`Linked Role`,value:a.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,y.jsx)(g,{title:`Configuration`,compact:!0,description:`Raw config stays available below, but status and traffic stay first.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Configuration`})}),Object.keys(k).length>0&&(0,y.jsx)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Object.entries(k).slice(0,6).map(([e,t])=>(0,y.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,y.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,y.jsx)(`p`,{className:`mt-1 truncate text-sm text-[var(--app-text)]`,children:String(t)})]},e))}),(0,y.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:JSON.stringify(k,null,2)})]}),(0,y.jsx)(g,{title:`Delivery Activity`,compact:!0,description:`Rules and log entries stay grouped as one operational block.`}),b.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(r,{size:14}),` Delivery Rules (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{variant:`outline`,children:e.eventType}),e.enabled?(0,y.jsx)(d,{variant:`success`,children:`active`}):(0,y.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`max `,e.maxPerMinute,`/min`]})]}),(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)] font-mono`,children:[`Rule: `,e.id]})]},e.id))})]}),C.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(i,{size:14}),` Delivery Log (`,C.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:C.slice(0,10).map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--app-border)] p-2`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.taskId.slice(0,8)}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:_(e.createdAt)})]}),(0,y.jsx)(d,{variant:e.status===`delivered`?`default`:e.status===`failed`?`destructive`:`outline`,children:e.status})]},e.id))})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as ChannelDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,E as n,O as r,S as i,b as a,lt as o,n as s,s as c,w as l}from"./vendor-icons-jzPiR6xl.js";import{t as u}from"./vendor-react-CIkiuNDu.js";import{t as d}from"./Button-VPwTNGpF.js";import{t as f}from"./api-D-UzHSDq.js";import{t as p}from"./index-Bl-2p6d8.js";import{i as m,r as h,t as g}from"./Card-C2N6k4gh.js";import{t as _}from"./PageHeader-D9lLjo0N.js";import{t as v}from"./SectionHeader-BB3H3F_P.js";import{t as y}from"./EmptyState-CWS9PJND.js";import{t as b}from"./ui-CerQw0jA.js";var x=e(o(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`],w={telegram:`{
|
|
2
2
|
"botToken": ""
|
|
3
3
|
}`,slack:`{
|
|
4
4
|
"botToken": "",
|
|
@@ -9,4 +9,4 @@ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,D as n,T as r,k
|
|
|
9
9
|
"gatewayUrl": "ws://127.0.0.1:18789"
|
|
10
10
|
}`,wechat:`{
|
|
11
11
|
"baseUrl": "https://ilinkai.weixin.qq.com"
|
|
12
|
-
}`,whatsapp:`{}`},T=e=>{switch(e){case`connected`:return`success`;case`connecting`:return`warning`;case`degraded`:return`warning`;case`error`:return`destructive`;default:return`secondary`}};function E({initial:e,onSubmit:t,onCancel:n}){let[r,i]=(0,x.useState)(e?.name??``),[a,
|
|
12
|
+
}`,whatsapp:`{}`},T=e=>{switch(e){case`connected`:return`success`;case`connecting`:return`warning`;case`degraded`:return`warning`;case`error`:return`destructive`;default:return`secondary`}};function E({initial:e,onSubmit:t,onCancel:n}){let[r,i]=(0,x.useState)(e?.name??``),[a,o]=(0,x.useState)(e?.platform??`telegram`),[c,l]=(0,x.useState)(e?.config?JSON.stringify(e.config,null,2):w[e?.platform??`telegram`]??`{}`),[u,f]=(0,x.useState)(e?.enabled??!0),[p,h]=(0,x.useState)(``);function _(e){if(e.preventDefault(),!r.trim()){h(`Name is required`);return}let n;try{n=JSON.parse(c)}catch{h(`Invalid JSON in config`);return}h(``),t({name:r.trim(),platform:a,config:n,enabled:u})}return(0,S.jsx)(g,{children:(0,S.jsxs)(`form`,{onSubmit:_,className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e?`Edit Channel`:`New Channel`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,type:`button`,onClick:n,children:(0,S.jsx)(s,{size:14})})]}),p&&(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-danger)]`,children:p}),(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Name`}),(0,S.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`My Telegram Bot`,className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Platform`}),(0,S.jsx)(`select`,{value:a,onChange:t=>{o(t.target.value),e||l(w[t.target.value]??`{}`)},className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Config (JSON)`}),(0,S.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),rows:4,className:`resize-none rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`checkbox`,id:`ch-enabled`,checked:u,onChange:e=>f(e.target.checked),className:`rounded border-[var(--app-border)] bg-[var(--app-panel-elevated)]`}),(0,S.jsx)(`label`,{htmlFor:`ch-enabled`,className:`text-xs text-[var(--app-text-muted)]`,children:`Enabled`})]}),!e&&a===`wechat`&&(0,S.jsx)(`div`,{className:`rounded bg-[var(--app-accent-soft-bg)] border border-[var(--app-accent-soft-border)] px-3 py-2 text-xs text-[var(--app-accent)]`,children:`Creating a WeChat channel will start a QR code scan. Have your WeChat app ready.`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(d,{type:`submit`,size:`sm`,children:e?`Save`:a===`wechat`&&!e?`Create & Connect`:`Create`}),(0,S.jsx)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`})]})]})})}function D({channelId:e,onClose:t}){let[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(!0);return(0,x.useEffect)(()=>{(async()=>{try{r((await f(`/channels/${e}/messages`)).messages)}catch{}a(!1)})()},[e]),(0,S.jsxs)(g,{children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,S.jsx)(m,{children:`Channel Messages`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,onClick:t,children:(0,S.jsx)(s,{size:14})})]}),i?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):n.length===0?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No messages yet`}):(0,S.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-2`,children:n.map(e=>(0,S.jsxs)(`div`,{className:`rounded bg-[var(--app-panel-elevated)]/50 px-3 py-2 text-xs`,children:[(0,S.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,S.jsx)(`span`,{className:e.role===`user`?`text-[var(--app-accent)]`:`text-[var(--app-success)]`,children:e.role}),(0,S.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(e.createdAt).toLocaleTimeString()})]}),(0,S.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.content})]},e.id))})]})}function O(){let[e,o]=(0,x.useState)([]),[s,u]=(0,x.useState)(!0),[C,w]=(0,x.useState)(!1),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{I()},[]);async function I(){try{o((await f(`/channels`)).channels)}catch{}u(!1)}async function L(e){try{let t=await f(`/channels`,{method:`POST`,body:JSON.stringify(e)});w(!1),I(),e.platform===`wechat`&&t.channel?.id&&z(t.channel.id)}catch{}}async function R(e){if(O)try{await f(`/channels/${O.id}`,{method:`PATCH`,body:JSON.stringify(e)}),k(null),I()}catch{}}async function z(t){if(e.find(e=>e.id===t)?.platform===`wechat`)try{let e=await f(`/channels/${t}/wechat/qr-start`,{method:`POST`});if(e.qrcodeUrl&&e.sessionKey){N({channelId:t,qrcodeUrl:e.qrcodeUrl,sessionKey:e.sessionKey}),F(!0);try{(await f(`/channels/${t}/wechat/qr-wait`,{method:`POST`,body:JSON.stringify({sessionKey:e.sessionKey,timeoutMs:12e4})})).connected&&I()}catch{}N(null),F(!1)}}catch{}else try{await f(`/channels/${t}/connect`,{method:`POST`}),I()}catch{}}async function B(e){try{await f(`/channels/${e}/disconnect`,{method:`POST`}),I()}catch{}}async function V(e){try{await f(`/channels/${e}`,{method:`DELETE`}),o(t=>t.filter(t=>t.id!==e))}catch{}}return s?(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,S.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsx)(_,{eyebrow:`Delivery`,title:`Channels`,description:`Connection status, volume, and edit access for every delivery endpoint.`,metrics:[{label:`Connected`,value:e.filter(e=>e.status===`connected`).length},{label:`Enabled`,value:e.filter(e=>e.enabled).length},{label:`Messages`,value:e.reduce((e,t)=>e+t.messageCount,0)}],compact:!0,actions:(0,S.jsxs)(d,{size:`sm`,onClick:()=>{w(!0),k(null)},children:[(0,S.jsx)(i,{size:14}),`Add Channel`]})}),(0,S.jsx)(v,{title:`Endpoints`,description:`Connect, disconnect, edit, inspect messages, or add a new endpoint.`,compact:!0,action:(0,S.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` channel`,e.length===1?``:`s`]})}),C&&!O&&(0,S.jsx)(E,{onSubmit:L,onCancel:()=>w(!1)}),O&&(0,S.jsx)(E,{initial:O,onSubmit:R,onCancel:()=>k(null)}),A&&(0,S.jsx)(D,{channelId:A,onClose:()=>j(null)}),M&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,S.jsxs)(g,{className:`max-w-sm text-center`,children:[(0,S.jsx)(m,{className:`mb-3 text-[var(--app-text)]`,children:`Scan QR Code with WeChat`}),(0,S.jsx)(`img`,{src:`https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${encodeURIComponent(M.qrcodeUrl)}`,alt:`WeChat QR Code`,className:`mx-auto h-64 w-64 rounded bg-white p-2`}),(0,S.jsx)(`p`,{className:`mt-3 text-xs text-[var(--app-text-muted)]`,children:P?`Waiting for scan...`:`Open WeChat and scan the QR code`}),(0,S.jsx)(`a`,{href:M.qrcodeUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mt-1 block text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)] truncate max-w-[280px] mx-auto`,children:M.qrcodeUrl}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,className:`mt-3`,onClick:()=>{N(null),F(!1)},children:`Cancel`})]})}),e.length===0&&!C?(0,S.jsx)(g,{children:(0,S.jsx)(y,{icon:(0,S.jsx)(a,{size:b.hero}),title:`No channels`,description:`Add a channel to connect Adam to messaging platforms like Telegram, Slack, or Discord.`})}):(0,S.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsxs)(g,{children:[(0,S.jsxs)(h,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(a,{size:16,className:`text-[var(--app-text-muted)]`}),(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e.name})]}),(0,S.jsx)(p,{variant:T(e.status),children:e.status})]}),(0,S.jsxs)(`div`,{className:`space-y-2 text-xs text-[var(--app-text-muted)]`,children:[(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Platform`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.platform})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Messages`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.messageCount})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Enabled`}),(0,S.jsx)(`span`,{className:e.enabled?`text-[var(--app-success)]`:`text-[var(--app-text-subtle)]`,children:e.enabled?`Yes`:`No`})]})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 border-t border-[var(--app-border)] pt-3`,children:[e.status===`connected`?(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void B(e.id),children:[(0,S.jsx)(l,{size:12}),` Disconnect`]}):(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void z(e.id),children:[(0,S.jsx)(t,{size:12}),` Connect`]}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>{k(e),w(!1)},children:(0,S.jsx)(n,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>j(e.id),children:(0,S.jsx)(r,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void V(e.id),children:(0,S.jsx)(c,{size:12})})]})]},e.id))})]})}export{O as Channels};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-D-UzHSDq.js","assets/rolldown-runtime-Dw2cE7zH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,C as n,Y as r,f as i,g as a,j as o,lt as s,n as c,p as l,s as u,st as d,y as f}from"./vendor-icons-PF9RcPJx.js";import{p,t as m}from"./vendor-react-Cxy4EVtR.js";import{r as h}from"./dist-CgGno8kE.js";import{t as g}from"./Button-CYDgoTTo.js";import{n as _}from"./vendor-state-aQJ7d4tA.js";import{t as v}from"./api-D-UzHSDq.js";import{t as y}from"./PageHeader-CugYeCci.js";import{a as b}from"./format-BUYXZqDw.js";import{t as x}from"./EmptyState-EuQHAv5Y.js";import{t as S}from"./ui-CerQw0jA.js";import{t as C}from"./useIsMobileLayout-2GbB90oO.js";var w=e(s(),1),T=_((e,t)=>({sessions:[],activeSessionId:null,messages:[],loading:!1,sending:!1,_chatWs:null,_chatWsReconnectDelay:1e3,fetchSessions:async()=>{try{e({sessions:(await v(`/chat/sessions`)).sessions})}catch{}},fetchMessages:async t=>{e({loading:!0});try{e({messages:(await v(`/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 v(`/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 v(`/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 v(`/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 v(`/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 v(`/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()),s=!1;o.onopen=()=>{s=!0,e({_chatWs:o,_chatWsReconnectDelay:1e3})},o.onclose=async()=>{if(!s&&i){let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await p(async()=>{let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await import(`./api-D-UzHSDq.js`).then(e=>e.n);return{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}},__vite__mapDeps([0,1]));if(!await e(i).catch(()=>!0)){t(),n();return}}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}))}})),E=m();function D({message:e}){let t=e.role===`user`,n=t?`You`:e.taskId?`Adam · execution`:`Adam`;return(0,E.jsx)(`div`,{className:h(`flex`,t?`justify-end`:`justify-start`),children:(0,E.jsxs)(`div`,{className:h(`max-w-[85%] rounded-lg px-4 py-3 text-sm leading-7 shadow-[var(--app-shadow-md)]`,t?`surface-accent text-white`:`surface-panel text-[var(--app-text)]`),children:[(0,E.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[11px] uppercase tracking-[0.16em]`,children:[(0,E.jsx)(`span`,{className:t?`text-white/70`:`text-[var(--app-kicker)]`,children:n}),(0,E.jsx)(`span`,{className:t?`text-white/45`:`text-[var(--app-text-subtle)]`,children:b(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]}),(0,E.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})})}function O({onSend:e,disabled:t,placeholder:n=`Type a message...`,starterActions:r=[],showStarterActions:i=!0,compact:o=!1}){let[s,c]=(0,w.useState)(``),l=(0,w.useRef)(null),u=()=>{let n=s.trim();!n||t||(e(n),c(``),l.current&&(l.current.style.height=`auto`))},d=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u())},f=()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};return(0,E.jsxs)(`div`,{className:o?`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-3`:`surface-panel-elevated rounded-xl p-3`,children:[i&&r.length>0?(0,E.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:r.map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{c(e.value),requestAnimationFrame(()=>l.current?.focus())},className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-3 py-1.5 text-xs font-medium text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,children:e.label},e.label))}):null,(0,E.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,E.jsx)(`textarea`,{ref:l,value:s,onChange:e=>{c(e.target.value),f()},onKeyDown:d,placeholder:n,disabled:t,rows:1,className:`min-h-12 flex-1 resize-none rounded-lg border border-[var(--app-border)] bg-white/[0.04] px-4 py-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-border-strong)] focus:outline-none focus:ring-1 focus:ring-[var(--app-accent)] disabled:opacity-50`}),(0,E.jsxs)(g,{onClick:u,disabled:t||!s.trim(),size:`default`,"aria-label":`Send message`,children:[(0,E.jsx)(a,{size:16}),`Send`]})]}),(0,E.jsx)(`div`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:`Enter to send; Shift+Enter for a new line.`})]})}function k({session:e,isActive:t,onSelect:n,onArchive:r,onRestore:i,onDelete:a}){let o=e.status===`archived`,s=(e,t)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())};return(0,E.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:h(`group flex w-full flex-col gap-1 rounded-lg border px-3 py-3 text-left transition-colors`,t?`border-[var(--app-border-strong)] bg-white/[0.08] text-[var(--app-text)]`:`border-transparent text-[var(--app-text-muted)] hover:border-[var(--app-border)] hover:bg-white/[0.04] hover:text-[var(--app-text)]`,o&&`opacity-60`),"aria-label":e.title??e.id.slice(0,8),children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title??e.id.slice(0,8)}),(0,E.jsxs)(`div`,{className:h(`flex gap-0.5 transition-opacity`,t?`opacity-100`:`opacity-100 lg:opacity-0 lg:group-hover:opacity-100 lg:group-focus-within:opacity-100`),children:[o?(0,E.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-success)]`,onClick:e=>{e.stopPropagation(),i()},onKeyDown:e=>s(e,i),title:`Restore session`,"aria-label":`Restore session`,children:(0,E.jsx)(f,{size:S.xs})}):(0,E.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-warning)]`,onClick:e=>{e.stopPropagation(),r()},onKeyDown:e=>s(e,r),title:`Archive session`,"aria-label":`Archive session`,children:(0,E.jsx)(d,{size:S.xs})}),(0,E.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-danger)]`,onClick:e=>{e.stopPropagation(),a()},onKeyDown:e=>s(e,a),title:`Delete session`,"aria-label":`Delete session`,children:(0,E.jsx)(u,{size:S.xs})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-[var(--app-text-subtle)]`,children:[(0,E.jsxs)(`span`,{children:[e.messageCount,` turns`]}),(0,E.jsx)(`span`,{children:b(e.lastActiveAt)}),o&&(0,E.jsx)(`span`,{className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.16em]`,children:`archived`})]})]})}function A({sessions:e,activeSessionId:t,onSelectSession:r,onNewSession:i,onArchiveSession:a,onRestoreSession:o,onDeleteSession:s,onClose:c}){let{recentSessions:l,earlierSessions:u,archivedSessions:d,activeSessions:f}=(0,w.useMemo)(()=>{let t=Date.now(),n=1440*60*1e3,r=e.filter(e=>e.status===`active`);return{recentSessions:r.filter(e=>t-e.lastActiveAt<n),earlierSessions:r.filter(e=>t-e.lastActiveAt>=n),archivedSessions:e.filter(e=>e.status===`archived`),activeSessions:r}},[e]);return(0,E.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`text-section-label`,children:`Sessions`}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch context or reopen archived work.`})]}),(0,E.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:i,"aria-label":`New session`,children:[(0,E.jsx)(n,{size:14}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`New`})]})]}),(0,E.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[f.length===0&&d.length===0&&(0,E.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-[var(--app-text-subtle)]`,children:`No sessions yet`}),l.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`mb-2 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Today`}),(0,E.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,E.jsx)(k,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]}),u.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Earlier`}),(0,E.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,E.jsx)(k,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]}),d.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Archived`}),(0,E.jsx)(`div`,{className:`space-y-1`,children:d.map(e=>(0,E.jsx)(k,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]})]})]})}var j=[{label:`Debug a failure`,value:`Review the most recent failed task and explain the next fix.`},{label:`Summarize status`,value:`Summarize the current system status, blockers, and active work.`},{label:`Plan a task`,value:`Break down the next implementation task into a concrete execution plan.`}];function M(){let e=T(e=>e.sessions),a=T(e=>e.activeSessionId),s=T(e=>e.messages),u=T(e=>e.sending),d=T(e=>e.fetchSessions),f=T(e=>e.sendMessage),p=T(e=>e.createSession),m=T(e=>e.archiveSession),h=T(e=>e.restoreSession),_=T(e=>e.deleteSession),v=T(e=>e.setActiveSession),b=T(e=>e.connectChatStream),k=T(e=>e.disconnectChatStream),M=(0,w.useRef)(null),[P,F]=(0,w.useState)(!1),I=C(1024),L=e.filter(e=>e.status===`active`),R=e.filter(e=>e.status===`archived`),z=e.length>0,B=s.length>0,V=e.find(e=>e.id===a)??null;(0,w.useEffect)(()=>{d()},[d]),(0,w.useEffect)(()=>(b(),()=>k()),[b,k]),(0,w.useEffect)(()=>{M.current?.scrollIntoView?.({behavior:`smooth`})},[s]),(0,w.useEffect)(()=>{I||F(!1)},[I]),(0,w.useEffect)(()=>{if(a||e.length===0)return;let t=[...e].filter(e=>e.status===`active`).sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0]??[...e].sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0];t&&v(t.id)},[a,e,v]);let H=async e=>{await f(e)};return(0,E.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-5`,children:[(0,E.jsx)(y,{title:`Chat`,description:z?`Resume the latest session, inspect context, and keep the composer in view.`:`Start the first session and use Adam as the working surface for review, debugging, and planning.`,compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>void p(),children:[(0,E.jsx)(n,{size:14}),`New Session`]}),(0,E.jsxs)(g,{variant:`secondary`,size:`sm`,className:`lg:hidden`,onClick:()=>F(!0),"aria-label":`Manage sessions`,children:[(0,E.jsx)(o,{size:16}),`Sessions`]})]})}),P?(0,E.jsxs)(`div`,{className:`fixed inset-0 z-40 lg:hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":`Session manager`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>F(!1)}),(0,E.jsxs)(`div`,{className:`relative z-50 h-full w-full max-w-sm border-r border-[var(--app-border)] bg-[var(--app-canvas)] shadow-[var(--app-shadow-lg)]`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`p`,{className:`text-section-label`,children:`Sessions`}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch, archive, restore, or start a new conversation.`})]}),(0,E.jsx)(g,{variant:`ghost`,size:`icon`,onClick:()=>F(!1),"aria-label":`Close session manager`,children:(0,E.jsx)(c,{size:16})})]}),(0,E.jsx)(A,{sessions:e,activeSessionId:a,onSelectSession:v,onNewSession:()=>{p(),F(!1)},onArchiveSession:e=>void m(e),onRestoreSession:e=>void h(e),onDeleteSession:e=>void _(e),onClose:()=>F(!1)})]})]}):null,(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden rounded-xl border border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_88%,transparent)] shadow-[var(--app-shadow-lg)]`,children:[(0,E.jsx)(`div`,{className:`hidden w-72 flex-shrink-0 border-r border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_90%,transparent)] lg:block`,children:(0,E.jsx)(A,{sessions:e,activeSessionId:a,onSelectSession:v,onNewSession:()=>void p(),onArchiveSession:e=>void m(e),onRestoreSession:e=>void h(e),onDeleteSession:e=>void _(e)})}),(0,E.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 lg:px-6`,children:B?(0,E.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-3`,children:[s.map(e=>(0,E.jsx)(D,{message:e},e.id)),(0,E.jsx)(`div`,{ref:M})]}):z?(0,E.jsx)(`div`,{className:`mx-auto flex h-full w-full max-w-4xl items-start`,children:(0,E.jsxs)(`div`,{className:`surface-panel-muted flex w-full flex-col gap-4 rounded-xl p-5`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`p`,{className:`text-kicker`,children:`Working Surface`}),(0,E.jsx)(`h2`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:V?`Session ${V.title??V.id.slice(0,8)}`:`Pick a session to continue`}),(0,E.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-[var(--app-text-muted)]`,children:V?`This session has no loaded transcript yet. Continue here or start a new thread without leaving the page.`:`Archived history exists, but no session is active. Select one from the rail or start a new conversation.`})]}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-[var(--app-text-subtle)]`,children:[(0,E.jsxs)(`span`,{children:[L.length,` active`]}),(0,E.jsxs)(`span`,{children:[R.length,` archived`]})]})]}),(0,E.jsx)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:j.map(e=>(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void H(e.value),className:`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-4 text-left transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05]`,children:[(0,E.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:e.label}),(0,E.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:e.value})]},e.label))})]})}):(0,E.jsx)(x,{icon:(0,E.jsx)(t,{size:S.hero}),title:`Start a conversation with Adam`,description:`Use the starter prompts below to inspect recent work, diagnose failures, or create an execution plan.`,className:`h-full min-h-[24rem]`,action:(0,E.jsxs)(`div`,{className:`grid gap-3 text-left sm:grid-cols-3`,children:[(0,E.jsx)(N,{icon:l,title:`Inspect live status`,description:`Summarize active work, risk, and recent changes.`}),(0,E.jsx)(N,{icon:i,title:`Dig into a task`,description:`Review recent execution output and the next concrete step.`}),(0,E.jsx)(N,{icon:r,title:`Recover context`,description:`Continue from the latest session without losing history.`})]})})}),(0,E.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 pb-4 lg:px-6`,children:(0,E.jsx)(O,{onSend:H,disabled:u,starterActions:j,showStarterActions:!z&&!B,compact:z})})]})]})]})}function N({icon:e,title:t,description:n}){return(0,E.jsxs)(`div`,{className:`surface-panel-muted rounded-lg p-4`,children:[(0,E.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white/[0.05] text-[var(--app-kicker)]`,children:(0,E.jsx)(e,{size:S.lg})}),(0,E.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:t}),(0,E.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:n})]})}export{M as Chat};
|
|
2
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,S as n,Y as r,d as i,f as a,h as o,k as s,lt as c,n as l,s as u,st as d,v as f}from"./vendor-icons-jzPiR6xl.js";import{p,t as m}from"./vendor-react-CIkiuNDu.js";import{r as h}from"./dist-CgGno8kE.js";import{t as g}from"./Button-VPwTNGpF.js";import{n as _}from"./vendor-state-CEOsUh-T.js";import{t as v}from"./api-D-UzHSDq.js";import{t as y}from"./PageHeader-D9lLjo0N.js";import{a as b}from"./format-BUYXZqDw.js";import{t as x}from"./EmptyState-CWS9PJND.js";import{t as S}from"./ui-CerQw0jA.js";import{t as C}from"./useIsMobileLayout-D6Tz5o5h.js";var w=e(c(),1),T=_((e,t)=>({sessions:[],activeSessionId:null,messages:[],loading:!1,sending:!1,_chatWs:null,_chatWsReconnectDelay:1e3,fetchSessions:async()=>{try{e({sessions:(await v(`/chat/sessions`)).sessions})}catch{}},fetchMessages:async t=>{e({loading:!0});try{e({messages:(await v(`/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 v(`/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 v(`/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 v(`/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 v(`/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 v(`/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()),s=!1;o.onopen=()=>{s=!0,e({_chatWs:o,_chatWsReconnectDelay:1e3})},o.onclose=async()=>{if(!s&&i){let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await p(async()=>{let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await import(`./api-D-UzHSDq.js`).then(e=>e.n);return{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}},__vite__mapDeps([0,1]));if(!await e(i).catch(()=>!0)){t(),n();return}}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}))}})),E=m();function D({message:e}){let t=e.role===`user`,n=t?`You`:e.taskId?`Adam · execution`:`Adam`;return(0,E.jsx)(`div`,{className:h(`flex`,t?`justify-end`:`justify-start`),children:(0,E.jsxs)(`div`,{className:h(`max-w-[85%] rounded-lg px-4 py-3 text-sm leading-7 shadow-[var(--app-shadow-md)]`,t?`surface-accent text-white`:`surface-panel text-[var(--app-text)]`),children:[(0,E.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[11px] uppercase tracking-[0.16em]`,children:[(0,E.jsx)(`span`,{className:t?`text-white/70`:`text-[var(--app-kicker)]`,children:n}),(0,E.jsx)(`span`,{className:t?`text-white/45`:`text-[var(--app-text-subtle)]`,children:b(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]}),(0,E.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})})}function O({onSend:e,disabled:t,placeholder:n=`Type a message...`,starterActions:r=[],showStarterActions:i=!0,compact:a=!1}){let[s,c]=(0,w.useState)(``),l=(0,w.useRef)(null),u=()=>{let n=s.trim();!n||t||(e(n),c(``),l.current&&(l.current.style.height=`auto`))},d=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u())},f=()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};return(0,E.jsxs)(`div`,{className:a?`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-3`:`surface-panel-elevated rounded-xl p-3`,children:[i&&r.length>0?(0,E.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:r.map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{c(e.value),requestAnimationFrame(()=>l.current?.focus())},className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-3 py-1.5 text-xs font-medium text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,children:e.label},e.label))}):null,(0,E.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,E.jsx)(`textarea`,{ref:l,value:s,onChange:e=>{c(e.target.value),f()},onKeyDown:d,placeholder:n,disabled:t,rows:1,className:`min-h-12 flex-1 resize-none rounded-lg border border-[var(--app-border)] bg-white/[0.04] px-4 py-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-border-strong)] focus:outline-none focus:ring-1 focus:ring-[var(--app-accent)] disabled:opacity-50`}),(0,E.jsxs)(g,{onClick:u,disabled:t||!s.trim(),size:`default`,"aria-label":`Send message`,children:[(0,E.jsx)(o,{size:16}),`Send`]})]}),(0,E.jsx)(`div`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:`Enter to send; Shift+Enter for a new line.`})]})}function k({session:e,isActive:t,onSelect:n,onArchive:r,onRestore:i,onDelete:a}){let o=e.status===`archived`,s=(e,t)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())};return(0,E.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:h(`group flex w-full flex-col gap-1 rounded-lg border px-3 py-3 text-left transition-colors`,t?`border-[var(--app-border-strong)] bg-white/[0.08] text-[var(--app-text)]`:`border-transparent text-[var(--app-text-muted)] hover:border-[var(--app-border)] hover:bg-white/[0.04] hover:text-[var(--app-text)]`,o&&`opacity-60`),"aria-label":e.title??e.id.slice(0,8),children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title??e.id.slice(0,8)}),(0,E.jsxs)(`div`,{className:h(`flex gap-0.5 transition-opacity`,t?`opacity-100`:`opacity-100 lg:opacity-0 lg:group-hover:opacity-100 lg:group-focus-within:opacity-100`),children:[o?(0,E.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-success)]`,onClick:e=>{e.stopPropagation(),i()},onKeyDown:e=>s(e,i),title:`Restore session`,"aria-label":`Restore session`,children:(0,E.jsx)(f,{size:S.xs})}):(0,E.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-warning)]`,onClick:e=>{e.stopPropagation(),r()},onKeyDown:e=>s(e,r),title:`Archive session`,"aria-label":`Archive session`,children:(0,E.jsx)(d,{size:S.xs})}),(0,E.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-danger)]`,onClick:e=>{e.stopPropagation(),a()},onKeyDown:e=>s(e,a),title:`Delete session`,"aria-label":`Delete session`,children:(0,E.jsx)(u,{size:S.xs})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-[var(--app-text-subtle)]`,children:[(0,E.jsxs)(`span`,{children:[e.messageCount,` turns`]}),(0,E.jsx)(`span`,{children:b(e.lastActiveAt)}),o&&(0,E.jsx)(`span`,{className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.16em]`,children:`archived`})]})]})}function A({sessions:e,activeSessionId:t,onSelectSession:r,onNewSession:i,onArchiveSession:a,onRestoreSession:o,onDeleteSession:s,onClose:c}){let{recentSessions:l,earlierSessions:u,archivedSessions:d,activeSessions:f}=(0,w.useMemo)(()=>{let t=Date.now(),n=1440*60*1e3,r=e.filter(e=>e.status===`active`);return{recentSessions:r.filter(e=>t-e.lastActiveAt<n),earlierSessions:r.filter(e=>t-e.lastActiveAt>=n),archivedSessions:e.filter(e=>e.status===`archived`),activeSessions:r}},[e]);return(0,E.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`text-section-label`,children:`Sessions`}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch context or reopen archived work.`})]}),(0,E.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:i,"aria-label":`New session`,children:[(0,E.jsx)(n,{size:14}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:`New`})]})]}),(0,E.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[f.length===0&&d.length===0&&(0,E.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-[var(--app-text-subtle)]`,children:`No sessions yet`}),l.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`mb-2 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Today`}),(0,E.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,E.jsx)(k,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]}),u.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Earlier`}),(0,E.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,E.jsx)(k,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]}),d.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Archived`}),(0,E.jsx)(`div`,{className:`space-y-1`,children:d.map(e=>(0,E.jsx)(k,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]})]})]})}var j=[{label:`Debug a failure`,value:`Review the most recent failed task and explain the next fix.`},{label:`Summarize status`,value:`Summarize the current system status, blockers, and active work.`},{label:`Plan a task`,value:`Break down the next implementation task into a concrete execution plan.`}];function M(){let e=T(e=>e.sessions),o=T(e=>e.activeSessionId),c=T(e=>e.messages),u=T(e=>e.sending),d=T(e=>e.fetchSessions),f=T(e=>e.sendMessage),p=T(e=>e.createSession),m=T(e=>e.archiveSession),h=T(e=>e.restoreSession),_=T(e=>e.deleteSession),v=T(e=>e.setActiveSession),b=T(e=>e.connectChatStream),k=T(e=>e.disconnectChatStream),M=(0,w.useRef)(null),[P,F]=(0,w.useState)(!1),I=C(1024),L=e.filter(e=>e.status===`active`),R=e.filter(e=>e.status===`archived`),z=e.length>0,B=c.length>0,V=e.find(e=>e.id===o)??null;(0,w.useEffect)(()=>{d()},[d]),(0,w.useEffect)(()=>(b(),()=>k()),[b,k]),(0,w.useEffect)(()=>{M.current?.scrollIntoView?.({behavior:`smooth`})},[c]),(0,w.useEffect)(()=>{I||F(!1)},[I]),(0,w.useEffect)(()=>{if(o||e.length===0)return;let t=[...e].filter(e=>e.status===`active`).sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0]??[...e].sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0];t&&v(t.id)},[o,e,v]);let H=async e=>{await f(e)};return(0,E.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-5`,children:[(0,E.jsx)(y,{title:`Chat`,description:z?`Resume the latest session, inspect context, and keep the composer in view.`:`Start the first session and use Adam as the working surface for review, debugging, and planning.`,compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>void p(),children:[(0,E.jsx)(n,{size:14}),`New Session`]}),(0,E.jsxs)(g,{variant:`secondary`,size:`sm`,className:`lg:hidden`,onClick:()=>F(!0),"aria-label":`Manage sessions`,children:[(0,E.jsx)(t,{size:16}),`Sessions`]})]})}),P?(0,E.jsxs)(`div`,{className:`fixed inset-0 z-40 lg:hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":`Session manager`,children:[(0,E.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>F(!1)}),(0,E.jsxs)(`div`,{className:`relative z-50 h-full w-full max-w-sm border-r border-[var(--app-border)] bg-[var(--app-canvas)] shadow-[var(--app-shadow-lg)]`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`p`,{className:`text-section-label`,children:`Sessions`}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch, archive, restore, or start a new conversation.`})]}),(0,E.jsx)(g,{variant:`ghost`,size:`icon`,onClick:()=>F(!1),"aria-label":`Close session manager`,children:(0,E.jsx)(l,{size:16})})]}),(0,E.jsx)(A,{sessions:e,activeSessionId:o,onSelectSession:v,onNewSession:()=>{p(),F(!1)},onArchiveSession:e=>void m(e),onRestoreSession:e=>void h(e),onDeleteSession:e=>void _(e),onClose:()=>F(!1)})]})]}):null,(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden rounded-xl border border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_88%,transparent)] shadow-[var(--app-shadow-lg)]`,children:[(0,E.jsx)(`div`,{className:`hidden w-72 flex-shrink-0 border-r border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_90%,transparent)] lg:block`,children:(0,E.jsx)(A,{sessions:e,activeSessionId:o,onSelectSession:v,onNewSession:()=>void p(),onArchiveSession:e=>void m(e),onRestoreSession:e=>void h(e),onDeleteSession:e=>void _(e)})}),(0,E.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,E.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 lg:px-6`,children:B?(0,E.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-3`,children:[c.map(e=>(0,E.jsx)(D,{message:e},e.id)),(0,E.jsx)(`div`,{ref:M})]}):z?(0,E.jsx)(`div`,{className:`mx-auto flex h-full w-full max-w-4xl items-start`,children:(0,E.jsxs)(`div`,{className:`surface-panel-muted flex w-full flex-col gap-4 rounded-xl p-5`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`p`,{className:`text-kicker`,children:`Working Surface`}),(0,E.jsx)(`h2`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:V?`Session ${V.title??V.id.slice(0,8)}`:`Pick a session to continue`}),(0,E.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-[var(--app-text-muted)]`,children:V?`This session has no loaded transcript yet. Continue here or start a new thread without leaving the page.`:`Archived history exists, but no session is active. Select one from the rail or start a new conversation.`})]}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-[var(--app-text-subtle)]`,children:[(0,E.jsxs)(`span`,{children:[L.length,` active`]}),(0,E.jsxs)(`span`,{children:[R.length,` archived`]})]})]}),(0,E.jsx)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:j.map(e=>(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void H(e.value),className:`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-4 text-left transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05]`,children:[(0,E.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:e.label}),(0,E.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:e.value})]},e.label))})]})}):(0,E.jsx)(x,{icon:(0,E.jsx)(s,{size:S.hero}),title:`Start a conversation with Adam`,description:`Use the starter prompts below to inspect recent work, diagnose failures, or create an execution plan.`,className:`h-full min-h-[24rem]`,action:(0,E.jsxs)(`div`,{className:`grid gap-3 text-left sm:grid-cols-3`,children:[(0,E.jsx)(N,{icon:a,title:`Inspect live status`,description:`Summarize active work, risk, and recent changes.`}),(0,E.jsx)(N,{icon:i,title:`Dig into a task`,description:`Review recent execution output and the next concrete step.`}),(0,E.jsx)(N,{icon:r,title:`Recover context`,description:`Continue from the latest session without losing history.`})]})})}),(0,E.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 pb-4 lg:px-6`,children:(0,E.jsx)(O,{onSend:H,disabled:u,starterActions:j,showStarterActions:!z&&!B,compact:z})})]})]})]})}function N({icon:e,title:t,description:n}){return(0,E.jsxs)(`div`,{className:`surface-panel-muted rounded-lg p-4`,children:[(0,E.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white/[0.05] text-[var(--app-kicker)]`,children:(0,E.jsx)(e,{size:S.lg})}),(0,E.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:t}),(0,E.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:n})]})}export{M as Chat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,N as n,Q as r,X as i,ct as a,lt as o}from"./vendor-icons-jzPiR6xl.js";import{r as s,t as c}from"./vendor-react-CIkiuNDu.js";import{t as l}from"./vendor-state-CEOsUh-T.js";import{f as u,n as d,t as f}from"./index-Bl-2p6d8.js";import{i as p,n as m,r as h,t as g}from"./Card-C2N6k4gh.js";import{t as _}from"./PageHeader-D9lLjo0N.js";import{t as v}from"./SectionHeader-BB3H3F_P.js";import{a as y,o as b,t as x}from"./format-BUYXZqDw.js";var S=e(o(),1),C=c();function w(){let{tasks:e,goals:o,roles:c,stats:w,readiness:D,executionPool:O}=u(l(e=>({tasks:e.tasks,goals:e.goals,roles:e.roles,stats:e.stats,readiness:e.readiness,executionPool:e.executionPool}))),k=u(e=>e.fetchTasks),A=u(e=>e.fetchGoals),j=u(e=>e.fetchRoles),M=u(e=>e.fetchExecutionPool);(0,S.useEffect)(()=>{k(),A(),j(),M();let e=setInterval(()=>{k(),M()},5e3);return()=>clearInterval(e)},[k,A,j,M]);let N=e.filter(e=>e.status===`running`).length,P=e.filter(e=>e.status===`queued`||e.status===`pending`).length,F=e.filter(e=>e.status===`failed`).length,I=(0,S.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]),L=(0,S.useMemo)(()=>I.slice(0,4),[I]),R=(0,S.useMemo)(()=>I.find(e=>e.status===`failed`)||I.find(e=>e.status===`running`)||I[0],[I]),z=(0,S.useMemo)(()=>D?Object.entries(D.checks):[],[D]),B=(0,S.useMemo)(()=>z.filter(([,e])=>e).length,[z]),V=R?.roleId?c.find(e=>e.id===R.roleId)?.name??R.roleId.slice(0,8):`Unassigned`,H=R?`/tasks/${R.id}`:`/work`,U=R?`Open task`:`Open work`,W=R?R.status===`failed`?`Review the failed task before queueing more work.`:R.status===`running`?`Track this active run and its next result.`:`Use the latest completed run as the starting point for follow-up work.`:`Queue work, review recent runs, or launch an automation.`,G=R?R.status===`failed`?`surface-critical`:R.status===`running`?`surface-accent`:`surface-panel-elevated`:`surface-panel-muted`,K=G===`surface-critical`?`critical`:G===`surface-accent`?`accent`:`neutral`,q=K===`accent`||K===`critical`,J=q?`text-white`:`text-[var(--app-text)]`,Y=q?`text-white/70`:`text-[var(--app-text-subtle)]`,X=q?`text-white/76`:`text-[var(--app-text-muted)]`;return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(_,{title:`Dashboard`,description:`Queue health, execution readiness, and the next task that needs attention.`,metrics:[{label:`Server`,value:D?.status===`ready`?`Ready`:`Attention`},{label:`Running`,value:w.activeTasks||N},{label:`Queued`,value:w.queuedTasks||P},{label:`Goals`,value:o.length},{label:`Execution Pool`,value:`${O.active}/${O.max} | ${O.queued} queued`}],compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:D?(0,C.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:(0,C.jsx)(f,{variant:D.status===`ready`?`success`:`destructive`,children:D.status===`ready`?`Server Ready`:`Not Ready`})}):null}),(0,C.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-2`,children:[(0,C.jsxs)(g,{className:`${G} self-start ${q?`text-white`:``}`,children:[(0,C.jsxs)(h,{className:`mb-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`text-kicker ${Y}`,children:`Current Focus`}),(0,C.jsx)(p,{className:`mt-2 ${J}`,children:R?b(R.prompt,92):`No active blockers`})]}),R?(0,C.jsx)(f,{variant:d(R.status),children:R.status}):null]}),(0,C.jsx)(m,{className:X,children:W}),(0,C.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))_auto]`,children:[(0,C.jsx)(E,{tone:K,label:`Created`,value:R?y(R.createdAt):`Idle`}),(0,C.jsx)(E,{tone:K,label:`Cost`,value:R?.costUsd==null?`No cost`:x(R.costUsd)}),(0,C.jsx)(E,{tone:K,label:`Role`,value:V}),(0,C.jsx)(s,{to:H,className:`inline-flex items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${q?`border-white/20 bg-white/10 text-white hover:bg-white/14`:`border-[var(--app-border)] bg-white/[0.05] text-[var(--app-text)] hover:border-[var(--app-border-strong)]`}`,children:U})]})]}),(0,C.jsxs)(g,{className:`surface-panel-elevated self-start`,children:[(0,C.jsx)(v,{title:`System Checks`,description:`${B}/${z.length||0} checks passing`,compact:!0}),D?(0,C.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:Object.entries(D.checks).map(([e,t])=>(0,C.jsxs)(`div`,{className:`surface-panel-muted flex items-center justify-between rounded-lg px-3 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(i,{size:10,className:t?`fill-[var(--app-success)] text-[var(--app-success)]`:`fill-[var(--app-danger)] text-[var(--app-danger)]`}),(0,C.jsx)(`span`,{className:`text-sm capitalize text-[var(--app-text)]`,children:e})]}),(0,C.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?`healthy`:`attention`})]},e))}):(0,C.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,role:`region`,"aria-label":`Server statistics`,children:[(0,C.jsx)(T,{icon:n,label:`Active Tasks`,value:w.activeTasks||N,color:`text-[var(--app-accent)]`}),(()=>{let e=c.filter(e=>e.status===`active`).length,t=c.length,n=c.filter(e=>e.status===`probation`).length,r=c.filter(e=>e.status===`retired`).length,i=[n>0?`${n} probation`:``,r>0?`${r} retired`:``].filter(Boolean).join(` · `);return(0,C.jsx)(T,{icon:a,label:`Role Health`,value:i?`${e}/${t} | ${i}`:`${e}/${t}`,color:r>0?`text-[var(--app-danger)]`:n>0?`text-[var(--app-warning)]`:`text-[var(--app-success)]`})})(),(0,C.jsx)(T,{icon:t,label:`Failed`,value:F,color:`text-[var(--app-danger)]`}),(0,C.jsx)(T,{icon:r,label:`Cost Today`,value:x(w.totalCostToday),color:`text-[var(--app-accent-strong)]`})]}),(0,C.jsxs)(g,{padding:!1,children:[(0,C.jsx)(`div`,{className:`px-4 pt-4`,children:(0,C.jsx)(v,{title:`Recent Tasks`,description:`Latest executions across the control plane.`,action:(0,C.jsx)(s,{to:`/work`,className:`text-sm font-medium text-[var(--app-accent-strong)] hover:underline`,children:`View all`})})}),(0,C.jsx)(`div`,{className:`mt-4 space-y-3 px-4 pb-4`,children:L.length===0?(0,C.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-6 text-sm text-[var(--app-text-subtle)]`,children:`No tasks yet`}):L.map(e=>(0,C.jsxs)(s,{to:`/tasks/${e.id}`,className:`surface-panel-muted flex flex-col gap-3 rounded-lg px-4 py-4 transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05] lg:flex-row lg:items-start lg:justify-between`,children:[(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(f,{variant:d(e.status),children:e.status}),(0,C.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.id.slice(0,8)}),e.roleId?(0,C.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`role `,e.roleId.slice(0,12)]}):null]}),(0,C.jsx)(`div`,{className:`text-sm font-medium text-[var(--app-text)]`,children:b(e.prompt,128)})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs text-[var(--app-text-subtle)]`,children:[(0,C.jsx)(`span`,{children:y(e.createdAt)}),(0,C.jsx)(`span`,{children:e.costUsd==null?`no cost`:x(e.costUsd)})]})]},e.id))})]})]})}function T({icon:e,label:t,value:n,color:r}){return(0,C.jsxs)(g,{className:`surface-panel-muted flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`rounded-lg bg-white/[0.05] p-3 ${r}`,children:(0,C.jsx)(e,{size:16})}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:n}),(0,C.jsx)(`div`,{className:`text-xs uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:t})]})]})}function E({label:e,value:t,tone:n=`accent`}){let r=n===`accent`||n===`critical`;return(0,C.jsxs)(`div`,{className:r?`rounded-lg border border-white/12 bg-black/10 px-3 py-3`:`surface-focus-metric rounded-lg px-3 py-3`,children:[(0,C.jsx)(`div`,{className:r?`text-[10px] uppercase tracking-[0.16em] text-white/62`:`text-[10px] uppercase tracking-[0.16em] text-[var(--app-text-subtle)]`,children:e}),(0,C.jsx)(`div`,{className:r?`mt-1 text-lg font-semibold text-white`:`mt-1 text-lg font-semibold text-[var(--app-text)]`,children:t})]})}export{w as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-
|
|
1
|
+
import{t as e}from"./vendor-react-CIkiuNDu.js";import{n as t}from"./dist-CgGno8kE.js";var n=e();function r({icon:e,title:r,description:i,action:a,compact:o=!1,className:s}){return(0,n.jsxs)(`div`,{className:t(`surface-panel-muted flex flex-col items-center justify-center rounded-xl text-center`,o?`px-5 py-6`:`px-6 py-10`,s),children:[e&&(0,n.jsx)(`div`,{className:t(`text-[var(--app-text-subtle)]`,o?`mb-3`:`mb-4`),children:e}),(0,n.jsx)(`h3`,{className:`text-base font-semibold text-[var(--app-text)]`,children:r}),i&&(0,n.jsx)(`p`,{className:t(`max-w-md text-sm text-[var(--app-text-muted)]`,o?`mt-1.5 leading-5`:`mt-2 leading-6`),children:i}),a&&(0,n.jsx)(`div`,{className:t(o?`mt-3`:`mt-4`),children:a})]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{H as t,S as n,U as r,lt as i,o as a,s as o}from"./vendor-icons-jzPiR6xl.js";import{t as s}from"./vendor-react-CIkiuNDu.js";import{n as c}from"./dist-CgGno8kE.js";import{t as l}from"./Button-VPwTNGpF.js";import{t as u}from"./api-D-UzHSDq.js";import{p as d}from"./index-Bl-2p6d8.js";import{i as f,r as p,t as m}from"./Card-C2N6k4gh.js";import{t as h}from"./ui-CerQw0jA.js";var g=e(i(),1),_=s(),v=g.forwardRef(({className:e,type:t,...n},r)=>(0,_.jsx)(`input`,{type:t,className:c(`flex h-8 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));v.displayName=`Input`;var y=/^[A-Za-z_][A-Za-z0-9_]*$/,b=/key|token|secret|password|credential/i;function x({envVars:e,onSave:i,mode:s,roleId:c,title:x=`Environment Variables`}){let[S,C]=(0,g.useState)([]),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(new Set),[O,k]=(0,g.useState)([]),[A,j]=(0,g.useState)(!1);(0,g.useEffect)(()=>{C(Object.entries(e??{}).map(([e,t])=>({key:e,value:t,isNew:!1})))},[e]);let M=(0,g.useCallback)(async()=>{try{let e=await u(s===`global`?`/config/env-diff`:`/roles/${c}/env-diff`);k(s===`global`?e.diffs.filter(e=>e.configPath?.startsWith(`defaults.env.`)):e.diffs),j(e.envFileExists)}catch{}},[s,c]);(0,g.useEffect)(()=>{M()},[M]);let N=()=>{let t=Object.fromEntries(S.filter(e=>e.key.trim()).map(e=>[e.key,e.value]));return JSON.stringify(t)!==JSON.stringify(e)},P=()=>{C(e=>[...e,{key:``,value:``,isNew:!0}])},F=e=>{C(t=>t.filter((t,n)=>n!==e))},I=(e,t,n)=>{C(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},L=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},R=()=>{let e=new Set;for(let t of S){let n=t.key.trim();if(n){if(!y.test(n))return`Invalid key format: "${n}"`;if(n.startsWith(`ANTHROPIC_`))return`ANTHROPIC_* keys are managed in the Anthropic section`;if(e.has(n))return`Duplicate key: "${n}"`;e.add(n)}}return e.size>100?`Maximum 100 environment variables`:null},z=async()=>{let e=R();if(e){d.error(e);return}T(!0);try{let e={};for(let t of S){let n=t.key.trim();n&&(e[n]=t.value)}s===`global`?await u(`/config/env`,{method:`PUT`,body:JSON.stringify(e)}):await u(`/roles/${c}`,{method:`PATCH`,body:JSON.stringify({envVars:e})}),d.success(`Environment variables saved`),i(),M()}catch(e){d.error(e instanceof Error?e.message:`Failed to save`)}finally{T(!1)}},B=async()=>{try{await u(s===`global`?`/config/sync-to-env`:`/roles/${c}/sync-to-env`,{method:`POST`}),d.success(`Synced DB to .env`),M()}catch(e){d.error(e instanceof Error?e.message:`Sync failed`)}},V=async()=>{try{await u(s===`global`?`/config/load-from-env`:`/roles/${c}/load-from-env`,{method:`POST`}),d.success(`Loaded .env to DB`),i(),M()}catch(e){d.error(e instanceof Error?e.message:`Load failed`)}};return(0,_.jsxs)(m,{children:[(0,_.jsxs)(p,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsx)(f,{className:`text-sm`,children:x}),(0,_.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,_.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:P,children:[(0,_.jsx)(n,{size:h.sm}),`Add`]}),N()&&(0,_.jsx)(l,{size:`sm`,onClick:()=>void z(),disabled:w,children:w?`Saving...`:`Save`})]})]}),s===`global`&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mt-1`,children:`ANTHROPIC_* variables are managed in the Anthropic section above.`})]}),O.length>0&&A&&(0,_.jsx)(`div`,{className:`mx-4 mb-3 rounded border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] p-3`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,_.jsx)(a,{size:14,className:`text-[var(--app-warning)]`}),(0,_.jsxs)(`span`,{className:`text-xs text-[var(--app-warning)]`,children:[`.env and DB differ on `,O.length,` key(s): `,O.map(e=>e.envKey).join(`, `)]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void B(),children:`DB → .env`}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void V(),children:`.env → DB`})]})]})}),(0,_.jsxs)(`div`,{className:`px-4 pb-4 space-y-2`,children:[S.length===0&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] py-2`,children:`No environment variables configured.`}),S.map((e,n)=>{let i=b.test(e.key),a=E.has(e.key)||e.isNew;return(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,_.jsx)(v,{className:`w-full font-mono text-xs md:w-48`,placeholder:`KEY_NAME`,value:e.key,onChange:e=>I(n,`key`,e.target.value)}),(0,_.jsx)(`span`,{className:`hidden text-[var(--app-text-subtle)] md:inline`,children:`=`}),(0,_.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,_.jsx)(v,{className:`font-mono text-xs pr-8`,type:i&&!a?`password`:`text`,placeholder:`value`,value:e.value,onChange:e=>I(n,`value`,e.target.value)}),i&&(0,_.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>L(e.key),children:a?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12})})]}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`self-end text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)] md:self-auto`,onClick:()=>F(n),children:(0,_.jsx)(o,{size:14})})]},n)})]})]})}export{x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t,ot as n,y as r}from"./vendor-icons-jzPiR6xl.js";import{d as i,f as a,t as o}from"./vendor-react-CIkiuNDu.js";import{t as s}from"./Button-VPwTNGpF.js";import{t as c}from"./api-D-UzHSDq.js";import{p as l,t as u}from"./index-Bl-2p6d8.js";import{t as d}from"./Card-C2N6k4gh.js";import{t as f}from"./SectionHeader-BB3H3F_P.js";import{t as p}from"./EmptyState-CWS9PJND.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./Table-D4lT5uHx.js";var b=e(t(),1),x=o(),S={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`},C={running:`info`,completed:`success`,failed:`destructive`,partial:`warning`,cancelled:`muted`};function w(){let{id:e}=a(),t=i(),[o,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(0),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(0),[V,H]=(0,b.useState)(!1),[U,W]=(0,b.useState)(`config`),G=(0,b.useCallback)(async()=>{if(e){E(!0);try{w(await c(`/event-defs/${e}`))}catch{l.error(`Event not found`),t(`/events`)}finally{E(!1)}}},[e,t]),K=(0,b.useCallback)(async(t=0)=>{if(e){A(!0);try{let n=t===0?void 0:new Date(Date.now()-10080*60*1e3).toISOString(),r=await c(`/event-defs/${e}/firings?${new URLSearchParams({limit:`20`,...n?{since:n}:{}})}`);O(t===0?r:e=>[...e,...r]),P(r.length===20),M(t)}catch{l.error(`Failed to load firings`)}finally{A(!1)}}},[e]);(0,b.useEffect)(()=>{G()},[G]),(0,b.useEffect)(()=>{U===`firings`&&D.length===0&&K(0)},[U,K,D.length]);let q=(0,b.useCallback)(async(t=0)=>{if(e){R(!0);try{let n=await c(`/event-defs/${e}/dispatches?${new URLSearchParams({limit:`20`,offset:String(t*20)})}`);I(t===0?n:e=>[...e,...n]),H(n.length===20),B(t)}catch{l.error(`Failed to load dispatches`)}finally{R(!1)}}},[e]);return(0,b.useEffect)(()=>{U===`dispatches`&&F.length===0&&q(0)},[U,q,F.length]),T?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):o?(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>t(`/events`),children:(0,x.jsx)(n,{size:14})}),(0,x.jsx)(f,{title:o.name,description:o.description,compact:!0,action:(0,x.jsx)(`div`,{className:`flex gap-2`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void G(),children:(0,x.jsx)(r,{size:14})})})})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(u,{variant:S[o.sourceType],children:o.sourceType===`directory_watch`?`file watcher`:o.sourceType}),(0,x.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${o.enabled?`bg-green-900/30 text-green-400`:`bg-gray-800/30 text-gray-400`}`,children:o.enabled?`Enabled`:`Disabled`}),(0,x.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Created `,new Date(o.createdAt).toLocaleDateString()]})]}),o.sourceType===`webhook`&&(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Webhook URL`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`code`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] break-all`,children:[window.location.origin,`/webhooks/events/`,o.id]}),(0,x.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>{if(!o)return;let e=`${window.location.origin}/webhooks/events/${o.id}`;navigator.clipboard.writeText(e),l.success(`Webhook URL copied to clipboard`)},children:`Copy`})]}),(0,x.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Send a POST request with JSON body: `,(0,x.jsx)(`code`,{className:`rounded bg-[var(--app-panel)] px-1`,children:`{ "type": "event.name", "payload": {...} }`})]})]}),(()=>{let e=o.sourceConfig?.cron;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Schedule`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)]`,children:e})]}):null})(),(()=>{let e=o.sourceConfig?.path;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Watch Directory`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)] break-all`,children:e})]}):null})(),(0,x.jsxs)(`div`,{className:`flex gap-1 border-b border-[var(--app-border)]`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`config`),className:`px-4 py-2 text-sm transition-colors ${U===`config`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Configuration`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`firings`),className:`px-4 py-2 text-sm transition-colors ${U===`firings`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Firings`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`dispatches`),className:`px-4 py-2 text-sm transition-colors ${U===`dispatches`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Dispatches`})]}),U===`firings`&&(0,x.jsx)(d,{padding:!1,children:k&&D.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):D.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(r,{size:32}),title:`No firings yet`,description:`This event has not been triggered yet.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(y,{children:[(0,x.jsx)(m,{children:(0,x.jsxs)(_,{children:[(0,x.jsx)(h,{children:`Occurred At`}),(0,x.jsx)(h,{children:`Type`}),(0,x.jsx)(h,{children:`Source`}),(0,x.jsx)(h,{children:`Confidence`}),(0,x.jsx)(h,{children:`Payload`})]})}),(0,x.jsx)(g,{children:D.map(e=>(0,x.jsxs)(_,{children:[(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)] whitespace-nowrap`,children:new Date(e.occurredAt).toLocaleString()}),(0,x.jsx)(v,{children:(0,x.jsx)(`code`,{className:`text-xs font-mono text-[var(--app-text)]`,children:e.type})}),(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)]`,children:e.source}),(0,x.jsx)(v,{className:`text-xs`,children:(0,x.jsx)(`span`,{className:e.confidence<1?`text-yellow-400`:`text-[var(--app-text-muted)]`,children:e.confidence})}),(0,x.jsx)(v,{className:`max-w-[200px]`,children:(0,x.jsxs)(`code`,{className:`text-xs font-mono text-[var(--app-text-muted)] truncate block`,children:[JSON.stringify(e.payload).slice(0,60),JSON.stringify(e.payload).length>60?`...`:``]})})]},e.id))})]}),N&&(0,x.jsx)(`div`,{className:`flex justify-center p-3 border-t border-[var(--app-border)]`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void K(j+1),disabled:k,children:k?`Loading...`:`Load more`})})]})}),U===`dispatches`&&(0,x.jsx)(d,{padding:!1,children:L&&F.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):F.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(r,{size:32}),title:`No dispatches yet`,description:`No task template has been dispatched from this event. Bind a template (trigger=event, eventDefId=this event) to see dispatch history.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(y,{children:[(0,x.jsx)(m,{children:(0,x.jsxs)(_,{children:[(0,x.jsx)(h,{children:`Started At`}),(0,x.jsx)(h,{children:`Template`}),(0,x.jsx)(h,{children:`Status`}),(0,x.jsx)(h,{children:`Duration`}),(0,x.jsx)(h,{children:`Error`})]})}),(0,x.jsx)(g,{children:F.map(e=>{let n=e.completedAt?`${e.completedAt-e.startedAt}ms`:`—`;return(0,x.jsxs)(_,{children:[(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)] whitespace-nowrap`,children:new Date(e.startedAt).toLocaleString()}),(0,x.jsx)(v,{children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>t(`/templates/${e.templateId}`),className:`text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:e.templateName??e.templateId})}),(0,x.jsx)(v,{children:(0,x.jsx)(u,{variant:C[e.status],children:e.status})}),(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,x.jsx)(v,{className:`max-w-[300px]`,children:e.error?(0,x.jsx)(`code`,{className:`text-xs font-mono text-[var(--app-danger)] truncate block`,title:e.error,children:e.error.length>80?`${e.error.slice(0,80)}…`:e.error}):(0,x.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`})})]},e.executionId)})})]}),V&&(0,x.jsx)(`div`,{className:`flex justify-center p-3 border-t border-[var(--app-border)]`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void q(z+1),disabled:L,children:L?`Loading...`:`Load more`})})]})})]}):null}export{w as EventDefDetail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{E as t,S as n,T as ee,lt as r,s as te,t as ne,y as re}from"./vendor-icons-jzPiR6xl.js";import{d as ie,t as i}from"./vendor-react-CIkiuNDu.js";import"./es2015-DCW7LI8d.js";import{t as a}from"./Button-VPwTNGpF.js";import{t as o}from"./api-D-UzHSDq.js";import{a as ae,c as s,i as c,l,o as u,p as d,r as f,s as oe,t as se,u as ce}from"./index-Bl-2p6d8.js";import{t as p}from"./Card-C2N6k4gh.js";import{t as le}from"./SectionHeader-BB3H3F_P.js";import{a as ue}from"./format-BUYXZqDw.js";import{t as de}from"./EmptyState-CWS9PJND.js";import{a as fe,i as m,n as pe,o as h,r as g,t as me}from"./Table-D4lT5uHx.js";import{t as he}from"./Switch-B_R_EX9s.js";var _=e(r(),1),v=i(),ge={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`};function y(e){let t=e.trim().split(/\s+/);return t.length===5?t.every(e=>/^(\*|(\*\/)?\d+(-\d+)?(,\d+(-\d+)?)*)$/.test(e)):!1}function b(){let e=ie(),[r,i]=(0,_.useState)([]),[b,x]=(0,_.useState)(!0),[_e,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(``),[T,ve]=(0,_.useState)(`webhook`),[E,D]=(0,_.useState)(``),[O,k]=(0,_.useState)(``),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(``),[B,ye]=(0,_.useState)(``),[V,be]=(0,_.useState)(`webhook`),[H,U]=(0,_.useState)(``),[W,G]=(0,_.useState)(``),[K,q]=(0,_.useState)(``),[xe,Se]=(0,_.useState)(!1),[J,Y]=(0,_.useState)(null),[X,Z]=(0,_.useState)(null),[Q,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),$=(0,_.useCallback)(async()=>{x(!0);try{i(await o(`/event-defs`))}catch{d.error(`Failed to load events`)}finally{x(!1)}},[]);(0,_.useEffect)(()=>{$()},[$]);let Ee=async()=>{if(C.trim()){if(T===`cron`&&!y(A)){N(`Invalid cron expression (expected 5 fields: minute hour day month weekday)`);return}F(!0);try{let e={name:C.trim(),sourceType:T,description:E.trim()||void 0,enabled:!0};T===`directory_watch`&&O.trim()?e.sourceConfig={path:O.trim(),stability_delay_ms:5e3}:T===`cron`&&A.trim()&&(e.sourceConfig={cron:A.trim()}),await o(`/event-defs`,{method:`POST`,body:JSON.stringify(e)}),w(``),D(``),k(``),j(``),N(``),S(!1),$(),d.success(`Event created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create event`;d.error(t)}finally{F(!1)}}},De=e=>{L(e.id),z(e.name),ye(e.description??``),be(e.sourceType),U(e.sourceConfig?.path??``),G(e.sourceConfig?.cron??``),q(``)},Oe=async()=>{if(!(!I||!R.trim())){if(V===`cron`&&!y(W)){q(`Invalid cron expression`);return}Se(!0);try{let e={name:R.trim(),description:B.trim()||void 0};V===`directory_watch`?e.sourceConfig={path:H.trim(),stability_delay_ms:5e3}:V===`cron`&&(e.sourceConfig={cron:W.trim()}),await o(`/event-defs/${I}`,{method:`PATCH`,body:JSON.stringify(e)}),L(null),$(),d.success(`Event updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update event`;d.error(t)}finally{Se(!1)}}},ke=async e=>{try{await o(`/event-defs/${e.id}`,{method:`PATCH`,body:JSON.stringify({enabled:!e.enabled})}),$()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle`;d.error(t)}},Ae=async e=>{try{await o(`/event-defs/${e}`,{method:`DELETE`}),Y(null),$(),d.success(`Event deleted`)}catch(e){let t=e instanceof Error?e.message:`Failed to delete`;d.error(t)}},je=async e=>{Te(!0);try{let t={};if(Q.trim())try{t.payload=JSON.parse(Q)}catch{t.payload={raw:Q}}await o(`/event-defs/${e}/fire`,{method:`POST`,body:JSON.stringify(t)}),Z(null),Ce(``),d.success(`Event fired`)}catch(e){let t=e instanceof Error?e.message:`Failed to fire event`;d.error(t)}finally{Te(!1)}},Me=r.find(e=>e.id===J);return(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsx)(le,{title:`Events`,description:`Event definitions that trigger automations. Configure webhooks, schedules, or file watchers.`,compact:!0,action:(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void $(),children:(0,v.jsx)(re,{size:14})}),(0,v.jsxs)(a,{size:`sm`,onClick:()=>S(!_e),children:[(0,v.jsx)(n,{size:14}),`New Event`]})]})}),_e&&(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`New Event`}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Event name`,value:C,onChange:e=>w(e.target.value)}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Description (optional)`,value:E,onChange:e=>D(e.target.value)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Source:`}),(0,v.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:T,onChange:e=>ve(e.target.value),children:[(0,v.jsx)(`option`,{value:`webhook`,children:`Webhook (HTTP)`}),(0,v.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,v.jsx)(`option`,{value:`directory_watch`,children:`File Watcher`}),(0,v.jsx)(`option`,{value:`manual`,children:`Manual`})]})]}),T===`directory_watch`&&(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Watch directory path (absolute)`,value:O,onChange:e=>k(e.target.value)}),T===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression (minute hour day month weekday)`,value:A,onChange:e=>{j(e.target.value),N(``)}}),M&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:M})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{onClick:()=>void Ee(),disabled:P||!C.trim()||T===`directory_watch`&&!O.trim(),children:P?`Creating...`:`Create`}),(0,v.jsx)(a,{variant:`ghost`,onClick:()=>S(!1),children:`Cancel`})]})]}),I!==null&&(r.find(e=>e.id===I)?(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Event`}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Event name`,value:R,onChange:e=>z(e.target.value)}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)]`,placeholder:`Description (optional)`,value:B,onChange:e=>ye(e.target.value)}),V===`directory_watch`&&(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)]`,placeholder:`Watch directory path`,value:H,onChange:e=>U(e.target.value)}),V===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)]`,placeholder:`Cron expression`,value:W,onChange:e=>{G(e.target.value),q(``)}}),K&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:K})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{onClick:()=>void Oe(),disabled:xe||!R.trim(),children:xe?`Saving...`:`Save`}),(0,v.jsx)(a,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`})]})]}):null),(0,v.jsx)(p,{padding:!1,children:b?(0,v.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,v.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):r.length===0?(0,v.jsx)(de,{icon:(0,v.jsx)(ne,{size:32}),title:`No events`,description:`Events are triggered by webhooks, schedules, or file changes and can start automations.`}):(0,v.jsxs)(me,{children:[(0,v.jsx)(fe,{children:(0,v.jsxs)(h,{children:[(0,v.jsx)(m,{children:`Name`}),(0,v.jsx)(m,{children:`Source`}),(0,v.jsx)(m,{children:`Enabled`}),(0,v.jsx)(m,{children:`Last Fired`}),(0,v.jsx)(m,{children:`Actions`})]})}),(0,v.jsx)(pe,{children:r.map(n=>(0,v.jsxs)(h,{children:[(0,v.jsxs)(g,{children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>e(`/events/${n.id}`),className:`font-medium text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:n.name}),n.description&&(0,v.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] truncate max-w-[200px]`,children:n.description})]}),(0,v.jsx)(g,{children:(0,v.jsx)(se,{variant:ge[n.sourceType],children:n.sourceType===`directory_watch`?`file watcher`:n.sourceType})}),(0,v.jsx)(g,{children:(0,v.jsx)(he,{checked:n.enabled,onCheckedChange:()=>void ke(n),"aria-label":`Toggle ${n.name}`})}),(0,v.jsx)(g,{className:`text-xs text-[var(--app-text-muted)]`,children:n.lastFiredAt?ue(n.lastFiredAt):`—`}),(0,v.jsx)(g,{children:(0,v.jsxs)(`div`,{className:`flex gap-1`,children:[(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>De(n),title:`Edit`,children:(0,v.jsx)(t,{size:12})}),n.sourceType===`manual`&&n.enabled&&(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>Z(n.id),title:`Fire now`,children:(0,v.jsx)(ee,{size:12})}),(0,v.jsx)(a,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Y(n.id),title:`Delete`,children:(0,v.jsx)(te,{size:12})})]})})]},n.id))})]})}),(0,v.jsx)(f,{open:X!==null,onOpenChange:e=>{e||Z(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(ce,{children:`Fire Event`}),(0,v.jsx)(oe,{children:`Fire the manual event immediately. Optionally provide a JSON payload.`})]}),(0,v.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder='{}' focus:border-[var(--app-accent)] focus:outline-none font-mono`,rows:4,placeholder:`{"key": "value"}`,value:Q,onChange:e=>Ce(e.target.value)}),(0,v.jsxs)(s,{children:[(0,v.jsx)(ae,{children:`Cancel`}),(0,v.jsx)(c,{onClick:()=>{X&&je(X),Z(null)},disabled:we,children:we?`Firing...`:`Fire Event`})]})]})}),(0,v.jsx)(f,{open:J!==null,onOpenChange:e=>{e||Y(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(ce,{children:`Delete Event`}),(0,v.jsxs)(oe,{children:[`Delete “`,Me?.name,`”? This action cannot be undone.`]})]}),(0,v.jsxs)(s,{children:[(0,v.jsx)(ae,{children:`Cancel`}),(0,v.jsx)(c,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{J&&Ae(J)},children:`Delete`})]})]})})]})}export{b as Events};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t,y as n,z as r}from"./vendor-icons-jzPiR6xl.js";import{t as i}from"./vendor-react-CIkiuNDu.js";import{t as a}from"./Button-VPwTNGpF.js";import{t as o}from"./api-D-UzHSDq.js";import{f as s,t as c}from"./index-Bl-2p6d8.js";import{t as l}from"./Card-C2N6k4gh.js";import{t as u}from"./PageHeader-D9lLjo0N.js";import{a as d}from"./format-BUYXZqDw.js";import{t as f}from"./EmptyState-CWS9PJND.js";var p=e(t(),1),m=i();function h(){let e=s(e=>e.roles),t=s(e=>e.fetchRoles),[i,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(!0),[v,y]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{t()},[t]);let b=(0,p.useCallback)(async()=>{_(!0);try{let e=new URLSearchParams({limit:`50`});v!==`all`&&e.set(`roleId`,v),h(await o(`/evolution-audit?${e}`))}catch{h([])}finally{_(!1)}},[v]);(0,p.useEffect)(()=>{b()},[b]);let x=t=>t?e.find(e=>e.id===t)?.name??t.slice(0,8):`System`;return(0,m.jsxs)(`div`,{className:`space-y-5`,children:[(0,m.jsx)(u,{eyebrow:`Learning`,title:`Evolution Audit`,compact:!0,description:`Rule mutations and diagnostic reports across roles.`,metrics:[{label:`Visible`,value:i.length},{label:`Role Filter`,value:v===`all`?`All`:x(v)},{label:`Catalog`,value:e.length}],actions:(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsxs)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:v,onChange:e=>y(e.target.value),children:[(0,m.jsx)(`option`,{value:`all`,children:`All roles`}),e.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,m.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:(0,m.jsx)(n,{size:14})})]})}),(0,m.jsx)(l,{children:g?(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-[var(--app-border)] border-t-[var(--app-accent)]`})}):i.length===0?(0,m.jsx)(f,{icon:(0,m.jsx)(r,{size:32}),title:`No evolution records`,description:`Evolution occurs when roles accumulate enough task experience.`,className:`py-8`}):(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[i.length,` records`]}),i.map(e=>(0,m.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,m.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,m.jsx)(c,{variant:`info`,children:x(e.roleId)}),(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:d(e.timestamp)}),e.triggerTaskId&&(0,m.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`triggered by task `,e.triggerTaskId.slice(0,8)]})]}),e.diff.includes(`--- Diagnostic Report ---`)?(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Diagnostic Report`}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-[var(--app-text-muted)]`,children:e.diff.split(`--- Rules Diff ---`)[0]?.replace(`--- Diagnostic Report ---
|
|
2
2
|
`,``).trim()})]}),(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Rules Changes`}),(0,m.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,m.jsxs)(`span`,{className:e.startsWith(`+`)?`text-[var(--app-success)]`:e.startsWith(`-`)?`text-[var(--app-danger)]`:`text-[var(--app-text-muted)]`,children:[e,`
|
|
4
4
|
`]},t))})]})]}):(0,m.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[var(--app-canvas)] p-2 font-mono text-xs`,children:e.diff.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-jzPiR6xl.js";import{t as n}from"./vendor-react-CIkiuNDu.js";import{t as r}from"./Button-VPwTNGpF.js";import{t as i}from"./api-D-UzHSDq.js";import{t as a}from"./index-Bl-2p6d8.js";import{t as o}from"./Card-C2N6k4gh.js";import{t as s}from"./SectionHeader-BB3H3F_P.js";import{t as c}from"./EmptyState-CWS9PJND.js";var l=e(t(),1),u=n(),d={new:`muted`,reviewed:`success`,dismissed:`secondary`,converted:`warning`};function f(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function p(){let[e,t]=(0,l.useState)([]),[n,p]=(0,l.useState)(!0),[m,h]=(0,l.useState)(`all`),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=(0,l.useCallback)(async()=>{p(!0);try{let e=new URLSearchParams({limit:`200`});m!==`all`&&e.set(`status`,m),t((await i(`/feature-requests?${e}`)).featureRequests)}catch{t([])}finally{p(!1)}},[m]);(0,l.useEffect)(()=>{b()},[b]);let x=async(e,t)=>{y(e);try{await i(`/feature-requests/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})}),await b()}finally{y(null)}};return(0,u.jsxs)(`div`,{className:`space-y-5`,children:[(0,u.jsx)(s,{title:`Feature Requests`,description:`Unmet user needs identified by the Feature Miner role.`,compact:!0,action:(0,u.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:`Refresh`})}),(0,u.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`reviewed`,`dismissed`,`converted`].map(e=>(0,u.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${m===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,u.jsx)(o,{children:(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,u.jsx)(o,{children:(0,u.jsx)(c,{title:`No feature requests`,description:`Run the Feature Mining template to extract unmet needs from chat sessions.`})}):(0,u.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,u.jsxs)(o,{padding:!1,children:[(0,u.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>_(g===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&_(g===e.id?null:e.id)},children:(0,u.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,u.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(a,{variant:d[e.status],children:e.status}),(0,u.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:f(e.extractedAt)}),e.tags&&e.tags.length>0&&(0,u.jsx)(`div`,{className:`flex gap-1`,children:e.tags.slice(0,3).map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)]`,children:e},e))})]}),e.summary?(0,u.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.summary}):null,(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)] line-clamp-2`,children:e.content})]})})}),g===e.id&&(0,u.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Content`}),(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.content})]}),e.evidenceQuote&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Quote`}),(0,u.jsx)(`blockquote`,{className:`border-l-2 border-[var(--app-border)] pl-3 text-sm text-[var(--app-text-muted)] italic`,children:e.evidenceQuote})]}),e.tags&&e.tags.length>0&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Tags`}),(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.tags.map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-0.5 text-xs text-[var(--app-text)]`,children:e},e))})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Extracted: `,new Date(e.extractedAt).toLocaleString()]}),e.sourceSessionId&&(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Session: `,e.sourceSessionId.slice(0,8)]})]}),(0,u.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`reviewed`,`dismissed`,`converted`].map(t=>(0,u.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:v===e.id||e.status===t,onClick:n=>{n.stopPropagation(),x(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{p as FeatureRequests};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{I as t,J as n,l as r,lt as i,ot as a,q as o}from"./vendor-icons-jzPiR6xl.js";import{f as s,r as c,t as l}from"./vendor-react-CIkiuNDu.js";import{t as u}from"./api-D-UzHSDq.js";import{t as d}from"./index-Bl-2p6d8.js";import{i as f,r as p,t as m}from"./Card-C2N6k4gh.js";import{t as h}from"./PageHeader-D9lLjo0N.js";import{t as g}from"./SectionHeader-BB3H3F_P.js";import{n as _}from"./format-BUYXZqDw.js";var v=e(i(),1),y=l();function b(){let{id:e}=s(),[i,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!i)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=i.targetValue>0?Math.min(100,i.currentValue/i.targetValue*100):0,E=i.deadline>0&&i.deadline<Date.now()&&i.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:i.name,compact:!0,description:i.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(i.status),children:i.status})},{label:`Role`,value:i.roleId},{label:`Metric`,value:i.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:i.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(i.targetValue-i.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:r,label:`Progress`,value:`${i.currentValue} / ${i.targetValue}`}),(0,y.jsx)(x,{icon:n,label:E?`Overdue`:`Deadline`,value:_(i.deadline),mono:!0}),(0,y.jsx)(x,{icon:o,label:`Budget`,value:`$${i.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(i.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[i.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[i.targetValue,` target`]})]})]}),(i.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(i.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]}),(0,y.jsxs)(d,{variant:`outline`,children:[e.trialCount,` trials`]})]},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,S as r,T as i,l as a,lt as o,n as s,s as c,y as l}from"./vendor-icons-jzPiR6xl.js";import{t as u}from"./vendor-react-CIkiuNDu.js";import"./es2015-DCW7LI8d.js";import{t as d}from"./Button-VPwTNGpF.js";import{t as f}from"./api-D-UzHSDq.js";import{a as p,c as m,d as ee,f as h,i as te,l as g,n as _,o as v,p as y,r as ne,s as b,t as x,u as re}from"./index-Bl-2p6d8.js";import{i as S,r as C,t as w}from"./Card-C2N6k4gh.js";import{t as T}from"./PageHeader-D9lLjo0N.js";import{n as E,t as D}from"./format-BUYXZqDw.js";import{t as O}from"./EmptyState-CWS9PJND.js";var k=e(o(),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([f(`/channels`).catch(()=>({channels:[]})),f(`/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-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] 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-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,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-[var(--app-text-subtle)]`,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-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,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-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(t,{size:12}),paused:(0,A.jsx)(i,{size:12}),completed:(0,A.jsx)(l,{size:12}),failed:(0,A.jsx)(l,{size:12})};function P(){let e=h(e=>e.goals),t=h(e=>e.fetchGoals),o=h(e=>e.updateGoal),u=h(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,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{t();let e=setInterval(()=>void t(),1e4);return()=>clearInterval(e)},[t]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await f(`/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.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void t(),children:(0,A.jsx)(l,{size:14})}),(0,A.jsxs)(d,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(r,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] 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:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(d,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(a,{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,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,a=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(C,{children:[a?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(S,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(x,{variant:_(e.status),children:e.status})]}),a?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] 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-[var(--app-text-muted)] 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-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[t,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${t>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,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-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,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-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(x,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:a?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await o(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),y.success(`Goal updated`)}catch(e){y.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{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)(n,{size:14})}),(0,A.jsxs)(d,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await o(e.id,{status:M[e.status]}),y.success(`Status changed to ${M[e.status]}`)}catch(e){y.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(i,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(ne,{children:[(0,A.jsx)(ee,{asChild:!0,children:(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(c,{size:14})})}),(0,A.jsxs)(v,{children:[(0,A.jsxs)(g,{children:[(0,A.jsx)(re,{children:`Delete goal`}),(0,A.jsxs)(b,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Cancel`}),(0,A.jsx)(te,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),y.success(`Goal deleted`)}catch(e){y.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{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,T as n,W as r,c as i,lt as a}from"./vendor-icons-jzPiR6xl.js";import{t as o}from"./vendor-react-CIkiuNDu.js";import{t as s}from"./Button-VPwTNGpF.js";import{f as c}from"./index-Bl-2p6d8.js";import{t as l}from"./Card-C2N6k4gh.js";import{t as u}from"./PageHeader-D9lLjo0N.js";import{t as d}from"./EmptyState-CWS9PJND.js";import{t as f}from"./ui-CerQw0jA.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(t,{size:f.sm}):(0,m.jsx)(n,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{g as t,it as n,lt as r,y as i}from"./vendor-icons-jzPiR6xl.js";import{t as a}from"./vendor-react-CIkiuNDu.js";import{t as o}from"./Button-VPwTNGpF.js";import{t as s}from"./api-D-UzHSDq.js";import{f as c,t as l}from"./index-Bl-2p6d8.js";import{t as u}from"./Card-C2N6k4gh.js";import{t as d}from"./PageHeader-D9lLjo0N.js";import{t as f}from"./SectionHeader-BB3H3F_P.js";import{a as p}from"./format-BUYXZqDw.js";import{t as m}from"./EmptyState-CWS9PJND.js";var h=e(r(),1),g=a();function _(){let e=c(e=>e.roles),r=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{r()},[r]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await s(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await s(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(i,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(t,{size:14})}),S&&(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(n,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};
|