agi-farm 1.0.2 → 1.1.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.
Files changed (45) hide show
  1. package/README.md +139 -56
  2. package/dashboard-dist/assets/Agents-BGp0VBL6.js +1 -0
  3. package/dashboard-dist/assets/Alerts-ChDOowdj.js +1 -0
  4. package/dashboard-dist/assets/Approvals-wArbqSa0.js +1 -0
  5. package/dashboard-dist/assets/Broadcast-CMCcYnIx.js +2 -0
  6. package/dashboard-dist/assets/Budget-D8f3izqR.js +1 -0
  7. package/dashboard-dist/assets/Comms-zQvLg7tX.js +4 -0
  8. package/dashboard-dist/assets/Crons-BzbHl0I3.js +1 -0
  9. package/dashboard-dist/assets/HITL-CwEsd-qm.js +1 -0
  10. package/dashboard-dist/assets/Jobs-CV2HnDQL.js +1 -0
  11. package/dashboard-dist/assets/Knowledge-C0I0KvXG.js +1 -0
  12. package/dashboard-dist/assets/LastUpdated-BVeFtHFH.js +1 -0
  13. package/dashboard-dist/assets/OKRs-BFjYFYsj.js +1 -0
  14. package/dashboard-dist/assets/Overview-OVGZf4_H.js +2 -0
  15. package/dashboard-dist/assets/Projects-BBOHTOLq.js +2 -0
  16. package/dashboard-dist/assets/RD-DRBHxZUS.js +1 -0
  17. package/dashboard-dist/assets/Tasks-CM3yheWF.js +1 -0
  18. package/dashboard-dist/assets/Usage-MqbkYIgO.js +1 -0
  19. package/dashboard-dist/assets/Velocity-C1jcs0W8.js +1 -0
  20. package/dashboard-dist/assets/charts-BhPBsBGB.js +36 -0
  21. package/dashboard-dist/assets/index-BFnAHHHY.js +2 -0
  22. package/dashboard-dist/assets/{index-CAS2IEKB.css → index-DaVmOqH2.css} +1 -1
  23. package/dashboard-dist/assets/vendor-5MxLWm27.js +9 -0
  24. package/dashboard-dist/index.html +5 -3
  25. package/dist/index.d.ts +93 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +180 -0
  28. package/dist/index.js.map +1 -0
  29. package/openclaw.plugin.json +65 -2
  30. package/package.json +8 -3
  31. package/scripts/dispatch.js +12 -0
  32. package/server/dashboard.js +331 -86
  33. package/server/services/audit.js +17 -0
  34. package/server/services/feature-flags.js +14 -0
  35. package/server/services/jobs.js +226 -0
  36. package/server/services/memory.js +66 -0
  37. package/server/services/metering.js +62 -0
  38. package/server/services/policy.js +124 -0
  39. package/server/services/secrets.js +66 -0
  40. package/server/services/skills.js +72 -0
  41. package/server/services/storage.js +43 -0
  42. package/server/services/worker.js +212 -0
  43. package/server/updater.js +154 -0
  44. package/server/utils.js +125 -0
  45. package/dashboard-dist/assets/index-eLocZsGk.js +0 -50
package/README.md CHANGED
@@ -29,21 +29,40 @@
29
29
  | 🔄 **Auto-Dispatcher** | Smart task delegation with HITL, backoff & dependencies |
30
30
  | 📦 **Portable Bundle** | Export your entire team to GitHub with one command |
31
31
  | 🏗️ **ESM Native** | Built for Node 20+ with full ES Module support |
32
- | 🛡️ **Production Hardened** | Security-audited with CSRF, Origin validation, and timing-safe auth |
33
- | 🧪 **28 Unit Tests** | Extension lifecycle, security, parsing, and CLI utilities verified with Jest/ESM |
32
+ | 🛡️ **Production Hardened** | Security-audited with CSRF, Origin validation, CSP headers, and timing-safe auth |
33
+ | 🔄 **Auto-Update** | Detects new releases on GitHub with one-click install from the dashboard |
34
+ | ⚙️ **Feature-Flagged Runtime** | Optional jobs, skills, memory, policy, approvals, and metering modules |
35
+ | 🧪 **103 Automated Tests** | Unit + integration + API smoke coverage with Jest/ESM |
34
36
 
35
37
  ---
36
38
 
37
- ## 🆕 Recent Updates
38
-
39
- - 🔐 **Origin validation**: mutation endpoints now validate `Origin` header — only localhost origins accepted.
40
- - 🔒 **Timing-safe auth hardened**: CSRF token comparison no longer leaks token length via timing.
41
- - 🧪 **28 unit tests**: added extension lifecycle, security, and shared utility test suites (was 6).
42
- - 📦 **Removed unused `sse.js`**: dependency cleaned from `package.json`.
43
- - 🔄 **Dynamic versioning**: extension reads version from `package.json` instead of hardcoding.
44
- - 🛠️ **ESM `__dirname` fix**: `src/index.ts` now uses `import.meta.dirname` with proper fallback.
45
- - 🧰 **Shared utilities**: extracted `runCommand` to `scripts/lib/run-command.js` eliminates duplication.
46
- - **Env var consistency**: `export.js` and `status.js` now respect `AGI_FARM_WORKSPACE` like all other scripts.
39
+ ## 🆕 What's New in v1.1.0
40
+
41
+ ### Auto-Update System
42
+ - 🔄 **GitHub release detection**: plugin polls GitHub Releases API (6-hour cache) to detect new versions
43
+ - 📢 **Dashboard update banner**: amber notification bar shows current latest version with release notes link
44
+ - **One-click install**: "Update Now" button runs `npm install -g agi-farm@latest` directly from the dashboard
45
+ - ⚙️ **Configurable**: `autoCheckUpdates` option in plugin config (default: `true`)
46
+
47
+ ### Feature-Flagged Core Runtime
48
+ - 🚀 **Core runtime added**: jobs, background worker, skills, memory index, policy gates, approvals, audit log, and usage metering
49
+ - 🧭 **New dashboard tabs**: Jobs, Approvals, Usage, Processes, Failures, Decisions, Memory
50
+ - 🔌 **New REST APIs**: `/api/jobs`, `/api/skills`, `/api/memory/search`, `/api/policies`, `/api/approvals`, `/api/usage`
51
+ - 🧪 **API integration smoke tests**: dashboard server tested end-to-end
52
+
53
+ ### Interactive Dashboard
54
+ - ➕ **Task Creation** — create tasks directly from the Tasks tab with assignee, priority, and dependencies
55
+ - 💬 **Agent Messaging** — send messages to individual agents from their cards
56
+ - 📝 **Broadcast Compose** — post team-wide announcements from the Broadcast tab
57
+ - 📚 **Knowledge CRUD** — add and remove knowledge entries from the dashboard
58
+ - 🔍 **Search & Sort** — filter tasks and agents with real-time search; sortable task columns
59
+
60
+ ### Security & Infrastructure
61
+ - 🔐 **CSRF + Origin hardening**: same-origin validation, timing-safe auth, CSP headers
62
+ - 🛡️ **Input validation**: `isSafeId()`, `sanitizeNote()`, path traversal protection
63
+ - 🧪 **103 automated tests** — unit, integration, API, updater, data extraction
64
+ - 🔔 **Toast notifications** — non-blocking success/error toasts for all actions
65
+ - 🛡️ **Atomic file writes** — `.tmp` → `rename` pattern with in-memory file locks
47
66
 
48
67
  ---
49
68
 
@@ -51,22 +70,26 @@
51
70
 
52
71
  ### Dashboard Overview
53
72
  ```
54
- ┌─────────────────────────────────────────────────────────────────┐
55
- │ 🦅 AGI Farm Dashboard Budget: $45.23/100 [LIVE]
56
- ├─────────────────────────────────────────────────────────────────┤
57
-
58
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
59
- 📊 42 38 4 🚨 2
60
- │ │ Tasks │ │ Done │ │ Active │ │ SLA Risk │ │
61
- └──────────┘ └──────────┘ └──────────┘ └──────────┘
62
-
63
- ┌─────────────────────────────────────────────────────────┐
64
- │ │ 🔮 Sage ✅ Ready 📨 3 msgs ⭐ 94% quality │ │
65
- │ ⚒️ Forge 🔄 Busy 📨 7 msgs ⭐ 89% quality
66
- 🐛 Pixel ✅ Ready 📨 2 msgs ⭐ 96% quality │ │
67
- └─────────────────────────────────────────────────────────┘
68
-
69
- └─────────────────────────────────────────────────────────────────┘
73
+ ┌──────────────────────────────────────────────────────────────────────┐
74
+ │ 🦅 AGI Ops Room ● LIVE Online: 8/11 Pending: 4 Budget: $45 │
75
+ ├──────────────────────────────────────────────────────────────────────┤
76
+ 🔄 Update available: v1.0.2 → v1.1.0 [Release Notes] [Update Now]
77
+ ├──────────────────────────────────────────────────────────────────────┤
78
+ Overview Agents Tasks Projects Crons HITLAlerts ...
79
+ ├──────────────────────────────────────────────────────────────────────┤
80
+
81
+ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
82
+ │ │ 📊 42 │ │ ✅ 38 │ │ ⏳ 4 │ │ 🚨 2 │ │
83
+ │ │ Tasks │ │ Done │ Active │ HITL │ │
84
+ └──────────┘ └──────────┘ └──────────┘ └──────────┘
85
+
86
+ ┌───────────────────────────────────────────────────────────┐
87
+ 🔮 Sage ✅ Ready 📨 3 msgs ⭐ 94% [Send Message] │ │
88
+ │ │ ⚒️ Forge 🔄 Busy 📨 7 msgs ⭐ 89% [Send Message] │ │
89
+ │ │ 🐛 Pixel ✅ Ready 📨 2 msgs ⭐ 96% [Send Message] │ │
90
+ │ └───────────────────────────────────────────────────────────┘ │
91
+ │ │
92
+ └──────────────────────────────────────────────────────────────────────┘
70
93
  ```
71
94
 
72
95
  ### Team Architecture
@@ -138,15 +161,15 @@ Answer the setup prompts and your team will be live in ~2 minutes:
138
161
 
139
162
  ## 📦 Commands
140
163
 
141
- | Command | Description | Example |
142
- |---------|-------------|---------|
143
- | 🎯 `agi-farm setup` | Full wizard — agents, workspace, crons | Sets up complete team |
144
- | 🗑️ `agi-farm teardown` | Full uninstall — removes agents, bundle, and AGI Farm-owned registries (`TASKS.json`, `AGENT_STATUS.json`) | Reverts system to clean state |
145
- | 📊 `agi-farm status` | Team health: agents, tasks, cron status | Shows real-time metrics |
146
- | 🔧 `agi-farm rebuild` | Regenerate workspace from bundle | After git pull |
147
- | 📤 `agi-farm export` | Push bundle to GitHub | Creates new release |
148
- | 🖥️ `agi-farm dashboard` | Launch live ops room (SSE, :8080) | Opens in browser |
149
- | ⚡ `agi-farm dispatch` | Run auto-dispatcher manually | Test task routing |
164
+ | Command | CLI Shortcut | Description |
165
+ |---------|-------------|-------------|
166
+ | 🎯 `agi-farm setup` | `agi-farm` | Full wizard — agents, workspace, crons |
167
+ | 🗑️ `agi-farm teardown` | `agi-farm-teardown` | Full uninstall — removes agents, bundle, and registries |
168
+ | 📊 `agi-farm status` | `agi-farm-status` | Team health: agents, tasks, cron status |
169
+ | 🔧 `agi-farm rebuild` | `agi-farm-rebuild` | Regenerate workspace from bundle |
170
+ | 📤 `agi-farm export` | `agi-farm-export` | Push bundle to GitHub |
171
+ | 🖥️ `agi-farm dashboard` | `agi-farm-dashboard` | Launch live ops room (SSE, :8080) |
172
+ | ⚡ `agi-farm dispatch` | `agi-farm-dispatch` | Run auto-dispatcher manually |
150
173
 
151
174
  ---
152
175
 
@@ -161,7 +184,8 @@ Answer the setup prompts and your team will be live in ~2 minutes:
161
184
  ├── 📂 dist/ Compiled TypeScript (backend)
162
185
  ├── 📂 dashboard-dist/ Built React frontend (production)
163
186
  ├── 🌐 server/
164
- │ ├── 🖥️ dashboard.js SSE server (Node.js)
187
+ │ ├── 🖥️ dashboard.js SSE server + CRUD API (Node.js)
188
+ │ ├── 🔄 updater.js GitHub release checker + auto-update
165
189
  │ └── 🛠️ utils.js Core parsing & logic (Unit Tested)
166
190
  ├── 📜 scripts/
167
191
  │ ├── 🎯 setup.js Setup wizard
@@ -202,13 +226,13 @@ Answer the setup prompts and your team will be live in ~2 minutes:
202
226
  │ │ SlowDataCache │ │ Broadcaster │ │
203
227
  │ │ (30s cache) │───▶│ (SSE fan-out) │ │
204
228
  │ └─────────────────────┘ └──────────────────┘ │
205
- │ │
206
- │ SSE stream │
207
- ▼ │
208
- ┌──────────────────┐ │
209
- │ React Frontend │ │
210
- │ (Vite + Recharts)│ │
211
- └──────────────────┘ │
229
+
230
+ ┌─────────────────────┐ │ SSE stream │
231
+ │ UpdateChecker │ ▼ │
232
+ │ (6h GitHub cache) │ ┌──────────────────┐ │
233
+ └─────────────────────┘ │ React Frontend │ │
234
+ │ (Vite + Recharts)│ │
235
+ └──────────────────┘ │
212
236
  │ │
213
237
  └──────────────────────────────────────────────────────────────┘
