@runfusion/fusion 0.10.0 → 0.11.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/dist/bin.js +5586 -4785
- package/dist/client/assets/AgentDetailView-B5tq9ius.css +1 -0
- package/dist/client/assets/AgentDetailView-DQBjJSPJ.js +18 -0
- package/dist/client/assets/AgentsView-DlA0yHBg.js +522 -0
- package/dist/client/assets/AgentsView-xm_3NO4M.css +1 -0
- package/dist/client/assets/{ChatView-Bra9fNAG.js → ChatView-DK5CmiAk.js} +1 -1
- package/dist/client/assets/{DevServerView-UkgjEw9-.js → DevServerView-BVixhlF0.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-Cls4HWxP.js → DirectoryPicker-tvBgHxa7.js} +1 -1
- package/dist/client/assets/{DocumentsView-BRBUPFVA.js → DocumentsView-DVw_wT6V.js} +1 -1
- package/dist/client/assets/{InsightsView-BRDqHCLb.js → InsightsView-G3MZhwSx.js} +2 -2
- package/dist/client/assets/{MemoryView-DvTrwFnQ.js → MemoryView-Bl9gx2Dw.js} +2 -2
- package/dist/client/assets/{NodesView-C4Ffl_o0.js → NodesView-dwVhD4V2.js} +4 -4
- package/dist/client/assets/{PiExtensionsManager-CeI1syeZ.js → PiExtensionsManager-CEHp6_Mj.js} +3 -3
- package/dist/client/assets/PluginManager-Dx0mcwat.js +1 -0
- package/dist/client/assets/ResearchView-BvlLYC_1.js +1 -0
- package/dist/client/assets/{RoadmapsView-DNb4x75S.js → RoadmapsView-DdYXssP2.js} +2 -2
- package/dist/client/assets/SettingsModal-Bgjg_4CD.js +31 -0
- package/dist/client/assets/{SettingsModal-CRMr4tL6.js → SettingsModal-CGWipm3s.js} +1 -1
- package/dist/client/assets/{SettingsModal-CDPDmHhd.css → SettingsModal-CriZP5Lp.css} +1 -1
- package/dist/client/assets/{SetupWizardModal-tF8B_aG_.js → SetupWizardModal-CKsJduYM.js} +1 -1
- package/dist/client/assets/{SkillsView-uyl47gSf.js → SkillsView-C4Tz7CxC.js} +1 -1
- package/dist/client/assets/{TodoView-CbzDtV53.js → TodoView-ByXJ90yL.js} +2 -2
- package/dist/client/assets/{folder-open-DPpmGJ-v.js → folder-open-CxOUgHDf.js} +1 -1
- package/dist/client/assets/index-BCz4ye4p.css +1 -0
- package/dist/client/assets/index-D7gT6mCr.js +656 -0
- package/dist/client/assets/{list-checks-D62pw1I8.js → list-checks--sf9u9ox.js} +1 -1
- package/dist/client/assets/{star-B8EbxNgI.js → star-CF1f2iPu.js} +1 -1
- package/dist/client/assets/{upload-CpnLno9z.js → upload-rOBd4OhB.js} +1 -1
- package/dist/client/assets/{users-B_C_0qzA.js → users-De-vFat1.js} +1 -1
- package/dist/client/fonts/SymbolsNerdFontMono-Regular.ttf +0 -0
- package/dist/client/index.html +16 -2
- package/dist/client/version.json +1 -1
- package/dist/extension.js +20410 -19703
- package/dist/pi-claude-cli/package.json +1 -1
- package/package.json +1 -1
- package/skill/fusion/SKILL.md +2 -0
- package/skill/fusion/references/engine-tools.md +4 -0
- package/skill/fusion/references/extension-tools.md +76 -0
- package/skill/fusion/references/fusion-capabilities.md +8 -0
- package/dist/client/assets/AgentDetailView-BtpZ4jxh.js +0 -18
- package/dist/client/assets/AgentDetailView-DIBOY8V-.css +0 -1
- package/dist/client/assets/AgentsView-Dxdtt0Bm.js +0 -522
- package/dist/client/assets/AgentsView-MotzGhZJ.css +0 -1
- package/dist/client/assets/PluginManager-BgeoYhLk.js +0 -1
- package/dist/client/assets/ResearchView-fmEOm4A2.js +0 -1
- package/dist/client/assets/SettingsModal-D1xq0WZm.js +0 -31
- package/dist/client/assets/index-BqK6TvSa.css +0 -1
- package/dist/client/assets/index-DyXZm9QN.js +0 -656
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusion/pi-claude-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Fusion vendored fork: pi coding-agent extension that routes LLM calls through the Claude Code CLI. Forked from rchern/pi-claude-cli (MIT). See UPSTREAM.md.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runfusion/fusion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Fusion CLI: HTTP API server, daemon, dashboard launcher, and task tooling for the Fusion AI coding agent.",
|
|
6
6
|
"homepage": "https://github.com/Runfusion/Fusion#readme",
|
package/skill/fusion/SKILL.md
CHANGED
|
@@ -32,6 +32,8 @@ Mission → Milestone → Slice → Feature → Task
|
|
|
32
32
|
- **Mission tools** — `fn_mission_create`, `fn_mission_list`, `fn_mission_show`, `fn_mission_delete`, `fn_milestone_add`, `fn_slice_add`, `fn_feature_add`, `fn_slice_activate`, `fn_feature_link_task`
|
|
33
33
|
- **Agent tools** — `fn_agent_stop`, `fn_agent_start`
|
|
34
34
|
- **Skills tools** — `fn_skills_search`, `fn_skills_install`
|
|
35
|
+
- **Insight tools** — `fn_insight_list`, `fn_insight_show`, `fn_insight_run_list`, `fn_insight_run_show`
|
|
36
|
+
- **Other tools** — `fn_research_run`, `fn_research_list`, `fn_research_get`, `fn_research_cancel`
|
|
35
37
|
<!-- END: tool-categories -->
|
|
36
38
|
- **Dashboard** — Use `/fn` command to start/stop the dashboard
|
|
37
39
|
|
|
@@ -17,6 +17,10 @@ These tools are **not** part of the pi extension's user-invokable `extension.ts`
|
|
|
17
17
|
| `fn_memory_search` | triage, executor, heartbeat | Search project/agent memory snippets | `query` (string), `limit?` (number) |
|
|
18
18
|
| `fn_memory_get` | triage, executor, heartbeat | Read a bounded memory file window | `path` (string), `startLine?` (number), `lineCount?` (number) |
|
|
19
19
|
| `fn_memory_append` | executor, heartbeat (when writable backend enabled) | Append long-term/daily memory notes | `scope?` (`project` \| `agent`), `layer` (`long-term` \| `daily`), `content` (string) |
|
|
20
|
+
| `fn_research_run` | triage, executor | Start a bounded research run (optionally wait for completion) and return structured findings metadata | `query` (string), `wait_for_completion?` (boolean), `max_wait_ms?` (number) |
|
|
21
|
+
| `fn_research_list` | triage, executor | List recent research runs with status/summary metadata | `status?` (`pending` \| `running` \| `completed` \| `failed` \| `cancelled`), `limit?` (number) |
|
|
22
|
+
| `fn_research_get` | triage, executor | Read one research run's structured findings/citations payload | `id` (string) |
|
|
23
|
+
| `fn_research_cancel` | triage, executor | Cancel an active research run via orchestrator cancellation path | `id` (string) |
|
|
20
24
|
| `fn_reflect_on_performance` | executor | Generate reflection insights from prior runs | `focus_area?` (string) |
|
|
21
25
|
| `fn_list_agents` | triage, executor, heartbeat | List agents (optionally filtered) | `role?` (string), `state?` (string), `includeEphemeral?` (boolean) |
|
|
22
26
|
| `fn_delegate_task` | triage, executor, heartbeat | Create and assign a new task to a specific agent | `agent_id` (string), `description` (string), `dependencies?` (string[]) |
|
|
@@ -283,6 +283,82 @@ Install an agent skill from skills.sh into the current project. Downloads skill
|
|
|
283
283
|
| `source` | string | ✓ | GitHub source in owner/repo format (e.g., 'firebase/agent-skills') |
|
|
284
284
|
| `skill` | string | — | Specific skill name to install (e.g., 'firebase-basics'). Omit to install all skills from the source. |
|
|
285
285
|
|
|
286
|
+
## Insight Tools
|
|
287
|
+
|
|
288
|
+
### fn_insight_list
|
|
289
|
+
|
|
290
|
+
List persisted project insights with optional category/status filters.
|
|
291
|
+
|
|
292
|
+
| Parameter | Type | Required | Description |
|
|
293
|
+
|-----------|------|----------|-------------|
|
|
294
|
+
| `category` | string(enum) | — | Filter by insight category |
|
|
295
|
+
| `status` | string(enum) | — | Filter by insight status |
|
|
296
|
+
| `runId` | string | — | Filter to insights linked to a specific run ID |
|
|
297
|
+
| `limit` | number | — | Max insights to return |
|
|
298
|
+
| `offset` | number | — | Number of rows to skip |
|
|
299
|
+
|
|
300
|
+
### fn_insight_show
|
|
301
|
+
|
|
302
|
+
Show a single persisted insight by ID.
|
|
303
|
+
|
|
304
|
+
| Parameter | Type | Required | Description |
|
|
305
|
+
|-----------|------|----------|-------------|
|
|
306
|
+
| `id` | string | ✓ | Insight ID (e.g. INS-XXXXX) |
|
|
307
|
+
|
|
308
|
+
### fn_insight_run_list
|
|
309
|
+
|
|
310
|
+
List recent insight-generation runs with optional status/trigger filters.
|
|
311
|
+
|
|
312
|
+
| Parameter | Type | Required | Description |
|
|
313
|
+
|-----------|------|----------|-------------|
|
|
314
|
+
| `status` | string(enum) | — | Filter by run status |
|
|
315
|
+
| `trigger` | string(enum) | — | Filter by run trigger |
|
|
316
|
+
| `limit` | number | — | Max runs to return |
|
|
317
|
+
| `offset` | number | — | Number of runs to skip |
|
|
318
|
+
|
|
319
|
+
### fn_insight_run_show
|
|
320
|
+
|
|
321
|
+
Show a single insight-generation run by ID.
|
|
322
|
+
|
|
323
|
+
| Parameter | Type | Required | Description |
|
|
324
|
+
|-----------|------|----------|-------------|
|
|
325
|
+
| `id` | string | ✓ | Insight run ID (e.g. INSR-XXXXX) |
|
|
326
|
+
|
|
327
|
+
## Other Tools
|
|
328
|
+
|
|
329
|
+
### fn_research_run
|
|
330
|
+
|
|
331
|
+
Start a bounded research run and optionally wait for findings.
|
|
332
|
+
|
|
333
|
+
| Parameter | Type | Required | Description |
|
|
334
|
+
|-----------|------|----------|-------------|
|
|
335
|
+
| `query` | string | ✓ | Research query or question |
|
|
336
|
+
|
|
337
|
+
### fn_research_list
|
|
338
|
+
|
|
339
|
+
List recent research runs.
|
|
340
|
+
|
|
341
|
+
| Parameter | Type | Required | Description |
|
|
342
|
+
|-----------|------|----------|-------------|
|
|
343
|
+
| `status` | string(enum) | — | |
|
|
344
|
+
| `limit` | number | — | Max runs to return (default: 10) |
|
|
345
|
+
|
|
346
|
+
### fn_research_get
|
|
347
|
+
|
|
348
|
+
Get one research run and structured findings.
|
|
349
|
+
|
|
350
|
+
| Parameter | Type | Required | Description |
|
|
351
|
+
|-----------|------|----------|-------------|
|
|
352
|
+
| `id` | string | ✓ | Research run ID |
|
|
353
|
+
|
|
354
|
+
### fn_research_cancel
|
|
355
|
+
|
|
356
|
+
Cancel a research run.
|
|
357
|
+
|
|
358
|
+
| Parameter | Type | Required | Description |
|
|
359
|
+
|-----------|------|----------|-------------|
|
|
360
|
+
| `id` | string | ✓ | Research run ID |
|
|
361
|
+
|
|
286
362
|
<!-- END: extension-tools -->
|
|
287
363
|
## Dashboard Command
|
|
288
364
|
|
|
@@ -29,6 +29,14 @@ All skill/extension tool invocations in this catalog use the public `fn_*` names
|
|
|
29
29
|
| `fn_task_import_github_issue` | Import a specific GitHub issue as a Fusion task. Fetches the issue by number and creates a single task in the planning column with the issue title and body. |
|
|
30
30
|
| `fn_task_browse_github_issues` | List open GitHub issues from a repository to browse before importing. Returns issue numbers, titles, and URLs for selection. Use with fn_task_import_github_issue to import specific issues by number. |
|
|
31
31
|
| `fn_task_plan` | Create a task via AI-guided planning mode — interactive conversation to refine your idea into a well-specified task. |
|
|
32
|
+
| `fn_research_run` | Start a bounded research run and optionally wait for findings. |
|
|
33
|
+
| `fn_research_list` | List recent research runs. |
|
|
34
|
+
| `fn_research_get` | Get one research run and structured findings. |
|
|
35
|
+
| `fn_research_cancel` | Cancel a research run. |
|
|
36
|
+
| `fn_insight_list` | List persisted project insights with optional category/status filters. |
|
|
37
|
+
| `fn_insight_show` | Show a single persisted insight by ID. |
|
|
38
|
+
| `fn_insight_run_list` | List recent insight-generation runs with optional status/trigger filters. |
|
|
39
|
+
| `fn_insight_run_show` | Show a single insight-generation run by ID. |
|
|
32
40
|
| `fn_mission_create` | Create a new mission — a high-level objective that can span multiple milestones. Missions contain milestones that break down work into phases. |
|
|
33
41
|
| `fn_mission_list` | List all missions with their current status. |
|
|
34
42
|
| `fn_mission_show` | Show mission details with full hierarchy: milestones → slices → features. |
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{r as t,j as e}from"./vendor-react-K0fH_qHe.js";import{c as _e,d7 as Ls,d8 as $s,d9 as Ps,da as Bs,L as V,R as Ve,ah as ms,Z as Is,ai as Be,N as Te,O as Ss,I as ks,db as Os,dc as Hs,dd as _s,p as Rs,co as Vs,de as Us,v as K,df as Js,s as hs,B as gs,K as we,M as fs,aV as ve,X as Ws,F as Ae,A as Me,z as Ue,dg as Gs,cj as qs,aA as Ys,bh as Ks,aj as Cs,Q as Zs,Y as Qs,$ as Xs,dh as Oe,k as ws,di as et,r as st,dj as tt,dk as at,dl as nt,dm as it,dn as rt,dp as Je,a5 as We,a7 as Ge,a8 as qe,C as ee,a3 as lt,dq as ot,dr as ct,j as dt,i as ut,l as mt,ds as He,_ as ht,dt as gt,du as ft,dv as xt,dw as pt,dx as vt,dy as bt,dz as jt,dA as yt,W as Nt,dB as St,U as kt,dC as Rt}from"./index-DyXZm9QN.js";import{S as Ms}from"./star-B8EbxNgI.js";import{S as Ct}from"./AgentsView-Dxdtt0Bm.js";import{L as Fs}from"./list-checks-D62pw1I8.js";import"./vendor-xterm-DzcZoU0P.js";import"./upload-CpnLno9z.js";import"./folder-open-DPpmGJ-v.js";/**
|
|
2
|
-
* @license lucide-react v1.7.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const wt=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Fe=_e("chart-column",wt);/**
|
|
7
|
-
* @license lucide-react v1.7.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Mt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],Ft=_e("square-activity",Mt);/**
|
|
12
|
-
* @license lucide-react v1.7.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Tt=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],At=_e("trending-down",Tt);function xs(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:s<36e5?`${Math.floor(s/6e4)}m`:`${(s/36e5).toFixed(1)}h`}function Dt(s){return`${Math.round(s*100)}%`}function ps(s){const a=Date.now(),i=new Date(s).getTime(),c=a-i;if(c<0){const d=Math.abs(c);return d<6e4?"in a moment":d<36e5?`in ${Math.floor(d/6e4)}m`:d<864e5?`in ${Math.floor(d/36e5)}h`:`in ${Math.floor(d/864e5)}d`}return c<6e4?"just now":c<36e5?`${Math.floor(c/6e4)}m ago`:c<864e5?`${Math.floor(c/36e5)}h ago`:`${Math.floor(c/864e5)}d ago`}function zt(s){switch(s){case"periodic":return"Periodic";case"post-task":return"Post-Task";case"manual":return"Manual";case"user-requested":return"User Requested";default:return s}}function xe(s){return s instanceof Error&&s.message?s.message:String(s)}function Et(s){switch(s){case"improving":return"↑ Improving";case"declining":return"↓ Declining";case"stable":return"→ Stable";default:return"Insufficient data"}}function Lt(s){switch(s){case"improving":return"trend-improving";case"declining":return"trend-declining";case"stable":return"trend-stable";default:return"trend-insufficient"}}function vs(s,a=5){return e.jsx("span",{className:"rating-stars",children:Array.from({length:a},(i,c)=>e.jsx(Ms,{size:14,className:c<s?"star-filled":"star-empty",fill:c<s?"currentColor":"none"},c))})}function $t({agentId:s,projectId:a,addToast:i}){const[c,d]=t.useState([]),[r,p]=t.useState(null),[m,N]=t.useState(null),[x,v]=t.useState([]),[z,b]=t.useState(!0),[B,I]=t.useState(!0),[E,o]=t.useState(!1),[y,C]=t.useState(!1),[O,A]=t.useState(null),[D,H]=t.useState(0),[J,W]=t.useState(""),[$,w]=t.useState(""),G=t.useCallback(async()=>{try{const[l,R]=await Promise.all([Ls(s,20,a),$s(s,void 0,a)]);d(l),p(R)}catch(l){i(`Failed to load reflections: ${xe(l)}`,"error")}finally{b(!1)}},[s,a,i]),h=t.useCallback(async()=>{try{const[l,R]=await Promise.all([Ps(s,a),Bs(s,{limit:50},a)]);N(l),v(R)}catch(l){i(`Failed to load ratings: ${xe(l)}`,"error")}finally{I(!1)}},[s,a,i]);t.useEffect(()=>{G(),h()},[G,h]);const U=async()=>{o(!0);try{if(!await Os(s,a)){i("Not enough history to generate a reflection yet","error");return}i("Reflection generated successfully","success"),b(!0),await G()}catch(l){const R=xe(l),P=R.toLowerCase();P.includes("agent not found")||P.includes("not found")?i("This agent is no longer available. It may have been deleted.","error"):P.includes("insufficient history")?i("Not enough history to generate a reflection yet","error"):i(`Failed to generate reflection: ${R}`,"error")}finally{o(!1)}},_=async l=>{if(l.preventDefault(),D!==0){C(!0);try{await Hs(s,{score:D,category:J||void 0,comment:$||void 0,raterType:"user"},a),H(0),W(""),w(""),i("Rating added","success"),await h()}catch(R){i(`Failed to add rating: ${xe(R)}`,"error")}finally{C(!1)}}},u=async l=>{try{await _s(s,l,a),i("Rating deleted","success"),await h()}catch(R){i(`Failed to delete rating: ${xe(R)}`,"error")}},S=l=>{A(R=>R===l?null:l)};if(z&&B)return e.jsx("div",{className:"reflections-tab",children:e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(V,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading evaluation..."})]})});const Z=r&&r.totalTasksCompleted===0&&r.totalTasksFailed===0&&r.recentReflectionCount===0;return e.jsxs("div",{className:"reflections-tab",children:[e.jsxs("div",{className:"reflections-header",children:[e.jsxs("h3",{children:[e.jsx(Fe,{size:16}),"Performance, Reflections & Ratings"]}),e.jsx("button",{className:"btn btn-secondary",onClick:U,disabled:E,title:"Generate a manual reflection",children:E?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:14,className:"animate-spin"}),"Reflecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:14}),"Reflect Now"]})})]}),r&&!Z&&e.jsxs("div",{className:"reflections-stats-grid",children:[e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(ms,{size:16,style:{color:"var(--color-success)"}}),r.totalTasksCompleted]}),e.jsx("div",{className:"stat-label",children:"Tasks Completed"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(At,{size:16,style:{color:"var(--color-error)"}}),r.totalTasksFailed]}),e.jsx("div",{className:"stat-label",children:"Tasks Failed"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Is,{size:16,style:{color:"var(--in-progress)"}}),xs(r.avgDurationMs)]}),e.jsx("div",{className:"stat-label",children:"Avg Duration"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Fe,{size:16,style:{color:r.successRate>=.8?"var(--color-success)":r.successRate>=.5?"var(--color-warning)":"var(--color-error)"}}),Dt(r.successRate)]}),e.jsx("div",{className:"stat-label",children:"Success Rate"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Be,{size:16,style:{color:"var(--color-info)"}}),r.recentReflectionCount]}),e.jsx("div",{className:"stat-label",children:"Reflections"})]})]}),Z&&e.jsxs("div",{className:"reflections-no-data",children:[e.jsx(Fe,{size:24,opacity:.3}),e.jsx("p",{children:"No performance data yet"})]}),e.jsxs("div",{className:"reflections-ratings-section",children:[e.jsx("h4",{children:"User Ratings"}),B?e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(V,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading ratings..."})]}):e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{className:"rating-summary-card",children:[e.jsxs("div",{className:"rating-score-display",children:[e.jsx("span",{className:"rating-average",children:m.averageScore.toFixed(1)}),vs(Math.round(m.averageScore))]}),e.jsxs("div",{className:"rating-stats",children:[e.jsxs("span",{className:"rating-count",children:[m.totalRatings," ratings"]}),e.jsx("span",{className:`rating-trend-badge ${Lt(m.trend)}`,children:Et(m.trend)})]})]}),m&&Object.keys(m.categoryAverages).length>0&&e.jsxs("div",{className:"category-breakdown",children:[e.jsx("h4",{children:"Category Averages"}),Object.entries(m.categoryAverages).map(([l,R])=>e.jsxs("div",{className:"category-item",children:[e.jsx("span",{className:"category-name",children:l}),e.jsx("span",{className:"category-score",children:R.toFixed(1)})]},l))]}),e.jsxs("form",{className:"add-rating-form",onSubmit:_,children:[e.jsx("h4",{children:"Add Rating"}),e.jsx("div",{className:"star-selector",children:[1,2,3,4,5].map(l=>e.jsx("button",{type:"button",className:"star-btn touch-target",onClick:()=>H(l),title:`${l} star${l>1?"s":""}`,children:e.jsx(Ms,{size:24,fill:l<=D?"currentColor":"none",className:l<=D?"star-filled":"star-empty"})},l))}),e.jsxs("select",{value:J,onChange:l=>W(l.target.value),className:"select add-rating-category-select",children:[e.jsx("option",{value:"",children:"Select category..."}),e.jsx("option",{value:"quality",children:"Quality"}),e.jsx("option",{value:"speed",children:"Speed"}),e.jsx("option",{value:"communication",children:"Communication"}),e.jsx("option",{value:"reliability",children:"Reliability"}),e.jsx("option",{value:"other",children:"Other"})]}),e.jsx("textarea",{value:$,onChange:l=>w(l.target.value),placeholder:"Optional comment...",className:"input add-rating-comment-input",rows:3}),e.jsx("button",{type:"submit",className:"btn btn-task-create",disabled:D===0||y,children:y?"Submitting...":"Submit Rating"})]}),e.jsxs("div",{className:"rating-history",children:[e.jsx("h4",{children:"Rating History"}),x.length===0?e.jsx("p",{className:"no-ratings",children:"No ratings yet"}):x.map(l=>e.jsxs("div",{className:"rating-history-item",children:[e.jsxs("div",{className:"rating-item-header",children:[vs(l.score),l.category&&e.jsx("span",{className:"rating-category-badge",children:l.category}),e.jsx("span",{className:"rating-time",children:ps(l.createdAt)}),e.jsx("button",{type:"button",className:"rating-delete-btn touch-target",onClick:()=>void u(l.id),title:"Delete rating",children:e.jsx(Te,{size:14})})]}),l.comment&&e.jsx("p",{className:"rating-comment",children:l.comment})]},l.id))]})]})]}),e.jsxs("div",{className:"reflections-list",children:[e.jsx("h4",{children:"Reflection History"}),z?e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(V,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading reflections..."})]}):c.length===0?e.jsxs("div",{className:"reflection-empty",children:[e.jsx(Be,{size:32,opacity:.3}),e.jsx("p",{children:"No reflections yet"}),e.jsx("p",{className:"text-secondary",children:"Trigger a reflection to get started"})]}):e.jsx("div",{className:"reflection-cards",children:c.map(l=>{const R=O===l.id;return e.jsxs("div",{className:`reflection-card ${R?"reflection-card--expanded":""}`,onClick:()=>S(l.id),role:"button",tabIndex:0,onKeyDown:P=>P.key==="Enter"&&S(l.id),children:[e.jsxs("div",{className:"reflection-card-header",children:[e.jsx("span",{className:`reflection-trigger-badge reflection-trigger-${l.trigger}`,children:zt(l.trigger)}),e.jsx("span",{className:"reflection-timestamp",children:ps(l.timestamp)}),e.jsx("span",{className:"reflection-chevron",children:R?e.jsx(Ss,{size:16}):e.jsx(ks,{size:16})})]}),e.jsx("div",{className:"reflection-summary",children:l.summary}),R&&e.jsxs("div",{className:"reflection-details",children:[l.insights.length>0&&e.jsxs("div",{className:"reflection-insights",children:[e.jsxs("h5",{children:[e.jsx(Be,{size:14})," Insights"]}),e.jsx("ul",{children:l.insights.map((P,g)=>e.jsx("li",{children:P},g))})]}),l.suggestedImprovements.length>0&&e.jsxs("div",{className:"reflection-suggestions",children:[e.jsxs("h5",{children:[e.jsx(ms,{size:14})," Suggested Improvements"]}),e.jsx("ul",{children:l.suggestedImprovements.map((P,g)=>e.jsx("li",{children:P},g))})]}),l.metrics&&e.jsxs("div",{className:"reflection-metrics",children:[e.jsx("h5",{children:"Metrics"}),e.jsxs("div",{className:"metrics-grid",children:[l.metrics.tasksCompleted!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Tasks:"}),e.jsx("span",{className:"metric-value",children:l.metrics.tasksCompleted})]}),l.metrics.tasksFailed!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Failed:"}),e.jsx("span",{className:"metric-value",children:l.metrics.tasksFailed})]}),l.metrics.avgDurationMs!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Avg Duration:"}),e.jsx("span",{className:"metric-value",children:xs(l.metrics.avgDurationMs)})]}),l.metrics.errorCount!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Errors:"}),e.jsx("span",{className:"metric-value",children:l.metrics.errorCount})]})]})]})]})]},l.id)})})]})]})}function X(...s){return s.filter(Boolean).join(" ")}function be(s){const a=Date.now(),i=new Date(s).getTime(),c=a-i;if(c<0){const d=Math.abs(c);return d<6e4?"in a moment":d<36e5?`in ${Math.floor(d/6e4)}m`:d<864e5?`in ${Math.floor(d/36e5)}h`:`in ${Math.floor(d/864e5)}d`}return c<6e4?"just now":c<36e5?`${Math.floor(c/6e4)}m ago`:c<864e5?`${Math.floor(c/36e5)}h ago`:`${Math.floor(c/864e5)}d ago`}const Pt=[{id:"dashboard",label:"Dashboard",icon:Ft},{id:"logs",label:"Logs",icon:Ae},{id:"runs",label:"Runs",icon:Me},{id:"tasks",label:"Tasks",icon:Fs},{id:"employees",label:"Employees",icon:Ue},{id:"soul",label:"Soul",icon:Gs},{id:"instructions",label:"Instructions",icon:qs},{id:"memory",label:"Agent Memory",icon:Ae},{id:"reflections",label:"Evaluation",icon:Fe},{id:"config",label:"Settings",icon:Ys}],Ye={idle:{bg:"var(--state-idle-bg)",text:"var(--state-idle-text)",border:"var(--state-idle-border)"},active:{bg:"var(--state-active-bg)",text:"var(--state-active-text)",border:"var(--state-active-border)"},running:{bg:"var(--state-active-bg)",text:"var(--state-active-text)",border:"var(--state-active-border)"},paused:{bg:"var(--state-paused-bg)",text:"var(--state-paused-text)",border:"var(--state-paused-border)"},error:{bg:"var(--state-error-bg)",text:"var(--state-error-text)",border:"var(--state-error-border)"},terminated:{bg:"var(--state-error-bg)",text:"var(--state-error-text)",border:"var(--state-error-border)"}},bs={completed:{icon:ee,color:"var(--color-success, #3fb950)"},failed:{icon:ft,color:"var(--color-error, #f85149)"},active:{icon:V,color:"var(--in-progress, #bc8cff)"},terminated:{icon:ve,color:"var(--text-muted, #8b949e)"}},js={"long-term":"Long-term",daily:"Daily",dreams:"Dreams"},Bt={"long-term":"Curated durable decisions, conventions, constraints, and pitfalls for this specific agent.",daily:"Raw daily observations and open loops recorded by this agent.",dreams:"Synthesized patterns and emerging themes distilled from this agent's daily memory."},It=Nt(He);function Ot(s,a){return s.some(i=>i.path===a)?a:s.find(i=>i.layer==="long-term")?.path??s[0]?.path??""}function da({agentId:s,projectId:a,onClose:i,addToast:c,onChildClick:d}){const[r,p]=t.useState(null),{confirm:m}=Rs(),[N,x]=t.useState([]),[v,z]=t.useState(!0),[b,B]=t.useState("dashboard"),[I,E]=t.useState(!1),[o,y]=t.useState(!1),C=t.useRef(null),O=t.useRef(null),A=t.useRef(!1);Vs(O,!0,"fusion:agent-detail-modal-size");const D=t.useRef(i),H=t.useRef(c),J=t.useRef(null),W=t.useRef(!1),$=t.useRef(0),w=t.useRef(s),G=t.useRef(a);D.current=i,H.current=c,J.current=r;const h=t.useCallback(async()=>{J.current===null&&z(!0);try{const M=await Us(s,a);p(M)}catch(M){H.current(`Failed to load agent: ${K(M)}`,"error"),D.current()}finally{z(!1)}},[s,a]),U=t.useCallback(async()=>{const g=$.current,M=s,f=a;if(r?.taskId)try{const L=await Js(r.taskId,f,{limit:100});if($.current!==g||s!==M||a!==f)return;x(L.entries)}catch(L){if($.current!==g||s!==M||a!==f)return;console.error("Failed to load task logs:",L)}},[r?.taskId,s,a]),_=t.useCallback(g=>{W.current=g},[]);t.useEffect(()=>{h()},[h]),t.useEffect(()=>{const g=setInterval(()=>{h()},3e4);return()=>{clearInterval(g)}},[h]),t.useEffect(()=>{r?.taskId&&U()},[r?.taskId,U]),t.useEffect(()=>{(w.current!==s||G.current!==a)&&(w.current=s,G.current=a,$.current++,x([]),E(!1),W.current=!1)},[s,a]),t.useEffect(()=>{const g=a?`?projectId=${encodeURIComponent(a)}`:"",M=$.current;return hs(`/api/events${g}`,{events:{"agent:updated":f=>{if($.current===M)try{const L=JSON.parse(f.data);if(!L||typeof L!="object"||L.id!==s||W.current)return;h()}catch{}}}})},[s,a,h]),t.useEffect(()=>{if(b!=="logs"||!r?.taskId){E(!1);return}const g=$.current,M=r.taskId,f=a?`?projectId=${encodeURIComponent(a)}`:"",L=hs(`/api/tasks/${encodeURIComponent(M)}/logs/stream${f}`,{events:{"agent:log":le=>{if($.current===g)try{const je=JSON.parse(le.data);x(De=>[je,...De]);const de=C.current;de&&de.scrollTop<50&&(de.scrollTop=0)}catch{}}},onOpen:()=>{$.current===g&&E(!0)},onError:()=>{$.current===g&&E(!1)}});return()=>{L(),$.current===g&&E(!1)}},[r?.taskId,b,a]);const u=async g=>{if(o||!J.current)return;const M=J.current.state;if(M!==g){y(!0),p(f=>f&&{...f,state:g});try{await Qs(s,g,a),c(`Agent state updated to ${g}`,"success"),h()}catch(f){p(L=>L&&{...L,state:M}),c(`Failed to update state: ${K(f)}`,"error")}finally{y(!1)}}},S=async()=>{if(!(!r||!await m({title:"Delete Agent",message:`Delete agent "${r.name}"? This cannot be undone.`,danger:!0})))try{await Xs(s,a),c(`Agent "${r.name}" deleted`,"success"),i()}catch(M){c(`Failed to delete agent: ${K(M)}`,"error")}},Z=()=>r?Zs(r):{label:"Unknown",icon:e.jsx(gs,{size:14}),color:"var(--text-muted, #8b949e)",stateDerived:!1},l=()=>{r&&(navigator.clipboard.writeText(r.id),c("Agent ID copied to clipboard","success"))};if(v)return e.jsx("div",{className:"agent-detail-overlay",onMouseDown:g=>{g.target===g.currentTarget&&(A.current=!0)},onMouseUp:g=>{A.current&&g.target===g.currentTarget&&i(),A.current=!1},role:"dialog","aria-modal":"true",children:e.jsx("div",{className:"agent-detail-modal",ref:O,children:e.jsxs("div",{className:"agent-detail-loading",children:[e.jsx(V,{className:"animate-spin",size:24}),e.jsx("span",{children:"Loading agent..."})]})})});if(!r)return null;const R=Ye[r.state],P=Z();return e.jsx("div",{className:"agent-detail-overlay",onClick:g=>g.target===g.currentTarget&&i(),role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"agent-detail-modal",children:[e.jsxs("div",{className:"agent-detail-header",children:[e.jsxs("div",{className:"agent-detail-identity",children:[e.jsx("div",{className:"agent-detail-icon",children:e.jsx(gs,{size:20})}),e.jsxs("div",{className:"agent-detail-info",children:[e.jsx("h2",{children:r.name}),e.jsxs("div",{className:"agent-detail-badges",children:[e.jsx("span",{className:"badge",style:{background:R.bg,color:R.text,border:`1px solid ${R.border}`},children:r.state}),e.jsxs("span",{className:"badge",style:{color:P.color},title:P.label,children:[P.icon,!P.stateDerived&&P.label]})]})]})]}),e.jsxs("div",{className:"agent-detail-controls",children:[r.state==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void u("active"),disabled:o,children:[e.jsx(we,{size:14}),"Start"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:S,children:[e.jsx(Te,{size:14}),"Delete"]})]}),r.state==="active"&&e.jsxs("button",{className:"btn btn--compact",onClick:()=>void u("paused"),disabled:o,children:[e.jsx(fs,{size:14}),"Pause"]}),r.state==="paused"&&e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void u("active"),disabled:o,children:[e.jsx(we,{size:14}),"Resume"]}),r.state==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--compact",onClick:()=>void u("paused"),disabled:o,children:[e.jsx(fs,{size:14}),"Pause"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void u("terminated"),disabled:o,children:[e.jsx(ve,{size:14}),"Stop"]})]}),r.state==="error"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void u("active"),disabled:o,children:[e.jsx(we,{size:14}),"Retry"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void u("terminated"),disabled:o,children:[e.jsx(ve,{size:14}),"Stop"]})]}),r.state==="terminated"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void u("active"),disabled:o,children:[e.jsx(we,{size:14}),"Start"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:S,children:[e.jsx(Te,{size:14}),"Delete"]})]})]}),e.jsxs("div",{className:"agent-detail-utility-actions",children:[e.jsx("button",{className:"btn-icon",onClick:()=>void h(),title:"Refresh",children:e.jsx(Ve,{size:16})}),e.jsx("button",{className:"btn-icon",onClick:i,"aria-label":"Close",title:"Close",children:e.jsx(Ws,{size:20})})]})]}),e.jsx("div",{className:"agent-detail-tabs",children:Pt.map(g=>e.jsxs("button",{className:X("agent-detail-tab",b===g.id&&"active"),onClick:()=>B(g.id),children:[e.jsx(g.icon,{size:16}),g.label]},g.id))}),e.jsxs("div",{className:"agent-detail-content",children:[b==="dashboard"&&e.jsx(Ht,{agent:r,health:P,onChildClick:d,projectId:a}),b==="logs"&&e.jsx(_t,{logs:N,isStreaming:I,containerRef:C,hasTask:!!r.taskId}),b==="runs"&&e.jsx(Ut,{addToast:c,agentId:r.id,projectId:a,agentState:r.state,agentName:r.name}),b==="tasks"&&e.jsx(qt,{agentId:r.id,projectId:a,addToast:c}),b==="employees"&&e.jsx(sa,{agentId:r.id,projectId:a,onChildClick:d}),b==="soul"&&e.jsx(Kt,{agent:r,projectId:a,addToast:c,onSaved:h}),b==="instructions"&&e.jsx(Qt,{agent:r,projectId:a,addToast:c,onSaved:h}),b==="memory"&&e.jsx(Zt,{agent:r,projectId:a,addToast:c,onSaved:h}),b==="reflections"&&e.jsx($t,{agentId:r.id,projectId:a,addToast:c}),b==="config"&&e.jsx(ea,{agent:r,projectId:a,addToast:c,onSaved:h,onHasChangesChange:_,onDelete:S})]}),e.jsxs("div",{className:"agent-detail-footer",children:[e.jsx("button",{className:"btn-icon",onClick:l,title:"Copy Agent ID",children:e.jsx(Ks,{size:14})}),e.jsx("span",{className:"agent-detail-id",onClick:l,children:r.id}),r.taskId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"divider",children:"|"}),e.jsx("span",{className:"text-muted",children:"Working on:"}),e.jsxs("a",{href:`/tasks/${r.taskId}`,className:"link",children:[r.taskId,e.jsx(Cs,{size:12})]})]})]})]})})}function Ht({agent:s,health:a,onChildClick:i,projectId:c}){const d=Ye[s.state],[r,p]=t.useState([]),[m,N]=t.useState(!0),[x,v]=t.useState(null),[z,b]=t.useState([]),B=typeof s.runtimeConfig?.runtimeHint=="string"?s.runtimeConfig.runtimeHint:"",I=(()=>{const o=s.runtimeConfig??{};if(B){const y=z.find(C=>C.runtimeId===B);return y?y.name:B}if(o.modelProvider&&o.modelId)return`${o.modelProvider}/${o.modelId}`;if(typeof o.model=="string"&&o.model.includes("/")){const y=o.model.indexOf("/");return o.model.slice(y+1)}return null})();t.useEffect(()=>{Oe(s.id,c).then(v).catch(()=>v(null))},[s.id,c]),t.useEffect(()=>{ws(c).then(b).catch(()=>b([]))},[c]),t.useEffect(()=>{let o=!1;return N(!0),et(s.id,c).then(y=>{if(o)return;const C=y.length>0&&y[0]?.id===s.id?[...y].reverse():y;p(C)}).catch(()=>{o||p([])}).finally(()=>{o||N(!1)}),()=>{o=!0}},[s.id,c]);const E=t.useMemo(()=>{const o=s.completedRuns||[],y=new Date;y.setHours(0,0,0,0);const C=o.filter(A=>new Date(A.startedAt)>=y),O=o.filter(A=>A.status==="completed");return{totalRuns:o.length,todayRuns:C.length,successfulRuns:O.length,successRate:o.length>0?Math.round(O.length/o.length*100):0}},[s]);return e.jsxs("div",{className:"dashboard-tab",children:[x?.isOverBudget&&e.jsxs("div",{className:"budget-warning-banner",role:"alert",children:[e.jsx("span",{children:"⚠️"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Budget Exhausted:"})," This agent has exceeded its token budget and may be operating with limited functionality."]})]}),e.jsxs("div",{className:"dashboard-section",children:[e.jsx("h3",{children:"Agent Information"}),e.jsxs("div",{className:"info-grid",children:[e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Name"}),e.jsx("span",{className:"info-value",children:s.name})]}),e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Role"}),e.jsx("span",{className:"info-value",children:s.role})]}),e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Skills"}),e.jsx("span",{className:"info-value",children:Array.isArray(s.metadata?.skills)&&s.metadata.skills.length>0?e.jsx("div",{className:"skill-badge-row",children:s.metadata.skills.map(o=>e.jsx("span",{className:"skill-badge",children:o},o))}):"—"})]}),e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"State"}),e.jsx("span",{className:"info-value",children:e.jsx("span",{className:"inline-badge",style:{background:d.bg,color:d.text},children:s.state})})]}),e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Health"}),e.jsx("span",{className:"info-value",style:{color:a.color},title:a.label,children:a.stateDerived?a.icon:a.label})]}),I&&e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:B?"Runtime":"Model"}),e.jsx("span",{className:"info-value",children:I})]}),x?.budgetLimit!=null&&e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Budget"}),e.jsx("span",{className:"info-value",children:e.jsx("span",{className:"budget-badge",style:{background:x.isOverBudget?"var(--state-error-bg, rgba(248,81,73,0.15))":x.isOverThreshold?"var(--state-paused-bg, rgba(227,181,65,0.15))":"var(--state-active-bg, rgba(63,185,80,0.15))",color:x.isOverBudget?"var(--state-error-text, #f85149)":x.isOverThreshold?"var(--state-paused-text, #e3b541)":"var(--state-active-text, #3fb950)",border:`1px solid ${x.isOverBudget?"var(--state-error-border, #f85149)":x.isOverThreshold?"var(--state-paused-border, #e3b541)":"var(--state-active-border, #3fb950)"}`},children:x.isOverBudget?"⚠ Budget Exhausted":`${Math.round(x.usagePercent??0)}% used`})})]}),e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Created"}),e.jsx("span",{className:"info-value",children:new Date(s.createdAt).toLocaleDateString()})]}),e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Last Heartbeat"}),e.jsx("span",{className:"info-value",children:s.lastHeartbeatAt?be(s.lastHeartbeatAt):"Never"})]}),(()=>{if(!(s.state==="active"||s.state==="running")||!s.lastHeartbeatAt)return null;const y=st(s.runtimeConfig?.heartbeatIntervalMs),C=new Date(new Date(s.lastHeartbeatAt).getTime()+y);return e.jsxs("div",{className:"info-item",children:[e.jsx("span",{className:"info-label",children:"Next Heartbeat"}),e.jsx("span",{className:"info-value",title:C.toLocaleString(),children:be(C.toISOString())})]})})()]})]}),e.jsxs("div",{className:"dashboard-section",children:[e.jsxs("h3",{children:[e.jsx(Ue,{size:16,style:{marginRight:"6px",verticalAlign:"-2px"}}),"Chain of Command"]}),m?e.jsxs("div",{className:"chain-of-command-loading",role:"status","aria-live":"polite",children:[e.jsx(V,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Loading reporting chain..."})]}):r.length<=1?e.jsx("p",{className:"text-muted",children:"No reporting chain"}):e.jsx("div",{className:"chain-of-command-path","aria-label":"Chain of command",children:r.map((o,y)=>{const C=y===r.length-1,O=!C;return e.jsxs("div",{className:"chain-of-command-item",children:[e.jsx("button",{type:"button",className:`chain-of-command-node${C?" chain-of-command-node--current":""}`,onClick:()=>O&&i?.(o.id),disabled:!O||!i,title:C?"Current agent":`View ${o.name}`,children:o.name}),!C&&e.jsx("span",{className:"chain-of-command-separator","aria-hidden":"true",children:"→"})]},o.id)})})]}),e.jsxs("div",{className:"dashboard-section",children:[e.jsx("h3",{children:"Statistics"}),e.jsxs("div",{className:"stats-grid",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-value",children:E.totalRuns}),e.jsx("div",{className:"stat-label",children:"Total Runs"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-value",children:E.todayRuns}),e.jsx("div",{className:"stat-label",children:"Runs Today"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsxs("div",{className:"stat-value",children:[E.successRate,"%"]}),e.jsx("div",{className:"stat-label",children:"Success Rate"})]})]})]}),s.taskId&&e.jsxs("div",{className:"dashboard-section",children:[e.jsx("h3",{children:"Current Task"}),e.jsxs("div",{className:"current-task",children:[e.jsx("span",{className:"task-badge",children:s.taskId}),e.jsxs("a",{href:`/tasks/${s.taskId}`,className:"btn btn--sm",children:["View Task ",e.jsx(Cs,{size:14})]})]})]}),s.metadata&&Object.keys(s.metadata).length>0&&e.jsxs("div",{className:"dashboard-section",children:[e.jsx("h3",{children:"Metadata"}),e.jsx("pre",{className:"metadata-json",children:JSON.stringify(s.metadata,null,2)})]})]})}function _t({logs:s,isStreaming:a,containerRef:i,hasTask:c}){return c?e.jsxs("div",{className:"logs-tab",children:[e.jsxs("div",{className:"logs-header",children:[e.jsxs("span",{className:"logs-count",children:[s.length," entries"]}),a&&e.jsxs("span",{className:"streaming-indicator",children:[e.jsx("span",{className:"streaming-dot"}),"Live"]})]}),e.jsx("div",{ref:i,className:"logs-container",children:s.length===0?e.jsxs("div",{className:"logs-empty",children:[e.jsx(Ae,{size:48,opacity:.3}),e.jsx("p",{children:"No log entries yet"}),e.jsx("p",{className:"text-muted",children:a?"Waiting for activity...":"Logs will appear here when the agent is active"})]}):s.map((d,r)=>{const p=r>0?s[r-1]:void 0,m=!p||p.agent!==d.agent;return e.jsx(Vt,{entry:d,showTimestamp:m},`${d.timestamp}-${r}`)})})]}):e.jsx("div",{className:"logs-tab",children:e.jsxs("div",{className:"logs-empty",children:[e.jsx(Ae,{size:48,opacity:.3}),e.jsx("p",{children:"No task assigned"}),e.jsx("p",{className:"text-muted",children:"Agent logs are available when the agent is assigned to a task"})]})})}function Vt({entry:s,showTimestamp:a}){const c=(()=>{switch(s.type){case"tool":return{color:"var(--accent)",borderLeft:"3px solid var(--accent)",background:"var(--log-tool-bg)"};case"tool_result":return{color:"var(--color-success)",borderLeft:"3px solid var(--color-success)",background:"var(--log-success-bg)"};case"tool_error":return{color:"var(--color-error)",borderLeft:"3px solid var(--color-error)",background:"var(--log-error-bg)"};case"thinking":return{color:"var(--text-muted)",fontStyle:"italic",opacity:.7};default:return{color:"var(--text-primary)"}}})(),d=new Date(s.timestamp).toLocaleTimeString();return e.jsxs("div",{className:"log-entry",style:c,children:[a&&e.jsxs("span",{className:"log-timestamp",children:["[",d,"]"]}),s.agent&&e.jsxs("span",{className:"log-agent",children:["[",s.agent,"]"]}),s.type==="tool"&&e.jsx("span",{className:"log-icon",children:"⚡"}),s.type==="tool_result"&&e.jsx("span",{className:"log-icon",children:"✓"}),s.type==="tool_error"&&e.jsx("span",{className:"log-icon",children:"✗"}),e.jsxs("span",{className:"log-text",children:[s.text,s.detail&&e.jsxs("span",{className:"log-detail",children:[" — ",s.detail]})]})]})}function Ut({addToast:s,agentId:a,projectId:i,agentState:c,agentName:d}){const[r,p]=t.useState([]),{confirm:m}=Rs(),[N,x]=t.useState(!0),[v,z]=t.useState(null),[b,B]=t.useState([]),[I,E]=t.useState(!1),[o,y]=t.useState(null),[C,O]=t.useState(!1),A=t.useCallback(async()=>{try{const u=await tt(a,50,i);p(u)}catch(u){s(`Failed to load runs: ${K(u)}`,"error")}finally{x(!1)}},[a,i,s]);t.useEffect(()=>{A()},[A]);const D=r.some(u=>u.status==="active");t.useEffect(()=>{if(!D)return;const u=setInterval(()=>{A()},5e3);return()=>clearInterval(u)},[D,A]);const H=t.useCallback(async u=>{if(v===u){z(null),B([]),y(null);return}z(u),E(!0),O(!0),B([]),y(null);try{const[S,Z]=await Promise.all([at(a,u,i),nt(a,u,i)]);B(S),y(Z)}catch(S){s(`Failed to load run details: ${K(S)}`,"error"),B([]),y(null)}finally{E(!1),O(!1)}},[v,a,i,s]),J=async()=>{try{await ht(a,i,{source:"on_demand",triggerDetail:"Triggered from dashboard"}),s(`Heartbeat run started for ${d??a}`,"success"),x(!0),A()}catch(u){s(`Failed to start heartbeat run: ${K(u)}`,"error")}},W=async()=>{if(await m({title:"Stop Active Run",message:"Stop the active run? The agent's work will be interrupted.",danger:!0}))try{await gt(a,i),s("Run stopped","success"),x(!0),A()}catch(S){s(`Failed to stop run: ${K(S)}`,"error")}},$=c==="active"||c==="idle";if(N&&r.length===0)return e.jsx("div",{className:"runs-tab",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"24px",justifyContent:"center"},children:[e.jsx(V,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading runs..."})]})});if(r.length===0)return e.jsxs("div",{className:"runs-tab",children:[$&&e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border-color)"},children:e.jsxs("button",{className:"btn btn--sm btn-task-create",onClick:()=>void J(),"aria-label":`Run now for ${d??a}`,children:[e.jsx(Me,{size:14})," Run Now"]})}),e.jsxs("div",{className:"runs-empty",children:[e.jsx(Me,{size:48,opacity:.3}),e.jsx("p",{children:"No runs yet"}),e.jsx("p",{className:"text-muted",children:"Heartbeat runs will appear here"})]})]});const w=[...r].sort((u,S)=>new Date(S.startedAt).getTime()-new Date(u.startedAt).getTime()),G=w.filter(u=>u.status==="active"),h=w.filter(u=>u.status!=="active"),U=u=>u?e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-secondary)",display:"flex",gap:"12px",flexWrap:"wrap"},children:[e.jsxs("span",{children:["Input: ",u.inputTokens.toLocaleString()]}),e.jsxs("span",{children:["Output: ",u.outputTokens.toLocaleString()]}),u.cachedTokens>0&&e.jsxs("span",{children:["Cached: ",u.cachedTokens.toLocaleString()]})]}):null,_=(u,S,Z)=>{const l=bs[u.status]||bs.completed,R=l.icon,P=u.endedAt?Jt(new Date(u.startedAt),new Date(u.endedAt)):"In progress",g=v===u.id;return e.jsxs("div",{children:[e.jsxs("div",{className:X("run-card",Z&&"run-card--active",g&&"run-card--selected"),onClick:()=>void H(u.id),style:{cursor:"pointer"},role:"button",tabIndex:0,"aria-expanded":g,"aria-label":`${Z?"Active":""} run ${u.id.slice(0,8)}, ${u.status}`,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),H(u.id))},children:[e.jsxs("div",{className:"run-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[g?e.jsx(Ss,{size:14}):e.jsx(ks,{size:14}),Z?e.jsxs("span",{className:"run-live-indicator",children:[e.jsx("span",{className:"live-dot"}),"Live Run"]}):e.jsxs("span",{className:"run-id",children:["#",S+1," ",u.id.slice(0,8)]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.invocationSource&&e.jsx("span",{className:"badge",style:{fontSize:"10px",padding:"1px 6px"},children:u.invocationSource}),Z&&e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:M=>{M.preventDefault(),M.stopPropagation(),W()},"aria-label":"Stop active run",children:[e.jsx(ve,{size:12})," Stop"]}),e.jsxs("span",{className:X("run-status",u.status),children:[e.jsx(R,{size:14,className:l.color,style:u.status==="active"?{color:l.color}:void 0}),u.status]})]})]}),e.jsxs("div",{className:"run-details",children:[e.jsxs("span",{children:["Started ",be(u.startedAt)]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:P}),u.triggerDetail&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"text-muted",children:u.triggerDetail})]})]})]}),g&&e.jsxs("div",{className:"run-logs-container",style:{padding:"12px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",borderTop:"1px solid var(--border-color)"},children:[C?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 0"},children:[e.jsx(V,{size:14,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading details..."})]}):o&&e.jsxs("div",{style:{marginBottom:"12px"},children:[o.usageJson&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary)",marginBottom:"4px"},children:"Token Usage"}),U(o.usageJson)]}),o.stdoutExcerpt&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary)",marginBottom:"4px"},children:"Output"}),e.jsx("pre",{style:{background:"var(--bg-tertiary, #161b22)",padding:"8px 12px",borderRadius:"6px",fontSize:"12px",maxHeight:"200px",overflow:"auto",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o.stdoutExcerpt.length>2e3?`${o.stdoutExcerpt.slice(0,2e3)}
|
|
17
|
-
|
|
18
|
-
... (truncated, ${o.stdoutExcerpt.length} chars total)`:o.stdoutExcerpt})]}),o.stderrExcerpt&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"var(--color-error, #f85149)",marginBottom:"4px"},children:"Errors"}),e.jsx("pre",{style:{background:"rgba(248, 81, 73, 0.1)",color:"var(--color-error, #f85149)",padding:"8px 12px",borderRadius:"6px",fontSize:"12px",maxHeight:"200px",overflow:"auto",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:o.stderrExcerpt})]}),o.resultJson&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary)",marginBottom:"4px"},children:"Result"}),e.jsx("pre",{style:{background:"var(--bg-tertiary, #161b22)",padding:"8px 12px",borderRadius:"6px",fontSize:"12px",maxHeight:"200px",overflow:"auto",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(o.resultJson,null,2)})]}),o.contextSnapshot&&Object.keys(o.contextSnapshot).length>0&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary)",marginBottom:"4px"},children:"Context"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 12px",fontSize:"12px"},children:Object.entries(o.contextSnapshot).map(([M,f])=>e.jsxs("span",{children:[e.jsxs("span",{className:"text-muted",children:[M,":"]})," ",e.jsx("span",{children:String(f)})]},M))})]}),!o.stdoutExcerpt&&!o.stderrExcerpt&&!o.resultJson&&e.jsx("div",{className:"text-muted",style:{padding:"8px 0",fontStyle:"italic",fontSize:"12px"},children:"No output captured"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-color)",paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"var(--text-secondary)",marginBottom:"4px"},children:"Agent Logs"}),I?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 0"},children:[e.jsx(V,{size:14,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading logs..."})]}):b.length===0?e.jsx("div",{className:"text-muted",style:{padding:"8px 0",fontStyle:"italic"},children:"No logs available for this run"}):e.jsx(xt,{entries:b,loading:!1})]})]})]},u.id)};return e.jsxs("div",{className:"runs-tab",children:[$&&e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border-color)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:[r.length," run",r.length!==1?"s":"",D&&e.jsxs("span",{className:"run-live-indicator",style:{marginLeft:"8px"},children:[e.jsx("span",{className:"live-dot"}),"Live"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[D&&e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:()=>void W(),"aria-label":`Stop active run for ${d??a}`,children:[e.jsx(ve,{size:14})," Stop Run"]}),e.jsxs("button",{className:"btn btn--sm btn-task-create",onClick:()=>void J(),"aria-label":`Run now for ${d??a}`,children:[e.jsx(Me,{size:14})," Run Now"]})]})]}),G.map((u,S)=>_(u,S,!0)),h.map((u,S)=>_(u,G.length+S,!1))]})}function Jt(s,a){const i=Math.floor((a.getTime()-s.getTime())/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m ${i%60}s`:`${Math.floor(i/3600)}h ${Math.floor(i%3600/60)}m`}const Wt={triage:"Triage",todo:"Todo","in-progress":"In Progress","in-review":"In Review",done:"Done",archived:"Archived"};function Gt(s){const a=s.title?.trim()||s.description?.trim()||s.id;return a.length>80?`${a.slice(0,77)}...`:a}function qt({agentId:s,projectId:a,addToast:i}){const[c,d]=t.useState([]),[r,p]=t.useState(!0);return t.useEffect(()=>{let m=!1;return p(!0),it(s,a).then(N=>{m||d(N)}).catch(N=>{m||(d([]),i(`Failed to load assigned tasks: ${K(N)}`,"error"))}).finally(()=>{m||p(!1)}),()=>{m=!0}},[s,a,i]),r?e.jsxs("div",{className:"agent-tasks-empty",children:[e.jsx(V,{size:16,className:"animate-spin"}),e.jsx("p",{children:"Loading assigned tasks..."})]}):c.length===0?e.jsxs("div",{className:"agent-tasks-empty",children:[e.jsx(Fs,{size:18}),e.jsx("p",{children:"No tasks assigned to this agent"})]}):e.jsx("div",{className:"agent-tasks-list",children:c.map(m=>e.jsxs("a",{className:"agent-task-item",href:`/tasks/${m.id}`,children:[e.jsxs("div",{className:"agent-task-row",children:[e.jsx("span",{className:"agent-task-id",children:m.id}),e.jsx("span",{className:`agent-task-column column-${m.column}`,children:Wt[m.column]})]}),e.jsx("div",{className:"agent-task-title",title:m.title||m.description||m.id,children:Gt(m)}),e.jsxs("div",{className:"agent-task-status",children:[m.status??"idle"," · Updated ",be(m.updatedAt)]})]},m.id))})}const pe=[{key:"maxRetries",label:"Max Retries",type:"number",placeholder:"3",hint:"Maximum number of automatic retries on task failure (0–10, default 3)",min:0,max:10},{key:"timeoutMs",label:"Task Timeout (ms)",type:"number",placeholder:"600000",hint:"Maximum time in ms before a task is considered timed out (minimum 60000ms, default 600000ms)",min:6e4,max:864e5},{key:"logLevel",label:"Log Level",type:"select",hint:"Verbosity of agent log output",options:[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warning"},{value:"error",label:"Error"}]}];function Yt(s){const a={};for(const i of pe){const c=s[i.key]?.trim();if(c){if(i.type==="number"){const d=Number(c);if(Number.isNaN(d)||!Number.isFinite(d)){a[i.key]=`"${i.label}" must be a valid number`;continue}i.min!==void 0&&d<i.min&&(a[i.key]=`"${i.label}" must be at least ${i.min.toLocaleString()}`),i.max!==void 0&&d>i.max&&(a[i.key]=`"${i.label}" must be at most ${i.max.toLocaleString()}`)}if(i.type==="select"){const d=i.options?.map(r=>r.value)??[];d.length>0&&!d.includes(c)&&(a[i.key]=`"${i.label}" must be one of: ${d.join(", ")}`)}}}return a}function Kt({agent:s,projectId:a,addToast:i,onSaved:c}){const[d,r]=t.useState(s.soul??""),[p,m]=t.useState(!1),[N,x]=t.useState(!1),[v,z]=t.useState(!1);t.useEffect(()=>{r(s.soul??""),x(!1),z(!1)},[s.id,s.soul]);const b=d!==(s.soul??""),B=async()=>{if(d.length>1e4){i("Soul must be at most 10,000 characters","error");return}m(!0);try{await pt(s.id,d,a),i("Soul saved","success"),x(!0),setTimeout(()=>x(!1),3e3),await c()}catch(I){i(`Failed to save soul: ${K(I)}`,"error")}finally{m(!1)}};return e.jsx("div",{className:"config-tab",children:e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Soul"}),e.jsx("p",{className:"config-description",children:"Define this agent's personality and identity."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-soul",children:"Agent Soul"}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${v?"":"btn-primary"}`,onClick:()=>z(!1),disabled:!v,"aria-label":"Edit mode",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${v?"btn-primary":""}`,onClick:()=>z(!0),disabled:v,"aria-label":"Preview mode",children:[e.jsx(We,{size:14}),"Preview"]})]})}),v?d.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:d})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No soul defined yet. Switch to Edit mode to define the agent's personality."}):e.jsx("textarea",{id:"agent-soul",className:"input",rows:12,placeholder:"Describe this agent's personality, tone, and behavioral traits...",value:d,onChange:I=>{r(I.target.value),x(!1)},style:{fontFamily:"monospace",fontSize:"0.875rem",resize:"vertical"}}),!v&&e.jsx("span",{className:"config-hint",children:"Defines the agent's character and identity. Max 10,000 characters."})]})}),!v&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!b||p,onClick:()=>void B(),children:p?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Save Soul"]})}),!b&&N&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ee,{size:14}),"Soul saved"]})]})]})})}function Zt({agent:s,projectId:a,addToast:i,onSaved:c}){const[d,r]=t.useState(s.memory??""),[p,m]=t.useState(!1),[N,x]=t.useState(!1),[v,z]=t.useState(!1),[b,B]=t.useState([]),[I,E]=t.useState(!1),[o,y]=t.useState(""),[C,O]=t.useState(""),[A,D]=t.useState(!1),[H,J]=t.useState(!1),[W,$]=t.useState(!1),[w,G]=t.useState(!1),[h,U]=t.useState(""),_=s.state==="running",u=d!==(s.memory??""),S=t.useMemo(()=>b.find(f=>f.path===o),[b,o]),Z=S?Bt[S.layer]:"Select a memory file to view or edit.",l=t.useCallback(async f=>{J(!0);try{const L=await ot(s.id,f,a);y(L.path),O(L.content),D(!1),G(!1)}catch(L){i(`Failed to load agent memory file: ${K(L)}`,"error")}finally{J(!1)}},[s.id,a,i]),R=t.useCallback(async(f="")=>{E(!0);try{const{files:L}=await ct(s.id,a);if(B(L),L.length===0){y(""),O(""),D(!1);return}const le=Ot(L,f);await l(le)}catch(L){i(`Failed to load memory files: ${K(L)}`,"error"),B([]),y(""),O(""),D(!1)}finally{E(!1)}},[s.id,a,i,l]);t.useEffect(()=>{r(s.memory??""),x(!1),z(!1),U(""),G(!1),R()},[s.id,s.memory,R]);const P=async()=>{if(d.length>5e4){i("Memory must be at most 50,000 characters","error");return}m(!0);try{await jt(s.id,d,a),i("Memory saved","success"),x(!0),setTimeout(()=>x(!1),3e3),await c()}catch(f){i(`Failed to save memory: ${K(f)}`,"error")}finally{m(!1)}},g=async f=>{if(!(!f||f===o)){if(A){U("Save the current file before switching to another file.");return}U(""),await l(f)}},M=async()=>{if(o){$(!0);try{await yt(s.id,o,C,a),D(!1),G(!0),setTimeout(()=>G(!1),3e3),U(""),await R(o),i("Agent memory file saved","success")}catch(f){i(`Failed to save agent memory file: ${K(f)}`,"error")}finally{$(!1)}}};return e.jsx("div",{className:"config-tab",children:e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Agent Memory"}),e.jsx("p",{className:"config-description",children:"Store context that belongs to this agent only. Workspace memory, daily notes, dreams, and qmd search live in project settings under Project Memory."}),_&&e.jsx("p",{className:"config-hint",style:{marginBottom:12},children:"Read-only while this agent is running."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-memory",children:"Inline Memory"}),e.jsx("span",{className:"config-hint",style:{display:"block",marginBottom:8},children:"Short-form memory stored directly on the agent record and injected into prompts."}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[!_&&e.jsxs("button",{className:`btn btn-sm ${v?"":"btn-primary"}`,onClick:()=>z(!1),disabled:!v,"aria-label":"Edit mode",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${v?"btn-primary":""}`,onClick:()=>z(!0),disabled:v,"aria-label":"Preview mode",children:[e.jsx(We,{size:14}),"Preview"]})]})}),v?d.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:d})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No agent memory defined yet. Switch to Edit mode to add memory content."}):e.jsx("textarea",{id:"agent-memory","aria-label":"Agent Memory",className:"input",rows:10,placeholder:"Durable preferences, operating habits, and context this agent should carry across tasks...",value:d,readOnly:_,onChange:f=>{r(f.target.value),x(!1)},style:{fontFamily:"monospace",fontSize:"0.875rem",resize:"vertical"}}),!v&&e.jsx("span",{className:"config-hint",children:"This is the inline memory field on the agent JSON record. Max 50,000 characters."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-memory-file-select",children:"Memory Files"}),e.jsxs("span",{className:"config-hint",style:{display:"block",marginBottom:8},children:["Full OpenClaw memory files at ",e.jsxs("code",{children:[".fusion/agent-memory/",s.id,"/"]})," (MEMORY.md, DREAMS.md, and daily notes)."]}),e.jsx("select",{id:"agent-memory-file-select",className:"select",value:o,disabled:I||H||W||b.length===0,onChange:f=>{g(f.target.value)},children:b.length===0?e.jsx("option",{value:"",children:"No memory files found"}):b.map(f=>e.jsxs("option",{value:f.path,children:[js[f.layer]," • ",f.label]},f.path))}),I&&e.jsxs("span",{className:"config-hint",style:{display:"inline-flex",gap:6,marginTop:8},children:[e.jsx(V,{size:14,className:"animate-spin"}),"Loading memory files…"]}),S&&e.jsxs("div",{className:"config-hint",style:{marginTop:8},children:[e.jsx("strong",{children:js[S.layer]})," · ",Z,e.jsx("br",{}),S.size.toLocaleString()," bytes · Updated ",be(S.updatedAt)]}),e.jsx("textarea",{className:"input",rows:14,placeholder:"Select a memory file to view and edit its content...",value:C,readOnly:_||!o||H,onChange:f=>{O(f.target.value),D(!0),G(!1),U("")},style:{fontFamily:"monospace",fontSize:"0.875rem",resize:"vertical",marginTop:8}}),H&&e.jsxs("span",{className:"config-hint",style:{display:"inline-flex",gap:6,marginTop:8},children:[e.jsx(V,{size:14,className:"animate-spin"}),"Loading file content…"]}),h&&e.jsx("span",{className:"config-hint",style:{display:"block",marginTop:8},children:h})]})]}),e.jsxs("div",{className:"config-actions",children:[!v&&e.jsx("button",{className:"btn btn-task-create",disabled:!u||p||_,onClick:()=>void P(),children:p?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Save Memory"]})}),e.jsx("button",{className:"btn",disabled:!A||W||!o||_,onClick:()=>void M(),children:W?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Saving file…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Save Memory File"]})}),!u&&N&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ee,{size:14}),"Memory saved"]}),!A&&w&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ee,{size:14}),"Memory file saved"]})]})]})})}function Qt({agent:s,projectId:a,addToast:i,onSaved:c}){const[d,r]=t.useState(s.instructionsText??""),[p,m]=t.useState(s.instructionsPath??""),[N,x]=t.useState(!1),[v,z]=t.useState(""),[b,B]=t.useState(!1),[I,E]=t.useState(!1),[o,y]=t.useState(!1),[C,O]=t.useState(!1),[A,D]=t.useState(!1),[H,J]=t.useState(!1);t.useEffect(()=>{const h=p.trim();if(!h){z(""),E(!1);return}B(!0),lt("project",h).then(U=>{z(U.content),E(!1)}).catch(U=>{const _=K(U);_.includes("ENOENT")||_.includes("Not found")||_.includes("not found")?(z(""),E(!1)):(i(`Failed to load instructions file: ${_}`,"error"),z(""))}).finally(()=>{B(!1)})},[p,i]),t.useEffect(()=>{r(s.instructionsText??""),m(s.instructionsPath??""),D(!1),J(!1),x(!1)},[s.id,s.instructionsText,s.instructionsPath]);const W=(()=>{const h=d??"",U=s.instructionsText??"",_=p?.trim()??"",u=s.instructionsPath?.trim()??"";return h!==U||_!==u})(),$=async()=>{y(!0);try{await vt(s.id,{instructionsText:d||void 0,instructionsPath:p.trim()||void 0},a),i("Instructions saved","success"),D(!0),setTimeout(()=>D(!1),3e3),await c()}catch(h){i(`Failed to save instructions: ${K(h)}`,"error")}finally{y(!1)}},w=async()=>{const h=p.trim();if(!h){i("No instructions file path set","error");return}O(!0);try{await bt("project",h,v),i("Instructions file saved","success"),E(!1),J(!0),setTimeout(()=>J(!1),3e3)}catch(U){i(`Failed to save instructions file: ${K(U)}`,"error")}finally{O(!1)}},G=!!p.trim();return e.jsxs("div",{className:"config-tab",children:[e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Custom Instructions"}),e.jsx("p",{className:"config-description",children:"Append custom instructions to this agent's system prompt at execution time. Use this to customize behavior, coding style, or project conventions without modifying built-in prompts."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"instructions-text",children:"Inline Instructions"}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${N?"":"btn-primary"}`,onClick:()=>x(!1),disabled:!N,"aria-label":"Edit mode","data-testid":"instructions-edit-toggle",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${N?"btn-primary":""}`,onClick:()=>x(!0),disabled:N,"aria-label":"Preview mode","data-testid":"instructions-preview-toggle",children:[e.jsx(We,{size:14}),"Preview"]})]})}),N?d.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:d})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No inline instructions defined yet. Switch to Edit mode to add instructions."}):e.jsx("textarea",{id:"instructions-text",className:"input",rows:10,placeholder:"Enter custom instructions to append to this agent's system prompt...",value:d,onChange:h=>{r(h.target.value),D(!1)},style:{fontFamily:"monospace",fontSize:"0.875rem",resize:"vertical"}}),!N&&e.jsx("span",{className:"config-hint",children:"Markdown formatting supported. Max 50,000 characters."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"instructions-path",children:"Instructions File Path"}),e.jsx("input",{id:"instructions-path",type:"text",className:"input",placeholder:"e.g., .fusion/agents/my-agent-instructions.md",value:p,onChange:h=>{m(h.target.value),D(!1)}}),e.jsx("span",{className:"config-hint",children:"Path to a .md file (relative to project root). Contents are read and appended at execution time."})]})]}),!N&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!W||o,onClick:()=>void $(),children:o?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Save Instructions"]})}),!W&&A&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ee,{size:14}),"Instructions saved"]})]})]}),G&&e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Instructions File Editor"}),e.jsx("p",{className:"config-description",children:"Edit the instructions file directly. Changes are saved separately from the path configuration."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[e.jsx("label",{htmlFor:"instructions-file-content",children:"File Content"}),b&&e.jsxs("span",{className:"config-hint",style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(V,{size:12,className:"animate-spin"}),"Loading..."]}),I&&!b&&e.jsx("span",{className:"config-hint",style:{color:"var(--color-warning, #e3b541)"},children:"Unsaved changes"})]}),e.jsx("textarea",{id:"instructions-file-content",className:"input",rows:20,placeholder:"File content will appear here when loaded...",value:v,readOnly:b,onChange:h=>{z(h.target.value),E(!0),J(!1)},style:{fontFamily:"monospace",fontSize:"0.875rem",resize:"vertical"}}),e.jsx("span",{className:"config-hint",children:"Edit the markdown file content directly. Save separately using the button below."})]})}),e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!I||C,onClick:()=>void w(),children:C?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Save File"]})}),!I&&H&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ee,{size:14}),"File saved"]})]})]})]})}function ys(s){const a=s??{},i={};return a.heartbeatIntervalMs!==void 0&&a.heartbeatIntervalMs!==null&&(i.heartbeatIntervalMs=String(Number(a.heartbeatIntervalMs)/1e3)),a.heartbeatTimeoutMs!==void 0&&a.heartbeatTimeoutMs!==null&&(i.heartbeatTimeoutMs=String(Number(a.heartbeatTimeoutMs)/1e3)),a.maxConcurrentRuns!==void 0&&a.maxConcurrentRuns!==null&&(i.maxConcurrentRuns=String(a.maxConcurrentRuns)),(a.messageResponseMode==="immediate"||a.messageResponseMode==="on-heartbeat")&&(i.messageResponseMode=a.messageResponseMode),i}function Ie(s){return s?.enabled!==!1}function Ns(s){const a=(s??{}).budgetConfig,i={};return a&&(a.tokenBudget!==void 0&&a.tokenBudget!==null&&(i.tokenBudget=String(a.tokenBudget)),a.usageThreshold!==void 0&&a.usageThreshold!==null&&(i.usageThreshold=String(Number(a.usageThreshold)*100)),a.budgetPeriod!==void 0&&a.budgetPeriod!==null&&(i.budgetPeriod=String(a.budgetPeriod)),a.resetDay!==void 0&&a.resetDay!==null&&(i.resetDay=String(a.resetDay))),i}function Xt({agent:s,projectId:a,addToast:i,onSaved:c}){const[d,r]=t.useState(!1),p=s.heartbeatProcedurePath?.trim(),m=`.fusion/agents/${s.id}/HEARTBEAT.md`,N=p===m,x=async()=>{r(!0);try{const v=await Rt(s.id,a);i(v.procedureFileSeeded?`Heartbeat procedure file ready at ${v.heartbeatProcedurePath}`:`Heartbeat procedure path set to ${v.heartbeatProcedurePath}`,"success"),await c()}catch(v){i(`Failed to upgrade heartbeat procedure: ${K(v)}`,"error")}finally{r(!1)}};return e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Heartbeat Procedure"}),e.jsx("p",{className:"config-description",children:"The per-tick procedure this agent runs every wake. Defaults to a project-level markdown file you can edit. Resets on every tick — no need to restart the agent after editing."}),e.jsxs("div",{className:"config-fields",children:[e.jsx("div",{className:"config-field",children:e.jsxs("span",{className:"config-hint",children:["Current path: ",e.jsx("code",{children:p||"(none — using built-in default)"})]})}),e.jsxs("div",{className:"config-field",children:[e.jsx("button",{className:"btn",disabled:d||N,onClick:()=>void x(),"aria-label":"Upgrade agent to default heartbeat procedure file",children:d?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Upgrading…"]}):N?e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Already on default"]}):"Upgrade to Default Heartbeat Procedure"}),e.jsxs("span",{className:"config-hint",children:["Sets ",e.jsx("code",{children:"heartbeatProcedurePath"})," to"," ",e.jsx("code",{children:m})," ","and seeds the file from the built-in template if it doesn't exist. Each agent gets its own per-agent file, so edits stay scoped to this agent. Operator edits to the file are preserved."]})]})]})]})}function ea({agent:s,projectId:a,addToast:i,onSaved:c,onHasChangesChange:d,onDelete:r}){const[p,m]=t.useState(s.name),[N,x]=t.useState(s.role),[v,z]=t.useState(s.title??""),[b,B]=t.useState(s.icon??""),[I,E]=t.useState(s.reportsTo??""),[o,y]=t.useState([]),[C,O]=t.useState(!1),[A,D]=t.useState(()=>{const n={};for(const k of pe){const T=s.metadata[k.key];T!=null&&(n[k.key]=String(T))}return n}),[H,J]=t.useState(()=>ys(s.runtimeConfig)),[W,$]=t.useState(()=>Ie(s.runtimeConfig)),[w,G]=t.useState(()=>Ns(s.runtimeConfig)),[h,U]=t.useState(s.bundleConfig?.mode??""),[_,u]=t.useState(s.bundleConfig?.entryFile??"AGENTS.md"),[S,Z]=t.useState(s.bundleConfig?.externalPath??""),[l,R]=t.useState(s.bundleConfig?.files??[]),[P,g]=t.useState(Array.isArray(s.metadata?.skills)?s.metadata.skills:[]),[M,f]=t.useState([]),[L,le]=t.useState(!1),[je,de]=t.useState([]),[De,Ke]=t.useState(!1),ye=(()=>{const n=s.runtimeConfig??{};return n.modelProvider&&n.modelId?`${n.modelProvider}/${n.modelId}`:typeof n.model=="string"&&n.model.includes("/")?n.model:""})(),oe=typeof s.runtimeConfig?.runtimeHint=="string"?s.runtimeConfig.runtimeHint:"",[ae,ze]=t.useState(oe?"runtime":"model"),[ce,Ze]=t.useState(ye),[Ne,Ee]=t.useState(oe),Se=I.trim(),Qe=t.useMemo(()=>o.filter(n=>n.id!==s.id),[o,s.id]),Ts=!!Se&&!Qe.some(n=>n.id===Se);t.useEffect(()=>{let n=!1;return O(!0),dt(void 0,a).then(k=>{n||y(k)}).catch(()=>{n||y([])}).finally(()=>{n||O(!1)}),()=>{n=!0}},[a]),t.useEffect(()=>{le(!0),ut().then(n=>f(n.models)).catch(()=>{}).finally(()=>le(!1))},[]),t.useEffect(()=>{Ke(!0),ws(a).then(de).catch(()=>de([])).finally(()=>Ke(!1))},[a]);const[ne,Le]=t.useState(null),[Xe,es]=t.useState(!1);t.useEffect(()=>{Oe(s.id,a).then(Le).catch(()=>Le(null))},[s.id,a]);const As=async()=>{es(!0);try{await St(s.id,a),i("Budget usage reset successfully","success");const n=await Oe(s.id,a);Le(n)}catch(n){i(`Failed to reset budget: ${K(n)}`,"error")}finally{es(!1)}},[ss,ts]=t.useState(!1),[F,ke]=t.useState({}),[Ds,ue]=t.useState(!1),as=s.state==="idle"||s.state==="terminated",he=t.useRef(null),ns=t.useRef(null);t.useEffect(()=>()=>{he.current&&clearTimeout(he.current)},[]);const ie=(()=>{if(p!==s.name||N!==s.role||v!==(s.title??"")||b!==(s.icon??"")||I!==(s.reportsTo??"")||h!==(s.bundleConfig?.mode??"")||_!==(s.bundleConfig?.entryFile??"AGENTS.md")||S!==(s.bundleConfig?.externalPath??"")||JSON.stringify(l)!==JSON.stringify(s.bundleConfig?.files??[]))return!0;for(const Y of pe){const re=A[Y.key]?.trim()??"",Q=s.metadata[Y.key]!==void 0&&s.metadata[Y.key]!==null?String(s.metadata[Y.key]):"";if(re!==Q)return!0}const n=s.runtimeConfig??{};if(W!==Ie(s.runtimeConfig))return!0;for(const Y of["heartbeatIntervalMs","heartbeatTimeoutMs","maxConcurrentRuns","messageResponseMode"]){const re=H[Y]?.trim()??"";let Q=n[Y]!==void 0&&n[Y]!==null?String(n[Y]):"";if((Y==="heartbeatIntervalMs"||Y==="heartbeatTimeoutMs")&&Q&&(Q=String(Number(Q)/1e3)),re!==Q)return!0}const k=n.budgetConfig;for(const Y of["tokenBudget","budgetPeriod","resetDay"]){const re=w[Y]?.trim()??"",Q=k?.[Y]!==void 0&&k?.[Y]!==null?String(k[Y]):"";if(re!==Q)return!0}const T=w.usageThreshold?.trim()??"",se=k?.usageThreshold!==void 0&&k?.usageThreshold!==null?String(Number(k.usageThreshold)*100):"";if(T!==se)return!0;const ge=Array.isArray(s.metadata?.skills)?s.metadata.skills:[];return JSON.stringify(P)!==JSON.stringify(ge)||ae!==(oe?"runtime":"model")||ce!==ye||Ne!==oe})(),is=t.useRef(null);t.useEffect(()=>{d&&is.current!==ie&&(is.current=ie,d(ie))},[ie,d]),t.useEffect(()=>()=>{d?.(!1)},[d]),t.useEffect(()=>{const n={id:s.id,updatedAt:s.updatedAt},k=ns.current;(!k||k.id!==n.id||k.updatedAt!==n.updatedAt)&&(ie||(ns.current=n,J(ys(s.runtimeConfig)),$(Ie(s.runtimeConfig)),G(Ns(s.runtimeConfig)),Ze(ye),Ee(oe),ze(oe?"runtime":"model")))},[s,ie,ye,oe]);const rs=(n,k)=>{D(T=>({...T,[n]:k})),ue(!1),F[n]&&ke(T=>{const se={...T};return delete se[n],se})},Re=(n,k)=>{J(T=>({...T,[n]:k})),ue(!1),F[n]&&ke(T=>{const se={...T};return delete se[n],se})},zs=n=>{$(n),ue(!1)},Ce=(n,k)=>{G(T=>({...T,[n]:k})),ue(!1),F[n]&&ke(T=>{const se={...T};return delete se[n],se})},Es=async()=>{const n=Yt(A);for(const[j,te]of Object.entries({heartbeatIntervalMs:{label:"Heartbeat Interval",min:1},heartbeatTimeoutMs:{label:"Heartbeat Timeout",min:5},maxConcurrentRuns:{label:"Max Concurrent Runs",min:1}})){const fe=H[j]?.trim();if(!fe)continue;const Pe=Number(fe);Number.isNaN(Pe)||!Number.isFinite(Pe)?n[j]=`"${te.label}" must be a valid number`:Pe<te.min&&(n[j]=`"${te.label}" must be at least ${te.min.toLocaleString()}`)}const k=H.messageResponseMode?.trim();k&&!["immediate","on-heartbeat"].includes(k)&&(n.messageResponseMode='"Message Response Mode" must be either immediate or on-heartbeat');const T=w.tokenBudget?.trim();if(T){const j=Number(T);Number.isNaN(j)||!Number.isFinite(j)?n.tokenBudget='"Token Budget" must be a valid number':j<=0&&(n.tokenBudget='"Token Budget" must be greater than 0')}const se=w.usageThreshold?.trim();if(se){const j=Number(se);Number.isNaN(j)||!Number.isFinite(j)?n.usageThreshold='"Usage Threshold" must be a valid number':(j<1||j>100)&&(n.usageThreshold='"Usage Threshold" must be between 1 and 100')}const ge=w.budgetPeriod?.trim();ge&&!["daily","weekly","monthly","lifetime"].includes(ge)&&(n.budgetPeriod='"Budget Period" must be one of: daily, weekly, monthly, lifetime');const Y=w.resetDay?.trim(),re=ge||"lifetime";if(Y){const j=Number(Y);Number.isNaN(j)||!Number.isFinite(j)?n.resetDay='"Reset Day" must be a valid number':re==="weekly"?(j<0||j>6||!Number.isInteger(j))&&(n.resetDay='"Reset Day" must be between 0 (Sunday) and 6 (Saturday) for weekly period'):re==="monthly"&&(j<1||j>31||!Number.isInteger(j))&&(n.resetDay='"Reset Day" must be between 1 and 31 for monthly period')}if(Object.keys(n).length>0){ke(n),i("Please fix validation errors before saving","error");return}const Q={...s.metadata};for(const j of pe){const te=A[j.key]?.trim();te?j.type==="number"?Q[j.key]=Number(te):Q[j.key]=te:delete Q[j.key]}P.length>0?Q.skills=P:delete Q.skills;const q={...s.runtimeConfig};q.enabled=W;for(const j of["heartbeatIntervalMs","heartbeatTimeoutMs","maxConcurrentRuns"]){const te=H[j]?.trim();if(!te)delete q[j];else{const fe=Number(te);q[j]=j==="maxConcurrentRuns"?fe:fe*1e3}}const ls=H.messageResponseMode?.trim();if(ls?q.messageResponseMode=ls:delete q.messageResponseMode,ae==="runtime")Ne.trim()?q.runtimeHint=Ne.trim():delete q.runtimeHint,delete q.modelProvider,delete q.modelId,delete q.model;else if(delete q.runtimeHint,ce.trim()){const j=ce.indexOf("/");j!==-1&&(q.modelProvider=ce.slice(0,j),q.modelId=ce.slice(j+1),q.model=ce.trim())}else delete q.modelProvider,delete q.modelId,delete q.model;const me={},os=w.tokenBudget?.trim(),cs=w.usageThreshold?.trim(),ds=w.budgetPeriod?.trim(),us=w.resetDay?.trim();os&&(me.tokenBudget=Number(os)),cs&&(me.usageThreshold=Number(cs)/100),ds&&(me.budgetPeriod=ds),us&&(me.resetDay=Number(us)),Object.keys(me).length>0?q.budgetConfig=me:delete q.budgetConfig;let $e;h&&($e={mode:h,entryFile:_||"AGENTS.md",files:l.length>0?l:["AGENTS.md"]},h==="external"&&S.trim()&&($e.externalPath=S.trim())),ts(!0);try{await kt(s.id,{name:p.trim()||void 0,role:N,title:v.trim()||void 0,icon:b.trim()||void 0,reportsTo:I.trim()||void 0,metadata:Q,runtimeConfig:q,bundleConfig:$e},a),i("Settings saved","success"),ue(!0),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>ue(!1),3e3),await c()}catch(j){i(`Failed to save settings: ${K(j)}`,"error")}finally{ts(!1)}};return e.jsxs("div",{className:"config-tab",children:[e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Agent Configuration"}),e.jsx("p",{className:"config-description",children:"Configure agent settings and behavior."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-name",children:"Name"}),e.jsx("input",{id:"agent-name",type:"text",className:"input",value:p,onChange:n=>m(n.target.value)})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-role",children:"Role"}),e.jsxs("select",{id:"agent-role",className:"select",value:N,onChange:n=>x(n.target.value),children:[e.jsx("option",{value:"triage",children:"Triage"}),e.jsx("option",{value:"executor",children:"Executor"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"merger",children:"Merger"}),e.jsx("option",{value:"scheduler",children:"Scheduler"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-title",children:"Title"}),e.jsx("input",{id:"agent-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:v,onChange:n=>z(n.target.value)})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-icon",children:"Icon"}),e.jsx("input",{id:"agent-icon",type:"text",className:"input",placeholder:"e.g. 🤖",value:b,onChange:n=>B(n.target.value)})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-reports-to",children:"Reports To"}),e.jsxs("select",{id:"agent-reports-to",className:"select",value:I,onChange:n=>E(n.target.value),disabled:C,children:[e.jsx("option",{value:"",children:"No manager"}),Ts&&e.jsxs("option",{value:Se,children:["Unknown manager (",Se,")"]}),Qe.map(n=>e.jsxs("option",{value:n.id,children:[n.name," (",n.id,")"]},n.id))]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Skills"}),e.jsx("p",{className:"config-description",children:"Assign skills to this agent for specialized behavior."}),e.jsx("div",{className:"config-fields",children:e.jsx("div",{className:"config-field",children:e.jsx(Ct,{id:"agent-skills",label:"Skills",value:P,onChange:g,projectId:a})})})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Model"}),e.jsx("p",{className:"config-description",children:"Choose either a built-in model or a plugin runtime for this agent. These options are mutually exclusive."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Runtime Source"}),e.jsxs("div",{className:"config-runtime-tabs",role:"tablist","aria-label":"Runtime source",children:[e.jsx("button",{type:"button",className:`config-runtime-tab${ae==="model"?" active":""}`,role:"tab","aria-selected":ae==="model",tabIndex:ae==="model"?0:-1,onClick:()=>{ze("model"),Ee("")},children:"Built-in Model"}),e.jsx("button",{type:"button",className:`config-runtime-tab${ae==="runtime"?" active":""}`,role:"tab","aria-selected":ae==="runtime",tabIndex:ae==="runtime"?0:-1,onClick:()=>ze("runtime"),children:"Plugin Runtime"})]})]}),ae==="model"?e.jsx("div",{className:"config-field",children:e.jsx(mt,{models:M,value:ce,onChange:Ze,placeholder:"Use global default",label:"Agent Model",disabled:L})}):e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-runtime-hint",children:"Runtime"}),De?e.jsx("span",{className:"config-hint",children:"Loading runtimes…"}):e.jsxs("select",{id:"agent-runtime-hint",className:"select",value:Ne,onChange:n=>Ee(n.target.value),children:[e.jsx("option",{value:"",children:je.length>0?"Select a plugin runtime…":"No plugin runtimes available"}),je.map(n=>e.jsx("option",{value:n.runtimeId,children:n.description?`${n.name} — ${n.description}`:n.name},`${n.pluginId}:${n.runtimeId}`))]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Heartbeat Settings"}),e.jsx("p",{className:"config-description",children:"Configure how this agent's heartbeat is monitored. Leave a field empty to use system defaults."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-enabled",children:[e.jsx("input",{id:"hb-enabled",type:"checkbox",checked:W,onChange:n=>zs(n.target.checked)}),"Heartbeat Enabled"]}),e.jsx("span",{className:"config-hint",children:"When enabled, this agent receives scheduled heartbeat runs based on its interval."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-heartbeatIntervalMs",children:"Heartbeat Interval (s)"}),e.jsx("input",{id:"hb-heartbeatIntervalMs",type:"text",inputMode:"numeric",className:X("input",!!F.heartbeatIntervalMs&&"input--error"),placeholder:String(He/1e3),value:H.heartbeatIntervalMs??"",onChange:n=>Re("heartbeatIntervalMs",n.target.value)}),F.heartbeatIntervalMs?e.jsx("span",{className:"config-error",children:F.heartbeatIntervalMs}):e.jsxs("span",{className:"config-hint",children:["How often heartbeats are checked. Leave empty for system default (",He/1e3,"s / ",It,")."]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-heartbeatTimeoutMs",children:"Heartbeat Timeout (s)"}),e.jsx("input",{id:"hb-heartbeatTimeoutMs",type:"text",inputMode:"numeric",className:X("input",!!F.heartbeatTimeoutMs&&"input--error"),placeholder:"60",value:H.heartbeatTimeoutMs??"",onChange:n=>Re("heartbeatTimeoutMs",n.target.value)}),F.heartbeatTimeoutMs?e.jsx("span",{className:"config-error",children:F.heartbeatTimeoutMs}):e.jsx("span",{className:"config-hint",children:"Time without heartbeat before agent is considered unresponsive. Leave empty for system default (60s)"})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-maxConcurrentRuns",children:"Max Concurrent Runs"}),e.jsx("input",{id:"hb-maxConcurrentRuns",type:"text",inputMode:"numeric",className:X("input",!!F.maxConcurrentRuns&&"input--error"),placeholder:"1",value:H.maxConcurrentRuns??"",onChange:n=>Re("maxConcurrentRuns",n.target.value)}),F.maxConcurrentRuns?e.jsx("span",{className:"config-error",children:F.maxConcurrentRuns}):e.jsx("span",{className:"config-hint",children:"Maximum simultaneous heartbeat runs for this agent. Leave empty for system default (1)."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-messageResponseMode",children:"Message Response Mode"}),e.jsxs("select",{id:"hb-messageResponseMode",className:X("select",!!F.messageResponseMode&&"input--error"),value:H.messageResponseMode??"",onChange:n=>Re("messageResponseMode",n.target.value),children:[e.jsx("option",{value:"",children:"System Default (On Heartbeat)"}),e.jsx("option",{value:"on-heartbeat",children:"On Heartbeat"}),e.jsx("option",{value:"immediate",children:"Immediate"})]}),F.messageResponseMode?e.jsx("span",{className:"config-error",children:F.messageResponseMode}):e.jsx("span",{className:"config-hint",children:"How this agent responds to incoming messages. 'Immediate' wakes the agent as soon as a message arrives. 'On Heartbeat' defers processing to the next scheduled heartbeat."})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Budget Settings"}),e.jsx("p",{className:"config-description",children:"Configure token budget limits for this agent. Leave all fields empty to disable budget tracking."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-tokenBudget",children:"Token Budget"}),e.jsx("input",{id:"budget-tokenBudget",type:"text",inputMode:"numeric",className:X("input",!!F.tokenBudget&&"input--error"),placeholder:"No limit",value:w.tokenBudget??"",onChange:n=>Ce("tokenBudget",n.target.value)}),F.tokenBudget?e.jsx("span",{className:"config-error",children:F.tokenBudget}):e.jsx("span",{className:"config-hint",children:"Total token cap (input + output) for this agent. Leave empty for no limit."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-usageThreshold",children:"Usage Threshold (%)"}),e.jsx("input",{id:"budget-usageThreshold",type:"text",inputMode:"numeric",className:X("input",!!F.usageThreshold&&"input--error"),placeholder:"80",value:w.usageThreshold??"",onChange:n=>Ce("usageThreshold",n.target.value)}),F.usageThreshold?e.jsx("span",{className:"config-error",children:F.usageThreshold}):e.jsx("span",{className:"config-hint",children:"Warning threshold as a percentage. Agent warns when usage reaches this level. Default: 80%."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-budgetPeriod",children:"Budget Period"}),e.jsxs("select",{id:"budget-budgetPeriod",className:X("select",!!F.budgetPeriod&&"input--error"),value:w.budgetPeriod??"",onChange:n=>Ce("budgetPeriod",n.target.value),children:[e.jsx("option",{value:"",children:"No reset (lifetime)"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]}),F.budgetPeriod?e.jsx("span",{className:"config-error",children:F.budgetPeriod}):e.jsx("span",{className:"config-hint",children:"How often the budget counter resets. Leave empty for lifetime budget."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-resetDay",children:"Reset Day"}),e.jsx("input",{id:"budget-resetDay",type:"text",inputMode:"numeric",className:X("input",!!F.resetDay&&"input--error"),placeholder:"Auto",value:w.resetDay??"",onChange:n=>Ce("resetDay",n.target.value)}),F.resetDay?e.jsx("span",{className:"config-error",children:F.resetDay}):e.jsx("span",{className:"config-hint",children:w.budgetPeriod==="weekly"?"Day of week (0=Sunday to 6=Saturday) for reset.":w.budgetPeriod==="monthly"?"Day of month (1-31) for reset.":"Day for reset (weekly: 0-6, monthly: 1-31). Leave empty for automatic."})]}),ne?.budgetLimit!=null&&e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Current Usage"}),e.jsxs("div",{className:"budget-progress-container",children:[e.jsx("div",{className:"budget-progress-bar",children:e.jsx("div",{className:X("budget-progress-bar__fill",(ne.usagePercent??0)>=100?"budget-progress-bar__fill--red":(ne.usagePercent??0)>=80?"budget-progress-bar__fill--amber":"budget-progress-bar__fill--green"),style:{width:`${Math.min(ne.usagePercent??0,100)}%`}})}),e.jsxs("span",{className:"budget-progress-label",children:[(ne.currentUsage??0).toLocaleString()," / ",(ne.budgetLimit??0).toLocaleString()," tokens (",Math.round(ne.usagePercent??0),"% used)"]})]})]}),ne?.budgetLimit!=null&&e.jsx("div",{className:"config-field",children:e.jsx("button",{className:"btn btn-reset-budget",onClick:()=>void As(),disabled:Xe,children:Xe?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:14,className:"animate-spin"}),"Resetting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:14}),"Reset Budget Usage"]})})})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Instruction Bundle"}),e.jsx("p",{className:"config-description",children:"Configure the agent's instruction bundle. Leave empty to use inline instructions only."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-mode",children:"Bundle Mode"}),e.jsxs("select",{id:"bundle-mode",className:"select",value:h,onChange:n=>U(n.target.value),children:[e.jsx("option",{value:"",children:"None (use inline instructions)"}),e.jsx("option",{value:"managed",children:"Managed (system-managed directory)"}),e.jsx("option",{value:"external",children:"External (user-specified path)"})]}),e.jsxs("span",{className:"config-hint",children:[h==="managed"&&"Files will be stored in a system-managed directory within .fusion/agents/",h==="external"&&"Specify an external directory path for the instruction files",!h&&"Select a mode to enable instruction bundling"]})]}),h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-entry-file",children:"Entry File"}),e.jsx("input",{id:"bundle-entry-file",type:"text",className:"input",placeholder:"AGENTS.md",value:_,onChange:n=>u(n.target.value)}),e.jsx("span",{className:"config-hint",children:"Primary instructions file name (default: AGENTS.md)"})]}),h==="external"&&e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-external-path",children:"External Path"}),e.jsx("input",{id:"bundle-external-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/my-agent",value:S,onChange:n=>Z(n.target.value)}),e.jsx("span",{className:"config-hint",children:"Absolute or relative path to the external directory"})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-files",children:"Files (comma-separated)"}),e.jsx("input",{id:"bundle-files",type:"text",className:"input",placeholder:"AGENTS.md, PROMPTS.md",value:l.join(", "),onChange:n=>R(n.target.value.split(",").map(k=>k.trim()).filter(Boolean))}),e.jsx("span",{className:"config-hint",children:"List of file names in the bundle directory"})]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Advanced Settings"}),e.jsx("p",{className:"config-description",children:"Advanced configuration options for this agent. Leave a field empty to use system defaults."}),e.jsx("div",{className:"config-fields",children:pe.map(n=>{const k=!!F[n.key];return e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:`adv-${n.key}`,children:n.label}),n.type==="select"?e.jsxs("select",{id:`adv-${n.key}`,className:X("select",k&&"input--error"),value:A[n.key]??"",onChange:T=>rs(n.key,T.target.value),children:[e.jsx("option",{value:"",children:"System Default"}),n.options?.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))]}):e.jsx("input",{id:`adv-${n.key}`,type:"text",inputMode:n.type==="number"?"numeric":void 0,className:X("input",k&&"input--error"),placeholder:n.placeholder,value:A[n.key]??"",onChange:T=>rs(n.key,T.target.value)}),k&&e.jsx("span",{className:"config-error",children:F[n.key]}),!k&&n.hint&&e.jsx("span",{className:"config-hint",children:n.hint})]},n.key)})}),e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!ie||ss,onClick:()=>void Es(),children:ss?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:16}),"Save Settings"]})}),!ie&&Ds&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ee,{size:14}),"Settings saved"]})]})]}),e.jsx(Xt,{agent:s,projectId:a,addToast:i,onSaved:c}),e.jsxs("div",{className:"config-section config-section--danger",children:[e.jsx("h3",{children:"Danger Zone"}),e.jsx("p",{className:"config-description",children:"Permanently delete this agent from the project."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsxs("button",{className:"btn btn--danger",disabled:!as||!r,onClick:()=>void r?.(),children:[e.jsx(Te,{size:16}),"Delete Agent"]}),e.jsx("span",{className:"config-danger-note",children:as?"Deletion is permanent and cannot be undone.":`Agent deletion is only available when state is idle or terminated (current state: ${s.state}).`})]})})]})]})}function sa({agentId:s,projectId:a,onChildClick:i}){const[c,d]=t.useState([]),[r,p]=t.useState(!0);return t.useEffect(()=>{p(!0),rt(s,a).then(d).finally(()=>p(!1))},[s,a]),r?e.jsxs("div",{className:"detail-section",children:[e.jsx("div",{className:"detail-section-header",children:e.jsx("h3",{children:"Employees"})}),e.jsxs("div",{className:"detail-section-body",style:{display:"flex",alignItems:"center",gap:8,padding:16},children:[e.jsx(V,{size:16,className:"spin"}),e.jsx("span",{className:"text-secondary",children:"Loading employees..."})]})]}):e.jsxs("div",{className:"detail-section",children:[e.jsxs("div",{className:"detail-section-header",children:[e.jsx("h3",{children:"Employees"}),e.jsxs("span",{className:"text-secondary",children:["(",c.length,")"]})]}),e.jsx("div",{className:"detail-section-body",children:c.length===0?e.jsxs("div",{className:"agent-empty",style:{padding:24},children:[e.jsx(Ue,{size:32,opacity:.3}),e.jsx("p",{children:"No employees"}),e.jsx("p",{className:"text-secondary",children:"This agent has no employees"})]}):e.jsx("div",{className:"agent-tree__children",children:c.map(m=>{const N=Ye[m.state];return e.jsxs("div",{className:"agent-tree__node agent-is-child",onClick:()=>i?.(m.id),role:"button",tabIndex:0,onKeyDown:x=>x.key==="Enter"&&i?.(m.id),style:{cursor:i?"pointer":"default"},children:[e.jsx("span",{className:"agent-tree__icon",children:m.icon??"🤖"}),e.jsx("span",{className:"agent-tree__name",children:m.name}),e.jsx("span",{className:"agent-tree__badge",style:{background:N?.bg??"var(--state-idle-bg)",color:N?.text??"var(--state-idle-text)",border:`1px solid ${N?.border??"var(--state-idle-border)"}`},children:m.state})]},m.id)})})})]})}export{da as AgentDetailView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.agent-detail-overlay{position:fixed;inset:0;background:#0009;backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:100;padding:20px}.agent-detail-modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);width:100%;min-width:480px;max-width:calc(100vw - 40px);min-height:320px;max-height:calc(100dvh - 40px);display:flex;flex-direction:column;overflow:hidden;resize:both;box-shadow:0 20px 60px #0000004d}.agent-detail-modal:not([style*=width]){width:min(900px,calc(100vw - 40px))}.agent-detail-modal:not([style*=height]){height:min(85vh,calc(100dvh - 40px))}.agent-detail-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:60px;color:var(--text-muted)}.agent-detail-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-md);padding:12px 20px;border-bottom:1px solid var(--border);background:var(--bg-secondary)}.agent-detail-identity{display:flex;align-items:center;gap:var(--space-md);flex-shrink:0;min-width:0}.agent-detail-icon{width:36px;height:36px;border-radius:var(--radius-md);background:var(--todo);display:flex;align-items:center;justify-content:center;color:#fff;flex-shrink:0}.agent-detail-info{min-width:0}.agent-detail-info h2{font-size:16px;font-weight:600;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-detail-badges{display:flex;gap:var(--space-xs);margin-top:2px}.agent-detail-controls{display:flex;align-items:center;gap:6px;flex-shrink:0}.btn--compact{padding:5px 10px;font-size:12px;gap:4px}.agent-detail-utility-actions{display:flex;align-items:center;gap:var(--space-xs);flex-shrink:0}.agent-detail-title{display:flex;align-items:center;gap:var(--space-lg)}.agent-detail-actions{display:flex;align-items:center;gap:var(--space-sm)}.agent-detail-tabs{display:flex;gap:4px;padding:0 20px;border-bottom:1px solid var(--border);background:var(--bg-secondary)}.agent-detail-tab{display:flex;align-items:center;gap:var(--space-xs);padding:10px 12px;background:none;border:none;border-bottom:2px solid transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:all var(--transition-fast)}.agent-detail-tab:hover{color:var(--text);background:var(--card-hover)}.agent-detail-tab.active{color:var(--todo);border-bottom-color:var(--todo)}.agent-detail-content{flex:1;overflow-y:auto;padding:24px}.agent-detail-footer{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-md) 24px;border-top:1px solid var(--border);background:var(--bg-secondary);font-size:12px;color:var(--text-muted)}.agent-detail-id{font-family:var(--font-mono);cursor:pointer}.agent-detail-id:hover{color:var(--text)}.dashboard-tab{display:flex;flex-direction:column;gap:24px}.dashboard-section{background:var(--bg-secondary);border-radius:var(--radius-md);padding:20px}.dashboard-section h3{font-size:14px;font-weight:600;margin:0 0 var(--space-lg) 0;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.info-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:var(--space-lg)}.info-item{display:flex;flex-direction:column;gap:4px}.info-label{font-size:12px;color:var(--text-muted)}.info-value{font-size:14px;font-weight:500}.inline-badge{display:inline-block;padding:2px var(--space-sm);border-radius:var(--radius-sm);font-size:12px;text-transform:capitalize}.stats-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--space-lg)}.stat-card{background:var(--surface);border-radius:var(--radius-md);padding:var(--space-lg);text-align:center}.stat-value{font-size:28px;font-weight:700;color:var(--todo)}.stat-label{font-size:12px;color:var(--text-muted);margin-top:4px}.current-task{display:flex;align-items:center;gap:var(--space-md)}.task-badge{font-family:var(--font-mono);background:var(--surface);padding:6px var(--space-md);border-radius:var(--radius-sm);font-size:14px}.metadata-json{background:var(--surface);padding:var(--space-md);border-radius:var(--radius-sm);font-size:12px;overflow-x:auto;margin:0}.logs-tab{display:flex;flex-direction:column;height:100%}.logs-header{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--space-md);margin-bottom:var(--space-md);border-bottom:1px solid var(--border)}.logs-count{font-size:12px;color:var(--text-muted)}.streaming-indicator{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--color-success)}.streaming-dot{width:8px;height:8px;background:var(--color-success);border-radius:50%;animation:pulse 1.5s infinite}.logs-container{flex:1;overflow-y:auto;font-family:var(--font-mono);font-size:13px;line-height:1.6;max-height:400px}.logs-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px;color:var(--text-muted);text-align:center}.logs-empty p{margin:var(--space-sm) 0 0 0}.log-entry{display:flex;gap:var(--space-sm);padding:4px var(--space-sm);margin:2px 0;border-radius:var(--radius-sm)}.log-timestamp{color:var(--text-muted);font-size:11px;flex-shrink:0}.log-agent{color:var(--text-muted);font-size:11px;font-weight:600;text-transform:uppercase;flex-shrink:0}.log-icon{flex-shrink:0}.log-text{word-break:break-word}.log-detail{color:var(--text-muted);font-size:12px}.runs-tab{display:flex;flex-direction:column;gap:var(--space-md)}.runs-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px;color:var(--text-muted);text-align:center}.runs-empty p{margin:var(--space-sm) 0 0 0}.run-card{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg)}.run-card--active{border-color:var(--in-progress);background:color-mix(in srgb,var(--in-progress) 5%,transparent)}.run-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--space-sm)}.run-live-indicator{display:flex;align-items:center;gap:6px;font-weight:600;color:var(--in-progress)}.live-dot{width:8px;height:8px;background:var(--in-progress);border-radius:50%;animation:pulse 1.5s infinite}.run-id{font-family:var(--font-mono);font-size:13px;color:var(--text-muted)}.run-status{display:flex;align-items:center;gap:6px;font-size:13px;text-transform:capitalize}.run-status.active{color:var(--in-progress)}.run-status.completed{color:var(--color-success)}.run-status.failed{color:var(--color-error)}.run-status.terminated{color:var(--text-muted)}.run-details{display:flex;gap:var(--space-sm);font-size:12px;color:var(--text-muted)}.agent-tasks-list{display:flex;flex-direction:column;gap:var(--space-sm)}.agent-task-item{display:flex;flex-direction:column;gap:6px;padding:12px 14px;border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-secondary);text-decoration:none;transition:background var(--transition-fast),border-color var(--transition-fast)}.agent-task-item:hover{background:var(--card-hover);border-color:var(--text-dim)}.agent-task-row{display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.agent-task-id{font-family:var(--font-mono);font-size:12px;font-weight:600;color:var(--todo)}.agent-task-title{font-size:14px;font-weight:500;color:var(--text);line-height:1.4}.agent-task-status{font-size:12px;color:var(--text-muted)}.agent-task-column{display:inline-flex;align-items:center;padding:2px 8px;border-radius:9999px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.4px}.agent-task-column.column-triage{color:var(--triage, #1f6feb);background:color-mix(in srgb,var(--triage, #1f6feb) 18%,transparent)}.agent-task-column.column-todo{color:var(--todo, #58a6ff);background:color-mix(in srgb,var(--todo, #58a6ff) 18%,transparent)}.agent-task-column.column-in-progress{color:var(--in-progress, #bc8cff);background:color-mix(in srgb,var(--in-progress, #bc8cff) 18%,transparent)}.agent-task-column.column-in-review{color:var(--in-review, #f2cc60);background:color-mix(in srgb,var(--in-review, #f2cc60) 18%,transparent)}.agent-task-column.column-done{color:var(--done, #3fb950);background:color-mix(in srgb,var(--done, #3fb950) 18%,transparent)}.agent-task-column.column-archived{color:var(--text-muted);background:color-mix(in srgb,var(--text-muted) 18%,transparent)}.agent-tasks-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:48px;color:var(--text-muted);text-align:center}.agent-tasks-empty p{margin:0}.config-tab{display:flex;flex-direction:column;gap:24px}.config-section{background:var(--bg-secondary);border-radius:var(--radius-md);padding:20px}.config-section h3{font-size:16px;font-weight:600;margin:0 0 var(--space-sm) 0}.config-section--danger{border:1px solid color-mix(in srgb,var(--color-error) 40%,transparent)}.config-danger-note{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted)}.agent-content-toolbar{display:flex;align-items:center;gap:var(--space-md);padding:var(--space-sm) var(--space-lg);border-bottom:1px solid var(--border);background:var(--surface);flex-shrink:0}.agent-content-mode-toggle{display:flex;align-items:center;gap:var(--space-xs)}.agent-content-mode-toggle .btn{display:inline-flex;align-items:center;gap:6px}.agent-content-preview{overflow-y:auto;padding:var(--space-lg);min-height:150px}.agent-content-placeholder{color:var(--text-muted);text-align:center;padding:var(--space-xl);min-height:150px;display:flex;align-items:center;justify-content:center}.config-description{font-size:14px;color:var(--text-muted);margin:0 0 20px}.config-fields{display:flex;flex-direction:column;gap:var(--space-lg)}.config-field{display:flex;flex-direction:column;gap:6px}.config-field label{font-size:13px;font-weight:500}.config-runtime-tabs{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-sm);margin-bottom:var(--space-md)}.config-runtime-tab{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--card);color:var(--text-muted);padding:var(--space-sm) var(--space-md);font-size:calc(var(--space-sm) + var(--space-xs));font-weight:600;cursor:pointer;transition:border-color var(--transition-fast),background var(--transition-fast),color var(--transition-fast),box-shadow var(--transition-fast)}.config-runtime-tab:hover{border-color:var(--todo);color:var(--text);background:var(--card-hover)}.config-runtime-tab:focus-visible{outline:none;border-color:var(--todo);box-shadow:var(--focus-ring-strong)}.config-runtime-tab.active{border-color:var(--todo);color:var(--text);background:color-mix(in srgb,var(--todo) 12%,transparent)}.config-hint{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted);font-style:italic}.config-error{font-size:11px;color:var(--color-error)}.input--error{border-color:var(--color-error)!important}.config-actions{display:flex;align-items:center;gap:var(--space-md);margin-top:20px;padding-top:var(--space-lg);border-top:1px solid var(--border)}.config-saved-indicator{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--color-success)}.rating-summary-card{background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:var(--radius-md);padding:20px;display:flex;flex-direction:column;gap:12px}.rating-score-display{display:flex;align-items:center;gap:12px}.rating-average{font-size:32px;font-weight:700;line-height:1}.rating-stats{display:flex;align-items:center;gap:12px}.rating-count{font-size:14px;color:var(--text-muted)}.rating-trend-badge{font-size:12px;padding:4px 10px;border-radius:12px;font-weight:500}.trend-improving{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.trend-declining{background:color-mix(in srgb,var(--color-error) 15%,transparent);color:var(--color-error)}.trend-stable{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.trend-insufficient{background:var(--bg-tertiary);color:var(--text-muted)}.category-breakdown{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg)}.category-breakdown h4{margin:0 0 var(--space-md) 0;font-size:.875rem;font-weight:600}.category-breakdown .category-item{display:flex;justify-content:space-between;align-items:center;padding:var(--space-sm) 0;border-bottom:1px solid var(--border)}.category-breakdown .category-item:last-child{border-bottom:none}.category-name{text-transform:capitalize;font-size:.875rem}.category-score{font-weight:600;font-size:.875rem}.add-rating-form{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md)}.add-rating-form h4{margin:0;font-size:.875rem;font-weight:600}.star-selector{display:flex;gap:var(--space-xs)}.star-btn{background:none;border:none;padding:var(--space-xs);cursor:pointer;border-radius:var(--radius-sm);color:var(--text-muted);transition:background-color var(--transition-fast),color var(--transition-fast)}.star-btn:hover{background:var(--card-hover)}.star-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.rating-stars{display:inline-flex;gap:var(--space-xs)}.rating-stars .star-filled{color:var(--color-warning)}.rating-stars .star-empty{color:var(--text-muted)}.add-rating-form .add-rating-category-select,.add-rating-form .add-rating-comment-input{width:100%}.add-rating-form .add-rating-comment-input{resize:vertical;min-height:calc(var(--space-xl) + var(--space-2xl))}.rating-history{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg);max-height:calc(var(--space-xl) * 12 + var(--space-md));overflow-y:auto}.rating-history h4{margin:0 0 var(--space-md) 0;font-size:.875rem;font-weight:600}.rating-history .no-ratings{color:var(--text-muted);font-size:.875rem;text-align:center;padding:var(--space-lg)}.rating-history-item{padding:var(--space-md) 0;border-bottom:1px solid var(--border)}.rating-history-item:last-child{border-bottom:none}.rating-item-header{display:flex;align-items:center;gap:var(--space-sm);flex-wrap:wrap}.rating-category-badge{font-size:.75rem;padding:calc(var(--space-xs) * .5) var(--space-sm);background:var(--card-hover);border-radius:var(--radius-pill);text-transform:capitalize}.rating-time{font-size:.75rem;color:var(--text-muted);margin-left:auto}.rating-delete-btn{background:none;border:none;padding:var(--space-xs);cursor:pointer;color:var(--text-muted);border-radius:var(--radius-sm);transition:color var(--transition-fast),background-color var(--transition-fast)}.rating-delete-btn:hover{color:var(--color-error);background:color-mix(in srgb,var(--color-error) 10%,transparent)}.rating-comment{margin:var(--space-sm) 0 0 0;font-size:.8125rem;color:var(--text-secondary);line-height:1.4}@media(max-width:768px){.config-runtime-tabs{grid-template-columns:1fr}.agent-detail-overlay{padding:0;align-items:stretch}.agent-detail-modal{min-width:0!important;min-height:0!important;width:100vw!important;height:100vh!important;height:100dvh!important;max-width:100vw!important;max-height:100vh;max-height:100dvh;margin:0;border-radius:0;border:none;resize:none}.agent-detail-header{flex-wrap:wrap;gap:var(--space-sm);padding:12px;padding-top:max(12px,env(safe-area-inset-top,0))}.agent-detail-identity{flex:1 1 auto;min-width:0;gap:var(--space-sm)}.agent-detail-icon{width:32px;height:32px;flex-shrink:0}.agent-detail-icon svg{width:16px;height:16px}.agent-detail-info h2{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-detail-badges{flex-wrap:wrap}.agent-detail-controls{flex:1 1 100%;flex-wrap:wrap;gap:6px;order:3}.agent-detail-controls .btn--compact{padding:6px 10px;font-size:12px;min-height:36px}.agent-detail-controls .btn--compact svg{width:14px;height:14px}.agent-detail-utility-actions{flex-shrink:0}.agent-detail-utility-actions .btn-icon{min-height:36px;min-width:36px}.agent-detail-title{flex:1 1 auto;min-width:0;gap:var(--space-md)}.agent-detail-actions{flex:1 1 100%;flex-wrap:wrap;gap:6px}.agent-detail-actions .btn{padding:6px 10px;font-size:13px;min-height:36px}.agent-detail-actions .btn svg{width:14px;height:14px}.agent-detail-actions .btn-icon{min-height:36px;min-width:36px}.agent-detail-tabs{padding:0;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}.agent-detail-tabs::-webkit-scrollbar{display:none}.agent-detail-tab{padding:12px 14px;font-size:13px;white-space:nowrap;min-height:36px}.agent-detail-content{padding:16px}.agent-detail-footer{flex-wrap:wrap;gap:var(--space-sm);padding:var(--space-sm) 16px;padding-bottom:max(var(--space-sm),env(safe-area-inset-bottom,0));font-size:11px}.agent-detail-id{max-width:140px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dashboard-tab{gap:16px}.dashboard-section{padding:16px}.info-grid{grid-template-columns:repeat(2,1fr);gap:var(--space-md)}.stats-grid{grid-template-columns:repeat(3,1fr);gap:var(--space-md)}.stat-value{font-size:22px}.logs-container{max-height:50vh}.logs-empty{padding:32px 16px}.log-entry{padding:4px 2px;font-size:12px}.log-text{min-width:0;overflow-wrap:anywhere}.run-card{padding:var(--space-md)}.run-header{flex-wrap:wrap;gap:6px}.run-details{flex-wrap:wrap}.run-details .text-muted{min-width:0;overflow-wrap:anywhere}.config-tab{gap:16px}.config-section{padding:16px}.config-section .input,.config-section .select,.config-section textarea{font-size:16px;min-height:36px}.config-actions{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.config-actions .btn{width:100%;justify-content:center}}@media(max-width:480px){.info-grid,.stats-grid{grid-template-columns:1fr}.agent-detail-actions{flex-direction:column;width:100%}.agent-detail-actions .btn{width:100%;justify-content:center}.agent-detail-actions .btn-icon{align-self:flex-end}.agent-detail-footer .divider,.agent-detail-footer .text-muted,.agent-detail-footer .link{display:none}}@media(max-width:768px){.agent-dialog-overlay{padding:0;align-items:stretch}.agent-dialog{width:100vw!important;height:100vh;height:100dvh;max-width:100%!important;max-height:100vh;max-height:100dvh;border-radius:0;border:none}.agent-dialog-header{padding:max(var(--space-md),env(safe-area-inset-top,0px)) var(--space-lg) var(--space-md) var(--space-lg);flex-shrink:0}.agent-dialog-body{padding:var(--space-lg);-webkit-overflow-scrolling:touch}.agent-dialog-footer{padding:var(--space-md) var(--space-lg);padding-bottom:max(var(--space-md),env(safe-area-inset-bottom,0px));flex-wrap:wrap;gap:var(--space-sm)}.agent-dialog-field .input,.agent-dialog-field .select,.agent-dialog-field textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-lg) * 2 + var(--space-xs))}.agent-dialog-summary-row{flex-direction:column;gap:calc(var(--space-xs) * .5)}.agent-dialog-summary-row>span:first-child,.agent-dialog-summary-row-label{width:auto}.agent-dialog-steps{padding:var(--space-sm) var(--space-lg)}.agent-dialog-step{flex:1;width:auto;height:calc(var(--space-xs) - var(--space-xs) * .25)}.agent-dialog-tabs{grid-template-columns:1fr;gap:calc(var(--space-sm) - var(--space-xs) * .5);margin-bottom:var(--space-md)}.agent-dialog-tab{min-height:calc(var(--space-lg) * 2 + var(--space-xs));text-align:left}.agent-import-file-upload{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.agent-import-textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-xl) * 4 + var(--space-xs))}.agent-import-agent-list{max-height:calc(100dvh - (var(--space-xl) * 10 + var(--space-lg)))}.agent-import-result-stats{flex-direction:column;gap:var(--space-sm);align-items:center}.agent-import-browse-list{max-height:calc(100dvh - (var(--space-xl) * 10 + var(--space-lg)))}.agent-import-skill-list{max-height:calc(100dvh - (var(--space-xl) * 15 + var(--space-md)))}}@media(max-width:480px){.agent-dialog-body{padding:var(--space-md)}.agent-dialog-footer{flex-direction:column}.agent-dialog-footer .btn{width:100%;justify-content:center}}.reflections-tab{padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-lg)}.reflections-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-md)}.reflections-header h3{display:flex;align-items:center;gap:var(--space-sm);font-size:1rem;font-weight:600;color:var(--text)}.reflections-stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:var(--space-md)}.reflections-stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md);text-align:center}.reflections-stat-card .stat-value{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);font-size:1.5rem;font-weight:700;color:var(--text);margin-bottom:var(--space-xs)}.reflections-stat-card .stat-label{font-size:.75rem;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em}.reflections-no-data{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-xl);color:var(--text-secondary);text-align:center}.reflections-list{display:flex;flex-direction:column;gap:var(--space-md)}.reflections-loading-indicator{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-lg)}.reflections-ratings-section{display:flex;flex-direction:column;gap:var(--space-md)}.reflections-ratings-section>h4,.reflections-list h4{font-size:.875rem;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.reflection-cards{display:flex;flex-direction:column;gap:var(--space-sm)}.reflection-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md);cursor:pointer;transition:border-color .15s,background-color .15s}.reflection-card:hover{border-color:var(--border-active);background:var(--card-hover)}.reflection-card:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.reflection-card--expanded{border-color:var(--color-primary)}.reflection-card-header{display:flex;align-items:center;gap:var(--space-sm);margin-bottom:var(--space-sm)}.reflection-trigger-badge{font-size:.7rem;font-weight:600;padding:2px 6px;border-radius:var(--radius-sm);text-transform:uppercase;letter-spacing:.05em}.reflection-trigger-periodic{background:color-mix(in srgb,var(--color-info) 15%,transparent);color:var(--color-info)}.reflection-trigger-post-task{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.reflection-trigger-manual{background:color-mix(in srgb,var(--color-primary) 15%,transparent);color:var(--color-primary)}.reflection-trigger-user-requested{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.reflection-timestamp{font-size:.75rem;color:var(--text-muted);flex:1}.reflection-chevron{color:var(--text-muted)}.reflection-summary{font-size:.875rem;color:var(--text);line-height:1.5}.reflection-details{margin-top:var(--space-md);padding-top:var(--space-md);border-top:1px solid var(--border);display:flex;flex-direction:column;gap:var(--space-md)}.reflection-insights h5,.reflection-suggestions h5{display:flex;align-items:center;gap:var(--space-xs);font-size:.8rem;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.reflection-insights ul,.reflection-suggestions ul{list-style:none;display:flex;flex-direction:column;gap:var(--space-xs)}.reflection-insights li,.reflection-suggestions li{font-size:.8rem;color:var(--text-secondary);padding-left:var(--space-md);position:relative}.reflection-insights li:before{content:"•";position:absolute;left:4px;color:var(--color-success)}.reflection-suggestions li:before{content:"→";position:absolute;left:0;color:var(--color-primary)}.reflection-metrics{background:var(--bg);border-radius:var(--radius-sm);padding:var(--space-sm)}.reflection-metrics h5{font-size:.75rem;font-weight:600;color:var(--text-muted);margin-bottom:var(--space-xs)}.metrics-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:var(--space-sm)}.metric{display:flex;flex-direction:column;gap:2px}.metric-label{font-size:.7rem;color:var(--text-muted)}.metric-value{font-size:.875rem;font-weight:600;color:var(--text)}.reflection-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-2xl);color:var(--text-secondary);text-align:center}.reflection-empty p{font-size:.875rem}@media(max-width:768px){.reflections-header{flex-wrap:wrap;align-items:flex-start}.reflections-header .btn{width:100%;justify-content:center}}.budget-progress-container{margin-top:4px}.budget-progress-bar{width:100%;height:8px;background:var(--bg-secondary, #161b22);border-radius:4px;overflow:hidden;margin-top:4px}.budget-progress-bar__fill{height:100%;border-radius:4px;transition:width .3s ease,background-color .3s ease}.budget-progress-bar__fill--green{background:var(--state-active-text, #3fb950)}.budget-progress-bar__fill--amber{background:var(--state-paused-text, #e3b541)}.budget-progress-bar__fill--red{background:var(--state-error-text, #f85149)}.budget-progress-label{font-size:.75rem;color:var(--text-secondary, #8b949e);margin-top:4px;display:block}.budget-badge{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:12px;font-size:.75rem;font-weight:500}.budget-warning-banner{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;background:var(--state-error-bg, rgba(248,81,73,.15));color:var(--state-error-text, #f85149);border:1px solid var(--state-error-border, #f85149);font-size:.875rem;margin-bottom:12px}.btn-reset-budget{margin-top:8px}.chat-sidebar-footer{display:none}@media(max-width:768px){.chat-view{flex-direction:column}.chat-sidebar{width:100%;min-width:100%;height:100%;max-height:none;border-right:none;border-bottom:1px solid var(--border);flex-direction:column}.chat-sidebar-header,.chat-sidebar-search{display:none}.chat-sidebar-list{flex:1;min-height:0;overflow-y:auto}.chat-sidebar-footer{display:flex;padding:var(--space-md);border-top:1px solid var(--border);background:var(--bg-secondary)}.chat-sidebar-footer-btn{flex:1;justify-content:center}.chat-sidebar--hidden{display:none}.chat-message{max-width:90%}.chat-new-dialog{width:95vw;margin:16px}.chat-thread-header{padding:8px 12px}.chat-skill-menu{left:var(--space-md);right:calc(var(--space-md) + var(--mobile-nav-height));min-width:0;max-width:none}}@media(max-width:768px){.file-mention-popup{max-height:200px}.file-mention-popup-item{min-height:36px;padding:10px 12px}.agent-mention-popup{max-width:280px;min-width:200px}}
|