@jx0/agency 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -49
- package/dashboard/out/404.html +1 -1
- package/dashboard/out/_next/static/chunks/app/_not-found/{page-ad40673d821037f6.js → page-5cb94002960ab71a.js} +1 -1
- package/dashboard/out/_next/static/chunks/app/layout-6249f74085ad56b1.js +1 -0
- package/dashboard/out/_next/static/chunks/app/page-0a5ee03ddf4553ab.js +1 -0
- package/dashboard/out/_next/static/chunks/{main-app-1d848b791b823fa6.js → main-app-0398d52862f5c730.js} +1 -1
- package/dashboard/out/_next/static/css/a13af72b10a7d74f.css +1 -0
- package/dashboard/out/index.html +1 -1
- package/dashboard/out/index.txt +4 -4
- package/docs/images/agency_cli_ps.png +0 -0
- package/docs/images/agency_ui_ai_prodivder_settings.png +0 -0
- package/docs/images/agency_ui_aws_settings.png +0 -0
- package/docs/images/agency_ui_identity_settings.png +0 -0
- package/docs/images/agency_ui_import_skills.jpeg +0 -0
- package/docs/images/agency_ui_knowledge.png +0 -0
- package/docs/images/agency_ui_mission_control.png +0 -0
- package/docs/images/agency_ui_skills_marketplace.png +0 -0
- package/docs/images/agent_ui_agent_config.png +0 -0
- package/package.json +9 -1
- package/src/api/db/migrations/004_nullable_human_refs.ts +129 -0
- package/src/api/db/migrations/005_agent_skills.ts +14 -0
- package/src/api/db/migrations/006_runtime_machine.ts +24 -0
- package/src/api/db/seed.ts +62 -46
- package/src/api/index.ts +11 -4
- package/src/api/lib/deploy.ts +412 -0
- package/src/api/lib/env-vars.ts +19 -0
- package/src/api/lib/exec.ts +77 -0
- package/src/api/lib/fleet-sync.ts +49 -32
- package/src/api/lib/fs-store.ts +350 -0
- package/src/api/lib/import-skills.ts +105 -0
- package/src/api/lib/metrics.ts +183 -0
- package/src/api/lib/processes.ts +82 -12
- package/src/api/lib/provision-openclaw.ts +376 -0
- package/src/api/lib/remote-deploy.ts +77 -0
- package/src/api/lib/ssh.ts +97 -0
- package/src/api/lib/sync-skills.ts +171 -0
- package/src/api/lib/tunnels.ts +7 -38
- package/src/api/routes/agents.ts +184 -132
- package/src/api/routes/documents.ts +24 -5
- package/src/api/routes/knowledge.ts +7 -5
- package/src/api/routes/machines.ts +107 -0
- package/src/api/routes/messages.ts +23 -19
- package/src/api/routes/repos.ts +74 -0
- package/src/api/routes/role-configs.ts +29 -46
- package/src/api/routes/skills.ts +198 -40
- package/src/api/routes/tasks.ts +24 -11
- package/src/cli/commands/init.ts +47 -18
- package/src/cli/commands/machines.ts +97 -0
- package/src/cli/commands/ps.ts +6 -4
- package/src/cli/commands/repos.ts +78 -0
- package/src/cli/commands/ssh.ts +14 -36
- package/src/cli/index.ts +5 -1
- package/src/daemon.ts +120 -1
- package/src/templates/solo/agents-config.md +39 -0
- package/src/templates/solo/agents.md +41 -0
- package/src/templates/solo/heartbeat.md +48 -0
- package/src/templates/solo/tools.md +35 -0
- package/dashboard/out/_next/static/chunks/app/layout-056f12675e691d12.js +0 -1
- package/dashboard/out/_next/static/chunks/app/page-80f01fdbb09b43c8.js +0 -1
- package/dashboard/out/_next/static/css/27d1ea794f04e96a.css +0 -1
- /package/dashboard/out/_next/static/{pU1nwWH_dNUOCI8y4nl3C → TCwq0pYHnHPlPIcOGjzu7}/_buildManifest.js +0 -0
- /package/dashboard/out/_next/static/{pU1nwWH_dNUOCI8y4nl3C → TCwq0pYHnHPlPIcOGjzu7}/_ssgManifest.js +0 -0
package/README.md
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
# Agency
|
|
1
|
+
# Agency
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Run a team of AI agents that write code together.**
|
|
4
|
+
|
|
5
|
+
Agency is an orchestrator + worker platform for autonomous software development. An orchestrator agent breaks down work into tasks, assigns them to worker agents, and reviews results. Workers claim tasks, write code, run tests, and report back. You manage everything from a dashboard or CLI.
|
|
6
|
+
|
|
7
|
+
Each agent is an [OpenClaw](https://openclaw.ai/) instance with full shell access, file I/O, and browser control. Agency adds the coordination layer on top: task routing, inter-agent messaging, a skill marketplace, role-based configuration, knowledge sharing, per-agent skill selection, and fleet management across local, Docker, and remote SSH deployments.
|
|
8
|
+
|
|
9
|
+

|
|
4
10
|
|
|
5
11
|
```
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
└───────────┬───────────┘
|
|
19
|
-
│ Tasks (via API)
|
|
20
|
-
┌───────────┼───────────┐
|
|
21
|
-
▼ ▼ ▼
|
|
22
|
-
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
23
|
-
│ Worker A │ │ Worker B │ │ Worker C │
|
|
24
|
-
│ (OpenClaw)│ │(OpenClaw)│ │(OpenClaw)│
|
|
25
|
-
│ │ │ │ │ │
|
|
26
|
-
│ Claims → │ │ │ │ │
|
|
27
|
-
│ Codes → │ │ ... │ │ ... │
|
|
28
|
-
│ Ships │ │ │ │ │
|
|
29
|
-
└──────────┘ └──────────┘ └──────────┘
|
|
12
|
+
You (dashboard / CLI)
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
┌─────────────┐
|
|
16
|
+
│ Orchestrator │ Investigates → Plans → Delegates
|
|
17
|
+
└──────┬──────┘
|
|
18
|
+
│ tasks via API
|
|
19
|
+
┌─────────┼─────────┐
|
|
20
|
+
▼ ▼ ▼
|
|
21
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
22
|
+
│ Worker A│ │ Worker B│ │ Worker C│ Claims → Codes → Ships
|
|
23
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
30
24
|
```
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
### Highlights
|
|
27
|
+
|
|
28
|
+
- **Multi-agent coordination** — Orchestrator decomposes work, workers execute in parallel, task comments serve as the communication channel
|
|
29
|
+
- **Skill marketplace** — Browse and install skills from [anthropics/skills](https://github.com/anthropics/skills), [obra/superpowers](https://github.com/obra/superpowers), [ComposioHQ/awesome-claude-skills](https://github.com/ComposioHQ/awesome-claude-skills), or any repo that follows the convention
|
|
30
|
+
- **Deploy anywhere** — Local (Bun subprocess), Docker, or any remote SSH host with automatic reverse tunnels
|
|
31
|
+
- **Knowledge base** — Agents learn facts during work and share them with the team
|
|
32
|
+
- **Role system** — Configure agent behavior with Soul, Identity, Tools, Agents, and Heartbeat prompts per role
|
|
33
|
+
- **Claude Max OAuth** — Use your Claude subscription directly, no API key required
|
|
34
|
+
- **Single binary** — `bun install -g @jx0/agency` — API, dashboard, and CLI in one package
|
|
33
35
|
|
|
34
36
|
## Install
|
|
35
37
|
|
|
@@ -74,7 +76,9 @@ Created by `agency init`. This is the only directory Agency writes to in your pr
|
|
|
74
76
|
```
|
|
75
77
|
.agency/
|
|
76
78
|
├── agency.db # SQLite database (all state)
|
|
77
|
-
|
|
79
|
+
├── fleet.json # Agent fleet config
|
|
80
|
+
├── repos.json # Git repos for agent workspaces
|
|
81
|
+
└── machines.json # Remote SSH host configurations
|
|
78
82
|
```
|
|
79
83
|
|
|
80
84
|
Everything else — settings, skills, role configs — lives in the database, editable via the dashboard or CLI.
|
|
@@ -89,7 +93,7 @@ agency ps List agents
|
|
|
89
93
|
agency start <name> Start an agent
|
|
90
94
|
agency stop <name> Stop an agent
|
|
91
95
|
agency logs <name> Tail agent logs
|
|
92
|
-
agency ssh <name> SSH into agent (
|
|
96
|
+
agency ssh <name> SSH into agent (remote only)
|
|
93
97
|
agency tasks create <title> [flags] Create a task
|
|
94
98
|
agency tasks list [--status S] List tasks
|
|
95
99
|
agency tasks ready Show your assigned tasks
|
|
@@ -116,6 +120,10 @@ agency skills list List skills
|
|
|
116
120
|
agency skills show <id> Show a skill
|
|
117
121
|
agency skills create <name> Create a skill (stdin)
|
|
118
122
|
agency skills delete <id> Delete a skill
|
|
123
|
+
agency machines list List configured machines
|
|
124
|
+
agency machines add <name> [flags] Add a machine (--host, --user, --port, --auth, --key-file)
|
|
125
|
+
agency machines remove <name> Remove a machine
|
|
126
|
+
agency machines show <name> Show machine details
|
|
119
127
|
agency --version Show version
|
|
120
128
|
```
|
|
121
129
|
|
|
@@ -137,9 +145,15 @@ agency --version Show version
|
|
|
137
145
|
| GET | `/notifications/pending/:agent` | Pending notifications |
|
|
138
146
|
| GET/POST | `/knowledge` | Knowledge base |
|
|
139
147
|
| GET/POST | `/documents` | Documents |
|
|
148
|
+
| GET/PUT | `/documents/:id` | Document details/update |
|
|
140
149
|
| GET/PUT/DELETE | `/settings` | Settings (key-value) |
|
|
141
|
-
| GET/POST/PUT/DELETE | `/skills` | Skills
|
|
150
|
+
| GET/POST/PUT/DELETE | `/skills` | Skills CRUD |
|
|
151
|
+
| GET | `/skills/available` | List skills from public repos |
|
|
152
|
+
| GET | `/skills/import/preview?url=` | Preview importable skills from a repo |
|
|
153
|
+
| POST | `/skills/import` | Import skills from a GitHub repo |
|
|
142
154
|
| GET/PUT/DELETE | `/role-configs/:role/:type` | Role configuration docs |
|
|
155
|
+
| GET/POST/PUT/DELETE | `/repos` | Git repo configuration (wtm-managed) |
|
|
156
|
+
| GET/POST/PUT/DELETE | `/machines` | Remote SSH machine configuration |
|
|
143
157
|
|
|
144
158
|
## Database Schema
|
|
145
159
|
|
|
@@ -159,13 +173,25 @@ All state lives in `.agency/agency.db` (SQLite):
|
|
|
159
173
|
|
|
160
174
|
## Dashboard
|
|
161
175
|
|
|
162
|
-
|
|
176
|
+
Eight views accessible from the top nav:
|
|
163
177
|
|
|
164
178
|
- **Mission Control** — Agent roster + task kanban board + live activity feed
|
|
165
179
|
- **Agent Config** — Browse agent workspace files (served from role_configs in DB)
|
|
166
|
-
- **Settings** — Categorized editor for Identity, AI Provider,
|
|
167
|
-
- **Skills** —
|
|
180
|
+
- **Settings** — Categorized editor for Identity, AI Provider, Agent Defaults, Repos, and Machines
|
|
181
|
+
- **Skills** — Browse installed skills, discover and install from public repos, or create custom skills
|
|
168
182
|
- **Roles** — Markdown editor for role configs (Heartbeat, Tools, Agents, etc.)
|
|
183
|
+
- **Knowledge** — Key-value knowledge base editor with tag filtering and search
|
|
184
|
+
- **Docs** — Document editor for creating and managing team documents
|
|
185
|
+
|
|
186
|
+
### Mission Control
|
|
187
|
+
|
|
188
|
+
The main dashboard view shows your agent roster on the left, a kanban board of tasks organized by status (Inbox, Assigned, In Progress, Review, Done), and a live activity feed on the right.
|
|
189
|
+
|
|
190
|
+

|
|
191
|
+
|
|
192
|
+
### Agent Config
|
|
193
|
+
|
|
194
|
+
Configure each agent's role-specific prompts. Select an agent from the sidebar to view and edit their Soul, User, Agents, Memory, and Tools configuration tabs. Deploy, stop, or delete agents directly from this view.
|
|
169
195
|
|
|
170
196
|

|
|
171
197
|
|
|
@@ -173,10 +199,56 @@ Five views accessible from the top nav:
|
|
|
173
199
|
|
|
174
200
|
Sensitive values (API keys, SSH keys, credentials) are masked in the API and revealed on demand in the UI. AI provider settings support both direct API key entry and Claude Max OAuth (import tokens from Claude Code with one click).
|
|
175
201
|
|
|
202
|
+
Categories: **Identity**, **AI Provider**, **Agent Defaults**, **Repos**, and **Machines**.
|
|
203
|
+
|
|
204
|
+
- **Repos** — Configure git repositories managed via [wtm](https://github.com/jarredkenny/worktree-manager) (worktree-manager). Each repo has a name, URL, and default base branch. Agents use `wtm init` to set up bare repos and `wtm create --from <base>` to spawn isolated worktrees for each coding task.
|
|
205
|
+
- **Machines** — Configure remote SSH hosts for deploying agents. Each machine has a name, host, user, port, and SSH key. Keys are masked in the API and UI.
|
|
206
|
+
|
|
176
207
|
| | |
|
|
177
208
|
|---|---|
|
|
178
209
|
|  |  |
|
|
179
|
-
|
|
210
|
+
|
|
211
|
+
### Skills
|
|
212
|
+
|
|
213
|
+
The skills view has two tabs — **Installed** and **Available**.
|
|
214
|
+
|
|
215
|
+
**Installed** shows all skills currently in your database. Select a skill to view and edit its markdown body. Create new custom skills with the + button, or search and delete existing ones.
|
|
216
|
+
|
|
217
|
+
**Available** aggregates skills from known public repositories ([anthropics/skills](https://github.com/anthropics/skills), [obra/superpowers](https://github.com/obra/superpowers), [ComposioHQ/awesome-claude-skills](https://github.com/ComposioHQ/awesome-claude-skills)). Browse descriptions, see which are already installed, and install any skill with one click. The list is cached server-side for 5 minutes.
|
|
218
|
+
|
|
219
|
+

|
|
220
|
+
|
|
221
|
+
You can also bulk-import from any GitHub repo that follows the `skills/<name>/SKILL.md` or `<name>/SKILL.md` convention. Click **Import**, enter a repo URL, preview the available skills, select which to import, and confirm.
|
|
222
|
+
|
|
223
|
+

|
|
224
|
+
|
|
225
|
+
Skills are synced to disk and pushed to all active agents whenever they change.
|
|
226
|
+
|
|
227
|
+
### Knowledge
|
|
228
|
+
|
|
229
|
+
Key-value knowledge base editor. Agents and humans store learned facts and context as knowledge entries, each with a unique key, content body, and tags. The sidebar supports search (filters by key and content) and tag display. Create new entries inline, edit content and tags, and save — entries are upserted by key.
|
|
230
|
+
|
|
231
|
+

|
|
232
|
+
|
|
233
|
+
CLI equivalent:
|
|
234
|
+
```bash
|
|
235
|
+
agency learn "postgres needs --lock-timeout 5s" --tags postgres,ops
|
|
236
|
+
agency recall "postgres"
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Roles
|
|
240
|
+
|
|
241
|
+
Editor for role configuration documents. Each agent role (e.g. orchestrator, implementer) has a set of config types — Heartbeat, Tools, Agents, Soul, Identity — that control how agents behave. Select a role and config type from the sidebar to edit the markdown content.
|
|
242
|
+
|
|
243
|
+
### Docs
|
|
244
|
+
|
|
245
|
+
Document editor for creating and managing team documents. Documents have a title, content body, and type label. Create new documents from the sidebar, edit title/content/type in the editor panel, and save. Documents serve as an audit trail — there is no delete.
|
|
246
|
+
|
|
247
|
+
CLI equivalent:
|
|
248
|
+
```bash
|
|
249
|
+
agency doc create "Architecture Decision Record" --type adr < content.md
|
|
250
|
+
agency doc show <id>
|
|
251
|
+
```
|
|
180
252
|
|
|
181
253
|
## How It Works
|
|
182
254
|
|
|
@@ -186,7 +258,8 @@ Every agent in Agency is an [OpenClaw](https://openclaw.ai/) instance. OpenClaw
|
|
|
186
258
|
|
|
187
259
|
- **Role configs** — each agent gets injected with role-specific prompts (Soul, Identity, Tools, Agents, Heartbeat) that define its behavior
|
|
188
260
|
- **Task coordination** — agents poll the Agency API for assigned work, post progress via task comments, and transition tasks through the workflow
|
|
189
|
-
- **Fleet management** — deploy agents locally (Bun subprocess), via Docker, or on
|
|
261
|
+
- **Fleet management** — deploy agents locally (Bun subprocess), via Docker, or on any remote SSH host with automatic tunnels
|
|
262
|
+
- **Per-agent skills** — select which skills each agent receives from the skill chooser in the agent detail panel
|
|
190
263
|
|
|
191
264
|
Agents can run any model OpenClaw supports (Claude, GPT, local models), configured through the AI Provider settings.
|
|
192
265
|
|
|
@@ -196,34 +269,29 @@ Agents can run any model OpenClaw supports (Claude, GPT, local models), configur
|
|
|
196
269
|
|------|-------------|
|
|
197
270
|
| **Local** | Spawns a Bun subprocess on the host machine. Agent talks to API at `localhost:3100` directly. |
|
|
198
271
|
| **Docker** | Runs `docker compose up` for the agent container. |
|
|
199
|
-
| **
|
|
272
|
+
| **Remote** | Connects to a configured SSH machine, deploys the agent, and opens a reverse tunnel back to the host API. |
|
|
200
273
|
|
|
201
|
-
####
|
|
202
|
-
|
|
203
|
-
1. Configure SSH in Settings → SSH (paste your private key, set the username)
|
|
204
|
-
2. Add `host` to the agent's entry in `.agency/fleet.json`:
|
|
205
|
-
|
|
206
|
-
```json
|
|
207
|
-
{
|
|
208
|
-
"agents": {
|
|
209
|
-
"nova": { "role": "implementer", "location": "ec2", "host": "54.123.45.67" }
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
```
|
|
274
|
+
#### Remote Agent Setup
|
|
213
275
|
|
|
276
|
+
1. Add a machine in **Settings → Machines** (host, user, port, SSH private key)
|
|
277
|
+
2. Create an agent with location **Remote** and select the machine from the dropdown
|
|
214
278
|
3. Click **Deploy** in the dashboard (or `agency start nova`)
|
|
215
279
|
|
|
216
280
|
The daemon opens `ssh -R 3100:localhost:3100 user@host -N` — a persistent reverse tunnel with auto-reconnect. The remote agent's CLI commands (`agency tasks list`, `agency msg`, etc.) hit `localhost:3100` which forwards through the tunnel to the host API. No agent-side configuration needed.
|
|
217
281
|
|
|
218
282
|
On stop, the tunnel is torn down. On daemon shutdown, all tunnels are cleaned up.
|
|
219
283
|
|
|
220
|
-
You can also SSH directly into any
|
|
284
|
+
You can also SSH directly into any remote agent:
|
|
221
285
|
|
|
222
286
|
```bash
|
|
223
287
|
agency ssh nova # interactive shell
|
|
224
288
|
agency ssh nova ls -la # run a command
|
|
225
289
|
```
|
|
226
290
|
|
|
291
|
+
### Per-Agent Skills
|
|
292
|
+
|
|
293
|
+
Each agent can be configured to receive only a subset of installed skills. In the agent detail panel, use the skill chooser to select which skills the agent should have. If no skills are selected, the agent receives all skills (default behavior). Selected skills are stored in `fleet.json` and synced to the agent on deploy.
|
|
294
|
+
|
|
227
295
|
### Task Lifecycle
|
|
228
296
|
|
|
229
297
|
```
|
package/dashboard/out/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><!--
|
|
1
|
+
<!DOCTYPE html><!--TCwq0pYHnHPlPIcOGjzu7--><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/a13af72b10a7d74f.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-4e6bf084ac60582b.js"/><script src="/_next/static/chunks/4bd1b696-c023c6e3521b1417.js" async=""></script><script src="/_next/static/chunks/255-67e8754147461423.js" async=""></script><script src="/_next/static/chunks/main-app-0398d52862f5c730.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><title>Agency</title><meta name="description" content="Agency AI Dashboard"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="min-h-screen"><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-4e6bf084ac60582b.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[9766,[],\"\"]\n3:I[8924,[],\"\"]\n4:I[4431,[],\"OutletBoundary\"]\n6:I[5278,[],\"AsyncMetadataOutlet\"]\n8:I[4431,[],\"ViewportBoundary\"]\na:I[4431,[],\"MetadataBoundary\"]\nb:\"$Sreact.suspense\"\nd:I[7150,[],\"\"]\n:HL[\"/_next/static/css/a13af72b10a7d74f.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"TCwq0pYHnHPlPIcOGjzu7\",\"p\":\"\",\"c\":[\"\",\"_not-found\"],\"i\":false,\"f\":[[[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],[\"\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/a13af72b10a7d74f.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\",\"nonce\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"min-h-screen\",\"children\":[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]}]}]]}],{\"children\":[\"/_not-found\",[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[\"__PAGE__\",[\"$\",\"$1\",\"c\",{\"children\":[[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":404}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null,[\"$\",\"$L4\",null,{\"children\":[\"$L5\",[\"$\",\"$L6\",null,{\"promise\":\"$@7\"}]]}]]}],{},null,false]},null,false]},null,false],[\"$\",\"$1\",\"h\",{\"children\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],[[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],null],[\"$\",\"$La\",null,{\"children\":[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$b\",null,{\"fallback\":null,\"children\":\"$Lc\"}]}]}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$d\",[]],\"s\":false,\"S\":true}\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n5:null\n"])</script><script>self.__next_f.push([1,"7:{\"metadata\":[[\"$\",\"title\",\"0\",{\"children\":\"Agency\"}],[\"$\",\"meta\",\"1\",{\"name\":\"description\",\"content\":\"Agency AI Dashboard\"}]],\"error\":null,\"digest\":\"$undefined\"}\n"])</script><script>self.__next_f.push([1,"c:\"$7:metadata\"\n"])</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[492],{4585:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"styles",{enumerable:!0,get:function(){return l}});let l={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},desc:{display:"inline-block"},h1:{display:"inline-block",margin:"0 20px 0 0",padding:"0 23px 0 0",fontSize:24,fontWeight:500,verticalAlign:"top",lineHeight:"49px"},h2:{fontSize:14,fontWeight:400,lineHeight:"49px",margin:0}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[492],{4585:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"styles",{enumerable:!0,get:function(){return l}});let l={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},desc:{display:"inline-block"},h1:{display:"inline-block",margin:"0 20px 0 0",padding:"0 23px 0 0",fontSize:24,fontWeight:500,verticalAlign:"top",lineHeight:"49px"},h2:{fontSize:14,fontWeight:400,lineHeight:"49px",margin:0}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8408:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/_not-found/page",function(){return l(9520)}])},8886:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"HTTPAccessErrorFallback",{enumerable:!0,get:function(){return o}});let r=l(5155),n=l(4585);function o(e){let{status:t,message:l}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:t+": "+l}),(0,r.jsx)("div",{style:n.styles.error,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}),(0,r.jsx)("h1",{className:"next-error-h1",style:n.styles.h1,children:t}),(0,r.jsx)("div",{style:n.styles.desc,children:(0,r.jsx)("h2",{style:n.styles.h2,children:l})})]})})]})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},9520:(e,t,l)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let r=l(5155),n=l(8886),o=function(){return(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)(n.HTTPAccessErrorFallback,{status:404,message:"This page could not be found."})})})};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},e=>{e.O(0,[441,255,358],()=>e(e.s=8408)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{3673:()=>{},7877:(e,s,_)=>{Promise.resolve().then(_.t.bind(_,3673,23))}},e=>{e.O(0,[978,441,255,358],()=>e(e.s=7877)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1768:(e,t,a)=>{Promise.resolve().then(a.bind(a,2139))},2139:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>H});var s,r=a(5155),l=a(2115);let n=null!=(s=a(5704).env.NEXT_PUBLIC_API_URL)?s:"";async function o(e){let t=await fetch("".concat(n).concat(e),{cache:"no-store"});if(!t.ok)throw Error("API error: ".concat(t.status));return t.json()}async function c(e,t,a){let s=await fetch("".concat(n).concat(e),{method:t,headers:a?{"Content-Type":"application/json"}:void 0,body:a?JSON.stringify(a):void 0});if(!s.ok){var r;throw Error(null!=(r=(await s.json().catch(()=>({error:"HTTP ".concat(s.status)}))).error)?r:"API error: ".concat(s.status))}return s.json()}let d=[{key:"mission",label:"Tasks"},{key:"config",label:"Agents"},{key:"roles",label:"Roles"},{key:"skills",label:"Skills"},{key:"documents",label:"Docs"},{key:"knowledge",label:"Knowledge"}];function i(e){let{activeView:t,onViewChange:a}=e,[s,n]=(0,l.useState)(""),[c,i]=(0,l.useState)(!0);return(0,l.useEffect)(()=>{let e=async()=>{try{await o("/agents"),i(!0)}catch(e){i(!1)}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,l.useEffect)(()=>{let e=()=>{n(new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[]),(0,r.jsxs)("header",{style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border)"},className:"h-14 flex items-center justify-between px-5 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-white text-xs font-bold",style:{background:"var(--accent-green)"},children:"A"}),(0,r.jsx)("span",{className:"font-semibold text-sm",children:"Agency"})]}),(0,r.jsx)("nav",{className:"flex gap-1",children:d.map(e=>(0,r.jsx)("button",{onClick:()=>a(e.key),className:"px-3 py-1.5 rounded-md text-sm font-medium transition-colors",style:{background:t===e.key?"var(--bg-tertiary)":"transparent",color:t===e.key?"var(--text-primary)":"var(--text-secondary)"},children:e.label},e.key))})]}),(0,r.jsxs)("div",{className:"flex items-center gap-4 text-sm",children:[(0,r.jsx)("button",{onClick:()=>a("settings"),className:"w-8 h-8 rounded-md flex items-center justify-center transition-colors",style:{background:"settings"===t?"var(--bg-tertiary)":"transparent",color:"settings"===t?"var(--text-primary)":"var(--text-secondary)"},title:"Settings",children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M6.86 1.45a1.2 1.2 0 0 1 2.28 0l.2.6a1.2 1.2 0 0 0 1.57.7l.58-.24a1.2 1.2 0 0 1 1.6 1.14l-.02.63a1.2 1.2 0 0 0 1.04 1.22l.62.1a1.2 1.2 0 0 1 .8 1.97l-.43.46a1.2 1.2 0 0 0 0 1.6l.43.46a1.2 1.2 0 0 1-.8 1.97l-.62.1a1.2 1.2 0 0 0-1.04 1.22l.02.63a1.2 1.2 0 0 1-1.6 1.14l-.58-.24a1.2 1.2 0 0 0-1.57.7l-.2.6a1.2 1.2 0 0 1-2.28 0l-.2-.6a1.2 1.2 0 0 0-1.57-.7l-.58.24a1.2 1.2 0 0 1-1.6-1.14l.02-.63a1.2 1.2 0 0 0-1.04-1.22l-.62-.1a1.2 1.2 0 0 1-.8-1.97l.43-.46a1.2 1.2 0 0 0 0-1.6l-.43-.46a1.2 1.2 0 0 1 .8-1.97l.62-.1A1.2 1.2 0 0 0 2.91 4.3l-.02-.63a1.2 1.2 0 0 1 1.6-1.14l.58.24a1.2 1.2 0 0 0 1.57-.7l.2-.6Z"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"2.5"})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-2",style:{color:"var(--text-muted)"},children:[(0,r.jsx)("span",{className:"font-mono text-xs",children:s}),(0,r.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(c?"bg-green-500":"bg-red-500")})]})]})]})}let x={orchestrator:{label:"LEAD",color:"#5c7c5a",bg:"#e8f0e7"},implementer:{label:"INT",color:"#5c6b8c",bg:"#e7ecf0"},specialist:{label:"SPC",color:"#8c6b5c",bg:"#f0ece7"}},m={system:{label:"SYS",color:"#6b7280",bg:"#f3f4f6"},docker:{label:"DOCKER",color:"#2563eb",bg:"#eff6ff"}};function u(e){return e>=0x40000000?(e/0x40000000).toFixed(1)+" GB":e>=1048576?(e/1048576).toFixed(0)+" MB":(e/1024).toFixed(0)+" KB"}function p(e){let{label:t,percent:a,detail:s}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[9px] w-6 shrink-0",style:{color:"var(--text-muted)"},children:t}),(0,r.jsx)("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden",style:{background:"var(--border)"},children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:"".concat(Math.max(2,a),"%"),background:a>=80?"#ef4444":a>=50?"#eab308":"#22c55e"}})}),(0,r.jsx)("span",{className:"text-[9px] w-12 text-right shrink-0",style:{color:"var(--text-muted)"},children:s})]})}function y(e){let{agents:t}=e;return(0,r.jsxs)("div",{className:"w-[200px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsx)("div",{className:"px-4 py-3 text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"AGENTS"}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:t.map(e=>{var t,a;let s=null!=(a=x[t=e.role])?a:{label:t.slice(0,3).toUpperCase(),color:"#6b6b6b",bg:"#f0f0f0"};return(0,r.jsx)("div",{className:"px-2 py-2 rounded-md hover:bg-black/[0.03] cursor-default",children:(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 ".concat("active"===e.status?"bg-green-500":"blocked"===e.status?"bg-red-500":"bg-gray-400")}),(0,r.jsx)("span",{className:"text-sm font-semibold truncate",children:e.name})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[(0,r.jsx)("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded",style:{color:s.color,background:s.bg},children:s.label}),e.runtime&&m[e.runtime]&&(0,r.jsx)("span",{className:"text-[9px] font-bold px-1 py-0.5 rounded",style:{color:m[e.runtime].color,background:m[e.runtime].bg},children:m[e.runtime].label}),e.machine&&(0,r.jsx)("span",{className:"text-[9px] font-bold px-1 py-0.5 rounded",style:{color:"#7c3aed",background:"#f5f3ff"},children:e.machine})]}),e.metrics&&(0,r.jsxs)("div",{className:"mt-1 space-y-0.5",children:[(0,r.jsx)(p,{label:"CPU",percent:e.metrics.cpuPercent,detail:"".concat(e.metrics.cpuPercent,"%")}),(0,r.jsx)(p,{label:"MEM",percent:e.metrics.memTotalBytes>0?Math.round(e.metrics.memUsedBytes/e.metrics.memTotalBytes*100):0,detail:"".concat(u(e.metrics.memUsedBytes),"/").concat(u(e.metrics.memTotalBytes))})]})]})},e.id)})})]})}let h={1:"var(--accent-red)",2:"var(--accent-yellow)",3:"var(--border)"};function v(e){var t,a,s,l;let{task:n,onClick:o}=e,c=null==(t=n.assignees)?void 0:t[0],d=null!=(s=n.updated_at)?s:n.created_at;return(0,r.jsxs)("button",{onClick:o,className:"w-full text-left rounded-lg p-3 transition-all hover:shadow-md",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-light)",borderLeft:"3px solid ".concat(null!=(l=h[n.priority])?l:"var(--border)")},children:[(0,r.jsx)("div",{className:"font-semibold text-sm mb-1 leading-snug",children:n.title}),n.description&&(0,r.jsx)("div",{className:"text-xs mb-2 leading-relaxed line-clamp-2",style:{color:"var(--text-secondary)"},children:n.description}),(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-white text-[9px] font-bold",style:{background:"var(--accent-blue)"},children:c.name.charAt(0).toUpperCase()}),(0,r.jsx)("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:c.name})]}),d&&(0,r.jsxs)("span",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:[c?" \xb7 ":"",function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let a=Math.floor(t/60);if(a<60)return"".concat(a,"m ago");let s=Math.floor(a/60);if(s<24)return"about ".concat(s," hour").concat(s>1?"s":""," ago");let r=Math.floor(s/24);return"".concat(r,"d ago")}(d)]})]})}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:n.task_type}),c&&(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:"var(--accent-blue)",color:"white"},children:c.name}),null==(a=n.tags)?void 0:a.map(e=>(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e},e))]})]})}let b=["inbox","assigned","in_progress","review","done"];function g(e){var t;let{taskId:a,onClose:s}=e,[n,d]=(0,l.useState)(null),[i,x]=(0,l.useState)([]),[m,u]=(0,l.useState)(""),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(""),g=(0,l.useCallback)(()=>{o("/tasks/".concat(a)).then(d).catch(console.error)},[a]);(0,l.useEffect)(()=>{g(),o("/agents").then(x).catch(console.error);let e=setInterval(g,5e3);return()=>clearInterval(e)},[g]);let f=async e=>{await c("/tasks/".concat(a),"PATCH",{status:e,from:"human"}),g()},j=async()=>{if(h)try{await c("/tasks/".concat(a,"/assign"),"POST",{agentName:h}),v(""),g()}catch(e){console.error("Assign failed:",e.message),alert(e.message)}},k=async()=>{if(m.trim()){y(!0);try{await c("/tasks/".concat(a,"/messages"),"POST",{from:"human",content:m.trim()}),u(""),g()}catch(e){console.error(e.message)}finally{y(!1)}}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/20 z-40",onClick:s}),(0,r.jsxs)("div",{className:"fixed inset-y-0 right-0 w-[600px] overflow-y-auto z-50 shadow-xl flex flex-col",style:{background:"var(--bg-secondary)",borderLeft:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto",children:[(0,r.jsx)("button",{onClick:s,className:"mb-4 text-sm font-medium px-2 py-1 rounded hover:bg-black/5 transition-colors",style:{color:"var(--text-secondary)"},children:"Close"}),n&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h2",{className:"text-xl font-bold",children:n.title}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2 items-center",children:b.map(e=>(0,r.jsx)("button",{onClick:()=>f(e),className:"px-2 py-1 rounded text-xs font-medium transition-colors",style:{background:n.status===e?"var(--accent-green)":"var(--bg-tertiary)",color:n.status===e?"white":"var(--text-secondary)"},children:e.replace("_"," ")},e))}),(0,r.jsxs)("div",{className:"text-sm",style:{color:"var(--text-secondary)"},children:["Priority: P",n.priority," \xb7 Assignees:"," ",(null==(t=n.assignees)?void 0:t.map(e=>e.name).join(", "))||"none"]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsxs)("select",{value:h,onChange:e=>v(e.target.value),className:"px-2 py-1 rounded text-sm",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("option",{value:"",children:"Assign agent..."}),i.filter(e=>"human"!==e.name).map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}),h&&(0,r.jsx)("button",{onClick:j,className:"px-3 py-1 rounded text-xs font-medium text-white",style:{background:"var(--accent-blue)"},children:"Assign"})]}),n.description&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"DESCRIPTION"}),(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap rounded p-3",style:{background:"var(--bg-tertiary)"},children:n.description})]}),n.design&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"DESIGN"}),(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap rounded p-3",style:{background:"var(--bg-tertiary)"},children:n.design})]}),n.acceptance&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"ACCEPTANCE"}),(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap rounded p-3",style:{background:"var(--bg-tertiary)"},children:n.acceptance})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"MESSAGES"}),(0,r.jsx)("div",{className:"space-y-2 mb-3",children:n.messages&&n.messages.length>0?n.messages.map((e,t)=>{var a;return(0,r.jsxs)("div",{className:"pl-3",style:{borderLeft:"2px solid var(--border)"},children:[(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[(0,r.jsx)("span",{className:"font-bold",style:{color:"var(--text-secondary)"},children:null!=(a=e.from_name)?a:"?"})," ","\xb7 ",new Date(e.created_at).toLocaleString()]}),(0,r.jsx)("div",{className:"text-sm mt-0.5",children:e.content})]},t)}):(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No messages yet"})})]})]})]}),n&&(0,r.jsx)("div",{className:"p-4 border-t",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:m,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),k())},placeholder:"Write a message...",className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{onClick:k,disabled:p||!m.trim(),className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:p||!m.trim()?.5:1},children:p?"...":"Send"})]})})]})]})}function f(e){let{open:t,onClose:a,onCreated:s}=e,[n,d]=(0,l.useState)(""),[i,x]=(0,l.useState)(""),[m,u]=(0,l.useState)(2),[p,y]=(0,l.useState)("task"),[h,v]=(0,l.useState)(""),[b,g]=(0,l.useState)([]),[f,j]=(0,l.useState)(null),[k,N]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{t&&o("/agents").then(g).catch(console.error)},[t]),!t)return null;let w=async e=>{e.preventDefault(),j(null),N(!0);try{await c("/tasks","POST",{title:n,description:i,from:"human",priority:m,task_type:p,...h?{assign:h}:{}}),d(""),x(""),u(2),y("task"),v(""),s(),a()}catch(e){j(e.message)}finally{N(!1)}};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:a,children:(0,r.jsxs)("form",{onClick:e=>e.stopPropagation(),onSubmit:w,className:"rounded-lg shadow-xl w-[480px] max-h-[90vh] overflow-y-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"px-5 py-4 border-b",style:{borderColor:"var(--border)"},children:(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Create Task"})}),(0,r.jsxs)("div",{className:"px-5 py-4 space-y-4",children:[f&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded",style:{background:"#fef2f2",color:"#dc2626"},children:f}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Title"}),(0,r.jsx)("input",{type:"text",value:n,onChange:e=>d(e.target.value),placeholder:"Task title",required:!0,className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Description"}),(0,r.jsx)("textarea",{value:i,onChange:e=>x(e.target.value),placeholder:"Describe the task...",required:!0,rows:4,className:"w-full px-3 py-2 rounded-md text-sm resize-y",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Priority"}),(0,r.jsx)("div",{className:"flex gap-3",children:[1,2,3].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"priority",value:e,checked:m===e,onChange:()=>u(e)}),"P",e]},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Type"}),(0,r.jsx)("div",{className:"flex gap-3",children:["task","bug","feature"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"task_type",value:e,checked:p===e,onChange:()=>y(e)}),e.charAt(0).toUpperCase()+e.slice(1)]},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Assign to (optional)"}),(0,r.jsxs)("select",{value:h,onChange:e=>v(e.target.value),className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("option",{value:"",children:"Unassigned"}),b.filter(e=>"human"!==e.name).map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," (",e.role,")"]},e.id))]})]})]}),(0,r.jsxs)("div",{className:"px-5 py-3 flex justify-end gap-2 border-t",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)"},children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:k,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:k?.6:1},children:k?"Creating...":"Create Task"})]})]})})}let j=["inbox","assigned","in_progress","review","done"],k={inbox:"INBOX",assigned:"ASSIGNED",in_progress:"IN PROGRESS",review:"REVIEW",done:"DONE"};function N(){let[e,t]=(0,l.useState)([]),[a,s]=(0,l.useState)(null),[n,c]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=()=>o("/tasks").then(t).catch(console.error);e();let a=setInterval(e,5e3);return()=>clearInterval(a)},[]),(0,r.jsxs)("div",{className:"flex-1 overflow-x-auto p-4",children:[(0,r.jsx)("div",{className:"flex gap-4 min-w-0",children:j.map(t=>{let a=e.filter(e=>e.status===t);return(0,r.jsxs)("div",{className:"flex-1 min-w-[200px]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3 px-1",children:[(0,r.jsx)("h3",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:k[t]}),"inbox"===t&&(0,r.jsx)("button",{onClick:()=>c(!0),className:"w-5 h-5 flex items-center justify-center rounded text-xs font-bold leading-none",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},title:"Create task",children:"+"}),(0,r.jsx)("span",{className:"text-[11px] font-medium px-1.5 rounded-full",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:a.length})]}),(0,r.jsx)("div",{className:"space-y-2",children:a.map(e=>(0,r.jsx)(v,{task:e,onClick:()=>s(e.id)},e.id))})]},t)})}),a&&(0,r.jsx)(g,{taskId:a,onClose:()=>s(null)}),(0,r.jsx)(f,{open:n,onClose:()=>c(!1),onCreated:()=>o("/tasks").then(t).catch(console.error)})]})}let w=["All","Tasks","Comments","Status"],S={Tasks:["task_created","assigned","document_created"],Comments:["message"],Status:["status_changed"]};function C(){let[e,t]=(0,l.useState)([]),[a,s]=(0,l.useState)("All"),[n,c]=(0,l.useState)(null);(0,l.useEffect)(()=>{let e=()=>o("/activities?limit=50").then(t).catch(console.error);e();let a=setInterval(e,5e3);return()=>clearInterval(a)},[]);let d=[...new Set(e.map(e=>e.agent_name).filter(Boolean))],i=e.filter(e=>{if(n&&e.agent_name!==n)return!1;if("All"!==a){let t=S[a];if(t&&e.type&&!t.includes(e.type))return!1}return!0});return(0,r.jsxs)("div",{className:"w-[300px] shrink-0 overflow-y-auto border-l flex flex-col",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3",children:[(0,r.jsx)("div",{className:"text-xs font-bold tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"LIVE FEED"}),(0,r.jsx)("div",{className:"flex gap-1 mb-3",children:w.map(e=>(0,r.jsx)("button",{onClick:()=>s(e),className:"px-2 py-1 rounded text-xs font-medium transition-colors",style:{background:a===e?"var(--bg-tertiary)":"transparent",color:a===e?"var(--text-primary)":"var(--text-muted)"},children:e},e))}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1 mb-3",children:[(0,r.jsx)("button",{onClick:()=>c(null),className:"px-2 py-0.5 rounded-full text-[11px] font-medium transition-colors",style:{background:null===n?"var(--accent-green)":"var(--bg-tertiary)",color:null===n?"white":"var(--text-secondary)"},children:"All Agents"}),d.map(e=>(0,r.jsx)("button",{onClick:()=>c(e),className:"px-2 py-0.5 rounded-full text-[11px] font-medium transition-colors",style:{background:n===e?"var(--accent-green)":"var(--bg-tertiary)",color:n===e?"white":"var(--text-secondary)"},children:e},e))]})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 pb-4 space-y-3",children:[i.map(e=>{var t,a;return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white text-[10px] font-bold shrink-0 mt-0.5",style:{background:"var(--accent-olive)"},children:(null!=(t=e.agent_name)?t:"S").charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsx)("span",{className:"font-semibold",children:null!=(a=e.agent_name)?a:"system"})," ",(0,r.jsx)("span",{style:{color:"var(--text-secondary)"},children:e.summary})]}),(0,r.jsx)("div",{className:"text-[11px]",style:{color:"var(--text-muted)"},children:function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);if(t<60)return"just now";let a=Math.floor(t/60);if(a<60)return"".concat(a,"m ago");let s=Math.floor(a/60);if(s<24)return"".concat(s,"h ago");let r=Math.floor(s/24);return"".concat(r,"d ago")}(e.created_at)})]})]},e.id)}),0===i.length&&(0,r.jsx)("div",{className:"text-sm text-center py-8",style:{color:"var(--text-muted)"},children:"No activity yet"})]})]})}function _(e){let{content:t,filename:a}=e,s=t.split("\n");return(0,r.jsx)("div",{className:"flex-1 overflow-auto font-mono text-sm",style:{background:"var(--bg-primary)"},children:(0,r.jsx)("div",{className:"p-4",children:s.map((e,t)=>(0,r.jsxs)("div",{className:"flex leading-6 hover:bg-black/[0.02]",children:[(0,r.jsx)("span",{className:"w-12 text-right pr-4 select-none shrink-0",style:{color:"var(--text-muted)",fontSize:"0.8rem"},children:t+1}),(0,r.jsx)("span",{className:"flex-1 whitespace-pre-wrap break-all",children:function(e){if(e.startsWith("# "))return(0,r.jsx)("span",{style:{color:"var(--accent-green)",fontWeight:700,fontSize:"1.1em"},children:e});if(e.startsWith("## "))return(0,r.jsx)("span",{style:{color:"var(--accent-blue)",fontWeight:700},children:e});if(e.startsWith("### "))return(0,r.jsx)("span",{style:{color:"var(--accent-olive)",fontWeight:600},children:e});if(e.startsWith("- ")||e.startsWith("* "))return(0,r.jsx)("span",{style:{color:"var(--text-primary)"},children:e});if(e.startsWith("```"))return(0,r.jsx)("span",{style:{color:"var(--text-muted)"},children:e});let t=e.split(/(\*\*[^*]+\*\*)/g);return t.length>1?(0,r.jsx)(r.Fragment,{children:t.map((e,t)=>e.startsWith("**")&&e.endsWith("**")?(0,r.jsx)("strong",{children:e.slice(2,-2)},t):(0,r.jsx)("span",{children:e},t))}):(0,r.jsx)("span",{children:e})}(e)})]},t))})})}function E(e){let{open:t,onClose:a,onCreated:s}=e,[n,d]=(0,l.useState)(""),[i,x]=(0,l.useState)(""),[m,u]=(0,l.useState)([]),[p,y]=(0,l.useState)("docker"),[h,v]=(0,l.useState)(""),[b,g]=(0,l.useState)([]),[f,j]=(0,l.useState)(!1),[k,N]=(0,l.useState)(""),[w,S]=(0,l.useState)(""),[C,_]=(0,l.useState)(null),[E,T]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{t&&(o("/agents/roles").then(e=>{u(e),e.length>0&&!i&&x(e[0])}),o("/machines").then(e=>{g(e),e.length>0&&!h&&v(e[0].name)}))},[t]),!t)return null;let A=async e=>{e.preventDefault(),_(null),T(!0);try{await c("/agents","POST",{name:n,role:i,location:p,..."remote"===p&&h?{machine:h}:{},...k?{slack_bot_token:k}:{},...w?{slack_app_token:w}:{}}),d(""),N(""),S(""),j(!1),s(),a()}catch(e){_(e.message)}finally{T(!1)}};return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:a,children:(0,r.jsxs)("form",{onClick:e=>e.stopPropagation(),onSubmit:A,className:"rounded-lg shadow-xl w-[420px] max-h-[90vh] overflow-y-auto",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"px-5 py-4 border-b",style:{borderColor:"var(--border)"},children:(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Create Agent"})}),(0,r.jsxs)("div",{className:"px-5 py-4 space-y-4",children:[C&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded",style:{background:"#fef2f2",color:"#dc2626"},children:C}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Name"}),(0,r.jsx)("input",{type:"text",value:n,onChange:e=>d(e.target.value),placeholder:"my-agent",required:!0,pattern:"^[a-z][a-z0-9-]{1,30}$",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("div",{className:"text-xs mt-1",style:{color:"var(--text-muted)"},children:"Lowercase letters, numbers, hyphens. 2-31 chars."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Role"}),(0,r.jsx)("select",{value:i,onChange:e=>x(e.target.value),required:!0,className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:m.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Location"}),(0,r.jsx)("div",{className:"flex gap-3",children:["docker","remote","local"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"location",value:e,checked:p===e,onChange:()=>y(e)}),e.charAt(0).toUpperCase()+e.slice(1)]},e))})]}),"remote"===p&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Machine"}),0===b.length?(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:"No machines configured. Add one in Settings → Machines."}):(0,r.jsx)("select",{value:h,onChange:e=>v(e.target.value),className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:b.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name," (",e.user,"@",e.host,")"]},e.name))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>j(!f),className:"text-sm font-medium flex items-center gap-1",style:{color:"var(--text-secondary)"},children:[(0,r.jsx)("span",{style:{display:"inline-block",transform:f?"rotate(90deg)":"none",transition:"transform 0.15s"},children:"▶"}),"Slack Configuration"]}),f&&(0,r.jsxs)("div",{className:"mt-2 space-y-3 pl-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium mb-1",children:"Bot Token"}),(0,r.jsx)("input",{type:"password",value:k,onChange:e=>N(e.target.value),placeholder:"xoxb-...",className:"w-full px-3 py-1.5 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-medium mb-1",children:"App Token"}),(0,r.jsx)("input",{type:"password",value:w,onChange:e=>S(e.target.value),placeholder:"xapp-...",className:"w-full px-3 py-1.5 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]})]})]})]}),(0,r.jsxs)("div",{className:"px-5 py-3 flex justify-end gap-2 border-t",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)"},children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:E,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:E?.6:1},children:E?"Creating...":"Create"})]})]})})}function T(e){var t,a;let{agent:s,onRefresh:n}=e,[o,d]=(0,l.useState)(!1),[i,x]=(0,l.useState)(!1),[m,u]=(0,l.useState)(!1),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(null),[b,g]=(0,l.useState)(null!=(t=s.slack_bot_token)?t:""),[f,j]=(0,l.useState)(null!=(a=s.slack_app_token)?a:""),[k,N]=(0,l.useState)(!1);(0,l.useEffect)(()=>{var e,t;g(null!=(e=s.slack_bot_token)?e:""),j(null!=(t=s.slack_app_token)?t:"")},[s.slack_bot_token,s.slack_app_token]);let w=async()=>{d(!0),v(null);try{var e;let t=await c("/agents/".concat(s.name,"/deploy"),"POST");v(null!=(e=t.instructions)?e:"Deployed (".concat(t.method,")")),n()}catch(e){v(e.message)}finally{d(!1)}},S=async()=>{x(!0),v(null);try{await c("/agents/".concat(s.name,"/stop"),"POST"),v("Stopped"),n()}catch(e){v(e.message)}finally{x(!1)}},C=async()=>{u(!0);try{await c("/agents/".concat(s.name),"DELETE"),n()}catch(e){v(e.message),u(!1)}},_=async()=>{N(!0);try{await c("/agents/".concat(s.name),"PATCH",{slack_bot_token:b||null,slack_app_token:f||null}),v("Slack tokens saved"),n()}catch(e){v(e.message)}finally{N(!1)}},E="active"===s.status?"#22c55e":"blocked"===s.status?"#ef4444":"#9ca3af";return(0,r.jsxs)("div",{className:"p-5 space-y-4 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"w-2.5 h-2.5 rounded-full",style:{background:E}}),(0,r.jsx)("span",{className:"font-semibold",children:s.name}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:s.role}),s.runtime&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:s.runtime}),s.machine&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:s.machine})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:w,disabled:o,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#22c55e",opacity:o?.6:1},children:o?"Deploying...":"Deploy"}),(0,r.jsx)("button",{onClick:S,disabled:i,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#f59e0b",opacity:i?.6:1},children:i?"Stopping...":"Stop"}),p?(0,r.jsx)("button",{onClick:C,disabled:m,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#dc2626",opacity:m?.6:1},children:m?"Deleting...":"Confirm Delete"}):(0,r.jsx)("button",{onClick:()=>y(!0),className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"#ef4444"},children:"Delete"})]})]}),h&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:h}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Slack Tokens"}),(0,r.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,r.jsx)("input",{type:"password",value:b,onChange:e=>g(e.target.value),placeholder:"Bot Token",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"password",value:f,onChange:e=>j(e.target.value),placeholder:"App Token",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{onClick:_,disabled:k,className:"px-3 py-1.5 rounded text-xs font-medium",style:{background:"var(--bg-tertiary)"},children:k?"Saving...":"Save"})]})]})]})}let A=[{label:"Soul",file:"SOUL.md"},{label:"User",file:"USER.md"},{label:"Agents",file:"AGENTS.md"},{label:"Memory",file:"MEMORY.md"},{label:"Tools",file:"TOOLS.md"}];function D(e){let{agents:t}=e,[a,s]=(0,l.useState)(t),[n,c]=(0,l.useState)(null),[d,i]=(0,l.useState)(A[0].file),[x,m]=(0,l.useState)(""),[u,p]=(0,l.useState)(!1),[y,h]=(0,l.useState)(null),[v,b]=(0,l.useState)(!1),g=a.find(e=>e.name===n),f=(0,l.useCallback)(async()=>{try{let e=await o("/agents");s(e)}catch(e){}},[]);return(0,l.useEffect)(()=>{!n&&a.length>0&&c(a[0].name)},[a,n]),(0,l.useEffect)(()=>{n&&(p(!0),h(null),o("/agents/".concat(n,"/files/").concat(d)).then(e=>{m(e.content),p(!1)}).catch(e=>{h("File not found"),m(""),p(!1)}))},[n,d]),(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[240px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"AGENTS"}),(0,r.jsx)("button",{onClick:()=>b(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},title:"Create agent",children:"+"})]}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:a.map(e=>(0,r.jsxs)("button",{onClick:()=>{c(e.name),i(A[0].file)},className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-left transition-colors",style:{background:n===e.name?"var(--bg-tertiary)":"transparent"},children:[(0,r.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-bold shrink-0",style:{background:"var(--accent-green)"},children:e.name.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0 ".concat("active"===e.status?"bg-green-500":"blocked"===e.status?"bg-red-500":"bg-gray-400")}),(0,r.jsx)("span",{className:"text-sm font-semibold truncate",children:e.name})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mt-0.5",children:[(0,r.jsx)("span",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:e.role}),e.location&&(0,r.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded",style:{background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:e.location})]})]})]},e.id))})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:g?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T,{agent:g,onRefresh:()=>{f(),a.find(e=>e.name===n)||c(null)}}),(0,r.jsx)("div",{className:"flex gap-0 border-b px-4",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:A.map(e=>(0,r.jsxs)("button",{onClick:()=>i(e.file),className:"px-3 py-2 text-sm font-medium transition-colors relative",style:{color:d===e.file?"var(--text-primary)":"var(--text-muted)"},children:[e.label,d===e.file&&(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5",style:{background:"var(--accent-green)"}})]},e.file))}),u?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Loading..."}):y?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:y}):(0,r.jsx)(_,{content:x,filename:d})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select an agent"})}),(0,r.jsx)(E,{open:v,onClose:()=>b(!1),onCreated:()=>{f()}})]})}let P="********",L=[{id:"identity",label:"Identity"},{id:"ai",label:"AI Provider"},{id:"agent",label:"Agent Defaults"},{id:"env",label:"Environment"},{id:"repos",label:"Repos"},{id:"machines",label:"Machines"}],I=[{label:"Model",keys:["agent.model","agent.model_fallbacks","agent.thinking"]},{label:"Execution",keys:["agent.timeout_seconds","agent.max_concurrent","agent.heartbeat_interval"]},{label:"Tools",keys:["agent.tools_profile","agent.tools_allow","agent.tools_deny","agent.web_search","agent.exec_timeout_sec"]},{label:"Sandbox",keys:["agent.sandbox_mode","agent.sandbox_scope"]},{label:"Memory",keys:["agent.context_pruning","agent.compaction"]},{label:"Browser & Logging",keys:["agent.browser_enabled","agent.logging_level","agent.logging_redact"]}],U=new Set(["ai.oauth_access_token","ai.oauth_refresh_token","ai.oauth_expires_at","ai.oauth_subscription_type","ai.auth_method"]);function O(){var e;let[t,a]=(0,l.useState)([]),[s,n]=(0,l.useState)("identity"),[d,i]=(0,l.useState)({}),[x,m]=(0,l.useState)(null),[u,p]=(0,l.useState)(new Set),[y,h]=(0,l.useState)("api_key"),[v,b]=(0,l.useState)([]),[g,f]=(0,l.useState)({name:"",url:"",default_branch:"main"}),[j,k]=(0,l.useState)([]),[N,w]=(0,l.useState)({name:"",host:"",user:"ubuntu",port:22,auth:"key"}),[S,C]=(0,l.useState)(null),[_,E]=(0,l.useState)({}),[T,A]=(0,l.useState)(""),[D,O]=(0,l.useState)(""),[R,K]=(0,l.useState)(!1),F=(0,l.useCallback)(()=>{o("/settings").then(e=>{a(e);let t=e.find(e=>"ai.auth_method"===e.key);(null==t?void 0:t.value)&&t.value!==P&&h(t.value)}).catch(console.error)},[]),B=(0,l.useCallback)(()=>{o("/repos").then(b).catch(console.error)},[]),z=(0,l.useCallback)(()=>{o("/machines").then(k).catch(console.error)},[]);(0,l.useEffect)(()=>{F(),B(),z()},[F,B,z]);let W=t.filter(e=>e.category===s),H=async e=>{let t=d[e];if(void 0!==t){m(e);try{await c("/settings/".concat(e),"PUT",{value:t}),F(),i(t=>{let a={...t};return delete a[e],a})}catch(e){console.error(e.message)}finally{m(null)}}},G=async e=>{h(e),await c("/settings/ai.auth_method","PUT",{value:e}),F()},[V,q]=(0,l.useState)(null),[X,Y]=(0,l.useState)(!1),Z=async()=>{Y(!0),q(null);try{(await c("/oauth/claude/import","POST")).ok&&(h("oauth"),F())}catch(e){q(e.message)}finally{Y(!1)}},J=async()=>{q(null);try{let e=await o("/oauth/claude/authorize");if(e.error)return void q(e.error);if(e.url){window.open(e.url,"claude-oauth","width=600,height=700");let t=setInterval(()=>{o("/settings?category=ai").then(e=>{let a=e.find(e=>"ai.oauth_access_token"===e.key);a&&a.value===P&&(clearInterval(t),F())})},2e3);setTimeout(()=>clearInterval(t),12e4)}}catch(e){q(e.message)}},$=async()=>{for(let e of["ai.oauth_access_token","ai.oauth_refresh_token","ai.oauth_expires_at","ai.oauth_subscription_type"])await c("/settings/".concat(e),"PUT",{value:""});await c("/settings/ai.auth_method","PUT",{value:"api_key"}),h("api_key"),F()},Q=e=>{p(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},ee=e=>{var t;let a=void 0!==d[e.key],s=null!=(t=d[e.key])?t:e.value,l=a&&d[e.key]!==e.value;if(e.input_type.startsWith("select:")){let t=e.input_type.slice(7).split(",");return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("select",{value:s,onChange:t=>i(a=>({...a,[e.key]:t.target.value})),className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:t.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),l&&(0,r.jsx)(M,{keyName:e.key,saving:x,onSave:H})]})}if("readonly"===e.input_type)return(0,r.jsx)("span",{className:"text-sm px-3 py-2 block",style:{color:"var(--text-secondary)"},children:e.value||"—"});if("textarea"===e.input_type)return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("textarea",{value:s,onChange:t=>i(a=>({...a,[e.key]:t.target.value})),placeholder:e.sensitive?"Paste your private key":"",rows:8,className:"w-full px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",resize:"vertical"}}),l&&(0,r.jsx)(M,{keyName:e.key,saving:x,onSave:H})]});if("password"===e.input_type){let t=u.has(e.key);return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex-1 relative",children:[(0,r.jsx)("input",{type:t?"text":"password",value:s,onChange:t=>i(a=>({...a,[e.key]:t.target.value})),onFocus:()=>{a||e.value!==P||i(t=>({...t,[e.key]:""}))},placeholder:e.value===P?"••••••••":"",className:"w-full px-3 py-2 rounded-md text-sm pr-10",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{type:"button",onClick:()=>Q(e.key),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs px-1",style:{color:"var(--text-muted)"},children:t?"Hide":"Show"})]}),l&&(0,r.jsx)(M,{keyName:e.key,saving:x,onSave:H})]})}return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:s,onChange:t=>i(a=>({...a,[e.key]:t.target.value})),className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}}),l&&(0,r.jsx)(M,{keyName:e.key,saving:x,onSave:H})]})},et=(e,t,a,s,l,n)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex gap-2",children:["key","password"].map(a=>(0,r.jsx)("button",{type:"button",onClick:()=>t(a),className:"px-3 py-1.5 rounded-md text-xs font-medium transition-colors",style:{background:e===a?"var(--accent-blue)":"var(--bg-tertiary)",color:e===a?"white":"var(--text-secondary)",border:"1px solid var(--border)"},children:"key"===a?"SSH Key":"Password"},a))}),"key"===e?(0,r.jsx)("textarea",{value:null!=l?l:"",onChange:e=>a(e.target.value),placeholder:"SSH Private Key",rows:4,className:"w-full px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--bg-primary)",border:"1px solid var(--border)",resize:"vertical"}}):(0,r.jsx)("input",{type:"password",value:null!=n?n:"",onChange:e=>s(e.target.value),placeholder:"Password",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}})]});return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[200px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsx)("div",{className:"px-4 py-3 text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"CATEGORIES"}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:L.map(e=>(0,r.jsx)("button",{onClick:()=>n(e.id),className:"w-full text-left px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{background:s===e.id?"var(--bg-tertiary)":"transparent",color:s===e.id?"var(--text-primary)":"var(--text-secondary)"},children:e.label},e.id))})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold mb-4",children:[null==(e=L.find(e=>e.id===s))?void 0:e.label," Settings"]}),(()=>{if("ai"===s)return(()=>{let e=W.find(e=>"ai.anthropic_api_key"===e.key),a=t.find(e=>"ai.oauth_access_token"===e.key),s=t.find(e=>"ai.oauth_expires_at"===e.key),l=t.find(e=>"ai.oauth_subscription_type"===e.key),n=(null==a?void 0:a.value)===P,o=null!=s&&!!s.value&&new Date(s.value)<new Date;return(0,r.jsxs)("div",{className:"space-y-6 max-w-xl",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Authentication Method"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>G("api_key"),className:"px-4 py-2 rounded-md text-sm font-medium transition-colors",style:{background:"api_key"===y?"var(--accent-blue)":"var(--bg-secondary)",color:"api_key"===y?"white":"var(--text-secondary)",border:"1px solid var(--border)"},children:"API Key"}),(0,r.jsx)("button",{onClick:()=>G("oauth"),className:"px-4 py-2 rounded-md text-sm font-medium transition-colors",style:{background:"oauth"===y?"var(--accent-blue)":"var(--bg-secondary)",color:"oauth"===y?"white":"var(--text-secondary)",border:"1px solid var(--border)"},children:"Claude Max OAuth"})]})]}),"api_key"===y&&e&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:e.key}),e.description&&(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.description}),ee(e)]}),"oauth"===y&&(0,r.jsxs)("div",{className:"rounded-lg p-4 space-y-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Claude OAuth Status"}),V&&(0,r.jsx)("div",{className:"text-sm px-3 py-2 rounded-md",style:{background:"rgba(255,0,0,0.1)",color:"var(--accent-red, #ef4444)"},children:V}),!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--text-muted)"},children:"Not connected"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:Z,disabled:X,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-blue)",opacity:X?.6:1},children:X?"Importing...":"Import from Claude Code"}),(0,r.jsx)("button",{onClick:J,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Connect with OAuth"})]})]}),n&&!o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--accent-green)"},children:"Connected"}),(null==l?void 0:l.value)&&(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Subscription: ",l.value]}),(null==s?void 0:s.value)&&(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Expires: ",new Date(s.value).toLocaleString()]}),(0,r.jsx)("button",{onClick:$,className:"px-3 py-1.5 rounded-md text-xs font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Disconnect"})]}),n&&o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--accent-yellow, orange)"},children:"Token expired"}),(0,r.jsx)("button",{onClick:Z,disabled:X,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-blue)",opacity:X?.6:1},children:X?"Importing...":"Re-import from Claude Code"})]})]})]})})();if("agent"===s){let e=new Map(W.map(e=>[e.key,e]));return(0,r.jsxs)("div",{className:"space-y-6 max-w-xl",children:[(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:"These settings configure all OpenClaw agent instances. Changes take effect on next deploy."}),I.map(t=>{let a=t.keys.map(t=>e.get(t)).filter(Boolean);return 0===a.length?null:(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-bold tracking-wider mb-3 pb-1 border-b",style:{color:"var(--text-muted)",borderColor:"var(--border)"},children:t.label.toUpperCase()}),(0,r.jsx)("div",{className:"space-y-4",children:a.map(e=>(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:e.key.replace("agent.","")}),e.description&&(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.description}),ee(e)]},e.key))})]},t.label)})]})}if("env"===s){let e=t.filter(e=>"env"===e.category),a=async()=>{if(T.trim()){K(!0);try{await c("/settings/".concat(T.trim()),"PUT",{value:D,category:"env",sensitive:1,input_type:"password"}),A(""),O(""),F()}catch(e){console.error(e.message)}finally{K(!1)}}},s=async e=>{await c("/settings/".concat(e),"DELETE"),F()};return(0,r.jsxs)("div",{className:"space-y-4 max-w-xl",children:[(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Environment variables are injected into all agents on deploy. Use these for API keys, tokens, and other secrets."}),e.map(e=>{var t;let a=void 0!==d[e.key],l=null!=(t=d[e.key])?t:e.value,n=a&&d[e.key]!==e.value,o=u.has(e.key);return(0,r.jsxs)("div",{className:"rounded-lg p-4 space-y-2",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-sm font-medium font-mono",children:e.key}),(0,r.jsx)("button",{onClick:()=>s(e.key),className:"px-2 py-1 rounded text-xs font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"Remove"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex-1 relative",children:[(0,r.jsx)("input",{type:o?"text":"password",value:l,onChange:t=>i(a=>({...a,[e.key]:t.target.value})),onFocus:()=>{a||e.value!==P||i(t=>({...t,[e.key]:""}))},placeholder:e.value===P?"••••••••":"",className:"w-full px-3 py-2 rounded-md text-sm pr-10",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{type:"button",onClick:()=>Q(e.key),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs px-1",style:{color:"var(--text-muted)"},children:o?"Hide":"Show"})]}),n&&(0,r.jsx)(M,{keyName:e.key,saving:x,onSave:H})]})]},e.key)}),0===e.length&&(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--text-muted)"},children:"No environment variables configured yet."}),(0,r.jsxs)("div",{className:"rounded-lg p-4 space-y-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Add Variable"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("input",{type:"text",value:T,onChange:e=>A(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")),placeholder:"VARIABLE_NAME",className:"w-full px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"password",value:D,onChange:e=>O(e.target.value),placeholder:"Value",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{onClick:a,disabled:!T.trim()||R,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:!T.trim()||R?.5:1},children:R?"Adding...":"Add Variable"})]})]})]})}if("repos"===s){let e=async()=>{if(g.name&&g.url)try{await c("/repos","POST",{name:g.name,url:g.url,default_branch:g.default_branch||"main"}),f({name:"",url:"",default_branch:"main"}),B()}catch(e){console.error(e.message)}},t=async e=>{await c("/repos/".concat(e),"DELETE"),B()};return(0,r.jsxs)("div",{className:"space-y-4 max-w-xl",children:[(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Git repositories managed via ",(0,r.jsx)("code",{children:"wtm"})," (worktree-manager). Agents use ",(0,r.jsx)("code",{children:"wtm init"})," to set up bare repos and ",(0,r.jsx)("code",{children:"wtm create"})," to spawn worktrees for each coding task."]}),v.map(e=>(0,r.jsxs)("div",{className:"rounded-lg p-4 flex items-start justify-between gap-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsxs)("div",{className:"space-y-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:e.name}),(0,r.jsx)("div",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:e.url}),(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Default base branch: ",e.default_branch]})]}),(0,r.jsx)("button",{onClick:()=>t(e.name),className:"px-2 py-1 rounded text-xs font-medium shrink-0",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"Remove"})]},e.name)),(0,r.jsxs)("div",{className:"rounded-lg p-4 space-y-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Add Repository"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("input",{type:"text",value:g.name,onChange:e=>f(t=>({...t,name:e.target.value})),placeholder:"Name (e.g. my-project)",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"text",value:g.url,onChange:e=>f(t=>({...t,url:e.target.value})),placeholder:"Git URL (e.g. git@github.com:org/repo.git)",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"text",value:g.default_branch,onChange:e=>f(t=>({...t,default_branch:e.target.value})),placeholder:"Default base branch for new worktrees (e.g. main)",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("button",{onClick:e,disabled:!g.name||!g.url,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:g.name&&g.url?1:.5},children:"Add Repo"})]})]})]})}if("machines"===s)return(()=>{var e,t,a,s,l;let n=async()=>{if(N.name&&N.host&&N.user)try{await c("/machines","POST",N),w({name:"",host:"",user:"ubuntu",port:22,auth:"key"}),z()}catch(e){console.error(e.message)}},o=async e=>{await c("/machines/".concat(e),"DELETE"),z()},d=async e=>{try{await c("/machines/".concat(e),"PUT",_),C(null),E({}),z()}catch(e){console.error(e.message)}};return(0,r.jsxs)("div",{className:"space-y-4 max-w-xl",children:[(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Remote SSH hosts for deploying agents. Authenticate with an SSH key or password."}),j.map(e=>{var t;return(0,r.jsx)("div",{className:"rounded-lg p-4 space-y-2",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:S===e.name?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:e.name}),(0,r.jsx)("input",{type:"text",defaultValue:e.host,onChange:e=>E(t=>({...t,host:e.target.value})),placeholder:"Host",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",defaultValue:e.user,onChange:e=>E(t=>({...t,user:e.target.value})),placeholder:"User",className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"number",defaultValue:e.port,onChange:e=>E(t=>({...t,port:Number(e.target.value)})),placeholder:"Port",className:"w-20 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}})]}),et(null!=(t=_.auth)?t:e.auth,e=>E(t=>({...t,auth:e})),e=>E(t=>({...t,ssh_key:e,password:void 0})),e=>E(t=>({...t,password:e,ssh_key:void 0}))),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{onClick:()=>d(e.name),className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Save"}),(0,r.jsx)("button",{onClick:()=>{C(null),E({})},className:"px-3 py-1.5 rounded-md text-xs font-medium",style:{background:"var(--bg-tertiary)"},children:"Cancel"})]})]}):(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"space-y-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:e.name}),(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[e.user,"@",e.host,":",e.port]}),(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:["Auth: ",e.auth,"key"===e.auth&&e.ssh_key===P?" (configured)":"","password"===e.auth&&e.password===P?" (configured)":""]})]}),(0,r.jsxs)("div",{className:"flex gap-1 shrink-0",children:[(0,r.jsx)("button",{onClick:()=>{C(e.name),E({host:e.host,user:e.user,port:e.port,auth:e.auth})},className:"px-2 py-1 rounded text-xs font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"Edit"}),(0,r.jsx)("button",{onClick:()=>o(e.name),className:"px-2 py-1 rounded text-xs font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"Remove"})]})]})},e.name)}),(0,r.jsxs)("div",{className:"rounded-lg p-4 space-y-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Add Machine"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("input",{type:"text",value:null!=(e=N.name)?e:"",onChange:e=>w(t=>({...t,name:e.target.value})),placeholder:"Name (e.g. gpu-server)",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"text",value:null!=(t=N.host)?t:"",onChange:e=>w(t=>({...t,host:e.target.value})),placeholder:"Host (e.g. 10.0.1.5 or my-server.com)",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:null!=(a=N.user)?a:"ubuntu",onChange:e=>w(t=>({...t,user:e.target.value})),placeholder:"User",className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}}),(0,r.jsx)("input",{type:"number",value:null!=(s=N.port)?s:22,onChange:e=>w(t=>({...t,port:Number(e.target.value)})),placeholder:"Port",className:"w-20 px-3 py-2 rounded-md text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}})]}),et(null!=(l=N.auth)?l:"key",e=>w(t=>({...t,auth:e,ssh_key:void 0,password:void 0})),e=>w(t=>({...t,ssh_key:e})),e=>w(t=>({...t,password:e})),N.ssh_key,N.password),(0,r.jsx)("button",{onClick:n,disabled:!N.name||!N.host||!N.user,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:"var(--accent-green)",opacity:N.name&&N.host?1:.5},children:"Add Machine"})]})]})]})})();let e=W.filter(e=>!U.has(e.key));return(0,r.jsxs)("div",{className:"space-y-4 max-w-xl",children:[e.map(e=>(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:e.key}),e.description&&(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.description}),ee(e)]},e.key)),0===e.length&&(0,r.jsx)("div",{className:"text-sm",style:{color:"var(--text-muted)"},children:"No settings in this category."})]})})()]})]})}function M(e){let{keyName:t,saving:a,onSave:s}=e;return(0,r.jsx)("button",{onClick:()=>s(t),disabled:a===t,className:"px-3 py-2 rounded-md text-xs font-medium text-white shrink-0",style:{background:"var(--accent-green)",opacity:a===t?.6:1},children:a===t?"Saving...":"Save"})}function R(){let[e,t]=(0,l.useState)([]),[a,s]=(0,l.useState)(null),[n,d]=(0,l.useState)(""),[i,x]=(0,l.useState)(!1),[m,u]=(0,l.useState)(!1),[p,y]=(0,l.useState)(""),[h,v]=(0,l.useState)(""),[b,g]=(0,l.useState)("installed"),[f,j]=(0,l.useState)([]),[k,N]=(0,l.useState)(!1),[w,S]=(0,l.useState)(new Set),[C,_]=(0,l.useState)([]),[E,T]=(0,l.useState)("SKILL.md"),[A,D]=(0,l.useState)(!1),[P,L]=(0,l.useState)("");(0,l.useEffect)(()=>{I()},[]);let I=()=>{let e=h?"?search=".concat(encodeURIComponent(h)):"";o("/skills".concat(e)).then(t).catch(console.error)};(0,l.useEffect)(()=>{I()},[h]),(0,l.useEffect)(()=>{"available"!==b||0!==f.length||k||U()},[b]);let U=e=>{N(!0),o("/skills/available".concat(e?"?refresh=1":"")).then(j).catch(console.error).finally(()=>N(!1))},O=e.find(e=>e.id===a);(0,l.useEffect)(()=>{O?(T("SKILL.md"),o("/skills/".concat(O.name,"/files")).then(e=>_(e)).catch(()=>_([{path:"SKILL.md",isDirectory:!1}]))):_([])},[a,null==O?void 0:O.name]),(0,l.useEffect)(()=>{O&&E&&("SKILL.md"===E?d(O.body):o("/skills/".concat(O.name,"/files/").concat(E)).then(e=>d(e.content)).catch(()=>d("")))},[a,E,null==O?void 0:O.body,null==O?void 0:O.name]);let M=async()=>{if(a&&O){x(!0);try{"SKILL.md"===E?(await c("/skills/".concat(a),"PUT",{body:n}),t(e=>e.map(e=>e.id===a?{...e,body:n}:e))):await c("/skills/".concat(O.name,"/files/").concat(E),"PUT",{content:n})}catch(e){console.error(e.message)}finally{x(!1)}}},R=async()=>{if(O&&P.trim())try{await c("/skills/".concat(O.name,"/files/").concat(P.trim()),"PUT",{content:""});let e=await o("/skills/".concat(O.name,"/files"));_(e),T(P.trim()),L(""),D(!1)}catch(e){console.error(e.message)}},K=async e=>{if(O&&"SKILL.md"!==e)try{await c("/skills/".concat(O.name,"/files/").concat(e),"DELETE");let t=await o("/skills/".concat(O.name,"/files"));_(t),E===e&&T("SKILL.md")}catch(e){console.error(e.message)}},F=async()=>{if(p.trim())try{let e=await c("/skills","POST",{name:p,body:"# ".concat(p,"\n")});t(t=>[...t,e]),s(e.id),y(""),u(!1)}catch(e){console.error(e.message)}},B=async e=>{try{await c("/skills/".concat(e),"DELETE"),t(t=>t.filter(t=>t.id!==e)),a===e&&(s(null),d(""))}catch(e){console.error(e.message)}},z=async e=>{S(t=>new Set(t).add(e.name));try{var t;(null==(t=(await c("/skills/import","POST",{url:"https://github.com/".concat(e.repo),skills:[e.name]})).imported)?void 0:t.length)&&I()}catch(e){console.error(e.message)}finally{S(t=>{let a=new Set(t);return a.delete(e.name),a})}},W=new Set(e.map(e=>e.name)),[H,G]=(0,l.useState)("");(0,l.useEffect)(()=>{G(n)},[a,E]);let V=n!==H,q=h?f.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())||e.description.toLowerCase().includes(h.toLowerCase())):f;return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[260px] shrink-0 overflow-y-auto border-r flex flex-col",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"SKILLS"}),"installed"===b&&(0,r.jsx)("button",{onClick:()=>u(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"+"}),"available"===b&&(0,r.jsx)("button",{onClick:()=>U(!0),className:"px-1.5 h-6 rounded flex items-center justify-center text-xs",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},title:"Refresh",children:"Refresh"})]}),(0,r.jsxs)("div",{className:"flex mx-3 mb-2 rounded overflow-hidden",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[(0,r.jsxs)("button",{onClick:()=>g("installed"),className:"flex-1 px-2 py-1.5 text-xs font-medium transition-colors",style:{background:"installed"===b?"var(--bg-tertiary)":"transparent",color:"installed"===b?"var(--text-primary)":"var(--text-muted)"},children:["Installed (",e.length,")"]}),(0,r.jsx)("button",{onClick:()=>g("available"),className:"flex-1 px-2 py-1.5 text-xs font-medium transition-colors",style:{background:"available"===b?"var(--bg-tertiary)":"transparent",color:"available"===b?"var(--text-primary)":"var(--text-muted)"},children:"Available"})]}),(0,r.jsx)("div",{className:"px-3 pb-2",children:(0,r.jsx)("input",{type:"text",value:h,onChange:e=>v(e.target.value),placeholder:"installed"===b?"Search installed...":"Search available...",className:"w-full px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}})}),"installed"===b&&m&&(0,r.jsxs)("div",{className:"px-3 pb-2 flex gap-1",children:[(0,r.jsx)("input",{type:"text",value:p,onChange:e=>y(e.target.value),placeholder:"Skill name",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&F(),autoFocus:!0}),(0,r.jsx)("button",{onClick:F,className:"px-2 py-1.5 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"})]}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-0.5 px-2",children:["installed"===b&&e.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between group",children:[(0,r.jsxs)("button",{onClick:()=>s(e.id),className:"flex-1 text-left px-2 py-2 rounded-md text-sm transition-colors",style:{background:a===e.id?"var(--bg-tertiary)":"transparent"},children:[(0,r.jsx)("div",{className:"font-medium truncate",children:e.name}),(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[e.category,e.tags.length?" \xb7 ".concat(e.tags.join(", ")):""]})]}),(0,r.jsx)("button",{onClick:()=>B(e.id),className:"opacity-0 group-hover:opacity-100 px-1 text-xs",style:{color:"var(--accent-red)"},title:"Delete",children:"\xd7"})]},e.id)),"available"===b&&k&&(0,r.jsx)("div",{className:"px-2 py-4 text-xs text-center",style:{color:"var(--text-muted)"},children:"Loading skills from repos..."}),"available"===b&&!k&&q.map(e=>{let t=W.has(e.name),a=w.has(e.name);return(0,r.jsxs)("div",{className:"flex items-center justify-between group",children:[(0,r.jsxs)("div",{className:"flex-1 px-2 py-2 text-sm min-w-0",children:[(0,r.jsxs)("div",{className:"font-medium truncate flex items-center gap-1.5",children:[e.name,t&&(0,r.jsx)("span",{className:"text-[10px] px-1 rounded",style:{background:"var(--accent-green)",color:"white"},children:"installed"})]}),(0,r.jsx)("div",{className:"text-xs truncate",style:{color:"var(--text-muted)"},children:e.description||e.repo}),(0,r.jsx)("div",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:e.repo})]}),!t&&(0,r.jsx)("button",{onClick:()=>z(e),disabled:a,className:"shrink-0 px-2 py-1 rounded text-xs font-medium text-white opacity-0 group-hover:opacity-100",style:{background:"var(--accent-green)",opacity:a?.5:void 0},children:a?"...":"Install"})]},"".concat(e.repo,"/").concat(e.name))})]})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:O?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-semibold",children:O.name}),(0,r.jsx)("span",{className:"text-xs ml-2",style:{color:"var(--text-muted)"},children:O.category})]}),(0,r.jsx)("button",{onClick:M,disabled:!V||i,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)",opacity:!V||i?.4:1},children:i?"Saving...":"Save"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 px-3 py-2 border-b overflow-x-auto",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[C.filter(e=>!e.isDirectory).map(e=>(0,r.jsxs)("div",{className:"flex items-center group",children:[(0,r.jsx)("button",{onClick:()=>T(e.path),className:"px-2 py-1 rounded text-xs font-mono whitespace-nowrap",style:{background:E===e.path?"var(--bg-tertiary)":"transparent",color:E===e.path?"var(--text-primary)":"var(--text-muted)"},children:e.path}),"SKILL.md"!==e.path&&(0,r.jsx)("button",{onClick:()=>K(e.path),className:"opacity-0 group-hover:opacity-100 px-1 text-xs",style:{color:"var(--accent-red)"},title:"Delete file",children:"\xd7"})]},e.path)),A?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("input",{type:"text",value:P,onChange:e=>L(e.target.value),placeholder:"filename.ext",className:"px-2 py-1 rounded text-xs font-mono w-32",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&R(),autoFocus:!0}),(0,r.jsx)("button",{onClick:R,className:"px-2 py-1 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"}),(0,r.jsx)("button",{onClick:()=>{D(!1),L("")},className:"px-1 text-xs",style:{color:"var(--text-muted)"},children:"\xd7"})]}):(0,r.jsx)("button",{onClick:()=>D(!0),className:"px-2 py-1 rounded text-xs",style:{color:"var(--text-muted)"},title:"Add file",children:"+ Add file"})]}),(0,r.jsx)("textarea",{value:n,onChange:e=>d(e.target.value),className:"flex-1 p-4 font-mono text-sm resize-none",style:{background:"var(--bg-primary)",border:"none",outline:"none"}})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"available"===b?"Browse and install skills from public repositories":"Select a skill to edit"})})]})}function K(e){let{open:t,title:a,message:s,confirmLabel:l="Confirm",cancelLabel:n="Cancel",danger:o=!1,onConfirm:c,onCancel:d}=e;return t?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:d,children:(0,r.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"rounded-lg shadow-xl w-[400px]",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},children:[(0,r.jsx)("div",{className:"px-5 py-4 border-b",style:{borderColor:"var(--border)"},children:(0,r.jsx)("h2",{className:"text-lg font-semibold",children:a})}),(0,r.jsx)("div",{className:"px-5 py-4",children:(0,r.jsx)("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:s})}),(0,r.jsxs)("div",{className:"px-5 py-3 flex justify-end gap-2 border-t",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("button",{type:"button",onClick:d,className:"px-4 py-2 rounded-md text-sm font-medium",style:{background:"var(--bg-tertiary)"},children:n}),(0,r.jsx)("button",{type:"button",onClick:c,className:"px-4 py-2 rounded-md text-sm font-medium text-white",style:{background:o?"var(--accent-red)":"var(--accent-green)"},children:l})]})]})}):null}let F=[{key:"heartbeat",label:"Heartbeat"},{key:"agents-config",label:"Config"},{key:"tools",label:"Tools"},{key:"agents",label:"Agents"},{key:"environment",label:"Environment"},{key:"soul",label:"Soul"},{key:"identity",label:"Identity"}];function B(){let[e,t]=(0,l.useState)([]),[a,s]=(0,l.useState)([]),[n,d]=(0,l.useState)(null),[i,x]=(0,l.useState)("heartbeat"),[m,u]=(0,l.useState)(""),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(!1),[b,g]=(0,l.useState)(""),[f,j]=(0,l.useState)(null);(0,l.useEffect)(()=>{k()},[]);let k=async()=>{let e=await o("/role-configs");t(e);let a=[...new Set(e.map(e=>e.role))];s(a),!n&&a.length>0&&d(a[0])};(0,l.useEffect)(()=>{if(n&&i){var t;let a=e.find(e=>e.role===n&&e.config_type===i);u(null!=(t=null==a?void 0:a.content)?t:"")}},[n,i,e]);let N=e.find(e=>e.role===n&&e.config_type===i),w=N?m!==N.content:m.length>0,S=async()=>{if(n){y(!0);try{let e=await c("/role-configs/".concat(n,"/").concat(i),"PUT",{content:m});t(t=>{let a=t.findIndex(e=>e.role===n&&e.config_type===i);if(a>=0){let s=[...t];return s[a]=e,s}return[...t,e]})}catch(e){console.error(e.message)}finally{y(!1)}}},C=async()=>{b.trim()&&(await c("/role-configs/".concat(b,"/heartbeat"),"PUT",{content:"# ".concat(b," Heartbeat\n\nAdd your heartbeat checklist here.")}),g(""),v(!1),await k(),d(b))},_=async()=>{if(f)try{if(await c("/role-configs/".concat(f),"DELETE"),t(e=>e.filter(e=>e.role!==f)),s(e=>e.filter(e=>e!==f)),n===f){var e;d(null!=(e=a.find(e=>e!==f))?e:null)}}catch(e){console.error(e.message)}finally{j(null)}};return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[200px] shrink-0 overflow-y-auto border-r",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"ROLES"}),(0,r.jsx)("button",{onClick:()=>v(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"+"})]}),h&&(0,r.jsxs)("div",{className:"px-3 pb-2 flex gap-1",children:[(0,r.jsx)("input",{type:"text",value:b,onChange:e=>g(e.target.value),placeholder:"Role name",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&C(),autoFocus:!0}),(0,r.jsx)("button",{onClick:C,className:"px-2 py-1.5 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"})]}),(0,r.jsx)("div",{className:"space-y-0.5 px-2",children:a.map(e=>(0,r.jsxs)("div",{className:"flex items-center group",children:[(0,r.jsx)("button",{onClick:()=>d(e),className:"flex-1 text-left px-3 py-2 rounded-md text-sm font-medium transition-colors",style:{background:n===e?"var(--bg-tertiary)":"transparent",color:n===e?"var(--text-primary)":"var(--text-secondary)"},children:e}),(0,r.jsx)("button",{onClick:()=>j(e),className:"opacity-0 group-hover:opacity-100 px-2 text-xs transition-opacity",style:{color:"var(--accent-red)"},title:"Delete role",children:"\xd7"})]},e))})]}),n?(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"flex gap-0 border-b px-4",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:F.map(e=>(0,r.jsxs)("button",{onClick:()=>x(e.key),className:"px-3 py-2 text-sm font-medium transition-colors relative",style:{color:i===e.key?"var(--text-primary)":"var(--text-muted)"},children:[e.label,i===e.key&&(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5",style:{background:"var(--accent-green)"}})]},e.key))}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsxs)("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:[n," / ",i]}),(0,r.jsx)("button",{onClick:S,disabled:!w||p,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)",opacity:!w||p?.4:1},children:p?"Saving...":"Save"})]}),(0,r.jsx)("textarea",{value:m,onChange:e=>u(e.target.value),className:"flex-1 p-4 font-mono text-sm resize-none",style:{background:"var(--bg-primary)",border:"none",outline:"none"}})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a role"}),(0,r.jsx)(K,{open:null!==f,title:"Delete Role",message:'Delete "'.concat(f,'" and all its configuration files? This cannot be undone.'),confirmLabel:"Delete",danger:!0,onConfirm:_,onCancel:()=>j(null)})]})}function z(){let[e,t]=(0,l.useState)([]),[a,s]=(0,l.useState)(null),[n,d]=(0,l.useState)(""),[i,x]=(0,l.useState)(""),[m,u]=(0,l.useState)(!1),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(""),[b,g]=(0,l.useState)(""),f=()=>{let e=b?"?search=".concat(encodeURIComponent(b)):"";o("/knowledge".concat(e)).then(t).catch(console.error)};(0,l.useEffect)(()=>{f()},[]),(0,l.useEffect)(()=>{f()},[b]);let j=e.find(e=>e.id===a);(0,l.useEffect)(()=>{j&&(d(j.content),x(j.tags.join(", ")))},[a]);let k=j&&(n!==j.content||i!==j.tags.join(", ")),N=async()=>{if(j){u(!0);try{let e=i.split(",").map(e=>e.trim()).filter(Boolean),s=await c("/knowledge","POST",{key:j.key,content:n,tags:e,from:"human"});t(e=>e.map(e=>e.id===a?s:e))}catch(e){console.error(e.message)}finally{u(!1)}}},w=async()=>{if(h.trim())try{let e=await c("/knowledge","POST",{key:h,content:"",tags:[],from:"human"});t(t=>[e,...t]),s(e.id),v(""),y(!1)}catch(e){console.error(e.message)}};return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[260px] shrink-0 overflow-y-auto border-r flex flex-col",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"KNOWLEDGE"}),(0,r.jsx)("button",{onClick:()=>y(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"+"})]}),(0,r.jsx)("div",{className:"px-3 pb-2",children:(0,r.jsx)("input",{type:"text",value:b,onChange:e=>g(e.target.value),placeholder:"Search knowledge...",className:"w-full px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"}})}),p&&(0,r.jsxs)("div",{className:"px-3 pb-2 flex gap-1",children:[(0,r.jsx)("input",{type:"text",value:h,onChange:e=>v(e.target.value),placeholder:"Key",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&w(),autoFocus:!0}),(0,r.jsx)("button",{onClick:w,className:"px-2 py-1.5 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto space-y-0.5 px-2",children:e.map(e=>(0,r.jsx)("div",{className:"flex items-center justify-between group",children:(0,r.jsxs)("button",{onClick:()=>s(e.id),className:"flex-1 text-left px-2 py-2 rounded-md text-sm transition-colors",style:{background:a===e.id?"var(--bg-tertiary)":"transparent"},children:[(0,r.jsx)("div",{className:"font-medium truncate",children:e.key}),(0,r.jsx)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:e.tags.length?e.tags.join(", "):"no tags"})]})},e.id))})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:j?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("span",{className:"font-semibold",children:j.key}),(0,r.jsx)("button",{onClick:N,disabled:!k||m,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)",opacity:!k||m?.4:1},children:m?"Saving...":"Save"})]}),(0,r.jsxs)("div",{className:"px-4 pt-3 pb-2",children:[(0,r.jsx)("label",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Tags (comma-separated)"}),(0,r.jsx)("input",{type:"text",value:i,onChange:e=>x(e.target.value),className:"w-full px-2 py-1.5 rounded text-xs mt-1",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsx)("textarea",{value:n,onChange:e=>d(e.target.value),className:"flex-1 p-4 font-mono text-sm resize-none",style:{background:"var(--bg-primary)",border:"none",outline:"none"}})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a knowledge entry to edit"})})]})}function W(){let[e,t]=(0,l.useState)([]),[a,s]=(0,l.useState)(null),[n,d]=(0,l.useState)(""),[i,x]=(0,l.useState)(""),[m,u]=(0,l.useState)(""),[p,y]=(0,l.useState)(!1),[h,v]=(0,l.useState)(!1),[b,g]=(0,l.useState)("");(0,l.useEffect)(()=>{o("/documents").then(t).catch(console.error)},[]);let f=e.find(e=>e.id===a);(0,l.useEffect)(()=>{f&&(d(f.title),x(f.content),u(f.doc_type))},[a]);let j=f&&(n!==f.title||i!==f.content||m!==f.doc_type),k=async()=>{if(a){y(!0);try{let e=await c("/documents/".concat(a),"PUT",{title:n,content:i,doc_type:m});t(t=>t.map(t=>t.id===a?e:t))}catch(e){console.error(e.message)}finally{y(!1)}}},N=async()=>{if(b.trim())try{let e=await c("/documents","POST",{title:b,content:"",doc_type:"general",from:"human"});t(t=>[e,...t]),s(e.id),g(""),v(!1)}catch(e){console.error(e.message)}};return(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsxs)("div",{className:"w-[260px] shrink-0 overflow-y-auto border-r flex flex-col",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[(0,r.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-bold tracking-wider",style:{color:"var(--text-muted)"},children:"DOCUMENTS"}),(0,r.jsx)("button",{onClick:()=>v(!0),className:"w-6 h-6 rounded flex items-center justify-center text-sm font-bold",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)"},children:"+"})]}),h&&(0,r.jsxs)("div",{className:"px-3 pb-2 flex gap-1",children:[(0,r.jsx)("input",{type:"text",value:b,onChange:e=>g(e.target.value),placeholder:"Document title",className:"flex-1 px-2 py-1.5 rounded text-xs",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onKeyDown:e=>"Enter"===e.key&&N(),autoFocus:!0}),(0,r.jsx)("button",{onClick:N,className:"px-2 py-1.5 rounded text-xs font-medium text-white",style:{background:"var(--accent-green)"},children:"Add"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto space-y-0.5 px-2",children:e.map(e=>(0,r.jsx)("div",{className:"flex items-center justify-between group",children:(0,r.jsxs)("button",{onClick:()=>s(e.id),className:"flex-1 text-left px-2 py-2 rounded-md text-sm transition-colors",style:{background:a===e.id?"var(--bg-tertiary)":"transparent"},children:[(0,r.jsx)("div",{className:"font-medium truncate",children:e.title}),(0,r.jsxs)("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[e.doc_type," \xb7 ",(e=>{try{return new Date(e).toLocaleDateString()}catch(t){return e}})(e.created_at)]})]})},e.id))})]}),(0,r.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:"var(--border)"},children:[(0,r.jsx)("span",{className:"font-semibold",children:f.title}),(0,r.jsx)("button",{onClick:k,disabled:!j||p,className:"px-3 py-1.5 rounded-md text-xs font-medium text-white",style:{background:"var(--accent-green)",opacity:!j||p?.4:1},children:p?"Saving...":"Save"})]}),(0,r.jsxs)("div",{className:"px-4 pt-3 pb-2 flex gap-4",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("label",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Title"}),(0,r.jsx)("input",{type:"text",value:n,onChange:e=>d(e.target.value),className:"w-full px-2 py-1.5 rounded text-xs mt-1",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Type"}),(0,r.jsx)("input",{type:"text",value:m,onChange:e=>u(e.target.value),className:"w-full px-2 py-1.5 rounded text-xs mt-1",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})]})]}),(0,r.jsx)("textarea",{value:i,onChange:e=>x(e.target.value),className:"flex-1 p-4 font-mono text-sm resize-none",style:{background:"var(--bg-primary)",border:"none",outline:"none"}})]}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center",style:{color:"var(--text-muted)"},children:"Select a document to edit"})})]})}function H(){let[e,t]=(0,l.useState)("mission"),[a,s]=(0,l.useState)([]);return(0,l.useEffect)(()=>{let e=()=>o("/agents").then(s).catch(console.error);e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,r.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,r.jsx)(i,{activeView:e,onViewChange:t}),"mission"===e?(0,r.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.jsx)(y,{agents:a}),(0,r.jsx)(N,{}),(0,r.jsx)(C,{})]}):"config"===e?(0,r.jsx)(D,{agents:a}):"settings"===e?(0,r.jsx)(O,{}):"skills"===e?(0,r.jsx)(R,{}):"roles"===e?(0,r.jsx)(B,{}):"knowledge"===e?(0,r.jsx)(z,{}):"documents"===e?(0,r.jsx)(W,{}):null]})}}},e=>{e.O(0,[441,255,358],()=>e(e.s=1768)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[358],{
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[358],{3548:(e,s,n)=>{Promise.resolve().then(n.t.bind(n,7150,23)),Promise.resolve().then(n.t.bind(n,1959,23)),Promise.resolve().then(n.t.bind(n,7989,23)),Promise.resolve().then(n.t.bind(n,3886,23)),Promise.resolve().then(n.t.bind(n,9766,23)),Promise.resolve().then(n.t.bind(n,5278,23)),Promise.resolve().then(n.t.bind(n,8924,23)),Promise.resolve().then(n.t.bind(n,4431,23)),Promise.resolve().then(n.bind(n,622))},9393:()=>{}},e=>{var s=s=>e(e.s=s);e.O(0,[441,255],()=>(s(1666),s(3548))),_N_E=e.O()}]);
|