214
238
  ```
@@ -324,8 +348,15 @@ Configure AGI Farm in your `openclaw.json`:
324
348
  "dashboardPort": 8080,
325
349
  "dashboardHost": "127.0.0.1",
326
350
  "autoStartDashboard": true,
351
+ "autoCheckUpdates": true,
327
352
  "workspacePath": "~/.openclaw/workspace",
328
- "bundlePath": "~/.openclaw/workspace/agi-farm-bundle"
353
+ "bundlePath": "~/.openclaw/workspace/agi-farm-bundle",
354
+ "featureJobs": false,
355
+ "featureSkills": false,
356
+ "featureMemory": false,
357
+ "featurePolicy": false,
358
+ "featureMetering": false,
359
+ "featureApprovals": false
329
360
  }
330
361
  }
331
362
  }
@@ -340,8 +371,29 @@ Configure AGI Farm in your `openclaw.json`:
340
371
  | `dashboardPort` | number | 8080 | Port for live ops dashboard |
341
372
  | `dashboardHost` | string | "127.0.0.1" | Bind address for dashboard |
342
373
  | `autoStartDashboard` | boolean | true | Auto-start dashboard on load |
374
+ | `autoCheckUpdates` | boolean | true | Check GitHub for new releases on startup |
343
375
  | `workspacePath` | string | ~/.openclaw/workspace | Path to OpenClaw workspace |
344
376
  | `bundlePath` | string | <workspace>/agi-farm-bundle | Path to bundle directory |
377
+ | `featureJobs` | boolean | false | Enable jobs runtime APIs + background worker |
378
+ | `featureSkills` | boolean | false | Enable skills registry and routing endpoints |
379
+ | `featureMemory` | boolean | false | Enable memory indexing + search endpoint |
380
+ | `featurePolicy` | boolean | false | Enable policy evaluation on runtime/mutation actions |
381
+ | `featureMetering` | boolean | false | Enable usage metering collection + API |
382
+ | `featureApprovals` | boolean | false | Enable approval workflows for policy-gated actions |
383
+
384
+ ### Runtime Files Added By Core Modules
385
+
386
+ When feature flags are enabled, AGI Farm lazily creates these additive workspace files:
387
+
388
+ - `JOBS.json`
389
+ - `JOB_RUNS.jsonl`
390
+ - `SKILLS_REGISTRY.json`
391
+ - `MEMORY_INDEX.json`
392
+ - `POLICIES.json`
393
+ - `APPROVALS.json`
394
+ - `AUDIT_LOG.jsonl`
395
+ - `USAGE_METERING.json`
396
+ - `SECRETS/` (encrypted blobs + metadata)
345
397
 
346
398
  ---
347
399
 
@@ -364,15 +416,38 @@ All data updates in real-time from workspace files:
364
416
  | 📚 Knowledge | `SHARED_KNOWLEDGE.json` | Instant | ~50ms |
365
417
  | 🧠 Memory | `MEMORY.md` | Instant | ~50ms |
366
418
  | 🔄 Agent Models | `openclaw agents list` | Cached | ~30s |
419
+ | 🗂️ Jobs | `JOBS.json` | Instant | ~50ms |
420
+ | ✅ Approvals | `APPROVALS.json` | Instant | ~50ms |
421
+ | 📊 Usage | `USAGE_METERING.json` | Instant | ~50ms |
367
422
 
368
423
  ### Interactive Actions (API)
369
424
 
370
- The dashboard enables direct control over team operations via the following REST endpoints:
425
+ The dashboard enables direct control over team operations via authenticated REST endpoints (all require CSRF token):
371
426
 
427
+ **HITL & Cron Controls:**
372
428
  - `POST /api/hitl/:id/approve` — Continue task with optional notes
373
429
  - `POST /api/hitl/:id/reject` — Block task and notify agent
374
430
  - `POST /api/cron/:id/trigger` — Manually run a specific cron job
375
431
  - `POST /api/cron/:id/toggle` — Enable or disable a cron job
432
+ - `POST /api/jobs` — Create a background job from high-level intent
433
+ - `GET /api/jobs` / `GET /api/jobs/:id` — List and inspect jobs
434
+ - `POST /api/jobs/:id/cancel` / `POST /api/jobs/:id/retry` — Control failed/running jobs
435
+ - `GET /api/skills` + `POST /api/skills/:id/(enable|disable)` — Manage skill activation
436
+ - `GET /api/memory/search?q=&tags=` — Search memory index
437
+ - `GET /api/policies` — Retrieve active policy rules
438
+ - `GET /api/approvals` + `POST /api/approvals/:id/(approve|reject)` — Human approval queue
439
+ - `GET /api/usage` — Usage and cost aggregates for dashboard
440
+
441
+ **CRUD Operations:**
442
+ - `POST /api/task` — Create a new task with assignee, priority, dependencies
443
+ - `POST /api/agent/:id/message` — Send a message to a specific agent
444
+ - `POST /api/broadcast` — Post a team-wide broadcast message
445
+ - `POST /api/knowledge` — Add a shared knowledge entry
446
+ - `DELETE /api/knowledge/:id` — Remove a knowledge entry
447
+
448
+ **Auto-Update:**
449
+ - `GET /api/update-check` — Force a fresh GitHub release check
450
+ - `POST /api/update-install` — Install latest version via npm
376
451
 
377
452
  **Total push latency:** ~350ms from file change to browser update
378
453
 
@@ -491,15 +566,23 @@ npm run start-dashboard
491
566
 
492
567
  ## 🔒 Security
493
568
 
494
- This plugin is designed with security in mind:
495
-
496
- | What It Does | What It Doesn't Do |
497
- |----------------|----------------------|
498
- | Binds dashboard to `127.0.0.1` only | Expose data to the network |
499
- | Validates `Origin` header on all mutations | Accept cross-origin requests |
500
- | Uses CSRF tokens with timing-safe comparison | Leak token length via timing |
501
- | Uses OpenClaw CLI (inherits credentials) | Store API keys or tokens |
502
- | Reads/writes local workspace files | Send data to external servers |
569
+ This plugin is designed with defense-in-depth security:
570
+
571
+ | Layer | Protection |
572
+ |-------|-----------|
573
+ | **Network** | Dashboard binds to `127.0.0.1` only not exposed to LAN or internet |
574
+ | **Origin validation** | `/api/session` gated by Origin/Referer cross-origin token theft blocked |
575
+ | **CSRF tokens** | All mutation endpoints require timing-safe CSRF token comparison |
576
+ | **SSE authentication** | `/api/stream` and `/api/data` require CSRF token prevents cross-origin data exfiltration |
577
+ | **Security headers** | CSP, X-Frame-Options (DENY), X-Content-Type-Options, Referrer-Policy |
578
+ | **Input validation** | Agent IDs validated via `isSafeId()` regex — blocks path traversal |
579
+ | **Note sanitization** | HITL notes stripped of control chars; CLI flag injection prevented |
580
+ | **Rate limiting** | 120 req/min (read), 30 req/min (mutations) per IP |
581
+ | **File locking** | Cron file writes use mutex to prevent concurrent corruption |
582
+ | **Atomic writes** | All file mutations use `.tmp` → `rename` pattern with in-memory locks |
583
+ | **Shell injection** | Update installer uses `execFile` (not `exec`) to prevent injection |
584
+ | **Credential isolation** | Uses OpenClaw CLI — no API keys stored in plugin |
585
+ | Supports encrypted secrets (`SECRETS/`, AES-256-GCM) | Expose secret values in API responses |
503
586
 
504
587
  **Your credentials stay in OpenClaw's configuration.**
505
588
 
@@ -0,0 +1 @@
1
+ import{r as p,a4 as e}from"./vendor-5MxLWm27.js";import{a as f}from"./index-BFnAHHHY.js";import{L as h}from"./LastUpdated-BVeFtHFH.js";function S({data:s,lastUpdated:r,toast:d}){const{agents:c=[],cache_age_seconds:i}=s,l=i??null,[o,g]=p.useState(""),m=c.filter(t=>{if(!o)return!0;const a=o.toLowerCase();return(t.name||"").toLowerCase().includes(a)||(t.id||"").toLowerCase().includes(a)||(t.role||"").toLowerCase().includes(a)});return e.jsxs("div",{className:"fade-in",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:12,gap:12,flexWrap:"wrap"},children:[e.jsx("input",{className:"input-base",placeholder:"Search agents...",value:o,onChange:t=>g(t.target.value),style:{flex:"0 1 200px"}}),e.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:[m.length," agent",m.length!==1?"s":""]}),l!=null&&e.jsxs("span",{style:{fontSize:10,color:l>25?"var(--amber)":"var(--muted)"},children:["🔄 cached ",l,"s ago"]}),e.jsx(h,{ts:r})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(280px,1fr))",gap:14},children:m.map(t=>e.jsx(v,{agent:t,toast:d},t.id))})]})}function v({agent:s,toast:r}){const[d,c]=p.useState(!1),[i,l]=p.useState(""),[o,g]=p.useState(!1),m={active:"dot-active",available:"dot-available",busy:"dot-busy",error:"dot-error"}[s.status]||"dot-offline",t={active:"badge-active",available:"badge-available",busy:"badge-busy",error:"badge-error"}[s.status]||"badge-offline",a=s.credibility??1,u=async()=>{if(i.trim()){g(!0);try{await f(`/api/comms/${s.id}/send`,{message:i.trim()}),r(`Message sent to ${s.name}`,"success"),l(""),c(!1)}catch(n){r(n.message,"error")}g(!1)}};return e.jsxs("div",{className:"card",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:28},children:s.emoji||"🤖"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:700,fontSize:15},children:s.name}),e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:s.role})]}),e.jsxs("div",{style:{textAlign:"right"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,justifyContent:"flex-end"},children:[e.jsx("span",{className:`dot ${m}`}),e.jsx("span",{className:`badge ${t}`,children:s.status})]}),s.inbox_count>0&&e.jsxs("div",{style:{fontSize:11,color:"var(--amber)",marginTop:4},children:["📬 ",s.inbox_count," msgs"]})]})]}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",marginBottom:10,fontFamily:"monospace"},children:s.model||"—"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8,marginBottom:10},children:[e.jsx(x,{label:"Done",value:s.tasks_completed??0}),e.jsx(x,{label:"Failed",value:s.tasks_failed??0,color:"var(--red)"}),e.jsx(x,{label:"Quality",value:`⭐${(s.quality_score||0).toFixed(1)}`,color:"var(--amber)"})]}),e.jsxs("div",{style:{fontSize:9,color:"var(--muted)",marginBottom:10,display:"flex",justifyContent:"space-between"},children:[e.jsxs("span",{children:["Heartbeat: ",s.heartbeat_age_minutes!=null?`${s.heartbeat_age_minutes}m ago`:"offline"]}),e.jsxs("span",{children:["ID: ",s.id]})]}),e.jsxs("div",{style:{marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--muted)",marginBottom:4},children:[e.jsx("span",{children:"Credibility"}),e.jsxs("span",{children:[(a*100).toFixed(0),"%"]})]}),e.jsx("div",{className:"progress-track",children:e.jsx("div",{className:"progress-fill",style:{width:`${a*100}%`,background:a>.8?"var(--green)":a>.5?"var(--amber)":"var(--red)"}})})]}),s.specializations?.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:10},children:s.specializations.map(n=>e.jsx("span",{style:{fontSize:9,padding:"2px 6px",background:"rgba(0,229,255,.07)",color:"var(--cyan)",border:"1px solid rgba(0,229,255,.2)",borderRadius:3},children:n},n))}),d?e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{className:"input-base",style:{flex:1},placeholder:"Type a message...",value:i,onChange:n=>l(n.target.value),onKeyDown:n=>n.key==="Enter"&&u(),maxLength:2e3}),e.jsx("button",{className:"btn-primary",onClick:u,disabled:o||!i.trim(),children:o?"...":"Send"}),e.jsx("button",{className:"input-base",style:{cursor:"pointer",padding:"4px 8px"},onClick:()=>c(!1),children:"X"})]}):e.jsx("button",{className:"input-base",style:{width:"100%",cursor:"pointer",marginTop:8,textAlign:"center",fontSize:10,color:"var(--muted)"},onClick:()=>c(!0),children:"Send Message"})]})}function x({label:s,value:r,color:d="var(--text)"}){return e.jsxs("div",{style:{textAlign:"center",padding:"6px",background:"var(--surface)",borderRadius:4},children:[e.jsx("div",{style:{fontSize:9,color:"var(--muted)",marginBottom:2},children:s}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:d},children:r})]})}export{S as default};
@@ -0,0 +1 @@
1
+ import{r as f,a4 as r}from"./vendor-5MxLWm27.js";import{L as j}from"./LastUpdated-BVeFtHFH.js";const h={critical:"var(--red)",high:"var(--red)",medium:"var(--amber)",low:"var(--muted)"},y={hitl:"🚨",sla_breach:"⏰",agent_error:"🔴",cron_error:"⚙️",blocked:"🚫"},g={hitl:"HITL",sla_breach:"SLA",agent_error:"Agent",cron_error:"Cron",blocked:"Blocked"};function S(n){if(!n)return"";try{const s=Math.round((Date.now()-new Date(n))/6e4);return s<1?"just now":s<60?`${s}m ago`:`${Math.round(s/60)}h ago`}catch{return""}}function _({data:n,lastUpdated:s}){const{alerts:o=[],agents:u=[]}=n,[a,p]=f.useState(new Set),[t,v]=f.useState("all"),x=o.filter(e=>!a.has(e.id)),m=x.filter(e=>t==="all"||e.type===t),b=["all",...new Set(o.map(e=>e.type))],d={critical:0,high:0,medium:0,low:0};return x.forEach(e=>{d[e.severity]!==void 0&&d[e.severity]++}),r.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:10},children:Object.entries(d).map(([e,i])=>r.jsxs("div",{className:"card",style:{textAlign:"center"},children:[r.jsx("div",{className:"section-title",style:{textTransform:"capitalize"},children:e}),r.jsx("div",{style:{fontSize:22,fontWeight:700,color:i?h[e]:"var(--muted)"},children:i})]},e))}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[b.map(e=>r.jsxs("button",{onClick:()=>v(e),style:{background:t===e?"rgba(0,229,255,.15)":"var(--surface)",border:`1px solid ${t===e?"rgba(0,229,255,.4)":"var(--border)"}`,color:t===e?"var(--cyan)":"var(--muted)",padding:"4px 12px",borderRadius:4,fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:[y[e]||""," ",g[e]||e]},e)),a.size>0&&r.jsxs("button",{onClick:()=>p(new Set),style:{marginLeft:"auto",background:"none",border:"1px solid var(--border)",color:"var(--muted)",padding:"4px 10px",borderRadius:4,fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:["↺ Restore ",a.size," dismissed"]}),r.jsx(j,{ts:s})]}),m.length===0&&r.jsxs("div",{className:"card",style:{color:"var(--green)",fontSize:13},children:["✅ ",o.length===0?"No alerts — all systems nominal.":"All alerts dismissed for this session."]}),m.map(e=>{const i=h[e.severity]||"var(--muted)",l=u.find(c=>c.id===e.agent_id);return r.jsxs("div",{style:{background:"var(--bg2)",borderRadius:8,border:`1px solid ${i}44`,boxShadow:`0 0 12px ${i}0d`,display:"flex",gap:14,padding:"14px 16px",alignItems:"flex-start"},children:[r.jsx("span",{style:{fontSize:22,flexShrink:0},children:y[e.type]||"⚠️"}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4,flexWrap:"wrap"},children:[r.jsx("span",{style:{fontWeight:700,fontSize:13},children:e.title}),r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:3,fontWeight:700,textTransform:"uppercase",color:i,background:`${i}18`,border:`1px solid ${i}44`},children:e.severity})]}),e.detail&&r.jsx("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginBottom:4},children:e.detail}),r.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:10},children:[l&&r.jsxs("span",{children:[l.emoji," ",l.name]}),r.jsx("span",{children:g[e.type]}),r.jsx("span",{children:S(e.ts)}),e.task_id&&r.jsx("span",{style:{color:"var(--cyan)"},children:e.task_id}),e.cron_id&&r.jsxs("span",{style:{color:"var(--cyan)",fontFamily:"monospace",fontSize:9},children:[e.cron_id.slice(0,8),"…"]})]})]}),r.jsx("button",{onClick:()=>p(c=>new Set([...c,e.id])),title:"Dismiss alert",style:{background:"none",border:"1px solid var(--border)",color:"var(--muted)",padding:"3px 8px",borderRadius:4,cursor:"pointer",fontSize:10,fontFamily:"inherit",flexShrink:0},children:"✕"})]},e.id)})]})}export{_ as default};
@@ -0,0 +1 @@
1
+ import{r as v,a4 as r}from"./vendor-5MxLWm27.js";import{L as x}from"./LastUpdated-BVeFtHFH.js";import{d as u,e as h}from"./index-BFnAHHHY.js";function b({data:t,lastUpdated:i}){const{approvals:n=[],featureFlags:o={}}=t,[s,l]=v.useState({});if(!o.approvals)return r.jsx("div",{className:"card",children:"Approvals feature is disabled. Enable `featureApprovals` in plugin config."});const a=n.filter(e=>e.status==="pending");async function d(e){try{await u(e,s[e]||"")}catch{}}async function p(e){try{await h(e,s[e]||"")}catch{}}return r.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[r.jsxs("div",{className:"section-title",style:{marginBottom:0},children:["Approvals (",a.length," pending)"]}),r.jsx(x,{ts:i})]}),a.length===0&&r.jsx("div",{className:"card",style:{color:"var(--muted)"},children:"No pending approvals."}),a.map(e=>r.jsxs("div",{className:"card",style:{display:"grid",gap:8},children:[r.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[r.jsx("span",{style:{fontWeight:700},children:e.action}),r.jsx("span",{className:"badge badge-hitl",children:"pending"}),r.jsx("span",{style:{color:"var(--muted)",fontSize:10},children:e.id})]}),r.jsxs("div",{style:{color:"var(--muted)",fontSize:12},children:["Job: ",e.jobId]}),r.jsxs("div",{style:{color:"var(--muted)",fontSize:12},children:["Reason: ",e.note||"approval required"]}),r.jsx("input",{value:s[e.id]||"",onChange:c=>l(g=>({...g,[e.id]:c.target.value})),placeholder:"Optional note",style:{width:"100%",background:"var(--bg3)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",padding:"8px 10px",fontFamily:"inherit"}}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("button",{onClick:()=>d(e.id),style:{background:"rgba(0,230,118,.1)",border:"1px solid rgba(0,230,118,.35)",color:"var(--green)",borderRadius:5,padding:"5px 10px",cursor:"pointer",fontFamily:"inherit",fontSize:11},children:"Approve"}),r.jsx("button",{onClick:()=>p(e.id),style:{background:"rgba(255,23,68,.1)",border:"1px solid rgba(255,23,68,.35)",color:"var(--red)",borderRadius:5,padding:"5px 10px",cursor:"pointer",fontFamily:"inherit",fontSize:11},children:"Reject"})]})]},e.id))]})}export{b as default};
@@ -0,0 +1,2 @@
1
+ import{r as n,a4 as t}from"./vendor-5MxLWm27.js";import{a as m}from"./index-BFnAHHHY.js";function v({data:a,toast:e}){const{broadcast:s=""}=a,i=n.useRef(null);n.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[s]);const[o,l]=n.useState(""),[c,d]=n.useState(!1),u=async()=>{if(o.trim()){d(!0);try{await m("/api/broadcast",{message:o.trim()}),e("Broadcast posted","success"),l("")}catch(r){e(r.message,"error")}d(!1)}},p=s.split(`
2
+ `);return t.jsxs("div",{className:"fade-in",children:[t.jsxs("div",{style:{display:"flex",gap:8,marginBottom:10},children:[t.jsx("input",{className:"input-base",style:{flex:1},placeholder:"Post a broadcast message...",value:o,onChange:r=>l(r.target.value),onKeyDown:r=>r.key==="Enter"&&u(),maxLength:2e3}),t.jsx("button",{className:"btn-primary",onClick:u,disabled:c||!o.trim(),children:c?"Posting...":"Post"})]}),t.jsxs("div",{style:{background:"var(--bg2)",border:"1px solid var(--border)",borderRadius:8,padding:16,fontFamily:"JetBrains Mono, monospace",fontSize:12,height:"calc(100vh - 160px)",overflowY:"auto"},ref:i,children:[p.length===0||s.trim()===""?t.jsx("span",{style:{color:"var(--muted)"},children:"No broadcasts yet."}):p.map((r,f)=>t.jsx(g,{line:r},f)),t.jsx("div",{style:{height:8}})]})]})}function g({line:a}){const e=a.toLowerCase();let s="var(--text)";return e.includes("[critical]")||e.includes("🔴")?s="var(--red)":e.includes("[blocked]")||e.includes("⚠")?s="var(--amber)":e.includes("[hitl]")||e.includes("🚨")?s="var(--purple)":e.includes("[done]")||e.includes("✅")?s="var(--green)":a.startsWith("#")?s="var(--cyan)":a.startsWith("---")?s="rgba(84,110,122,.5)":(e.includes("task_id:")||e.includes("from:"))&&(s="var(--muted)"),t.jsx("div",{style:{color:s,padding:"1px 0",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:a||" "})}export{v as default};
@@ -0,0 +1 @@
1
+ import{a4 as e}from"./vendor-5MxLWm27.js";import{L as b}from"./LastUpdated-BVeFtHFH.js";import{R as u,B as v,X as S,Y as w,T as k,d as _,f as z}from"./charts-BhPBsBGB.js";function C({data:c,lastUpdated:p}){const{budget:i={}}=c,a=i.limits||{},t=i.current||{},n=i.alerts||{},r=i.per_agent||{},m=i.per_model||{},h=i.notes||null,y=i.last_updated||null,j=[{label:"Daily",spent:t.daily_usd??0,limit:a.daily_usd??0,threshold:n.daily_threshold_pct??70},{label:"Weekly",spent:t.weekly_usd??0,limit:a.weekly_usd??0,threshold:n.weekly_threshold_pct??70},{label:"Monthly",spent:t.monthly_usd??0,limit:a.monthly_usd??0,threshold:80}];return e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[h&&e.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,214,0,.07)",border:"1px solid rgba(255,214,0,.25)",borderRadius:6,fontSize:11,color:"var(--amber)",display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx("span",{children:"⚠"}),e.jsxs("div",{children:[e.jsx("span",{children:h}),y&&e.jsxs("span",{style:{color:"var(--muted)",marginLeft:12},children:["Last updated: ",new Date(y).toLocaleString()]})]}),e.jsx(b,{ts:p})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3,1fr)",gap:14},children:j.map(({label:s,spent:l,limit:x,threshold:d})=>{const o=x>0?Math.min(100,l/x*100):0,g=o>=d;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:8},children:[e.jsx("span",{className:"section-title",children:s}),e.jsxs("span",{style:{fontSize:11,fontWeight:700,color:g?"var(--red)":"var(--cyan)"},children:["$",l.toFixed(2)," / $",x]})]}),e.jsxs("div",{className:"progress-track",style:{position:"relative"},children:[e.jsx("div",{className:"progress-fill",style:{width:`${o}%`,background:o>d?"var(--red)":o>d*.8?"var(--amber)":"var(--cyan)"}}),e.jsx("div",{style:{position:"absolute",top:-2,bottom:-2,left:`${d}%`,width:1,background:"var(--amber)",opacity:.6}})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:4,fontSize:10,color:"var(--muted)"},children:[e.jsxs("span",{children:[o.toFixed(1),"% used"]}),e.jsxs("span",{style:{color:"var(--amber)"},children:["⚠ at ",d,"%"]})]})]},s)})}),Object.keys(r).length>0&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-title",style:{marginBottom:12},children:"Agent Spend Distribution"}),e.jsx(u,{width:"100%",height:Math.max(200,Object.keys(r).length*32),children:e.jsxs(v,{data:Object.entries(r).map(([s,l])=>({name:s,spent:typeof l=="object"?l.spent??0:l})).sort((s,l)=>l.spent-s.spent),layout:"vertical",margin:{left:80,right:20,top:5,bottom:5},children:[e.jsx(S,{type:"number",tick:{fill:"#546e7a",fontSize:10},tickFormatter:s=>`$${s.toFixed(2)}`}),e.jsx(w,{type:"category",dataKey:"name",tick:{fill:"#b0bec5",fontSize:11},width:75}),e.jsx(k,{formatter:s=>[`$${s.toFixed(3)}`,"Spent"],contentStyle:{background:"#1a1a2e",border:"1px solid #2a2a4a",borderRadius:6,fontSize:11}}),e.jsx(_,{dataKey:"spent",radius:[0,4,4,0],children:Object.entries(r).map(([s],l)=>e.jsx(z,{fill:["#00e5ff","#00e676","#ffd600","#e040fb","#ff6e40","#18ffff","#76ff03","#ffab40"][l%8],fillOpacity:.7},s))})]})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},children:[e.jsx(f,{title:"By Agent",data:r}),e.jsx(f,{title:"By Model",data:m})]})]})}function f({title:c,data:p}){const i=Object.entries(p).sort(([,a],[,t])=>{const n=typeof a=="object"?a.spent??0:a;return(typeof t=="object"?t.spent??0:t)-n});return e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-title",children:c}),i.length===0?e.jsx("div",{style:{color:"var(--muted)",fontSize:11,paddingTop:8},children:"No spend data yet"}):e.jsxs("table",{style:{width:"100%",fontSize:11,borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid var(--border)"},children:[e.jsx("th",{style:{textAlign:"left",padding:"4px 0",color:"var(--muted)",fontSize:10},children:"Name"}),e.jsx("th",{style:{textAlign:"right",padding:"4px 0",color:"var(--muted)",fontSize:10},children:"Spent"}),e.jsx("th",{style:{textAlign:"right",padding:"4px 0",color:"var(--muted)",fontSize:10},children:"Calls"})]})}),e.jsx("tbody",{children:i.map(([a,t])=>{const n=typeof t=="object"?t.spent??0:t,r=typeof t=="object"?t.calls??"—":"—";return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.03)"},children:[e.jsx("td",{style:{padding:"5px 0",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),e.jsxs("td",{style:{padding:"5px 0",textAlign:"right",color:"var(--cyan)",fontWeight:600},children:["$",n.toFixed(3)]}),e.jsx("td",{style:{padding:"5px 0",textAlign:"right",color:"var(--muted)"},children:r})]},a)})})]})]})}export{C as default};
@@ -0,0 +1,4 @@
1
+ import{r as x,a4 as s}from"./vendor-5MxLWm27.js";import{a as C}from"./index-BFnAHHHY.js";import{L as z}from"./LastUpdated-BVeFtHFH.js";function w({content:r,label:d,color:o}){if(!r||r.trim()===""||r.trim()===`# ${d}
2
+
3
+ _No messages._`)return s.jsxs("div",{style:{color:"var(--muted)",fontSize:11,padding:"8px 0"},children:["No ",d.toLowerCase()," messages."]});const c=r.split(`
4
+ `);return s.jsx("div",{style:{fontFamily:"monospace",fontSize:11,lineHeight:1.7,maxHeight:400,overflowY:"auto"},children:c.map((t,i)=>{let n="var(--text)";return t.startsWith("## ")||t.startsWith("# ")?n=o:t.startsWith("---")?n="rgba(255,255,255,.1)":t.startsWith("- ")?n="var(--muted)":t.startsWith("**")&&(n="var(--amber)"),s.jsx("div",{style:{color:n,padding:"1px 0",borderBottom:t.startsWith("---")?"1px solid rgba(255,255,255,.06)":"none"},children:t||" "},i)})})}function L({data:r,lastUpdated:d,toast:o}){const{comms:c={},agents:t=[]}=r,[i,n]=x.useState(t[0]?.id||null),[a,b]=x.useState("inbox"),[m,p]=x.useState(""),[g,f]=x.useState(!1),y=async()=>{if(!(!m.trim()||!i)){f(!0);try{await C(`/api/comms/${i}/send`,{message:m.trim()}),o("Message sent","success"),p("")}catch(e){o(e.message,"error")}f(!1)}},v=c[i]||{inbox:"",outbox:""},l=t.find(e=>e.id===i),u=e=>(e?.match(/^## /gm)||[]).length;return s.jsxs("div",{className:"fade-in",style:{display:"grid",gridTemplateColumns:"200px 1fr",gap:14,minHeight:500},children:[s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.jsx("div",{className:"section-title",children:"Agents"}),t.map(e=>{const h=c[e.id]||{},j=u(h.inbox),S=u(h.outbox);return s.jsxs("button",{onClick:()=>n(e.id),style:{background:i===e.id?"rgba(0,229,255,.12)":"var(--surface)",border:`1px solid ${i===e.id?"rgba(0,229,255,.4)":"var(--border)"}`,borderRadius:6,padding:"8px 10px",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:8,fontFamily:"inherit"},children:[s.jsx("span",{style:{fontSize:18},children:e.emoji}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:12,fontWeight:600,color:i===e.id?"var(--cyan)":"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),s.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["📬",j," · 📤",S]})]})]},e.id)})]}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[l&&s.jsx("span",{style:{fontSize:20},children:l.emoji}),l&&s.jsx("span",{style:{fontWeight:700,fontSize:14},children:l.name}),s.jsx("div",{style:{display:"flex",gap:4,marginLeft:8},children:["inbox","outbox"].map(e=>s.jsxs("button",{onClick:()=>b(e),style:{background:a===e?"rgba(0,229,255,.15)":"var(--surface)",border:`1px solid ${a===e?"rgba(0,229,255,.4)":"var(--border)"}`,color:a===e?"var(--cyan)":"var(--muted)",padding:"4px 12px",borderRadius:4,fontSize:11,cursor:"pointer",fontFamily:"inherit",textTransform:"capitalize"},children:[e==="inbox"?"📬":"📤"," ",e]},e))}),s.jsx(z,{ts:d})]}),s.jsx("div",{className:"card",style:{flex:1},children:s.jsx(w,{content:v[a],label:a==="inbox"?"Inbox":"Outbox",color:a==="inbox"?"var(--cyan)":"var(--green)"})}),i&&s.jsxs("div",{className:"card",style:{display:"flex",gap:8,alignItems:"flex-end"},children:[s.jsx("textarea",{className:"input-base",placeholder:`Send message to ${l?.name||i}...`,value:m,onChange:e=>p(e.target.value),style:{flex:1,minHeight:60,resize:"vertical",fontFamily:"inherit"},maxLength:2e3}),s.jsx("button",{className:"btn-primary",onClick:y,disabled:g||!m.trim(),children:g?"Sending...":"Send"})]})]})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{r as x,a4 as r}from"./vendor-5MxLWm27.js";import{L as b}from"./LastUpdated-BVeFtHFH.js";import{a as m}from"./index-BFnAHHHY.js";function _(e){return e?e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m ${Math.round(e%6e4/1e3)}s`:"—"}function v(e){return e==null?"—":e<0?"overdue":e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}function S(e){return e==null?"—":e<60?`${e}s ago`:e<3600?`${Math.round(e/60)}m ago`:`${Math.round(e/3600)}h ago`}function j({status:e,errors:o}){return o>=3?r.jsx("span",{className:"dot dot-error",title:`${o} consecutive errors`}):e==="error"?r.jsx("span",{className:"dot dot-error"}):e==="running"?r.jsx("span",{className:"dot dot-active"}):e==="ok"?r.jsx("span",{className:"dot dot-available"}):r.jsx("span",{className:"dot dot-offline"})}function k({job:e,agents:o,onTrigger:s,onToggle:f}){const[a,c]=x.useState(!1),[l,u]=x.useState(!1),[i,g]=x.useState(e.enabled!==!1),d=o.find(p=>p.id===e.agentId),t=e._consecutive_errors||0,n=t>=3||e._status==="error";async function h(){c(!0),await m(`/api/cron/${e.id}/trigger`),s?.(e.id),setTimeout(()=>c(!1),2e3)}async function y(){u(!0);const p=await m(`/api/cron/${e.id}/toggle`);p.ok&&g(p.enabled),u(!1),f?.(e.id,p.enabled)}return r.jsxs(r.Fragment,{children:[r.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.03)",background:n?"rgba(255,23,68,.03)":"transparent",opacity:i?1:.5},children:[r.jsx("td",{style:{padding:"8px 12px"},children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx(j,{status:e._status,errors:t}),r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:12,fontWeight:t>=3?700:400,color:n?"var(--red)":"var(--text)"},children:e.name}),e.description&&r.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:e.description.slice(0,60)})]})]})}),r.jsx("td",{style:{padding:"8px 12px",fontSize:11},children:d?r.jsxs("span",{children:[d.emoji," ",d.name]}):r.jsx("span",{style:{color:"var(--muted)"},children:e.agentId})}),r.jsx("td",{style:{padding:"8px 12px",fontSize:10,color:"var(--muted)",fontFamily:"monospace"},children:e.schedule?.kind==="every"?`every ${Math.round((e.schedule.everyMs||0)/6e4)}m`:e.schedule?.cronExpression||e.schedule?.kind||"—"}),r.jsx("td",{style:{padding:"8px 12px",fontSize:11,color:v(e._next_run_sec)==="overdue"?"var(--red)":"var(--muted)"},children:v(e._next_run_sec)}),r.jsx("td",{style:{padding:"8px 12px",fontSize:11,color:"var(--muted)"},children:S(e._last_run_sec)}),r.jsx("td",{style:{padding:"8px 12px",fontSize:11,color:"var(--muted)"},children:_(e._duration_ms)}),r.jsxs("td",{style:{padding:"8px 12px"},children:[n&&r.jsxs("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:3,fontWeight:700,background:"rgba(255,23,68,.15)",color:"var(--red)",border:"1px solid rgba(255,23,68,.3)"},children:[t,"× err"]}),!n&&e._status==="ok"&&r.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:3,background:"rgba(0,230,118,.1)",color:"var(--green)",border:"1px solid rgba(0,230,118,.25)"},children:"ok"})]}),r.jsx("td",{style:{padding:"8px 12px"},children:r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{onClick:h,disabled:a,title:"Trigger now",style:{background:"rgba(0,229,255,.1)",border:"1px solid rgba(0,229,255,.3)",color:"var(--cyan)",padding:"3px 8px",borderRadius:4,cursor:a?"not-allowed":"pointer",fontSize:10,fontFamily:"inherit"},children:a?"...":"▶ Run"}),r.jsx("button",{onClick:y,disabled:l,title:i?"Disable":"Enable",style:{background:i?"rgba(255,214,0,.08)":"rgba(0,230,118,.08)",border:`1px solid ${i?"rgba(255,214,0,.3)":"rgba(0,230,118,.3)"}`,color:i?"var(--amber)":"var(--green)",padding:"3px 8px",borderRadius:4,cursor:l?"not-allowed":"pointer",fontSize:10,fontFamily:"inherit"},children:l?"...":i?"⏸ Off":"▶ On"})]})})]}),n&&e._last_error&&r.jsx("tr",{style:{background:"rgba(255,23,68,.04)"},children:r.jsxs("td",{colSpan:8,style:{padding:"4px 12px 8px 40px",fontSize:10,color:"var(--red)",fontFamily:"monospace"},children:["↳ ",e._last_error]})})]})}function w({data:e,lastUpdated:o}){const{crons:s=[],agents:f=[]}=e,[a,c]=x.useState("all"),l=s.filter(t=>(t._consecutive_errors||0)>=3||t._status==="error"),u=s.filter(t=>t._status==="running"),i=s.filter(t=>t.enabled===!1),g=s.filter(t=>a==="error"?(t._consecutive_errors||0)>=3||t._status==="error":a==="running"?t._status==="running":a==="disabled"?t.enabled===!1:!0),d={};return g.forEach(t=>{const n=t.agentId||"unknown";d[n]||(d[n]=[]),d[n].push(t)}),r.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:10},children:[["Total",s.length,"var(--muted)"],["Erroring",l.length,l.length?"var(--red)":"var(--muted)"],["Running",u.length,u.length?"var(--cyan)":"var(--muted)"],["Disabled",i.length,i.length?"var(--amber)":"var(--muted)"]].map(([t,n,h])=>r.jsxs("div",{className:"card",style:{textAlign:"center",cursor:"pointer"},onClick:()=>c(t.toLowerCase()),children:[r.jsx("div",{className:"section-title",children:t}),r.jsx("div",{style:{fontSize:22,fontWeight:700,color:h},children:n})]},t))}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[["all","error","running","disabled"].map(t=>r.jsx("button",{onClick:()=>c(t),style:{background:a===t?"rgba(0,229,255,.15)":"var(--surface)",border:`1px solid ${a===t?"rgba(0,229,255,.4)":"var(--border)"}`,color:a===t?"var(--cyan)":"var(--muted)",padding:"4px 12px",borderRadius:4,fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:t},t)),r.jsx(b,{ts:o})]}),r.jsx("div",{className:"card",style:{padding:0,overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsx("tr",{style:{background:"var(--bg3)",borderBottom:"1px solid var(--border)"},children:["Job","Agent","Schedule","Next","Last Run","Duration","Status","Actions"].map(t=>r.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontSize:10,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:".05em"},children:t},t))})}),r.jsxs("tbody",{children:[g.length===0&&r.jsx("tr",{children:r.jsx("td",{colSpan:8,style:{padding:"20px",color:"var(--muted)",textAlign:"center"},children:"No cron jobs match filter"})}),g.map(t=>r.jsx(k,{job:t,agents:f},t.id))]})]})})]})}export{w as default};
@@ -0,0 +1 @@
1
+ import{r as g,a4 as e}from"./vendor-5MxLWm27.js";import{L as h}from"./LastUpdated-BVeFtHFH.js";import{a as f}from"./index-BFnAHHHY.js";function v(t){if(!t)return"—";try{const i=Math.round((Date.now()-new Date(t))/6e4);return i<1?"just now":i<60?`${i}m ago`:i<1440?`${Math.round(i/60)}h ago`:`${Math.round(i/1440)}d ago`}catch{return t}}function m({task:t,agents:i,onAction:p}){const[c,a]=g.useState(""),[n,r]=g.useState(null),l=i.find(s=>s.id===t.assigned_to),o=v(t.created_at),d=(t.sla?.priority||t.priority||"").toUpperCase();async function x(s){r(s);try{await f(`/api/hitl/${t.id}/${s}`,{note:c||void 0}),p(t.id,s)}catch(u){console.error(u)}r(null)}return e.jsxs("div",{style:{background:"var(--bg2)",border:"1px solid rgba(224,64,251,.35)",borderRadius:10,padding:18,display:"grid",gap:14,boxShadow:"0 0 20px rgba(224,64,251,.08)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("span",{style:{fontSize:28},children:"🚨"}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:700,fontSize:15},children:t.title}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",color:"var(--muted)"},children:t.id}),d&&e.jsx("span",{className:d==="P1"?"p1":d==="P2"?"p2":"p3",children:d})]}),e.jsxs("div",{style:{fontSize:11,color:"var(--muted)"},children:[l&&e.jsxs("span",{children:[l.emoji," ",l.name," · "]}),"Waiting ",e.jsx("span",{style:{color:"var(--amber)",fontWeight:600},children:o}),t.sla?.deadline&&e.jsxs("span",{children:[" · Due ",new Date(t.sla.deadline).toLocaleString()]})]})]})]}),e.jsxs("div",{style:{padding:"12px 14px",background:"rgba(224,64,251,.08)",border:"1px solid rgba(224,64,251,.25)",borderRadius:7},children:[e.jsx("div",{style:{fontSize:10,color:"var(--purple)",fontWeight:700,textTransform:"uppercase",letterSpacing:".06em",marginBottom:6},children:"Decision Required"}),e.jsx("div",{style:{fontSize:13,color:"var(--text)",lineHeight:1.6},children:t.hitl_reason||"Human decision required before proceeding."})]}),t.description&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:".05em",marginBottom:4},children:"Context"}),e.jsx("div",{style:{fontSize:12,color:"var(--text)",lineHeight:1.6},children:t.description})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--muted)",marginBottom:6},children:"Optional note (sent to agent)"}),e.jsx("input",{value:c,onChange:s=>a(s.target.value),placeholder:"Add context for the agent...",style:{width:"100%",background:"var(--bg3)",border:"1px solid var(--border)",borderRadius:5,padding:"8px 10px",fontSize:12,color:"var(--text)",fontFamily:"inherit",outline:"none",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsx("button",{onClick:()=>x("approve"),disabled:!!n,style:{flex:1,padding:"10px",background:"rgba(0,230,118,.15)",border:"1px solid rgba(0,230,118,.4)",color:"var(--green)",borderRadius:6,cursor:n?"not-allowed":"pointer",fontFamily:"inherit",fontSize:13,fontWeight:700,transition:"all .15s"},children:n==="approve"?"...":"✅ Approve — Continue"}),e.jsx("button",{onClick:()=>x("reject"),disabled:!!n,style:{flex:1,padding:"10px",background:"rgba(255,23,68,.1)",border:"1px solid rgba(255,23,68,.35)",color:"var(--red)",borderRadius:6,cursor:n?"not-allowed":"pointer",fontFamily:"inherit",fontSize:13,fontWeight:700,transition:"all .15s"},children:n==="reject"?"...":"❌ Reject — Block Task"})]})]})}function S({data:t,lastUpdated:i}){const{hitl_tasks:p=[],agents:c=[]}=t,[a,n]=g.useState(new Set),r=p.filter(o=>!a.has(o.id));function l(o){n(d=>new Set([...d,o]))}return e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:r.length?"var(--red)":"var(--green)"},children:r.length?`🚨 ${r.length} decision${r.length>1?"s":""} awaiting your input`:"✅ No pending HITL decisions"}),e.jsx(h,{ts:i})]}),r.length===0&&e.jsx("div",{className:"card",style:{color:"var(--muted)",fontSize:13},children:"All clear — no human decisions required right now. Agents are running autonomously."}),r.map(o=>e.jsx(m,{task:o,agents:c,onAction:l},o.id)),a.size>0&&e.jsxs("div",{style:{padding:"10px 14px",background:"rgba(0,230,118,.06)",border:"1px solid rgba(0,230,118,.2)",borderRadius:6,fontSize:12,color:"var(--green)"},children:["✅ ",a.size," decision",a.size>1?"s":""," resolved this session — agents notified via task status update."]})]})}export{S as default};
@@ -0,0 +1 @@
1
+ import{r as s,a4 as e}from"./vendor-5MxLWm27.js";import{L as k}from"./LastUpdated-BVeFtHFH.js";import{c as C,b as J,r as N}from"./index-BFnAHHHY.js";function R({step:a}){const i=a.status==="complete"?"var(--green)":a.status==="running"?"var(--cyan)":a.status==="failed"?"var(--red)":a.status==="blocked"?"var(--amber)":"var(--muted)";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,padding:"3px 0"},children:[e.jsx("span",{style:{color:i},children:"●"}),e.jsx("span",{style:{minWidth:70},children:a.kind}),e.jsx("span",{style:{color:"var(--muted)"},children:a.status}),e.jsxs("span",{style:{color:"var(--muted)"},children:["attempt ",a.attempt||0,"/",a.maxAttempts||2]})]})}function F({data:a,lastUpdated:i}){const{jobs:l=[],featureFlags:b={}}=a,[n,o]=s.useState(""),[c,h]=s.useState("P2"),[p,u]=s.useState(""),[g,x]=s.useState(!1),[m,y]=s.useState(""),v=!b.jobs,d=s.useMemo(()=>[...l].sort((t,r)=>new Date(r.createdAt)-new Date(t.createdAt)),[l]);async function f(t){if(t.preventDefault(),!!n.trim()){x(!0),y("");try{await C({intent:n.trim(),priority:c,tags:p.split(",").map(r=>r.trim()).filter(Boolean)}),o(""),u("")}catch(r){y(r.message||"create_failed")}x(!1)}}async function j(t){try{await J(t)}catch{}}async function S(t){try{await N(t)}catch{}}return v?e.jsx("div",{className:"card",children:"Jobs feature is disabled. Enable `featureJobs` in plugin config."}):e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[e.jsxs("form",{onSubmit:f,className:"card",style:{display:"grid",gap:10},children:[e.jsx("div",{className:"section-title",children:"Create Job"}),e.jsx("input",{value:n,onChange:t=>o(t.target.value),placeholder:"High-level intent...",style:{width:"100%",background:"var(--bg3)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",padding:"8px 10px",fontFamily:"inherit"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr auto",gap:10},children:[e.jsxs("select",{value:c,onChange:t=>h(t.target.value),style:{background:"var(--bg3)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",padding:"8px"},children:[e.jsx("option",{value:"P1",children:"P1"}),e.jsx("option",{value:"P2",children:"P2"}),e.jsx("option",{value:"P3",children:"P3"})]}),e.jsx("input",{value:p,onChange:t=>u(t.target.value),placeholder:"tags (comma separated)",style:{width:"100%",background:"var(--bg3)",border:"1px solid var(--border)",borderRadius:6,color:"var(--text)",padding:"8px 10px",fontFamily:"inherit"}}),e.jsx("button",{type:"submit",disabled:g,style:{background:"rgba(0,229,255,.15)",border:"1px solid rgba(0,229,255,.4)",color:"var(--cyan)",borderRadius:6,padding:"8px 12px",cursor:"pointer"},children:g?"...":"Create"})]}),m&&e.jsx("div",{style:{color:"var(--red)",fontSize:11},children:m})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxs("div",{className:"section-title",style:{marginBottom:0},children:["Jobs (",d.length,")"]}),e.jsx(k,{ts:i})]}),d.length===0&&e.jsx("div",{className:"card",style:{color:"var(--muted)"},children:"No jobs yet."}),d.map(t=>e.jsxs("div",{className:"card",style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{fontWeight:700},children:t.title}),e.jsx("span",{className:"badge badge-pending",style:{textTransform:"none"},children:t.status}),e.jsx("span",{style:{color:"var(--muted)",fontSize:10},children:t.id}),e.jsx("span",{style:{marginLeft:"auto",color:"var(--muted)",fontSize:11},children:new Date(t.createdAt).toLocaleString()})]}),e.jsx("div",{style:{color:"var(--muted)",fontSize:12},children:t.intent}),e.jsx("div",{style:{display:"grid",gap:2},children:(t.steps||[]).map(r=>e.jsx(R,{step:r},r.id))}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>j(t.id),disabled:["complete","failed","cancelled","blocked"].includes(t.status),style:{background:"rgba(255,23,68,.1)",border:"1px solid rgba(255,23,68,.35)",color:"var(--red)",borderRadius:5,padding:"5px 10px",cursor:"pointer",fontFamily:"inherit",fontSize:11},children:"Cancel"}),e.jsx("button",{onClick:()=>S(t.id),disabled:!["failed","blocked"].includes(t.status),style:{background:"rgba(0,230,118,.1)",border:"1px solid rgba(0,230,118,.35)",color:"var(--green)",borderRadius:5,padding:"5px 10px",cursor:"pointer",fontFamily:"inherit",fontSize:11},children:"Retry"})]})]},t.id))]})}export{F as default};
@@ -0,0 +1 @@
1
+ import{r as i,a4 as a}from"./vendor-5MxLWm27.js";import{a as N,f as z}from"./index-BFnAHHHY.js";import{L as E}from"./LastUpdated-BVeFtHFH.js";function R({data:m,lastUpdated:f,toast:c}){const{shared_knowledge:l=[],agents:y=[]}=m,[g,v]=i.useState(""),[o,b]=i.useState("all"),[j,p]=i.useState(!1),[s,d]=i.useState({title:"",content:"",category:"general",tags:""}),[u,x]=i.useState(!1),w=async()=>{if(s.content.trim()){x(!0);try{const e={...s,tags:s.tags?s.tags.split(",").map(t=>t.trim()).filter(Boolean):[]};await N("/api/knowledge",e),c("Knowledge entry created","success"),p(!1),d({title:"",content:"",category:"general",tags:""})}catch(e){c(e.message,"error")}x(!1)}},C=async e=>{if(confirm("Delete this knowledge entry?"))try{await z(`/api/knowledge/${e}`),c("Entry deleted","success")}catch(t){c(t.message,"error")}},S=i.useMemo(()=>{const e=new Set(l.map(t=>t.category||"general"));return["all",...Array.from(e).sort()]},[l]),h=i.useMemo(()=>l.filter(e=>{const t=o==="all"||(e.category||"general")===o,n=g.toLowerCase(),r=!n||(e.content||e.summary||"").toLowerCase().includes(n)||(e.title||"").toLowerCase().includes(n)||(e.tags||[]).some(k=>k.toLowerCase().includes(n));return t&&r}),[l,g,o]);return a.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[a.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[a.jsx("input",{value:g,onChange:e=>v(e.target.value),placeholder:"Search knowledge base...",style:{flex:1,minWidth:200,background:"var(--bg3)",border:"1px solid var(--border)",borderRadius:5,padding:"7px 12px",fontSize:12,color:"var(--text)",fontFamily:"inherit",outline:"none"}}),S.map(e=>a.jsx("button",{onClick:()=>b(e),style:{background:o===e?"rgba(0,229,255,.15)":"var(--surface)",border:`1px solid ${o===e?"rgba(0,229,255,.4)":"var(--border)"}`,color:o===e?"var(--cyan)":"var(--muted)",padding:"5px 12px",borderRadius:4,fontSize:11,cursor:"pointer",fontFamily:"inherit",textTransform:"capitalize"},children:e},e)),a.jsx("button",{className:"btn-primary",onClick:()=>p(e=>!e),children:"+ New Entry"}),a.jsx(E,{ts:f})]}),j&&a.jsxs("div",{className:"card",style:{display:"grid",gap:8},children:[a.jsx("input",{className:"input-base",placeholder:"Title",value:s.title,onChange:e=>d(t=>({...t,title:e.target.value}))}),a.jsx("textarea",{className:"input-base",placeholder:"Content *",value:s.content,onChange:e=>d(t=>({...t,content:e.target.value})),style:{minHeight:80,resize:"vertical",fontFamily:"inherit"},maxLength:5e3}),a.jsxs("div",{style:{display:"flex",gap:8},children:[a.jsx("input",{className:"input-base",placeholder:"Category",value:s.category,onChange:e=>d(t=>({...t,category:e.target.value})),style:{flex:1}}),a.jsx("input",{className:"input-base",placeholder:"Tags (comma separated)",value:s.tags,onChange:e=>d(t=>({...t,tags:e.target.value})),style:{flex:2}})]}),a.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[a.jsx("button",{className:"btn-primary",onClick:w,disabled:u||!s.content.trim(),children:u?"Creating...":"Create"}),a.jsx("button",{className:"input-base",style:{cursor:"pointer"},onClick:()=>p(!1),children:"Cancel"})]})]}),a.jsxs("div",{style:{fontSize:11,color:"var(--muted)"},children:[h.length," / ",l.length," entries",l.length===0&&" — Cipher will populate this during synthesis crons"]}),h.length===0&&a.jsx("div",{className:"card",style:{color:"var(--muted)",fontSize:13},children:l.length===0?"Knowledge base is empty. Cipher's synthesis cron populates SHARED_KNOWLEDGE.json every 6 hours.":"No entries match your search."}),a.jsx("div",{style:{display:"grid",gap:10},children:h.map((e,t)=>{const n=y.find(r=>r.id===e.added_by||r.id===e.author);return a.jsxs("div",{className:"card",children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,marginBottom:8},children:[a.jsxs("div",{style:{flex:1},children:[e.title&&a.jsx("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:e.title}),a.jsx("div",{style:{fontSize:12,color:"var(--text)",lineHeight:1.6},children:e.content||e.summary||e.insight||"—"})]}),a.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:3,flexShrink:0,background:"rgba(0,229,255,.07)",color:"var(--cyan)",border:"1px solid rgba(0,229,255,.2)",textTransform:"capitalize"},children:e.category||"general"}),e.id&&a.jsx("button",{className:"btn-danger",onClick:r=>{r.stopPropagation(),C(e.id)},children:"X"})]}),e.tags?.length>0&&a.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap",marginBottom:8},children:e.tags.map(r=>a.jsx("span",{style:{fontSize:9,padding:"1px 5px",borderRadius:3,background:"rgba(255,214,0,.08)",color:"var(--amber)",border:"1px solid rgba(255,214,0,.2)"},children:r},r))}),a.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:12,flexWrap:"wrap"},children:[n&&a.jsxs("span",{children:[n.emoji," ",n.name]}),e.source_task&&a.jsxs("span",{children:["Task: ",a.jsx("span",{style:{color:"var(--cyan)"},children:e.source_task})]}),e.added_at&&a.jsx("span",{children:new Date(e.added_at).toLocaleString()}),e.confidence&&a.jsxs("span",{children:["Confidence: ",Math.round(e.confidence*100),"%"]})]})]},e.id||t)})})]})}export{R as default};
@@ -0,0 +1 @@
1
+ import{a4 as a}from"./vendor-5MxLWm27.js";function n({ts:e,count:t}){return e?a.jsxs("span",{style:{fontSize:9,color:"var(--muted)",marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[t!=null&&a.jsxs("span",{style:{color:"var(--cyan)",opacity:.6},children:["#",t]}),"↻ ",e.toLocaleTimeString()]}):null}export{n as L};
@@ -0,0 +1 @@
1
+ import{a4 as e}from"./vendor-5MxLWm27.js";import{L as v}from"./LastUpdated-BVeFtHFH.js";function f({data:l,lastUpdated:m}){const i=l.okrs||{},a=i.objectives||i.okrs||[];return e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:2},children:[e.jsx("span",{style:{fontSize:10,color:"var(--muted)",textTransform:"uppercase",letterSpacing:".08em"},children:i.quarter||"OKRs"}),e.jsx(v,{ts:m})]}),a.length===0&&e.jsxs("div",{className:"card",style:{color:"var(--muted)",fontSize:13},children:["No OKRs defined yet. Add objectives to ",e.jsx("code",{children:"OKRs.json"})," in your workspace."]}),a.map((r,o)=>e.jsxs("div",{className:"card",children:[e.jsx("div",{style:{fontWeight:700,fontSize:14,marginBottom:14,color:"var(--cyan)"},children:r.objective||r.title||`Objective ${o+1}`}),(r.key_results||r.krs||[]).map((t,d)=>{const c=t.current??0,n=t.target??100,s=n>0?Math.min(100,c/n*100):0,p=t.unit?` ${t.unit}`:"";return e.jsxs("div",{style:{marginBottom:14,paddingLeft:12,borderLeft:"2px solid rgba(0,229,255,.2)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:5},children:[e.jsx("span",{style:{fontSize:12,flex:1,paddingRight:12},children:t.result||t.title||t.description||`KR ${d+1}`}),e.jsxs("span",{style:{fontSize:11,fontWeight:600,whiteSpace:"nowrap",color:s>=100?"var(--green)":"var(--amber)"},children:[c," / ",n,p]})]}),e.jsx("div",{className:"progress-track",children:e.jsx("div",{className:"progress-fill",style:{width:`${s}%`,background:s>=100?"var(--green)":s>=70?"var(--cyan)":s>=40?"var(--amber)":"var(--red)"}})}),e.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:3},children:[s.toFixed(0),"%"]})]},t.id||d)})]},r.id||o))]})}export{f as default};
@@ -0,0 +1,2 @@
1
+ import{a4 as e}from"./vendor-5MxLWm27.js";import{L as w}from"./LastUpdated-BVeFtHFH.js";function C({agent:t}){const r={active:"dot-active",available:"dot-available",busy:"dot-busy",error:"dot-error"}[t.status]||"dot-offline";return e.jsxs("div",{className:"card",style:{padding:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[e.jsx("span",{style:{fontSize:18},children:t.emoji||"🤖"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:t.role})]}),t.inbox_count>0&&e.jsxs("span",{style:{fontSize:10,color:"var(--amber)",fontWeight:600},children:["📬",t.inbox_count]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{className:`dot ${r}`}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)",textTransform:"capitalize"},children:t.status}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["⭐",(t.avg_quality||0).toFixed(1)]})]})]})}function A({data:t,lastUpdated:r}){const{agents:m=[],tasks:n=[],task_counts:d={},sla_at_risk:l=[],projects:f=[],budget:g={},knowledge_count:S=0,memory_lines:N=0,broadcast:z="",crons:u=[],alerts:_=[],dispatcher:o={}}=t,c=u.filter(s=>(s._consecutive_errors||0)>=3).length,h=u.length,v=_.filter(s=>s.severity==="critical").length,k=g.limits||{},x=(g.current||{}).daily_usd??0,y=k.daily_usd??1,j=g.alerts?.daily_threshold_pct??70,b=z.split(`
2
+ `).filter(s=>s.trim()).slice(-3);return e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6,1fr)",gap:10},children:[["Pending",d.pending??0,"var(--amber)"],["In Progress",d["in-progress"]??0,"var(--cyan)"],["Complete",d.complete??0,"var(--green)"],["HITL 🚨",d.needs_human_decision??0,"var(--purple)"],["Knowledge",S,"var(--cyan)"],["Memory",`${N}L`,"var(--muted)"]].map(([s,p,i])=>e.jsxs("div",{className:"card",style:{textAlign:"center"},children:[e.jsx("div",{className:"section-title",children:s}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:s==="HITL 🚨"&&p>0?"var(--red)":i},children:p})]},s))}),v>0&&e.jsxs("div",{style:{padding:"10px 14px",background:"rgba(255,23,68,.08)",border:"1px solid rgba(255,23,68,.35)",borderRadius:6,display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:16},children:"🚨"}),e.jsxs("span",{style:{fontSize:12,color:"var(--red)",fontWeight:600},children:[v," critical alert",v>1?"s":""," require attention"]}),e.jsx("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:"auto"},children:"→ Alerts tab"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsx("div",{className:"card",style:{borderColor:c?"rgba(255,214,0,.3)":"var(--border)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:"⚙️"}),e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:2},children:"Cron Health"}),e.jsx("div",{style:{fontSize:13,fontWeight:700,color:c?"var(--amber)":"var(--green)"},children:c?`${c}/${h} erroring`:`${h}/${h} healthy`})]})]})}),e.jsx("div",{className:"card",children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:"🤖"}),e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:2},children:"Dispatcher"}),e.jsxs("div",{style:{fontSize:11,color:"var(--muted)"},children:["Last: ",o.last_run?new Date(o.last_run).toLocaleTimeString():"—",o.last_summary?.triggered?.length>0&&e.jsxs("span",{style:{color:"var(--cyan)",marginLeft:8},children:["↑ ",o.last_summary.triggered.length," triggered"]})]})]})]})})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6},children:[e.jsx("span",{className:"section-title",style:{marginBottom:0},children:"Daily Budget"}),e.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:8},children:["$",x.toFixed(2)," / $",y]}),e.jsx(w,{ts:r})]}),e.jsxs("div",{className:"progress-track",style:{position:"relative"},children:[e.jsx("div",{className:"progress-fill",style:{width:`${Math.min(100,x/y*100)}%`,background:x/y>j/100?"var(--red)":"var(--cyan)"}}),e.jsx("div",{style:{position:"absolute",top:-2,bottom:-2,left:`${j}%`,width:1,background:"var(--amber)",opacity:.5}})]})]}),e.jsxs("div",{className:"card",style:{borderColor:l.length>0?"rgba(255,23,68,.4)":"var(--border)"},children:[e.jsx("div",{className:"section-title",style:{color:l.length>0?"var(--red)":"var(--muted)"},children:l.length>0?`⚠ SLA At Risk (${l.length})`:"✅ No SLA at risk"}),l.map(s=>e.jsxs("div",{style:{display:"flex",gap:10,padding:"4px 0",fontSize:11},children:[e.jsx("span",{style:{color:"var(--muted)",minWidth:60},children:s.id}),e.jsx("span",{style:{flex:1},children:s.title}),e.jsx("span",{style:{color:"var(--red)"},children:s.sla?.deadline||""})]},s.id))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-title",children:"Agent Status"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(140px,1fr))",gap:8},children:m.map(s=>e.jsx(C,{agent:s},s.id))})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-title",children:"Recent Tasks"}),n.slice(-10).reverse().map(s=>e.jsx(L,{task:s},s.id)),n.length===0&&e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:"No tasks yet"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14},children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-title",children:"Active Projects"}),f.filter(s=>["active","ACTIVE"].includes(s.status)).length===0?e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:"No active projects"}):f.filter(s=>["active","ACTIVE"].includes(s.status)).map(s=>e.jsxs("div",{style:{padding:"8px 10px",marginBottom:8,background:"var(--surface)",borderRadius:6,border:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontWeight:600,fontSize:12,marginBottom:3},children:s.name||s.id}),e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:s.description||""})]},s.id))]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"section-title",children:"Broadcast (last 3)"}),b.length===0?e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:"No broadcasts yet"}):b.map((s,p)=>{const i=s.toLowerCase();let a="var(--text)";return i.includes("[critical]")||i.includes("🔴")?a="var(--red)":i.includes("[blocked]")?a="var(--amber)":i.includes("[hitl]")||i.includes("🚨")?a="var(--purple)":(i.includes("[done]")||i.includes("✅"))&&(a="var(--green)"),e.jsx("div",{style:{color:a,fontSize:11,padding:"3px 0",lineHeight:1.5,wordBreak:"break-word"},children:s},p)})]})]})]})}function L({task:t}){const r=(t.sla?.priority||t.priority||"").toUpperCase(),m=(t.status||"").toLowerCase().replace(/ /g,"-"),n={complete:"badge-complete",pending:"badge-pending","in-progress":"badge-in-progress",failed:"badge-failed",needs_human_decision:"badge-hitl",blocked:"badge-blocked"}[m]||"badge-pending";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 0",borderBottom:"1px solid rgba(255,255,255,.04)"},children:[e.jsx("span",{style:{color:"var(--muted)",fontSize:10,minWidth:50},children:t.id||"—"}),e.jsx("span",{style:{flex:1,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title||"—"}),r&&e.jsx("span",{className:r==="P1"?"p1":r==="P2"?"p2":"p3",children:r}),e.jsx("span",{className:`badge ${n}`,children:t.status||"—"})]})}export{A as default};
@@ -0,0 +1,2 @@
1
+ import{r as f,a4 as e}from"./vendor-5MxLWm27.js";import{L as se}from"./LastUpdated-BVeFtHFH.js";import{R as N,L as ne,C as oe,X as L,Y as I,T as W,a as V,b as G,c as ae,B as Z,d as z}from"./charts-BhPBsBGB.js";const M={active:"var(--cyan)",complete:"var(--green)",paused:"var(--amber)",archived:"var(--muted)",pending:"var(--muted)"},le={critical:"var(--red)",high:"var(--red)",medium:"var(--amber)",low:"var(--muted)"},de={blocked:"🚫",hitl_pending:"🚨",overdue:"⏰",agent_error:"🔴",sla_breach:"💥"},ce={task_complete:"✅",task_failed:"❌",decision:"🧠",risk:"⚠️",milestone:"🏁"},D={green:"var(--green)",amber:"var(--amber)",red:"var(--red)"};function $(t){if(!t)return"—";try{const r=Math.round((Date.now()-new Date(t))/6e4);return r<1?"just now":r<60?`${r}m ago`:r<1440?`${Math.round(r/60)}h ago`:`${Math.round(r/1440)}d ago`}catch{return t}}function ee(t,r){if(!t)return null;try{const i=Math.ceil((new Date(t)-Date.now())/864e5);return r?{label:new Date(t).toLocaleDateString(),color:"var(--muted)"}:i<0?{label:`${Math.abs(i)}d overdue`,color:"var(--red)"}:i===0?{label:"due today",color:"var(--amber)"}:i===1?{label:"due tomorrow",color:"var(--amber)"}:{label:`in ${i}d`,color:"var(--muted)"}}catch{return{label:t,color:"var(--muted)"}}}function j(t){const r=(t._risks||[]).filter(n=>!n.resolved),i=t._progress_pct??0,a=t.target_completion?Math.ceil((new Date(t.target_completion)-Date.now())/864e5):999,d=t._task_counts||{};return r.some(n=>n.severity==="critical")||(d.blocked||0)>2||a<-3?"red":r.length>1||(d.hitl||0)>0||a<0||i<30?"amber":"green"}function xe(t,r){const i=t._task_counts||{},a=[`# ${t.name}`,`**Status**: ${t.status} | **Progress**: ${t._progress_pct??0}% | **Health**: ${j(t).toUpperCase()}`,`**Owner**: ${r.find(s=>s.id===t.owner)?.name||t.owner}`,t.target_completion?`**Target**: ${new Date(t.target_completion).toLocaleDateString()}`:"",`**Tasks**: ${i.done||0}/${i.total||0} done`,"","## Description",t.description||"—","","## Milestones",...(t.milestones||[]).map(s=>`- [${s.status==="complete"?"x":" "}] **${s.title}** (${s.status})`),"","## Risks",...(t._risks||[]).filter(s=>!s.resolved).map(s=>`- 🚨 [${s.severity}] ${s.description}`),"","## Decisions",...(t.decisions||[]).map(s=>`- 🧠 **${s.decision}**`),"",`_Exported ${new Date().toLocaleString()}_`],d=new Blob([a.join(`
2
+ `)],{type:"text/markdown"}),n=URL.createObjectURL(d),g=document.createElement("a");g.href=n,g.download=`${t.id}.md`,g.click(),URL.revokeObjectURL(n)}function y({label:t,color:r,size:i=10}){return e.jsx("span",{style:{fontSize:i,padding:"2px 7px",borderRadius:3,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:r,background:`${r}18`,border:`1px solid ${r}44`},children:t})}function te({pct:t,size:r=56,color:i="var(--cyan)"}){const a=(r-8)/2,d=2*Math.PI*a,n=d*(t/100);return e.jsxs("svg",{width:r,height:r,style:{transform:"rotate(-90deg)",flexShrink:0},children:[e.jsx("circle",{cx:r/2,cy:r/2,r:a,fill:"none",stroke:"rgba(255,255,255,.06)",strokeWidth:6}),e.jsx("circle",{cx:r/2,cy:r/2,r:a,fill:"none",stroke:i,strokeWidth:6,strokeDasharray:`${n} ${d}`,strokeLinecap:"round",style:{transition:"stroke-dasharray .4s ease"}}),e.jsxs("text",{x:r/2,y:r/2,textAnchor:"middle",dominantBaseline:"middle",style:{fontSize:11,fontWeight:700,fill:i,transform:"rotate(90deg)",transformOrigin:`${r/2}px ${r/2}px`},children:[t,"%"]})]})}function re({agentId:t,agents:r,isOwner:i}){const a=r.find(d=>d.id===t);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,padding:"2px 7px",borderRadius:3,background:i?"rgba(0,229,255,.12)":"rgba(255,255,255,.04)",border:`1px solid ${i?"rgba(0,229,255,.4)":"var(--border)"}`,color:i?"var(--cyan)":"var(--text)"},children:[a?.emoji||"🤖"," ",a?.name||t,i?" 👑":""]})}function ie({health:t}){return e.jsx("span",{title:`Health: ${t}`,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",background:D[t],flexShrink:0,boxShadow:`0 0 6px ${D[t]}`}})}function T({iso:t}){const r=ee(t,!1);return r?e.jsxs("span",{style:{fontSize:10,color:r.color,fontWeight:600},children:["⏱ ",r.label]}):null}function pe({project:t}){const r=t.milestones||[];if(!r.length)return e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No milestones to display."});const i=new Date(t.created_at||Date.now()),a=new Date(t.target_completion||Date.now()+30*864e5),d=Math.max(1,a-i),n=Math.max(0,Math.min(100,(Date.now()-i)/d*100)),g={complete:"var(--green)","in-progress":"var(--cyan)",pending:"rgba(255,255,255,.15)",blocked:"var(--red)"};return e.jsxs("div",{style:{position:"relative",paddingTop:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:9,color:"var(--muted)",marginBottom:6},children:[e.jsx("span",{children:i.toLocaleDateString()}),e.jsx("span",{style:{color:"var(--amber)"},children:"TODAY"}),e.jsx("span",{children:a.toLocaleDateString()})]}),e.jsxs("div",{style:{position:"relative",background:"rgba(255,255,255,.03)",borderRadius:4,padding:"4px 0"},children:[e.jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,background:"var(--amber)",opacity:.7,zIndex:2}}),r.map(s=>{const x=s.due?new Date(s.due):a,c=Math.max(2,Math.min(100,(x-i)/d*100));return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,paddingRight:8},children:[e.jsx("div",{style:{fontSize:10,color:"var(--muted)",width:140,flexShrink:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:s.title,children:s.title}),e.jsxs("div",{style:{flex:1,position:"relative",height:16,background:"rgba(255,255,255,.03)",borderRadius:3},children:[e.jsx("div",{style:{position:"absolute",left:0,width:`${c}%`,height:"100%",borderRadius:3,background:g[s.status]||"rgba(255,255,255,.15)",opacity:s.status==="complete"?.6:1,transition:"width .4s ease"}}),s.status==="complete"&&e.jsx("span",{style:{position:"absolute",right:4,top:1,fontSize:9,color:"var(--green)"},children:"✓"})]}),e.jsx("div",{style:{fontSize:9,color:"var(--muted)",width:40,flexShrink:0,textAlign:"right"},children:s.due?new Date(s.due).toLocaleDateString("en",{month:"short",day:"numeric"}):"—"})]},s.id)})]})]})}function ge({project:t,tasks:r}){const i=r.filter(l=>(t.task_ids||[]).includes(l.id)),a=i.length;if(!a)return e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No tasks linked yet."});const d=new Date(t.created_at||Date.now()),n=new Date(t.target_completion||Date.now()+7*864e5),g=Math.max(1,Math.ceil((n-d)/864e5)),s=i.filter(l=>l.completed_at).map(l=>Math.max(0,Math.ceil((new Date(l.completed_at)-d)/864e5))).sort((l,h)=>l-h),x=Math.ceil((Date.now()-d)/864e5),c=Array.from({length:g+1},(l,h)=>({day:h,ideal:Math.round(a-a/g*h),actual:h<=x?a-s.filter(o=>o<=h).length:void 0}));return e.jsx(N,{width:"100%",height:180,children:e.jsxs(ne,{data:c,margin:{top:4,right:12,left:0,bottom:4},children:[e.jsx(oe,{stroke:"rgba(255,255,255,.04)"}),e.jsx(L,{dataKey:"day",tick:{fontSize:9,fill:"var(--muted)"}}),e.jsx(I,{tick:{fontSize:9,fill:"var(--muted)"}}),e.jsx(W,{contentStyle:{background:"var(--bg2)",border:"1px solid var(--border)",fontSize:11}}),e.jsx(V,{wrapperStyle:{fontSize:10}}),e.jsx(G,{type:"monotone",dataKey:"ideal",stroke:"rgba(255,255,255,.2)",strokeDasharray:"4 2",dot:!1,name:"Ideal"}),e.jsx(G,{type:"monotone",dataKey:"actual",stroke:"var(--cyan)",strokeWidth:2,dot:!1,name:"Actual"}),e.jsx(ae,{x,stroke:"var(--amber)",strokeDasharray:"3 3"})]})})}function he({project:t}){const r=t.budget?.allocated_usd||0,i=t.budget?.spent_usd||0,a=Math.max(0,r-i),d=r?Math.round(i/r*100):0,n=[{name:"Budget",Spent:i,Remaining:a}];return e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginBottom:6},children:["$",i.toFixed(2)," spent of $",r.toFixed(2)," (",d,"%)",d>80&&e.jsx("span",{style:{color:"var(--red)",marginLeft:6},children:"⚠️ Near limit"})]}),e.jsx(N,{width:"100%",height:80,children:e.jsxs(Z,{data:n,layout:"vertical",margin:{top:0,right:0,left:0,bottom:0},children:[e.jsx(L,{type:"number",tick:{fontSize:9,fill:"var(--muted)"},domain:[0,r||1]}),e.jsx(I,{type:"category",dataKey:"name",hide:!0}),e.jsx(W,{contentStyle:{background:"var(--bg2)",border:"1px solid var(--border)",fontSize:11},formatter:g=>`$${g.toFixed(2)}`}),e.jsx(z,{dataKey:"Spent",stackId:"a",fill:"var(--cyan)",radius:[3,0,0,3]}),e.jsx(z,{dataKey:"Remaining",stackId:"a",fill:"rgba(255,255,255,.06)",radius:[0,3,3,0]})]})})]})}function ue({project:t,tasks:r,agents:i}){const a=r.filter(n=>(t.task_ids||[]).includes(n.id)),d=(t.team||[]).map(n=>{const g=i.find(x=>x.id===n)||{},s=a.filter(x=>x.assigned_to===n);return{name:`${g.emoji||"🤖"} ${g.name||n}`,Open:s.filter(x=>!["complete","failed"].includes(x.status)).length,Done:s.filter(x=>x.status==="complete").length,Blocked:s.filter(x=>["blocked","needs_human_decision"].includes(x.status)).length}}).filter(n=>n.Open+n.Done+n.Blocked>0);return d.length?e.jsx(N,{width:"100%",height:Math.max(80,d.length*40),children:e.jsxs(Z,{data:d,layout:"vertical",margin:{top:0,right:12,left:80,bottom:0},children:[e.jsx(L,{type:"number",tick:{fontSize:9,fill:"var(--muted)"},allowDecimals:!1}),e.jsx(I,{type:"category",dataKey:"name",tick:{fontSize:10,fill:"var(--text)"},width:90}),e.jsx(W,{contentStyle:{background:"var(--bg2)",border:"1px solid var(--border)",fontSize:11}}),e.jsx(V,{wrapperStyle:{fontSize:10}}),e.jsx(z,{dataKey:"Done",fill:"var(--green)",stackId:"a"}),e.jsx(z,{dataKey:"Open",fill:"var(--cyan)",stackId:"a"}),e.jsx(z,{dataKey:"Blocked",fill:"var(--red)",stackId:"a",radius:[0,3,3,0]})]})}):e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No task assignments yet."})}function me({project:t,okrs:r}){if(!r?.objectives?.length)return e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No OKRs loaded."});const i=r.objectives.filter(a=>(t.okr_ids||[]).includes(a.id)||(t.tags||[]).some(d=>a.objective.toLowerCase().includes(d.toLowerCase())));return i.length?e.jsx("div",{style:{display:"grid",gap:8},children:i.map(a=>e.jsxs("div",{style:{padding:"10px 12px",background:"var(--surface)",borderRadius:6,border:"1px solid var(--border)"},children:[e.jsxs("div",{style:{fontSize:11,fontWeight:600,marginBottom:6},children:["🎯 ",a.objective]}),(a.key_results||[]).map(d=>{const n=d.target?Math.min(100,Math.round(d.current/d.target*100)):0,g=n>=100?"var(--green)":n>=50?"var(--cyan)":"var(--amber)";return e.jsxs("div",{style:{marginBottom:6},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:3,fontSize:10},children:[e.jsx("span",{style:{color:"var(--muted)"},children:d.result}),e.jsxs("span",{style:{color:g,fontWeight:600},children:[d.current,"/",d.target," ",d.unit]})]}),e.jsx("div",{className:"progress-track",style:{height:4},children:e.jsx("div",{className:"progress-fill",style:{width:`${n}%`,background:g,height:4}})})]},d.id)})]},a.id))}):e.jsxs("div",{style:{fontSize:11,color:"var(--muted)"},children:["No OKR linkage — add ",e.jsx("code",{children:"okr_ids"})," to PROJECTS.json."]})}function Q({ms:t,agents:r}){const i=ee(t.due,t.status==="complete"),a=r.find(n=>n.id===t.assigned_to),d={complete:"✅","in-progress":"🔄",pending:"⏳",blocked:"🚫"}[t.status]||"⏳";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 0",borderBottom:"1px solid rgba(255,255,255,.04)",opacity:t.status==="complete"?.7:1},children:[e.jsx("span",{style:{fontSize:16,flexShrink:0},children:d}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,textDecoration:t.status==="complete"?"line-through":"none",color:t.status==="complete"?"var(--muted)":"var(--text)"},children:t.title}),e.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:2,display:"flex",gap:8},children:[a&&e.jsxs("span",{children:[a.emoji," ",a.name]}),(t.task_ids||[]).length>0&&e.jsxs("span",{children:[t.task_ids.length," task",t.task_ids.length>1?"s":""]}),t.auto_complete&&e.jsx("span",{style:{color:"var(--cyan)"},children:"⚡ auto"})]})]}),i&&e.jsx("span",{style:{fontSize:10,color:i.color,flexShrink:0},children:i.label}),e.jsx(y,{label:t.status,color:M[t.status]||"var(--muted)"})]})}function X({risk:t,agents:r}){const i=le[t.severity]||"var(--muted)",a=r.find(d=>d.id===t.detected_by);return e.jsxs("div",{style:{display:"flex",gap:10,padding:"8px 10px",marginBottom:6,borderRadius:6,background:`${i}0d`,border:`1px solid ${i}33`},children:[e.jsx("span",{style:{fontSize:16,flexShrink:0},children:de[t.type]||"⚠️"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:12,color:"var(--text)",marginBottom:2},children:t.description}),e.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:10},children:[a&&e.jsxs("span",{children:[a.emoji," ",a.name]}),e.jsx("span",{children:$(t.detected_at)})]})]}),e.jsx(y,{label:t.severity,color:i})]})}function Y({item:t,agents:r}){const i=r.find(a=>a.id===t.agent);return e.jsxs("div",{style:{display:"flex",gap:10,padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,.03)"},children:[e.jsx("span",{style:{fontSize:14,flexShrink:0},children:ce[t.type]||"•"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.text}),e.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:2},children:[i&&e.jsxs("span",{children:[i.emoji," ",i.name," · "]}),$(t.ts)]})]})]})}function ve({sessions:t,agents:r}){return t?.length?e.jsxs("table",{style:{width:"100%",fontSize:11,borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},children:["Task","Agent","Proc ID","Status","Completed"].map(i=>e.jsx("th",{style:{textAlign:"left",padding:"4px 8px",fontSize:10,color:"var(--muted)",fontWeight:600},children:i},i))})}),e.jsx("tbody",{children:t.map((i,a)=>{const d=r.find(s=>s.id===i.assigned_to),n=(i.status||"").toLowerCase().replace(/ /g,"-"),g={complete:"badge-complete",failed:"badge-failed","in-progress":"badge-in-progress"}[n]||"badge-pending";return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.03)"},children:[e.jsx("td",{style:{padding:"5px 8px",color:"var(--cyan)",fontFamily:"monospace",fontSize:10},children:i.task_id}),e.jsx("td",{style:{padding:"5px 8px"},children:d?`${d.emoji} ${d.name}`:i.assigned_to}),e.jsx("td",{style:{padding:"5px 8px",color:"var(--muted)",fontFamily:"monospace",fontSize:10},children:i.proc_id||"—"}),e.jsx("td",{style:{padding:"5px 8px"},children:e.jsx("span",{className:`badge ${g}`,children:i.status})}),e.jsx("td",{style:{padding:"5px 8px",color:"var(--muted)"},children:i.completed_at?$(i.completed_at):"—"})]},a)})})]}):e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No sessions recorded yet."})}function ye({tasks:t,projectTaskIds:r,agents:i}){const[a,d]=f.useState(null),n=t.filter(s=>r.includes(s.id)),g=[{key:"pending",label:"Pending",color:"var(--muted)"},{key:"in-progress",label:"In Progress",color:"var(--cyan)"},{key:"needs_human_decision",label:"🚨 HITL",color:"var(--purple)"},{key:"blocked",label:"Blocked",color:"var(--red)"},{key:"complete",label:"Complete",color:"var(--green)"},{key:"failed",label:"Failed",color:"var(--red)"}];return n.length?e.jsx("div",{style:{display:"grid",gap:12},children:g.map(s=>{const x=n.filter(c=>c.status===s.key);return x.length?e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:10,fontWeight:600,color:s.color,textTransform:"uppercase",letterSpacing:".06em",marginBottom:6},children:[s.label," (",x.length,")"]}),x.map(c=>{const l=a===c.id,h=i.find(u=>u.id===c.assigned_to),o=(c.sla?.priority||c.priority||"").toUpperCase();return e.jsxs("div",{onClick:()=>d(l?null:c.id),style:{marginBottom:6,padding:"8px 10px",background:"var(--surface)",border:`1px solid ${l?"rgba(0,229,255,.3)":"var(--border)"}`,borderRadius:6,cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:10,color:"var(--muted)",fontFamily:"monospace",minWidth:50},children:c.id}),e.jsx("span",{style:{flex:1,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.title}),o&&e.jsx("span",{className:o==="P1"?"p1":o==="P2"?"p2":"p3",children:o}),h&&e.jsx("span",{style:{fontSize:11},children:h.emoji}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)"},children:l?"▲":"▼"})]}),l&&e.jsxs("div",{style:{marginTop:10,display:"grid",gap:8},children:[c.hitl_reason&&e.jsxs("div",{style:{padding:"6px 10px",background:"rgba(224,64,251,.08)",border:"1px solid rgba(224,64,251,.25)",borderRadius:5,fontSize:11,color:"var(--purple)"},children:["🚨 ",c.hitl_reason]}),c.description&&e.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5},children:c.description}),c.output&&e.jsxs("div",{style:{fontSize:11,color:"var(--text)",lineHeight:1.5,padding:"6px 10px",background:"rgba(0,230,118,.04)",border:"1px solid rgba(0,230,118,.15)",borderRadius:5},children:["✅ ",c.output]}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:10,color:"var(--muted)",flexWrap:"wrap"},children:[c.proc_id&&e.jsxs("span",{children:["Proc: ",e.jsx("span",{style:{color:"var(--cyan)"},children:c.proc_id})]}),c.completed_at&&e.jsxs("span",{children:["Done: ",new Date(c.completed_at).toLocaleString()]})]})]})]},c.id)})]},s.key):null})}):e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No tasks linked yet."})}function J({project:t,agents:r,selected:i,onClick:a}){const d=t._task_counts||{},n=t._milestone_counts||{},g=t._progress_pct??0,s=(t._risks||[]).filter(c=>!c.resolved),x=j(t);return e.jsxs("div",{onClick:a,className:"card",style:{cursor:"pointer",transition:"all .15s",borderColor:i?"rgba(0,229,255,.6)":s.length?"rgba(255,23,68,.3)":"var(--border)",boxShadow:i?"0 0 0 1px rgba(0,229,255,.2), var(--shadow)":"none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,marginBottom:10},children:[e.jsx(te,{pct:g,color:g===100?"var(--green)":s.length?"var(--red)":"var(--cyan)"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4,flexWrap:"wrap"},children:[e.jsx(ie,{health:x}),e.jsx("span",{style:{fontWeight:700,fontSize:13},children:t.name}),e.jsx(y,{label:t.status,color:M[t.status]||"var(--muted)"})]}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"monospace"},children:t.id})]})]}),e.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:10,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:t.description}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4,1fr)",gap:6,marginBottom:10},children:[["Tasks",`${d.done||0}/${d.total||0}`,"var(--cyan)"],["Milestones",`${n.done||0}/${n.total||0}`,"var(--green)"],["Quality",t._quality_score?`⭐${t._quality_score}`:"—","var(--amber)"],["Vel/day",t._velocity??"—","var(--muted)"]].map(([c,l,h])=>e.jsxs("div",{style:{textAlign:"center",padding:"5px 4px",background:"var(--surface)",borderRadius:4},children:[e.jsx("div",{style:{fontSize:9,color:"var(--muted)",marginBottom:2},children:c}),e.jsx("div",{style:{fontSize:12,fontWeight:700,color:h},children:l})]},c))}),s.length>0&&e.jsxs("div",{style:{fontSize:10,color:"var(--red)",marginBottom:8,padding:"4px 8px",background:"rgba(255,23,68,.07)",borderRadius:4,border:"1px solid rgba(255,23,68,.2)"},children:["🚨 ",s.length," risk",s.length>1?"s":"",": ",s[0].description.slice(0,60),s[0].description.length>60?"…":""]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsx(re,{agentId:t.owner,agents:r,isOwner:!0}),(t.tags||[]).slice(0,2).map(c=>e.jsx("span",{style:{fontSize:9,padding:"1px 5px",borderRadius:3,background:"rgba(0,229,255,.06)",color:"var(--cyan)",border:"1px solid rgba(0,229,255,.15)"},children:c},c)),e.jsxs("span",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(T,{iso:t.target_completion}),t._last_activity&&e.jsxs("span",{style:{fontSize:9,color:"var(--muted)"},children:["↺ ",$(t._last_activity)]})]})]})]})}const fe=["Overview","Milestones","Gantt","Tasks","Burndown","Risks","Team","Workload","Budget","OKRs","Activity","Sessions","Decisions"];function je({project:t,agents:r,tasks:i,okrs:a,onClose:d}){const[n,g]=f.useState("Overview"),s=t._task_counts||{},x=t._milestone_counts||{},c=t._progress_pct??0,l=(t._risks||[]).filter(o=>!o.resolved),h=j(t);return e.jsxs("div",{style:{background:"var(--bg2)",border:"1px solid rgba(0,229,255,.25)",borderRadius:10,overflow:"hidden",marginBottom:4},children:[e.jsxs("div",{style:{padding:"16px 20px",background:"var(--bg3)",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"flex-start",gap:16},children:[e.jsx(te,{pct:c,size:70,color:c===100?"var(--green)":l.length?"var(--red)":"var(--cyan)"}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6,flexWrap:"wrap"},children:[e.jsx(ie,{health:h}),e.jsx("span",{style:{fontSize:18,fontWeight:700},children:t.name}),e.jsx(y,{label:t.status,color:M[t.status]||"var(--muted)",size:11}),t.priority_weight&&e.jsx(y,{label:`P${t.priority_weight}`,color:"var(--amber)",size:10}),l.length>0&&e.jsx(y,{label:`${l.length} risk${l.length>1?"s":""}`,color:"var(--red)",size:10}),e.jsx(y,{label:`${h} health`,color:D[h],size:10})]}),e.jsx("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginBottom:8},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:10,color:"var(--muted)",flexWrap:"wrap",alignItems:"center"},children:[e.jsxs("span",{children:["Owner: ",e.jsx(re,{agentId:t.owner,agents:r,isOwner:!0})]}),t.target_completion&&e.jsx(T,{iso:t.target_completion}),t.created_at&&e.jsxs("span",{children:["Created: ",new Date(t.created_at).toLocaleDateString()]}),(t.tags||[]).map(o=>e.jsx("span",{style:{padding:"1px 5px",borderRadius:3,background:"rgba(0,229,255,.06)",color:"var(--cyan)",border:"1px solid rgba(0,229,255,.15)"},children:o},o))]})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsx("button",{onClick:()=>xe(t,r),style:{background:"none",border:"1px solid var(--border)",color:"var(--muted)",borderRadius:4,padding:"4px 10px",cursor:"pointer",fontSize:11,fontFamily:"inherit"},children:"⬇ MD"}),e.jsx("button",{onClick:d,style:{background:"none",border:"1px solid var(--border)",color:"var(--muted)",borderRadius:4,padding:"4px 10px",cursor:"pointer",fontSize:11,fontFamily:"inherit"},children:"✕"})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8,1fr)",borderBottom:"1px solid var(--border)",background:"var(--bg2)"},children:[["Tasks Done",`${s.done||0}/${s.total||0}`,"var(--cyan)"],["In Progress",s.active||0,"var(--amber)"],["Blocked",s.blocked||0,s.blocked?"var(--red)":"var(--muted)"],["HITL",s.hitl||0,s.hitl?"var(--purple)":"var(--muted)"],["Milestones",`${x.done||0}/${x.total||0}`,"var(--green)"],["Quality",t._quality_score?`⭐${t._quality_score}`:"—","var(--amber)"],["Vel/day",t._velocity??"—","var(--muted)"],["Budget",`$${t.budget?.spent_usd??0}/$${t.budget?.allocated_usd??0}`,"var(--cyan)"]].map(([o,u,v])=>e.jsxs("div",{style:{textAlign:"center",padding:"10px 4px",borderRight:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontSize:9,color:"var(--muted)",marginBottom:3,textTransform:"uppercase",letterSpacing:".04em"},children:o}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:v},children:u})]},o))}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--border)",background:"var(--bg3)",overflowX:"auto",padding:"0 16px",gap:2},children:fe.map(o=>{const u=o==="Risks"&&l.length?l.length:o==="Tasks"&&s.total?s.total:o==="Milestones"&&x.total?x.total:null;return e.jsxs("button",{onClick:()=>g(o),style:{background:"none",border:"none",cursor:"pointer",padding:"8px 12px",fontSize:11,fontFamily:"inherit",whiteSpace:"nowrap",fontWeight:n===o?600:400,color:n===o?"var(--cyan)":"var(--muted)",borderBottom:n===o?"2px solid var(--cyan)":"2px solid transparent"},children:[o,u?` (${u})`:""]},o)})}),e.jsxs("div",{style:{padding:20},children:[n==="Overview"&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},children:[e.jsxs("div",{children:[e.jsx("div",{className:"section-title",children:"Milestone Progress"}),e.jsx("div",{className:"progress-track",style:{marginBottom:8},children:e.jsx("div",{className:"progress-fill",style:{width:`${x.total?Math.round(x.done/x.total*100):0}%`,background:x.done===x.total&&x.total>0?"var(--green)":"var(--cyan)"}})}),(t.milestones||[]).slice(0,4).map(o=>e.jsx(Q,{ms:o,agents:r},o.id))]}),e.jsxs("div",{children:[e.jsx("div",{className:"section-title",children:"Recent Activity"}),(t._activity||[]).slice(0,6).map((o,u)=>e.jsx(Y,{item:o,agents:r},u)),(!t._activity||t._activity.length===0)&&e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No activity yet."})]}),l.length>0&&e.jsxs("div",{style:{gridColumn:"1/-1"},children:[e.jsx("div",{className:"section-title",style:{color:"var(--red)"},children:"🚨 Active Risks"}),l.slice(0,3).map(o=>e.jsx(X,{risk:o,agents:r},o.id))]}),t.notes&&e.jsxs("div",{style:{gridColumn:"1/-1",padding:"10px 14px",background:"rgba(0,229,255,.03)",border:"1px solid rgba(0,229,255,.12)",borderRadius:6},children:[e.jsx("div",{className:"section-title",children:"Notes"}),e.jsx("div",{style:{fontSize:12,color:"var(--text)",lineHeight:1.6},children:t.notes})]})]}),n==="Milestones"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:[x.done,"/",x.total," complete"]}),t.target_completion&&e.jsx(T,{iso:t.target_completion})]}),(t.milestones||[]).length===0?e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No milestones defined yet."}):(t.milestones||[]).map(o=>e.jsx(Q,{ms:o,agents:r},o.id))]}),n==="Gantt"&&e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:12},children:"Timeline — Milestones"}),e.jsx(pe,{project:t})]}),n==="Tasks"&&e.jsx(ye,{tasks:i,projectTaskIds:t.task_ids||[],agents:r}),n==="Burndown"&&e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:12},children:"Task Burndown"}),e.jsx(ge,{project:t,tasks:i})]}),n==="Risks"&&e.jsx("div",{children:l.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--green)"},children:"✅ No active risks."}):l.map(o=>e.jsx(X,{risk:o,agents:r},o.id))}),n==="Team"&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(200px,1fr))",gap:12},children:(t.team||[]).map(o=>{const u=r.find(b=>b.id===o),v=o===t.owner,B={active:"dot-active",available:"dot-available",busy:"dot-busy",error:"dot-error"}[u?.status]||"dot-offline";return e.jsxs("div",{className:"card",style:{borderColor:v?"rgba(0,229,255,.4)":"var(--border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[e.jsx("span",{style:{fontSize:24},children:u?.emoji||"🤖"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:13},children:u?.name||o}),e.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:u?.role||""})]}),v&&e.jsx("span",{style:{marginLeft:"auto",fontSize:14},children:"👑"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[e.jsx("span",{className:`dot ${B}`}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)"},children:u?.status||"unknown"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4,fontSize:10},children:[e.jsxs("div",{style:{textAlign:"center",background:"var(--surface)",padding:"4px",borderRadius:4},children:[e.jsx("div",{style:{color:"var(--muted)"},children:"Done"}),e.jsx("div",{style:{fontWeight:700,color:"var(--cyan)"},children:u?.tasks_completed||0})]}),e.jsxs("div",{style:{textAlign:"center",background:"var(--surface)",padding:"4px",borderRadius:4},children:[e.jsx("div",{style:{color:"var(--muted)"},children:"Quality"}),e.jsxs("div",{style:{fontWeight:700,color:"var(--amber)"},children:["⭐",(u?.avg_quality||0).toFixed(1)]})]})]})]},o)})}),n==="Workload"&&e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:12},children:"Agent Task Workload"}),e.jsx(ue,{project:t,tasks:i,agents:r})]}),n==="Budget"&&e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:12},children:"Budget"}),e.jsx(he,{project:t})]}),n==="OKRs"&&e.jsxs("div",{children:[e.jsx("div",{className:"section-title",style:{marginBottom:12},children:"OKR Linkage"}),e.jsx(me,{project:t,okrs:a})]}),n==="Activity"&&e.jsx("div",{children:(t._activity||[]).length===0?e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No activity yet."}):(t._activity||[]).map((o,u)=>e.jsx(Y,{item:o,agents:r},u))}),n==="Sessions"&&e.jsx(ve,{sessions:t._sessions,agents:r}),n==="Decisions"&&e.jsx("div",{children:(t.decisions||[]).length===0?e.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"No decisions logged yet."}):(t.decisions||[]).map(o=>{const u=r.find(v=>v.id===o.decided_by);return e.jsxs("div",{style:{marginBottom:12,padding:"12px 14px",background:"var(--surface)",border:"1px solid var(--border)",borderRadius:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[e.jsx("span",{style:{fontSize:14},children:"🧠"}),e.jsx("span",{style:{flex:1,fontWeight:600,fontSize:12},children:o.decision}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)"},children:$(o.decided_at)})]}),o.rationale&&e.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:6},children:o.rationale}),e.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:12},children:[u&&e.jsxs("span",{children:[u.emoji," ",u.name]}),o.task_id&&e.jsxs("span",{children:["Task: ",e.jsx("span",{style:{color:"var(--cyan)"},children:o.task_id})]})]})]},o.id)})})]})]})}function be({agents:t,filters:r,setFilters:i,sortKey:a,setSortKey:d,sortDir:n,setSortDir:g,total:s,visible:x}){const c={background:"var(--surface)",border:"1px solid var(--border)",color:"var(--text)",borderRadius:4,padding:"4px 10px",fontSize:11,fontFamily:"inherit"};return e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",marginBottom:12},children:[e.jsx("input",{placeholder:"🔍 Search…",value:r.search,onChange:l=>i(h=>({...h,search:l.target.value})),style:{...c,flex:"1 1 140px",minWidth:100}}),e.jsxs("select",{value:r.status,onChange:l=>i(h=>({...h,status:l.target.value})),style:c,children:[e.jsx("option",{value:"",children:"All statuses"}),["active","complete","paused","archived","pending"].map(l=>e.jsx("option",{value:l,children:l},l))]}),e.jsxs("select",{value:r.health,onChange:l=>i(h=>({...h,health:l.target.value})),style:c,children:[e.jsx("option",{value:"",children:"All health"}),e.jsx("option",{value:"green",children:"🟢 Green"}),e.jsx("option",{value:"amber",children:"🟡 Amber"}),e.jsx("option",{value:"red",children:"🔴 Red"})]}),e.jsxs("select",{value:r.owner,onChange:l=>i(h=>({...h,owner:l.target.value})),style:c,children:[e.jsx("option",{value:"",children:"All owners"}),t.map(l=>e.jsxs("option",{value:l.id,children:[l.emoji," ",l.name]},l.id))]}),e.jsxs("select",{value:a,onChange:l=>d(l.target.value),style:c,children:[e.jsx("option",{value:"priority_weight",children:"Priority"}),e.jsx("option",{value:"_progress_pct",children:"Progress"}),e.jsx("option",{value:"target_completion",children:"Deadline"}),e.jsx("option",{value:"health",children:"Health"}),e.jsx("option",{value:"_last_activity",children:"Activity"})]}),e.jsx("button",{onClick:()=>g(l=>l==="asc"?"desc":"asc"),style:{...c,cursor:"pointer",padding:"4px 8px"},children:n==="asc"?"↑":"↓"}),(r.search||r.status||r.health||r.owner)&&e.jsx("button",{onClick:()=>i({search:"",status:"",health:"",owner:""}),style:{...c,cursor:"pointer",color:"var(--muted)"},children:"✕ Clear"}),e.jsxs("span",{style:{fontSize:10,color:"var(--muted)",marginLeft:"auto"},children:[x,"/",s]})]})}function we({data:t,lastUpdated:r}){const{projects:i=[],agents:a=[],tasks:d=[],okrs:n}=t,[g,s]=f.useState(null),[x,c]=f.useState({search:"",status:"",health:"",owner:""}),[l,h]=f.useState("priority_weight"),[o,u]=f.useState("desc"),[v,B]=f.useState(!1),b=f.useMemo(()=>{let p=[...i];const{search:k,status:C,health:E,owner:U}=x;k&&(p=p.filter(m=>[m.name,m.description||"",m.id].join(" ").toLowerCase().includes(k.toLowerCase()))),C&&(p=p.filter(m=>m.status===C)),E&&(p=p.filter(m=>j(m)===E)),U&&(p=p.filter(m=>m.owner===U));const q={red:0,amber:1,green:2};return p.sort((m,S)=>{let _,w;return l==="health"?(_=q[j(m)],w=q[j(S)]):l==="target_completion"?(_=m.target_completion?new Date(m.target_completion).getTime():9e15,w=S.target_completion?new Date(S.target_completion).getTime():9e15):l==="_last_activity"?(_=m._last_activity?new Date(m._last_activity).getTime():0,w=S._last_activity?new Date(S._last_activity).getTime():0):(_=m[l]??0,w=S[l]??0),o==="asc"?_>w?1:-1:_<w?1:-1}),p},[i,x,l,o]),O=i.find(p=>p.id===g),A=f.useCallback(p=>s(k=>k===p?null:p),[]),P=b.filter(p=>p.status==="active"),K=b.filter(p=>p.status!=="active"),R=i.reduce((p,k)=>p+(k._risks||[]).filter(C=>!C.resolved).length,0),H=i.filter(p=>j(p)==="red").length,F=i.filter(p=>j(p)==="amber").length;return e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",gap:10,fontSize:11,alignItems:"center"},children:[e.jsxs("span",{style:{color:"var(--muted)"},children:[i.length," project",i.length!==1?"s":""]}),H>0&&e.jsx(y,{label:`🔴 ${H} critical`,color:"var(--red)"}),F>0&&e.jsx(y,{label:`🟡 ${F} at-risk`,color:"var(--amber)"}),R>0&&e.jsx(y,{label:`${R} risk${R>1?"s":""}`,color:"var(--red)"})]}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:6},children:e.jsx("button",{onClick:()=>B(p=>!p),style:{background:"none",border:"1px solid var(--border)",color:"var(--muted)",borderRadius:4,padding:"3px 9px",cursor:"pointer",fontSize:10,fontFamily:"inherit"},children:v?"⊞ Expand All":"⊟ Collapse All"})}),e.jsx(se,{ts:r})]}),e.jsx(be,{agents:a,filters:x,setFilters:c,sortKey:l,setSortKey:h,sortDir:o,setSortDir:u,total:i.length,visible:b.length}),O&&e.jsx(je,{project:O,agents:a,tasks:d,okrs:n,onClose:()=>s(null)}),!v&&P.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-title",children:"Active Projects"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(340px,1fr))",gap:14},children:P.map(p=>e.jsx(J,{project:p,agents:a,selected:g===p.id,onClick:()=>A(p.id)},p.id))})]}),!v&&K.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-title",style:{marginTop:8},children:"Other"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill,minmax(340px,1fr))",gap:14},children:K.map(p=>e.jsx(J,{project:p,agents:a,selected:g===p.id,onClick:()=>A(p.id)},p.id))})]}),b.length===0&&e.jsx("div",{className:"card",style:{color:"var(--muted)",fontSize:13},children:i.length===0?"No projects yet. Cooper writes to PROJECTS.json during sprint planning.":"No projects match your filters."})]})}export{we as default};
@@ -0,0 +1 @@
1
+ import{a4 as e}from"./vendor-5MxLWm27.js";function x({data:n}){const{experiments:d=[],backlog:o=[]}=n,a=n.benchmarks||{},i=a.evaluations||[],c=a.last_run;return e.jsxs("div",{className:"fade-in",style:{display:"grid",gap:14},children:[e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"section-title",children:["Nova Experiments (",d.length,")"]}),d.length===0?e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:"No experiments yet."}):e.jsxs("table",{style:{width:"100%",fontSize:11,borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},children:["ID","Title","Status","Started","Result"].map(t=>e.jsx("th",{style:{textAlign:"left",padding:"4px 8px",fontSize:10,color:"var(--muted)",fontWeight:600,textTransform:"uppercase"},children:t},t))})}),e.jsx("tbody",{children:d.map((t,r)=>{const s=(t.status||"").toLowerCase(),l=s==="complete"?"var(--green)":s==="running"?"var(--cyan)":s==="failed"?"var(--red)":"var(--muted)";return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.03)"},children:[e.jsx("td",{style:{padding:"6px 8px",color:"var(--cyan)",fontFamily:"monospace"},children:t.id||"—"}),e.jsx("td",{style:{padding:"6px 8px",maxWidth:200},children:e.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title||t.hypothesis||"—"})}),e.jsx("td",{style:{padding:"6px 8px"},children:e.jsx("span",{className:"badge",style:{color:l,background:`${l}22`,border:`1px solid ${l}44`},children:t.status||"—"})}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--muted)"},children:t.started_at?new Date(t.started_at).toLocaleDateString():"—"}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--muted)",maxWidth:200},children:e.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.result||t.outcome||"—"})})]},t.id||r)})})]})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"section-title",children:["Evolve Backlog (",o.length,")"]}),o.length===0?e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:"No items yet."}):o.slice(0,20).map((t,r)=>{const s=(t.priority||"").toUpperCase(),l=s==="HIGH"?"P1":s==="MEDIUM"?"P2":s==="LOW"?"P3":s;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 0",borderBottom:"1px solid rgba(255,255,255,.03)"},children:[l&&e.jsx("span",{className:l==="P1"?"p1":l==="P2"?"p2":"p3",children:l}),e.jsx("span",{style:{flex:1,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title||t.description||"—"}),e.jsx("span",{style:{fontSize:10,color:"var(--muted)"},children:t.category||t.type||""}),t.status==="done"&&e.jsx("span",{style:{fontSize:10,color:"var(--green)"},children:"✓"})]},t.id||r)})]}),e.jsxs("div",{className:"card",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:10},children:[e.jsx("span",{className:"section-title",style:{marginBottom:0},children:"Model Benchmarks"}),c&&e.jsxs("span",{style:{fontSize:10,color:"var(--muted)",marginLeft:"auto"},children:["Last run: ",new Date(c).toLocaleDateString()]})]}),i.length===0?e.jsx("div",{style:{color:"var(--muted)",fontSize:11},children:"No benchmark runs yet."}):e.jsxs("table",{style:{width:"100%",fontSize:11,borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--border)"},children:["Model","Score","Latency","Notes"].map(t=>e.jsx("th",{style:{textAlign:"left",padding:"4px 8px",fontSize:10,color:"var(--muted)",fontWeight:600},children:t},t))})}),e.jsx("tbody",{children:i.map((t,r)=>e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,.03)"},children:[e.jsx("td",{style:{padding:"6px 8px",fontFamily:"monospace",fontSize:10},children:t.model||"—"}),e.jsxs("td",{style:{padding:"6px 8px",color:"var(--amber)"},children:["⭐",(t.score??0).toFixed(2)]}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--muted)"},children:t.latency_ms?`${t.latency_ms}ms`:"—"}),e.jsx("td",{style:{padding:"6px 8px",color:"var(--muted)",fontSize:10},children:t.notes||"—"})]},r))})]})]})]})}export{x as default};