@runfusion/fusion 0.26.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/bin.js +12847 -2514
  2. package/dist/client/assets/AgentDetailView-B7QRcHJH.css +1 -0
  3. package/dist/client/assets/AgentDetailView-shgiiUb4.js +18 -0
  4. package/dist/client/assets/{AgentsView-CV3vm7Qk.css → AgentsView-B3ADnF0D.css} +1 -1
  5. package/dist/client/assets/{AgentsView-D6Zi5zfP.js → AgentsView-CpwqOVDz.js} +12 -7
  6. package/dist/client/assets/ChatView-DyRBOIKL.js +1 -0
  7. package/dist/client/assets/{DevServerView--_WBvIDQ.js → DevServerView-Cdelj9-m.js} +1 -1
  8. package/dist/client/assets/{DirectoryPicker-xedtR-Rd.js → DirectoryPicker-C0kmRv0u.js} +1 -1
  9. package/dist/client/assets/{DocumentsView-Bg2oaZks.js → DocumentsView-B94U9ijs.js} +1 -1
  10. package/dist/client/assets/{EvalsView-B3uOCXfr.js → EvalsView-O_4YWy--.js} +1 -1
  11. package/dist/client/assets/{ExperimentalAgentOnboardingModal-Bx6yXVS5.js → ExperimentalAgentOnboardingModal-CkEiF85-.js} +1 -1
  12. package/dist/client/assets/InsightsView-D-Qe0tRr.js +11 -0
  13. package/dist/client/assets/{MemoryView-xcN_eouf.js → MemoryView-CoRUmRvb.js} +2 -2
  14. package/dist/client/assets/NodesView-DQzXjcLc.js +14 -0
  15. package/dist/client/assets/{PiExtensionsManager-Cc8aAZXg.js → PiExtensionsManager-Dn1LmFbq.js} +2 -2
  16. package/dist/client/assets/PluginManager-Y0fs-6No.js +1 -0
  17. package/dist/client/assets/{ResearchView-CERNf7sJ.js → ResearchView-CjOxKhdS.js} +1 -1
  18. package/dist/client/assets/{SettingsModal-B1r0yASu.js → SettingsModal-Bg1-3JO_.js} +1 -1
  19. package/dist/client/assets/{SettingsModal-Cis-4Lot.css → SettingsModal-Ci0_sqbU.css} +1 -1
  20. package/dist/client/assets/SettingsModal-DL7tjJQa.js +31 -0
  21. package/dist/client/assets/SettingsModal-DWKgRxBA.css +1 -0
  22. package/dist/client/assets/{SetupWizardModal-D1q548_L.js → SetupWizardModal-DuzYPbuJ.js} +1 -1
  23. package/dist/client/assets/{SkillsView-ClLM6u6p.js → SkillsView-BIFoVNUf.js} +1 -1
  24. package/dist/client/assets/{StashRecoveryView-ze0pEZ5U.js → StashRecoveryView-C52KsV7f.js} +1 -1
  25. package/dist/client/assets/{TodoView-CTmIfy2M.js → TodoView-sS_mT0Y7.js} +2 -2
  26. package/dist/client/assets/{dashboard-view-CyWN-d02.js → dashboard-view-BWGH_fAq.js} +1 -1
  27. package/dist/client/assets/dashboard-view-BoTzlP8b.css +1 -0
  28. package/dist/client/assets/dashboard-view-MB-86hAu.js +21 -0
  29. package/dist/client/assets/{folder-open-BZuKESeq.js → folder-open-B9cwJ-OX.js} +1 -1
  30. package/dist/client/assets/index-BOjPRqEk.js +692 -0
  31. package/dist/client/assets/index-BmSEq8Rb.css +1 -0
  32. package/dist/client/assets/{star-D75YKEq-.js → star-BDn04UYV.js} +1 -1
  33. package/dist/client/assets/{upload-BYYTgWFj.js → upload-zdPPycKQ.js} +1 -1
  34. package/dist/client/assets/{users-RS90Aii3.js → users-CPYZjK2g.js} +1 -1
  35. package/dist/client/index.html +2 -2
  36. package/dist/client/version.json +1 -1
  37. package/dist/droid-cli/package.json +1 -1
  38. package/dist/droid-cli/src/__tests__/index.test.ts +228 -0
  39. package/dist/extension.js +7433 -1920
  40. package/dist/pi-claude-cli/package.json +1 -1
  41. package/dist/pi-claude-cli/src/__tests__/provider.test.ts +36 -22
  42. package/dist/pi-claude-cli/src/provider.ts +7 -1
  43. package/dist/plugins/fusion-plugin-cli-printing-press/manifest.json +19 -1
  44. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +20 -2
  45. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/TestRunnerPanel.test.tsx +99 -0
  46. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/config-flow.test.ts +91 -0
  47. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/dashboard-view.test.tsx +40 -0
  48. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/dashboard-views.test.ts +46 -0
  49. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/draft-store.test.ts +50 -0
  50. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/fixtures/exec-mock.ts +80 -0
  51. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/fixtures/fixtures.test.ts +40 -0
  52. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/fixtures/registry.ts +82 -0
  53. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/generator.test.ts +54 -0
  54. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/manage-view.test.tsx +98 -0
  55. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/manifest.test.ts +21 -5
  56. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/registration.test.ts +29 -0
  57. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/run-routes.test.ts +98 -0
  58. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/runner.test.ts +55 -0
  59. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/runtime-availability.test.ts +61 -0
  60. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/validation.test.ts +30 -0
  61. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/wizard-routes.test.ts +61 -0
  62. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/workflow-integration.test.ts +19 -0
  63. package/dist/plugins/fusion-plugin-cli-printing-press/src/dashboard-view.css +43 -0
  64. package/dist/plugins/fusion-plugin-cli-printing-press/src/dashboard-view.tsx +49 -0
  65. package/dist/plugins/fusion-plugin-cli-printing-press/src/generation/generator.ts +95 -0
  66. package/dist/plugins/fusion-plugin-cli-printing-press/src/generation/redact.ts +9 -0
  67. package/dist/plugins/fusion-plugin-cli-printing-press/src/generation/runner.ts +79 -0
  68. package/dist/plugins/fusion-plugin-cli-printing-press/src/generation/types.ts +31 -0
  69. package/dist/plugins/fusion-plugin-cli-printing-press/src/index.ts +46 -2
  70. package/dist/plugins/fusion-plugin-cli-printing-press/src/manage/EditDraftModal.tsx +75 -0
  71. package/dist/plugins/fusion-plugin-cli-printing-press/src/manage/useDrafts.ts +73 -0
  72. package/dist/plugins/fusion-plugin-cli-printing-press/src/manage-view.css +79 -0
  73. package/dist/plugins/fusion-plugin-cli-printing-press/src/manage-view.tsx +122 -0
  74. package/dist/plugins/fusion-plugin-cli-printing-press/src/routes/wizard-routes.ts +272 -0
  75. package/dist/plugins/fusion-plugin-cli-printing-press/src/run/TestRunnerPanel.css +70 -0
  76. package/dist/plugins/fusion-plugin-cli-printing-press/src/run/TestRunnerPanel.tsx +98 -0
  77. package/dist/plugins/fusion-plugin-cli-printing-press/src/run/useRunGeneratedCli.ts +37 -0
  78. package/dist/plugins/fusion-plugin-cli-printing-press/src/runtime/__tests__/executor-runtime-env.test.ts +191 -0
  79. package/dist/plugins/fusion-plugin-cli-printing-press/src/runtime/executor-runtime-env.ts +75 -0
  80. package/dist/plugins/fusion-plugin-cli-printing-press/src/storage/draft-store.ts +85 -0
  81. package/dist/plugins/fusion-plugin-cli-printing-press/src/store/__tests__/cli-press-store.test.ts +128 -0
  82. package/dist/plugins/fusion-plugin-cli-printing-press/src/store/__tests__/credentials.test.ts +62 -0
  83. package/dist/plugins/fusion-plugin-cli-printing-press/src/store/cli-press-store.ts +427 -0
  84. package/dist/plugins/fusion-plugin-cli-printing-press/src/store/cli-press-types.ts +110 -0
  85. package/dist/plugins/fusion-plugin-cli-printing-press/src/store/credentials.ts +95 -0
  86. package/dist/plugins/fusion-plugin-cli-printing-press/src/wizard/steps.tsx +55 -0
  87. package/dist/plugins/fusion-plugin-cli-printing-press/src/wizard/types.ts +33 -0
  88. package/dist/plugins/fusion-plugin-cli-printing-press/src/wizard/validation.ts +63 -0
  89. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  90. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  91. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  92. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  93. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  94. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  95. package/dist/plugins/fusion-plugin-reports/manifest.json +10 -0
  96. package/dist/plugins/fusion-plugin-reports/package.json +18 -2
  97. package/dist/plugins/fusion-plugin-reports/src/__tests__/approval.test.ts +164 -0
  98. package/dist/plugins/fusion-plugin-reports/src/__tests__/manifest.test.ts +14 -0
  99. package/dist/plugins/fusion-plugin-reports/src/__tests__/routes-approval.test.ts +109 -0
  100. package/dist/plugins/fusion-plugin-reports/src/__tests__/scaffold.test.ts +60 -0
  101. package/dist/plugins/fusion-plugin-reports/src/__tests__/share-blocks.test.ts +83 -0
  102. package/dist/plugins/fusion-plugin-reports/src/aggregation.ts +23 -0
  103. package/dist/plugins/fusion-plugin-reports/src/approval.ts +97 -0
  104. package/dist/plugins/fusion-plugin-reports/src/cadence.ts +23 -0
  105. package/dist/plugins/fusion-plugin-reports/src/dashboard/ReportsView.css +82 -0
  106. package/dist/plugins/fusion-plugin-reports/src/dashboard/ReportsView.tsx +24 -0
  107. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/ReportComparisonDrawer.test.tsx +12 -0
  108. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/ReportDetailPanel.test.tsx +12 -0
  109. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/ReportFiltersBar.test.tsx +14 -0
  110. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/ReportsView.test.tsx +27 -0
  111. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/api.test.ts +19 -0
  112. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/useReportSectionDiff.test.ts +11 -0
  113. package/dist/plugins/fusion-plugin-reports/src/dashboard/__tests__/useReports.test.ts +13 -0
  114. package/dist/plugins/fusion-plugin-reports/src/dashboard/api.ts +85 -0
  115. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportApprovalPanel.css +59 -0
  116. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportApprovalPanel.tsx +58 -0
  117. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportComparisonDrawer.tsx +21 -0
  118. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportDetailPanel.tsx +29 -0
  119. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportEmptyState.tsx +3 -0
  120. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportFiltersBar.tsx +19 -0
  121. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ReportListItem.tsx +8 -0
  122. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ShareBlocksPanel.css +29 -0
  123. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/ShareBlocksPanel.tsx +43 -0
  124. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/__tests__/ReportApprovalPanel.test.tsx +38 -0
  125. package/dist/plugins/fusion-plugin-reports/src/dashboard/components/__tests__/ShareBlocksPanel.test.tsx +24 -0
  126. package/dist/plugins/fusion-plugin-reports/src/dashboard/test-setup.ts +18 -0
  127. package/dist/plugins/fusion-plugin-reports/src/dashboard/types.ts +22 -0
  128. package/dist/plugins/fusion-plugin-reports/src/dashboard/useReportPreview.ts +44 -0
  129. package/dist/plugins/fusion-plugin-reports/src/dashboard/useReportSectionDiff.ts +59 -0
  130. package/dist/plugins/fusion-plugin-reports/src/dashboard/useReports.ts +71 -0
  131. package/dist/plugins/fusion-plugin-reports/src/dashboard/useViewportMode.ts +13 -0
  132. package/dist/plugins/fusion-plugin-reports/src/dashboard-view.tsx +6 -0
  133. package/dist/plugins/fusion-plugin-reports/src/index.ts +48 -2
  134. package/dist/plugins/fusion-plugin-reports/src/pipeline.ts +58 -0
  135. package/dist/plugins/fusion-plugin-reports/src/render/__tests__/escape.test.ts +20 -0
  136. package/dist/plugins/fusion-plugin-reports/src/render/__tests__/html-template.test.ts +110 -0
  137. package/dist/plugins/fusion-plugin-reports/src/render/__tests__/standalone-html.test.ts +66 -0
  138. package/dist/plugins/fusion-plugin-reports/src/render/escape.ts +12 -0
  139. package/dist/plugins/fusion-plugin-reports/src/render/html-styles.ts +40 -0
  140. package/dist/plugins/fusion-plugin-reports/src/render/html-template.ts +137 -0
  141. package/dist/plugins/fusion-plugin-reports/src/render/index.ts +4 -0
  142. package/dist/plugins/fusion-plugin-reports/src/render/standalone-html.ts +75 -0
  143. package/dist/plugins/fusion-plugin-reports/src/report-schema.ts +31 -0
  144. package/dist/plugins/fusion-plugin-reports/src/routes/__tests__/report-export-routes.test.ts +104 -0
  145. package/dist/plugins/fusion-plugin-reports/src/routes/report-approval-routes.ts +98 -0
  146. package/dist/plugins/fusion-plugin-reports/src/routes/report-export-routes.ts +77 -0
  147. package/dist/plugins/fusion-plugin-reports/src/routes/report-list-routes.ts +72 -0
  148. package/dist/plugins/fusion-plugin-reports/src/runs-store.ts +69 -0
  149. package/dist/plugins/fusion-plugin-reports/src/share-blocks.ts +82 -0
  150. package/dist/plugins/fusion-plugin-reports/src/store/report-store.ts +51 -2
  151. package/dist/plugins/fusion-plugin-reports/src/store/report-types.ts +6 -1
  152. package/dist/plugins/fusion-plugin-roadmap/bundled.js +1528 -29391
  153. package/dist/plugins/fusion-plugin-roadmap/manifest.json +1 -1
  154. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  155. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  156. package/package.json +1 -1
  157. package/skill/fusion/SKILL.md +1 -1
  158. package/skill/fusion/references/engine-tools.md +2 -2
  159. package/skill/fusion/references/extension-tools.md +4 -3
  160. package/skill/fusion/references/fusion-capabilities.md +1 -1
  161. package/skill/fusion/workflows/task-management.md +3 -1
  162. package/dist/client/assets/AgentDetailView-BwJaLqZh.css +0 -1
  163. package/dist/client/assets/AgentDetailView-Cv-vgOj3.js +0 -18
  164. package/dist/client/assets/ChatView-CAHjY9uO.js +0 -1
  165. package/dist/client/assets/InsightsView-Q1zvtF4F.js +0 -11
  166. package/dist/client/assets/NodesView-RxXg58_Q.js +0 -14
  167. package/dist/client/assets/PluginManager-BEkyBajl.js +0 -1
  168. package/dist/client/assets/SettingsModal-BLsac7CJ.js +0 -31
  169. package/dist/client/assets/SettingsModal-BNSrO1M9.css +0 -1
  170. package/dist/client/assets/dashboard-view-4xAN3yO5.js +0 -21
  171. package/dist/client/assets/dashboard-view-BkTMSZYn.css +0 -1
  172. package/dist/client/assets/index-Bdw6llW6.js +0 -692
  173. package/dist/client/assets/index-CZGlyJuS.css +0 -1
  174. package/dist/plugins/fusion-plugin-roadmap/bundled.css +0 -1093
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "roadmap-planner",
2
+ "id": "fusion-plugin-roadmap",
3
3
  "name": "Roadmaps",
4
4
  "version": "0.1.0",
5
5
  "description": "Standalone roadmap planning plugin",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/roadmap",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/whatsapp-chat",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "WhatsApp Web (Baileys) chat bridge for Fusion agents",
6
6
  "keywords": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runfusion/fusion",
3
- "version": "0.26.0",
3
+ "version": "0.27.1",
4
4
  "license": "MIT",
5
5
  "description": "Fusion CLI: HTTP API server, daemon, dashboard launcher, and task tooling for the Fusion AI coding agent.",
6
6
  "homepage": "https://github.com/Runfusion/Fusion#readme",
@@ -61,7 +61,7 @@ Based on the user's request, route to the appropriate workflow:
61
61
  <quick_reference>
62
62
 
63
63
  **Create a task:**
64
- Use `fn_task_create` with a descriptive message. Include the problem AND desired outcome.
64
+ Use `fn_task_create` with a descriptive message. Include the problem AND desired outcome, and set `priority` (`low`/`normal`/`high`/`urgent`) when urgency matters.
65
65
 
66
66
  **List tasks:**
67
67
  Use `fn_task_list` to see all tasks grouped by column. Use `column` param to filter.
@@ -11,7 +11,7 @@ These tools are **not** part of the user-invokable extension surface. They are i
11
11
 
12
12
  | Tool | Agent Types | Purpose | Parameters |
13
13
  |---|---|---|---|
14
- | `fn_task_create` | triage, executor, heartbeat | Create a follow-up task from within an agent run | `description` (string), `dependencies?` (string[]) |
14
+ | `fn_task_create` | triage, executor, heartbeat | Create a follow-up task from within an agent run | `description` (string), `dependencies?` (string[]), `priority?` (`low` \| `normal` \| `high` \| `urgent`) |
15
15
  | `fn_task_log` | executor, heartbeat | Write significant task log entries | `message` (string), `outcome?` (string) |
16
16
  | `fn_task_document_write` | triage, executor, heartbeat | Save/update a named task document revision | `key` (string), `content` (string), `author?` (string) |
17
17
  | `fn_task_document_read` | triage, executor, heartbeat | Read one task document or list all | `key?` (string) |
@@ -27,7 +27,7 @@ These tools are **not** part of the user-invokable extension surface. They are i
27
27
  | `fn_update_identity` | heartbeat | Update the current agent's own `soul`, `instructionsText`, or `memory` fields | `soul?` (string), `instructionsText?` (string), `memory?` (string) |
28
28
  | `fn_reflect_on_performance` | executor, heartbeat (when reflection service enabled) | Generate reflection insights from prior runs | `focus_area?` (string) |
29
29
  | `fn_list_agents` | triage, executor, heartbeat | List agents (optionally filtered) | `role?` (string), `state?` (string), `includeEphemeral?` (boolean) |
30
- | `fn_delegate_task` | triage, executor, heartbeat | Create and assign a new task to a specific agent | `agent_id` (string), `description` (string), `dependencies?` (string[]) |
30
+ | `fn_delegate_task` | triage, executor, heartbeat | Create and assign a new task to a specific agent | `agent_id` (string), `description` (string), `dependencies?` (string[]), `override?` (boolean) |
31
31
  | `fn_get_agent_config` | executor, heartbeat | Read full config for a direct-report agent | `agent_id` (string) |
32
32
  | `fn_update_agent_config` | executor, heartbeat | Update config fields for a direct-report, non-ephemeral agent | `agent_id` (string), optional: `soul`, `instructions_text`, `instructions_path`, `heartbeat_procedure_path`, `heartbeat_interval_ms`, `heartbeat_timeout_ms`, `max_concurrent_runs`, `message_response_mode` |
33
33
  | `fn_agent_create` | executor, heartbeat | Create a non-ephemeral direct-report agent | `name` (string), `role` (string), optional: `soul`, `instructions_text`, `instructions_path`, `reportsTo`, `heartbeat_interval_ms`, `heartbeat_timeout_ms`, `max_concurrent_runs`, `message_response_mode` |
@@ -17,6 +17,7 @@ Create a new task on the Fusion task board. The task enters the planning column
17
17
  | `description` | string | ✓ | What needs to be done — be descriptive |
18
18
  | `depends` | array | — | Task IDs this depends on (e.g. ['FN-001', 'FN-002']) |
19
19
  | `agentId` | string | — | Agent ID to assign this task to (e.g. 'agent-abc123') |
20
+ | `priority` | string(enum) | — | Task priority (low, normal, high, urgent) |
20
21
 
21
22
  ### fn_task_update
22
23
 
@@ -75,7 +76,7 @@ Unpause a task — resumes automated agent and scheduler interaction.
75
76
 
76
77
  ### fn_task_retry
77
78
 
78
- Retry a failed task — clears the error state. Tasks in other columns move to todo; tasks in in-review stay in-place for auto-merge retry.
79
+ Retry a failed task — clears the error state. Non-review failures move to todo; in-review execution failures move to todo preserving progress; in-review merge failures stay in-place for auto-merge retry.
79
80
 
80
81
  | Parameter | Type | Required | Description |
81
82
  |-----------|------|----------|-------------|
@@ -270,7 +271,7 @@ Create a new non-ephemeral agent.
270
271
  | Parameter | Type | Required | Description |
271
272
  |-----------|------|----------|-------------|
272
273
  | `name` | string | ✓ | Agent name |
273
- | `role` | string | ✓ | Agent role/capability |
274
+ | `role` | union | ✓ | Agent role/capability |
274
275
  | `soul` | string | — | Agent personality/identity text |
275
276
  | `instructions_text` | string | — | Inline custom instructions |
276
277
  | `instructions_path` | string | — | Path to instructions markdown |
@@ -286,7 +287,7 @@ Delete a non-ephemeral agent.
286
287
 
287
288
  | Parameter | Type | Required | Description |
288
289
  |-----------|------|----------|-------------|
289
- | `id` | string | ✓ | Agent ID to delete |
290
+ | `agent_id` | string | ✓ | Agent ID to delete |
290
291
  | `force` | boolean | — | Force delete when holding checkout |
291
292
  | `reassign_to` | string | — | Optional replacement agent for assigned tasks |
292
293
 
@@ -19,7 +19,7 @@ All skill/extension tool invocations in this catalog use the public `fn_*` names
19
19
  | `fn_task_attach` | Attach a file to a task. Supports images (png, jpg, gif, webp) and text files (txt, log, json, yaml, yml, toml, csv, xml). |
20
20
  | `fn_task_pause` | Pause a task — stops all automated agent and scheduler interaction for this task. |
21
21
  | `fn_task_unpause` | Unpause a task — resumes automated agent and scheduler interaction. |
22
- | `fn_task_retry` | Retry a failed task — clears the error state. Tasks in other columns move to todo; tasks in in-review stay in-place for auto-merge retry. |
22
+ | `fn_task_retry` | Retry a failed task — clears the error state. Non-review failures move to todo; in-review execution failures move to todo preserving progress; in-review merge failures stay in-place for auto-merge retry. |
23
23
  | `fn_task_duplicate` | Duplicate an existing task, creating a fresh copy in planning. Copies the title and description but resets all execution state. The AI planning agent will replan the new task. |
24
24
  | `fn_task_refine` | Request a refinement of a completed or in-review task. Creates a new follow-up task in planning that references the original task as a dependency. Use this when a done or in-review task needs additional work, improvements, or follow-up changes. |
25
25
  | `fn_task_archive` | Archive a done task (move from done → archived). Archived tasks are preserved for historical reference but moved out of the main board view. |
@@ -17,6 +17,7 @@ Use only the public `fn_*` extension tools in this workflow. Do not substitute i
17
17
  - Include the problem AND the desired outcome
18
18
  - Be specific — the AI triage agent uses your description to write the specification
19
19
  - Optionally add dependencies with the `depends` parameter
20
+ - Optionally set urgency with `priority` (`low`, `normal`, `high`, `urgent`)
20
21
 
21
22
  2. The task enters **triage** where the AI auto-generates a PROMPT.md with:
22
23
  - Steps, file scope, acceptance criteria
@@ -29,7 +30,8 @@ Example:
29
30
  ```
30
31
  fn_task_create({
31
32
  description: "The login form doesn't validate email format before submission. Add client-side email validation that shows an inline error message when the email is invalid. Use the existing form validation pattern from the signup form.",
32
- depends: ["FN-042"]
33
+ depends: ["FN-042"],
34
+ priority: "high"
33
35
  })
34
36
  ```
35
37
 
@@ -1 +0,0 @@
1
- .agent-detail-overlay{position:fixed;inset:0;background:color-mix(in srgb,var(--bg) 60%,transparent);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:100;padding:var(--space-lg)}.agent-detail-modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);width:100%;min-width:calc(var(--space-xl) * 20);max-width:calc(100vw - var(--space-2xl) - var(--space-xs) * 2);min-height:calc(var(--space-xl) * 13 + var(--space-sm));max-height:calc(100dvh - var(--space-2xl) - var(--space-xs) * 2);display:flex;flex-direction:column;overflow:hidden;resize:both;box-shadow:var(--shadow-lg)}.agent-detail-modal:not([style*=width]){width:min(calc(var(--space-xl) * 37 + var(--space-md)),calc(100vw - var(--space-2xl) - var(--space-xs) * 2))}.agent-detail-modal:not([style*=height]){height:min(85vh,calc(100dvh - var(--space-2xl) - var(--space-xs) * 2))}.agent-detail-inline-shell{width:100%;height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden}.agent-detail-inline{width:100%;height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden;background:var(--surface);border:1px solid var(--border)}.agent-detail-inline-loading{width:100%;height:100%;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden}.agent-detail-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:calc(var(--space-xl) * 2 + var(--space-md));color:var(--text-muted)}.agent-detail-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-md);padding:var(--space-md) calc(var(--space-lg) + var(--space-xs));border-bottom:1px solid var(--border);background:var(--bg-secondary)}.agent-detail-identity{display:flex;align-items:center;gap:var(--space-md);flex-shrink:0;min-width:0}.agent-detail-inline-back{display:inline-flex;align-items:center;gap:var(--space-xs);min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs));padding:calc(var(--space-sm) - var(--space-xs) * .5) calc(var(--space-sm) + var(--space-xs) * .5);flex-shrink:0}.agent-detail-icon{width:calc(var(--space-lg) * 2 + var(--space-xs));height:calc(var(--space-lg) * 2 + var(--space-xs));display:flex;align-items:center;justify-content:center;color:var(--text);flex-shrink:0}.agent-detail-info{min-width:0}.agent-detail-info h2{font-size:calc(var(--space-md) + var(--space-xs));font-weight:600;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-detail-badges{display:flex;gap:var(--space-xs);margin-top:calc(var(--space-xs) * .5)}.agent-detail-header-actions{display:flex;align-items:center;justify-content:flex-end;gap:var(--space-sm);flex:1 1 auto;min-width:0}.agent-detail-controls{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);flex-shrink:0}.btn--compact{padding:calc(var(--space-xs) + var(--space-xs) * .25) calc(var(--space-sm) + var(--space-xs) * .5);font-size:var(--space-md);gap:var(--space-xs)}.agent-detail-utility-actions{display:flex;align-items:center;gap:var(--space-xs);flex-shrink:0}.agent-detail-import-btn{min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-title{display:flex;align-items:center;gap:var(--space-lg)}.agent-detail-actions{display:flex;align-items:center;gap:var(--space-sm)}.agent-detail-tabs{display:flex;gap:var(--space-xs);padding:0 calc(var(--space-lg) + var(--space-xs));border-bottom:1px solid var(--border);background:var(--bg-secondary)}.agent-detail-tab{display:flex;align-items:center;gap:var(--space-xs);padding:calc(var(--space-sm) + var(--space-xs) * .5) var(--space-md);background:none;border:none;border-bottom:calc(var(--space-xs) * .5) solid transparent;color:var(--text-muted);font-size:calc(var(--space-sm) + var(--space-xs) + var(--space-xs) * .25);cursor:pointer;transition:all var(--transition-fast)}.agent-detail-tab:hover{color:var(--text);background:var(--card-hover)}.agent-detail-tab.active{color:var(--todo);border-bottom-color:var(--todo)}.agent-detail-tab:focus-visible{outline:none;box-shadow:var(--focus-ring-strong);background:color-mix(in srgb,var(--todo) 12%,transparent);color:var(--text);border-radius:var(--radius-sm)}.agent-detail-content{flex:1;overflow-y:auto;padding:var(--space-xl)}.agent-detail-footer{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-md) var(--space-xl);border-top:1px solid var(--border);background:var(--bg-secondary);font-size:var(--space-md);color:var(--text-muted)}.agent-detail-id{font-family:var(--font-mono);cursor:pointer}.agent-detail-id:hover{color:var(--text)}.dashboard-tab{display:flex;flex-direction:column;gap:var(--space-xl)}.dashboard-summary-layout{padding-bottom:var(--space-md)}.dashboard-summary-health-reason{margin-left:var(--space-xs);font-size:calc(var(--space-sm) + var(--space-xs))}.dashboard-summary-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md)}.budget-warning-banner{display:flex;gap:var(--space-sm);align-items:flex-start;border:1px solid var(--color-warning);background:color-mix(in srgb,var(--color-warning) 12%,transparent);border-radius:var(--radius-md);padding:var(--space-md)}.dashboard-summary-hero__heading{display:flex;align-items:center;gap:var(--space-sm)}.dashboard-summary-hero__heading h3{margin:0;font-size:calc(var(--space-lg) + var(--space-xs) * .5);font-weight:600}.dashboard-summary-hero__meta{display:flex;flex-wrap:wrap;gap:var(--space-md);color:var(--text-muted)}.agent-detail-approval-badge{display:inline-flex;align-items:center;gap:var(--space-xs);color:var(--color-warning)}.dashboard-summary-skills{display:inline-flex;align-items:center;gap:var(--space-sm)}.dashboard-summary-skill-badges{display:inline-flex;flex-wrap:wrap;gap:var(--space-xs)}.dashboard-summary-skill-badge{max-width:calc(var(--space-xl) * 8);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dashboard-summary-skill-badge-btn{cursor:pointer}.dashboard-summary-skill-badge-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.dashboard-summary-skill-badge--selected{border-color:var(--todo);background:color-mix(in srgb,var(--todo) 20%,transparent)}.dashboard-summary-skill-detail{margin-top:var(--space-sm);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);padding:var(--space-md);display:flex;flex-direction:column;gap:var(--space-sm)}.dashboard-summary-skill-detail-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.dashboard-summary-skill-detail-title{font-weight:600;color:var(--text)}.dashboard-summary-skill-detail-loading,.dashboard-summary-skill-detail-empty{display:inline-flex;align-items:center;gap:var(--space-xs);color:var(--text-muted)}.dashboard-summary-skill-detail-error{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-xs);color:var(--color-error)}.dashboard-summary-skill-detail-content{margin:0;padding:var(--space-sm);border-radius:var(--radius-sm);border:1px solid var(--border);background:var(--card);color:var(--text);white-space:pre-wrap;word-break:break-word;max-height:calc(var(--space-2xl) * 6);overflow:auto}.dashboard-summary-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(calc(var(--space-xl) * 6 + var(--space-sm)),1fr));gap:var(--space-md)}.dashboard-summary-grid p{margin:0}.dashboard-summary-label{font-size:calc(var(--space-sm) + var(--space-xs) * .5);color:var(--text-muted)}.dashboard-summary-health-row{display:inline-flex;align-items:center;gap:var(--space-xs)}.dashboard-summary-health-reason{margin-left:var(--space-xs);font-size:var(--space-md)}.runs-list{display:flex;flex-direction:column;gap:var(--space-sm)}.run-item{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:var(--space-sm)}.dashboard-section{background:var(--bg-secondary);border-radius:var(--radius-md);padding:calc(var(--space-lg) + var(--space-xs))}.dashboard-section h3{font-size:calc(var(--space-md) + var(--space-xs) * .5);font-weight:600;margin:0 0 var(--space-lg) 0;color:var(--text-muted);text-transform:uppercase;letter-spacing:calc(var(--space-xs) * .125)}.info-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(calc(var(--space-xl) * 7 + var(--space-sm)),1fr));gap:var(--space-lg)}.info-item{display:flex;flex-direction:column;gap:var(--space-xs)}.info-label{font-size:var(--space-md);color:var(--text-muted)}.info-value{font-size:calc(var(--space-md) + var(--space-xs) * .5);font-weight:500}.inline-badge{display:inline-block;padding:calc(var(--space-xs) * .5) var(--space-sm);border-radius:var(--radius-sm);font-size:var(--space-md);text-transform:capitalize}.stats-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--space-lg)}.stat-card{background:var(--surface);border-radius:var(--radius-md);padding:var(--space-lg);text-align:center}.stat-value{font-size:calc(var(--space-lg) + var(--space-xs) * .5);font-weight:700;color:var(--todo)}.stat-label{font-size:calc(var(--space-sm) + var(--space-xs) * .5);color:var(--text-muted);margin-top:var(--space-xs)}.current-task{display:flex;align-items:center;gap:var(--space-md)}.task-badge{font-family:var(--font-mono);background:var(--surface);padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm);font-size:calc(var(--space-md) + var(--space-xs) * .25)}.metadata-json{background:var(--surface);padding:var(--space-md);border-radius:var(--radius-sm);font-size:var(--space-md);overflow-x:auto;margin:0}.logs-tab{display:flex;flex-direction:column;height:100%}.logs-header{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--space-md);margin-bottom:var(--space-md);border-bottom:1px solid var(--border)}.logs-count{font-size:var(--space-md);color:var(--text-muted)}.streaming-indicator{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);font-size:var(--space-md);color:var(--color-success)}.streaming-dot{width:var(--space-sm);height:var(--space-sm);background:var(--color-success);border-radius:50%;animation:pulse 1.5s infinite}.logs-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:calc(var(--space-2xl) + var(--space-lg));color:var(--text-muted);text-align:center}.logs-empty p{margin:var(--space-sm) 0 0 0}.agent-mail-tab{display:flex;flex-direction:column;gap:var(--space-md)}.agent-mail-tab-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.agent-mail-tab-header h3{margin:0;font-size:calc(var(--space-md) + var(--space-xs) * .5)}.agent-mail-tab-error{display:flex;align-items:center;gap:var(--space-xs);color:var(--color-error)}.agent-detail-loading--inline{flex-direction:row;justify-content:flex-start;padding:var(--space-md) 0}.agent-mail-tab .agent-mail-tab-message{width:100%;border:0;background:transparent;text-align:left;color:inherit;cursor:pointer}.agent-mail-tab .agent-mail-tab-message:hover{background:var(--card-hover)}.agent-mail-tab .agent-mail-tab-message:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.agent-mail-tab .agent-mail-tab-message--selected{background:color-mix(in srgb,var(--todo) 12%,transparent)}.agent-mail-tab .agent-mail-tab-detail{display:flex;flex-direction:column;gap:var(--space-md);padding:var(--space-lg);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface)}.agent-mail-tab .agent-mail-tab-back{align-self:flex-start}.agent-mail-tab .agent-mail-tab-detail-meta{display:flex;flex-direction:column;gap:var(--space-sm)}.agent-mail-tab .agent-mail-tab-detail-row{display:flex;flex-wrap:wrap;gap:var(--space-md)}.agent-mail-tab .agent-mail-tab-detail-label{color:var(--text-muted);min-width:calc(var(--space-2xl) * 2)}.agent-mail-tab .agent-mail-tab-reply-context{color:var(--text-muted)}.agent-mail-tab .agent-mail-tab-detail-body{white-space:pre-wrap;word-break:break-word}.runs-tab{display:flex;flex-direction:column;gap:var(--space-md)}.runs-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:calc(var(--space-2xl) + var(--space-lg));color:var(--text-muted);text-align:center}.runs-empty p{margin:var(--space-sm) 0 0 0}.run-card{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg)}.run-card--active{border-color:var(--in-progress);background:color-mix(in srgb,var(--in-progress) 5%,transparent)}.run-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--space-sm)}.run-live-indicator{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);font-weight:600;color:var(--in-progress)}.live-dot{width:var(--space-sm);height:var(--space-sm);background:var(--in-progress);border-radius:50%;animation:pulse 1.5s infinite}.run-id{font-family:var(--font-mono);font-size:calc(var(--space-md) + var(--space-xs) * .25);color:var(--text-muted)}.run-status{display:flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25);font-size:calc(var(--space-md) + var(--space-xs) * .25);text-transform:capitalize}.run-status.active{color:var(--in-progress)}.run-status.completed{color:var(--color-success)}.run-status.failed{color:var(--color-error)}.run-status.terminated{color:var(--text-muted)}.run-details{display:flex;gap:var(--space-sm);font-size:var(--space-md);color:var(--text-muted)}.run-logs-container{padding:var(--space-md);background:var(--bg-secondary);border-top:1px solid var(--border);border-bottom:1px solid var(--border)}.run-details-loading-state{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) 0}.run-output-sections{margin-bottom:var(--space-md)}.run-output-section{margin-bottom:var(--space-sm)}.run-output-label{margin-bottom:var(--space-xs);color:var(--text-muted);font-size:calc(var(--space-sm) + var(--space-xs));font-weight:600;letter-spacing:calc(var(--space-xs) * .1);text-transform:uppercase}.run-output-label--error{color:var(--color-error)}.run-output-panel{margin:0;max-height:calc(var(--space-2xl) * 6.25);overflow:auto;border-radius:var(--radius-sm);padding:var(--space-sm) var(--space-md);background:var(--surface);border:1px solid var(--border);white-space:pre-wrap;word-break:break-word;font-size:calc(var(--space-sm) + var(--space-xs));line-height:1.5}.run-output-panel--error{color:var(--color-error);border-color:color-mix(in srgb,var(--color-error) 35%,var(--border));background:color-mix(in srgb,var(--color-error) 10%,transparent)}.run-context-grid{display:flex;flex-wrap:wrap;gap:var(--space-xs) var(--space-md);font-size:calc(var(--space-sm) + var(--space-xs))}.run-context-item{line-height:1.5}.run-output-empty{padding:var(--space-sm) 0;font-style:italic;font-size:calc(var(--space-sm) + var(--space-xs))}.run-agent-logs-section{margin-top:var(--space-xs);padding-top:var(--space-sm);border-top:1px solid var(--border)}.agent-tasks-list{display:flex;flex-direction:column;gap:var(--space-sm)}.agent-task-item{display:flex;flex-direction:column;gap:calc(var(--space-xs) + var(--space-sm) * .25);padding:var(--space-md) calc(var(--space-md) + var(--space-xs) * .5);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-secondary);text-decoration:none;transition:background var(--transition-fast),border-color var(--transition-fast)}.agent-task-item:hover{background:var(--card-hover);border-color:var(--text-dim)}.agent-task-row{display:flex;align-items:center;justify-content:space-between;gap:var(--space-sm)}.agent-task-id{font-family:var(--font-mono);font-size:var(--space-md);font-weight:600;color:var(--todo)}.agent-task-title{font-size:calc(var(--space-md) + var(--space-xs) * .5);font-weight:500;color:var(--text);line-height:1.4}.agent-task-status{font-size:var(--space-md);color:var(--text-muted)}.agent-task-column{display:inline-flex;align-items:center;padding:calc(var(--space-xs) * .5) var(--space-sm);border-radius:var(--radius-pill);font-size:calc(var(--space-sm) + var(--space-xs) * .5);font-weight:700;text-transform:uppercase;letter-spacing:calc(var(--space-xs) * .1)}.agent-task-column.column-triage{color:var(--triage);background:color-mix(in srgb,var(--triage) 18%,transparent)}.agent-task-column.column-todo{color:var(--todo);background:color-mix(in srgb,var(--todo) 18%,transparent)}.agent-task-column.column-in-progress{color:var(--in-progress);background:color-mix(in srgb,var(--in-progress) 18%,transparent)}.agent-task-column.column-in-review{color:var(--in-review);background:color-mix(in srgb,var(--in-review) 18%,transparent)}.agent-task-column.column-done{color:var(--done);background:color-mix(in srgb,var(--done) 18%,transparent)}.agent-task-column.column-archived{color:var(--text-muted);background:color-mix(in srgb,var(--text-muted) 18%,transparent)}.agent-tasks-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:calc(var(--space-2xl) + var(--space-lg));color:var(--text-muted);text-align:center}.agent-tasks-empty p{margin:0}.config-tab{display:flex;flex-direction:column;gap:var(--space-xl)}.config-section{background:var(--bg-secondary);border-radius:var(--radius-md);padding:calc(var(--space-md) + var(--space-sm))}.config-section h3{font-size:calc(var(--space-md) + var(--space-xs));font-weight:600;margin:0 0 var(--space-sm) 0}.config-section--danger{border:1px solid color-mix(in srgb,var(--color-error) 40%,transparent)}.config-danger-note{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted)}.agent-content-toolbar{display:flex;align-items:center;gap:var(--space-md);padding:var(--space-sm) var(--space-lg);border-bottom:1px solid var(--border);background:var(--surface);flex-shrink:0}.agent-content-mode-toggle{display:flex;align-items:center;gap:var(--space-xs)}.agent-content-mode-toggle .btn{display:inline-flex;align-items:center;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.agent-content-preview{overflow-y:auto;padding:var(--space-lg);min-height:150px}.agent-content-placeholder{color:var(--text-muted);text-align:center;padding:var(--space-xl);min-height:150px;display:flex;align-items:center;justify-content:center}.config-description{font-size:calc(var(--space-md) + var(--space-xs) * .5);color:var(--text-muted);margin:0 0 calc(var(--space-md) + var(--space-sm)) 0}.config-actions-row{display:flex;align-items:center;gap:var(--space-sm);margin-bottom:var(--space-md)}.config-fields{display:flex;flex-direction:column;gap:var(--space-lg)}.config-field{display:flex;flex-direction:column;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.config-field label{font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:500}.agent-avatar-editor{display:flex;align-items:center;gap:var(--space-md)}.agent-avatar-editor-preview{background:var(--card)}.agent-avatar-editor-actions{display:flex;align-items:center;gap:var(--space-sm);flex-wrap:wrap}.config-runtime-tabs{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-sm);margin-bottom:var(--space-md)}.config-runtime-tab{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--card);color:var(--text-muted);padding:var(--space-sm) var(--space-md);font-size:calc(var(--space-sm) + var(--space-xs));font-weight:600;cursor:pointer;transition:border-color var(--transition-fast),background var(--transition-fast),color var(--transition-fast),box-shadow var(--transition-fast)}.config-runtime-tab:hover{border-color:var(--todo);color:var(--text);background:var(--card-hover)}.config-runtime-tab:focus-visible{outline:none;border-color:var(--todo);box-shadow:var(--focus-ring-strong)}.config-runtime-tab.active{border-color:var(--todo);color:var(--text);background:color-mix(in srgb,var(--todo) 12%,transparent)}.config-hint{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted);font-style:italic}.config-error{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--color-error)}.input--error{border-color:var(--color-error)!important}.config-actions{display:flex;align-items:center;gap:var(--space-md);margin-top:calc(var(--space-md) + var(--space-sm));padding-top:var(--space-lg);border-top:1px solid var(--border)}.config-saved-indicator{display:flex;align-items:center;gap:calc(var(--space-sm) - var(--space-xs) * .5);font-size:calc(var(--space-md) + var(--space-xs) * .25);color:var(--color-success)}.config-saved-indicator--error{color:var(--color-error)}.heartbeat-procedure-actions{margin-top:var(--space-sm)}.heartbeat-procedure-viewer{margin-top:var(--space-lg)}.heartbeat-procedure-status{display:inline-flex;align-items:center;gap:var(--space-xs);margin-left:auto}.heartbeat-procedure-status--warning{color:var(--color-warning)}.rating-summary-card{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-md);padding:calc(var(--space-md) + var(--space-sm));display:flex;flex-direction:column;gap:var(--space-md)}.rating-score-display{display:flex;align-items:center;gap:var(--space-md)}.rating-average{font-size:var(--space-2xl);font-weight:700;line-height:1}.rating-stats{display:flex;align-items:center;gap:var(--space-md)}.rating-count{font-size:calc(var(--space-md) + var(--space-xs) * .5);color:var(--text-muted)}.rating-trend-badge{font-size:var(--space-md);padding:var(--space-xs) calc(var(--space-md) - var(--space-xs) * .5);border-radius:var(--radius-lg);font-weight:500}.trend-improving{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.trend-declining{background:color-mix(in srgb,var(--color-error) 15%,transparent);color:var(--color-error)}.trend-stable{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.trend-insufficient{background:var(--bg-tertiary);color:var(--text-muted)}.category-breakdown{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg)}.category-breakdown h4{margin:0 0 var(--space-md) 0;font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:600}.category-breakdown .category-item{display:flex;justify-content:space-between;align-items:center;padding:var(--space-sm) 0;border-bottom:1px solid var(--border)}.category-breakdown .category-item:last-child{border-bottom:none}.category-name{text-transform:capitalize;font-size:calc(var(--space-md) + var(--space-xs) * .25)}.category-score{font-weight:600;font-size:calc(var(--space-md) + var(--space-xs) * .25)}.add-rating-form{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-md)}.add-rating-form h4{margin:0;font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:600}.star-selector{display:flex;gap:var(--space-xs)}.star-btn{background:none;border:none;padding:var(--space-xs);cursor:pointer;border-radius:var(--radius-sm);color:var(--text-muted);transition:background-color var(--transition-fast),color var(--transition-fast)}.star-btn:hover{background:var(--card-hover)}.star-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.rating-stars{display:inline-flex;gap:var(--space-xs)}.rating-stars .star-filled{color:var(--color-warning)}.rating-stars .star-empty{color:var(--text-muted)}.add-rating-form .add-rating-category-select,.add-rating-form .add-rating-comment-input{width:100%}.add-rating-form .add-rating-comment-input{resize:vertical;min-height:calc(var(--space-xl) + var(--space-2xl))}.rating-history{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-lg);max-height:calc(var(--space-xl) * 12 + var(--space-md));overflow-y:auto}.rating-history h4{margin:0 0 var(--space-md) 0;font-size:calc(var(--space-md) + var(--space-xs) * .25);font-weight:600}.rating-history .no-ratings{color:var(--text-muted);font-size:calc(var(--space-md) + var(--space-xs) * .25);text-align:center;padding:var(--space-lg)}.rating-history-item{padding:var(--space-md) 0;border-bottom:1px solid var(--border)}.rating-history-item:last-child{border-bottom:none}.rating-item-header{display:flex;align-items:center;gap:var(--space-sm);flex-wrap:wrap}.rating-category-badge{font-size:calc(var(--space-sm) + var(--space-xs) * .5);padding:calc(var(--space-xs) * .5) var(--space-sm);background:var(--card-hover);border-radius:var(--radius-pill);text-transform:capitalize}.rating-time{font-size:calc(var(--space-sm) + var(--space-xs) * .5);color:var(--text-muted);margin-left:auto}.rating-delete-btn{background:none;border:none;padding:var(--space-xs);cursor:pointer;color:var(--text-muted);border-radius:var(--radius-sm);transition:color var(--transition-fast),background-color var(--transition-fast)}.rating-delete-btn:hover{color:var(--color-error);background:color-mix(in srgb,var(--color-error) 10%,transparent)}.rating-comment{margin:var(--space-sm) 0 0 0;font-size:calc(var(--space-sm) + var(--space-xs));color:var(--text-muted);line-height:1.4}.runs-loading-row{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-xl)}.runs-toolbar{padding:var(--space-sm) var(--space-lg);border-bottom:1px solid var(--border)}.runs-toolbar--between{display:flex;justify-content:space-between;align-items:center}.runs-toolbar-meta{font-size:calc(var(--space-sm) + var(--space-xs));color:var(--text-muted)}.run-card--clickable{cursor:pointer}.run-card--clickable:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.run-header-group{display:flex;align-items:center;gap:var(--space-sm)}.run-badge--compact{font-size:calc(var(--space-sm) + var(--space-xs) * .5);padding:calc(var(--space-xs) * .25) calc(var(--space-sm) * .75)}.run-output-summary{cursor:pointer;user-select:none}.run-live-indicator--with-margin{margin-left:var(--space-sm)}.detail-section-body--loading{display:flex;align-items:center;gap:var(--space-sm)}.agent-empty--padded{padding:var(--space-xl)}.logs-fallback-label{font-size:calc(var(--space-sm) + var(--space-xs))}.config-textarea-mono{font-family:var(--font-mono);font-size:calc(var(--space-md) + var(--space-xs) * .25);resize:vertical}.config-textarea-top-spacing{margin-top:var(--space-sm)}.config-hint--block-spacing{margin-bottom:var(--space-md)}.config-hint--block{display:block;margin-bottom:var(--space-sm)}.config-hint--top-spacing{margin-top:var(--space-sm)}.config-hint--inline-loader{display:inline-flex;gap:var(--space-xs);margin-top:var(--space-sm)}.config-inline-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space-sm)}.config-hint--inline-tight{display:flex;align-items:center;gap:var(--space-xs)}.config-hint--warning{color:var(--color-warning)}@media(max-width:768px){.config-runtime-tabs{grid-template-columns:1fr}.agent-detail-overlay{padding:0;align-items:stretch}.agent-detail-modal{min-width:0!important;min-height:0!important;width:100vw!important;height:100dvh!important;max-width:100vw!important;max-height:100dvh;margin:0;border-radius:0;border:none;resize:none}.agent-detail-header{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:var(--space-xs);row-gap:0;padding:var(--space-sm) var(--space-md);padding-top:max(var(--space-sm),env(safe-area-inset-top,0))}.agent-detail-identity{grid-column:1;grid-row:1;flex:1 1 auto;min-width:0;gap:var(--space-sm)}.agent-detail-icon{width:calc(var(--space-lg) * 2);height:calc(var(--space-lg) * 2);flex-shrink:0}.agent-detail-icon svg{width:calc(var(--space-sm) + var(--space-xs) * 2);height:calc(var(--space-sm) + var(--space-xs) * 2)}.agent-detail-info h2{font-size:calc(var(--space-md) + var(--space-xs) * .75);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.agent-detail-badges{flex-wrap:wrap}.agent-detail-header-actions{grid-column:2;grid-row:1;flex:0 0 auto;justify-content:flex-end;gap:calc(var(--space-xs) * .5)}.agent-detail-controls{flex:0 0 auto;gap:calc(var(--space-xs) * .5)}.agent-detail-controls .btn--compact{padding:calc(var(--space-sm) - var(--space-xs) * .5) calc(var(--space-md) - var(--space-xs) * .5);font-size:var(--space-md);min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-controls .agent-detail-mobile-icon-control{min-width:calc(var(--space-lg) + var(--space-md) + var(--space-xs));padding-left:calc(var(--space-sm) - var(--space-xs) * .5);padding-right:calc(var(--space-sm) - var(--space-xs) * .5)}.agent-detail-controls .agent-detail-mobile-icon-control .agent-detail-control-label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.agent-detail-controls .btn--compact svg{width:calc(var(--space-md) + var(--space-xs) * .5);height:calc(var(--space-md) + var(--space-xs) * .5)}.agent-detail-utility-actions{flex-shrink:0;margin-left:0}.agent-detail-utility-actions .btn-icon{min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs));min-width:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-import-btn{min-width:calc(var(--space-xl) * 3 + var(--space-xs))}.agent-detail-title{flex:1 1 auto;min-width:0;gap:var(--space-md)}.agent-detail-actions{flex:1 1 100%;flex-wrap:wrap;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.agent-detail-actions .btn{padding:calc(var(--space-sm) - var(--space-xs) * .5) calc(var(--space-md) - var(--space-xs) * .5);font-size:calc(var(--space-md) + var(--space-xs) * .25);min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-actions .btn svg{width:calc(var(--space-sm) + var(--space-xs) * 1.5);height:calc(var(--space-sm) + var(--space-xs) * 1.5)}.agent-detail-actions .btn-icon{min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs));min-width:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-tabs{padding:0;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none}.agent-detail-tabs::-webkit-scrollbar{display:none}.agent-detail-tab{padding:var(--space-md) calc(var(--space-md) + var(--space-xs) * .5);font-size:calc(var(--space-md) + var(--space-xs) * .25);white-space:nowrap;min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.agent-detail-content{padding:var(--space-lg)}.agent-detail-footer{flex-wrap:wrap;gap:var(--space-sm);padding:var(--space-sm) var(--space-lg);padding-bottom:max(var(--space-sm),env(safe-area-inset-bottom,0));font-size:calc(var(--space-sm) + var(--space-xs) * .75)}.agent-detail-id{max-width:140px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dashboard-tab{gap:var(--space-lg)}.dashboard-summary-skills,.dashboard-summary-skill-detail-header{flex-direction:column;align-items:flex-start}.dashboard-section{padding:var(--space-lg)}.info-grid{grid-template-columns:repeat(2,1fr);gap:var(--space-md)}.stats-grid{grid-template-columns:repeat(3,1fr);gap:var(--space-md)}.stat-value{font-size:calc(var(--space-lg) + var(--space-xs) * .5)}.logs-empty{padding:var(--space-2xl) var(--space-lg)}.agent-mail-tab-header{flex-direction:column;align-items:flex-start}.agent-mail-tab .mailbox-agent-subtabs{width:100%}.agent-mail-tab .mailbox-agent-subtab{flex:1}.agent-mail-tab .agent-mail-tab-detail{width:100%;padding:var(--space-md)}.agent-mail-tab .agent-mail-tab-back{min-height:calc(var(--space-lg) * 2 + var(--space-xs))}.run-card{padding:var(--space-md)}.run-header{flex-wrap:wrap;gap:calc(var(--space-xs) + var(--space-sm) * .25)}.run-details{flex-wrap:wrap}.run-logs-container{padding:var(--space-sm)}.run-output-panel{max-height:calc(var(--space-2xl) * 5)}.run-context-grid{flex-direction:column;gap:var(--space-xs)}.run-details .text-muted{min-width:0;overflow-wrap:anywhere}.config-tab{gap:var(--space-lg)}.config-section{padding:var(--space-lg)}.config-section .input,.config-section .select,.config-section textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-lg) + var(--space-md) + var(--space-xs))}.config-actions{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.config-actions .btn{width:100%;justify-content:center}.heartbeat-procedure-status{margin-left:0}}@media(max-width:480px){.info-grid,.stats-grid{grid-template-columns:1fr}.agent-detail-actions{flex-direction:column;width:100%}.agent-detail-actions .btn{width:100%;justify-content:center}.agent-detail-actions .btn-icon{align-self:flex-end}.agent-detail-footer .divider,.agent-detail-footer .text-muted,.agent-detail-footer .link{display:none}}@media(max-width:768px){.agent-avatar-editor{flex-direction:column;align-items:flex-start}.agent-avatar-editor-actions{width:100%}.agent-avatar-editor-actions .btn{min-height:calc(var(--space-lg) * 2 + var(--space-xs))}.agent-dialog-overlay{padding:0;align-items:stretch}.agent-dialog{width:100vw!important;height:100dvh;max-width:100%!important;max-height:100dvh;border-radius:0;border:none}.agent-dialog-header{padding:max(var(--space-md),env(safe-area-inset-top,0px)) var(--space-lg) var(--space-md) var(--space-lg);flex-shrink:0}.agent-dialog-body{padding:var(--space-lg);-webkit-overflow-scrolling:touch}.agent-dialog-footer{padding:var(--space-md) var(--space-lg);padding-bottom:max(var(--space-md),env(safe-area-inset-bottom,0px));flex-wrap:wrap;gap:var(--space-sm)}.agent-dialog-field .input,.agent-dialog-field .select,.agent-dialog-field textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-lg) * 2 + var(--space-xs))}.agent-dialog-summary-row{flex-direction:column;gap:calc(var(--space-xs) * .5)}.agent-dialog-summary-row>span:first-child,.agent-dialog-summary-row-label{width:auto}.agent-dialog-steps{padding:var(--space-sm) var(--space-lg)}.agent-dialog-step{flex:1;width:auto;height:calc(var(--space-xs) - var(--space-xs) * .25)}.agent-dialog-tabs{grid-template-columns:1fr;gap:calc(var(--space-sm) - var(--space-xs) * .5);margin-bottom:var(--space-md)}.agent-dialog-tab{min-height:calc(var(--space-lg) * 2 + var(--space-xs));text-align:left}.agent-import-file-upload{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.agent-import-textarea{font-size:calc(var(--space-md) + var(--space-xs));min-height:calc(var(--space-xl) * 4 + var(--space-xs))}.agent-import-agent-list{max-height:calc(100dvh - (var(--space-xl) * 10 + var(--space-lg)))}.agent-import-result-stats{flex-direction:column;gap:var(--space-sm);align-items:center}.agent-import-browse-list{max-height:calc(100dvh - (var(--space-xl) * 10 + var(--space-lg)))}.agent-import-skill-list{max-height:calc(100dvh - (var(--space-xl) * 15 + var(--space-md)))}}@media(max-width:480px){.agent-dialog-body{padding:var(--space-md)}.agent-dialog-footer{flex-direction:column}.agent-dialog-footer .btn{width:100%;justify-content:center}}.reflections-tab{padding:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-lg)}.reflections-header{display:flex;align-items:center;justify-content:space-between;gap:var(--space-md)}.reflections-header h3{display:flex;align-items:center;gap:var(--space-sm);font-size:1rem;font-weight:600;color:var(--text)}.reflections-stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:var(--space-md)}.reflections-stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md);text-align:center}.reflections-stat-card .stat-value{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);font-size:1.5rem;font-weight:700;color:var(--text);margin-bottom:var(--space-xs)}.reflections-stat-card .stat-label{font-size:.75rem;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em}.reflections-no-data{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-xl);color:var(--text-secondary);text-align:center}.reflections-list{display:flex;flex-direction:column;gap:var(--space-md)}.reflections-loading-indicator{display:flex;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-lg)}.reflections-ratings-section{display:flex;flex-direction:column;gap:var(--space-md)}.reflections-ratings-section>h4,.reflections-list h4{font-size:.875rem;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.reflection-cards{display:flex;flex-direction:column;gap:var(--space-sm)}.reflection-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md);cursor:pointer;transition:border-color .15s,background-color .15s}.reflection-card:hover{border-color:var(--border-active);background:var(--card-hover)}.reflection-card:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.reflection-card--expanded{border-color:var(--color-primary)}.reflection-card-header{display:flex;align-items:center;gap:var(--space-sm);margin-bottom:var(--space-sm)}.reflection-trigger-badge{font-size:.7rem;font-weight:600;padding:2px 6px;border-radius:var(--radius-sm);text-transform:uppercase;letter-spacing:.05em}.reflection-trigger-periodic{background:color-mix(in srgb,var(--color-info) 15%,transparent);color:var(--color-info)}.reflection-trigger-post-task{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.reflection-trigger-manual{background:color-mix(in srgb,var(--color-primary) 15%,transparent);color:var(--color-primary)}.reflection-trigger-user-requested{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.reflection-timestamp{font-size:.75rem;color:var(--text-muted);flex:1}.reflection-chevron{color:var(--text-muted)}.reflection-summary{font-size:.875rem;color:var(--text);line-height:1.5}.reflection-details{margin-top:var(--space-md);padding-top:var(--space-md);border-top:1px solid var(--border);display:flex;flex-direction:column;gap:var(--space-md)}.reflection-insights h5,.reflection-suggestions h5{display:flex;align-items:center;gap:var(--space-xs);font-size:.8rem;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.reflection-insights ul,.reflection-suggestions ul{list-style:none;display:flex;flex-direction:column;gap:var(--space-xs)}.reflection-insights li,.reflection-suggestions li{font-size:.8rem;color:var(--text-secondary);padding-left:var(--space-md);position:relative}.reflection-insights li:before{content:"•";position:absolute;left:4px;color:var(--color-success)}.reflection-suggestions li:before{content:"→";position:absolute;left:0;color:var(--color-primary)}.reflection-metrics{background:var(--bg);border-radius:var(--radius-sm);padding:var(--space-sm)}.reflection-metrics h5{font-size:.75rem;font-weight:600;color:var(--text-muted);margin-bottom:var(--space-xs)}.metrics-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:var(--space-sm)}.metric{display:flex;flex-direction:column;gap:2px}.metric-label{font-size:.7rem;color:var(--text-muted)}.metric-value{font-size:.875rem;font-weight:600;color:var(--text)}.reflection-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-sm);padding:var(--space-2xl);color:var(--text-secondary);text-align:center}.reflection-empty p{font-size:.875rem}@media(max-width:768px){.reflections-header{flex-wrap:wrap;align-items:flex-start}.reflections-header .btn{width:100%;justify-content:center}}.budget-progress-container{margin-top:4px}.budget-progress-bar{width:100%;height:8px;background:var(--bg-secondary, #161b22);border-radius:4px;overflow:hidden;margin-top:4px}.budget-progress-bar__fill{height:100%;border-radius:4px;transition:width .3s ease,background-color .3s ease}.budget-progress-bar__fill--green{background:var(--state-active-text, #3fb950)}.budget-progress-bar__fill--amber{background:var(--state-paused-text, #e3b541)}.budget-progress-bar__fill--red{background:var(--state-error-text, #f85149)}.budget-progress-label{font-size:.75rem;color:var(--text-secondary, #8b949e);margin-top:4px;display:block}.budget-badge{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:12px;font-size:.75rem;font-weight:500}.budget-warning-banner{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;background:var(--state-error-bg, rgba(248,81,73,.15));color:var(--state-error-text, #f85149);border:1px solid var(--state-error-border, #f85149);font-size:.875rem;margin-bottom:12px}.btn-reset-budget{margin-top:8px}.chat-sidebar-footer{display:none}@media(max-width:768px){.chat-view{flex-direction:column}.chat-sidebar{width:100%;min-width:100%;height:100%;max-height:none;border-right:none;border-bottom:1px solid var(--border);flex-direction:column}.chat-sidebar-header,.chat-sidebar-search{display:none}.chat-sidebar-list{flex:1;min-height:0;overflow-y:auto}.chat-sidebar-footer{display:flex;padding:var(--space-md);border-top:1px solid var(--border);background:var(--bg-secondary)}.chat-sidebar-footer-btn{flex:1;justify-content:center}.chat-sidebar--hidden{display:none}.chat-message{max-width:90%}.chat-new-dialog{width:95vw;margin:16px}.chat-thread-header{padding:8px 12px}.chat-skill-menu{left:var(--space-md);right:calc(var(--space-md) + var(--mobile-nav-height));min-width:0;max-width:none}}@media(max-width:768px){.file-mention-popup{max-height:200px}.file-mention-popup-item{min-height:36px;padding:10px 12px}.agent-mention-popup{max-width:280px;min-width:200px}}
@@ -1,18 +0,0 @@
1
- import{r as t,j as e}from"./vendor-react-K0fH_qHe.js";import{c as Ns,dz as St,dA as kt,dB as Ct,dC as wt,L as I,R as cs,ap as Ds,Z as Rt,aq as ms,W as rs,a as Gs,b as qs,dD as Mt,dE as Ft,dF as At,v as Ys,cI as Tt,dG as Et,z as Y,dH as Pt,dI as Ks,dJ as Zs,dK as Lt,s as ns,bp as Qs,k as Xs,U as hs,A as ls,V as zs,aQ as Le,X as et,F as Ve,dL as $t,cf as st,dM as tt,dN as Dt,cC as zt,an as Ot,bo as Ht,ar as at,B as ys,Y as Bt,a2 as It,a3 as Ut,a4 as _t,dO as ps,l as nt,dP as Vt,bz as Jt,r as Wt,ao as it,a1 as rt,dQ as Gt,C as ue,dR as lt,i as ot,dS as Os,br as Hs,dT as qt,dU as Yt,dV as Kt,dW as Je,a9 as We,ab as Ge,ac as qe,a7 as ct,dX as Zt,dY as Qt,h as Xt,j as Bs,$ as ea,dZ as sa,d_ as ta,m as aa,d$ as js,e0 as na,e1 as ia,O as ra,e2 as la,e3 as oa,e4 as dt,e5 as ca,e6 as da,e7 as ua,e8 as ma,e9 as ha}from"./index-Bdw6llW6.js";import{S as ut}from"./star-D75YKEq-.js";import{f as fs,S as fa,E as ga}from"./ExperimentalAgentOnboardingModal-Bx6yXVS5.js";import"./vendor-xterm-DzcZoU0P.js";/**
2
- * @license lucide-react v1.7.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const xa=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],is=Ns("chart-column",xa);/**
7
- * @license lucide-react v1.7.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ba=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],va=Ns("square-activity",ba);/**
12
- * @license lucide-react v1.7.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const pa=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],ja=Ns("trending-down",pa);function Is(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:s<36e5?`${Math.floor(s/6e4)}m`:`${(s/36e5).toFixed(1)}h`}function Na(s){return`${Math.round(s*100)}%`}function Us(s){const n=Date.now(),i=new Date(s).getTime(),r=n-i;if(r<0){const d=Math.abs(r);return d<6e4?"in a moment":d<36e5?`in ${Math.floor(d/6e4)}m`:d<864e5?`in ${Math.floor(d/36e5)}h`:`in ${Math.floor(d/864e5)}d`}return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}function ya(s){switch(s){case"periodic":return"Periodic";case"post-task":return"Post-Task";case"manual":return"Manual";case"user-requested":return"User Requested";default:return s}}function Ue(s){return s instanceof Error&&s.message?s.message:String(s)}function Sa(s){switch(s){case"improving":return"↑ Improving";case"declining":return"↓ Declining";case"stable":return"→ Stable";default:return"Insufficient data"}}function ka(s){switch(s){case"improving":return"trend-improving";case"declining":return"trend-declining";case"stable":return"trend-stable";default:return"trend-insufficient"}}function _s(s,n=5){return e.jsx("span",{className:"rating-stars",children:Array.from({length:n},(i,r)=>e.jsx(ut,{size:14,className:r<s?"star-filled":"star-empty",fill:r<s?"currentColor":"none"},r))})}function Ca({agentId:s,projectId:n,addToast:i}){const[r,d]=t.useState([]),[g,F]=t.useState(null),[h,p]=t.useState(null),[A,E]=t.useState([]),[c,k]=t.useState(!0),[C,L]=t.useState(!0),[j,U]=t.useState(!1),[G,b]=t.useState(!1),[m,O]=t.useState(null),[y,T]=t.useState(0),[M,_]=t.useState(""),[z,$]=t.useState(""),K=t.useCallback(async()=>{try{const[l,o]=await Promise.all([St(s,20,n),kt(s,void 0,n)]);d(l),F(o)}catch(l){i(`Failed to load reflections: ${Ue(l)}`,"error")}finally{k(!1)}},[s,n,i]),N=t.useCallback(async()=>{try{const[l,o]=await Promise.all([Ct(s,n),wt(s,{limit:50},n)]);p(l),E(o)}catch(l){i(`Failed to load ratings: ${Ue(l)}`,"error")}finally{L(!1)}},[s,n,i]);t.useEffect(()=>{K(),N()},[K,N]);const X=async()=>{U(!0);try{if(!await Mt(s,n)){i("Not enough history to generate a reflection yet","error");return}i("Reflection generated successfully","success"),k(!0),await K()}catch(l){const o=Ue(l),S=o.toLowerCase();S.includes("agent not found")||S.includes("not found")?i("This agent is no longer available. It may have been deleted.","error"):S.includes("insufficient history")?i("Not enough history to generate a reflection yet","error"):i(`Failed to generate reflection: ${o}`,"error")}finally{U(!1)}},P=async l=>{if(l.preventDefault(),y!==0){b(!0);try{await Ft(s,{score:y,category:M||void 0,comment:z||void 0,raterType:"user"},n),T(0),_(""),$(""),i("Rating added","success"),await N()}catch(o){i(`Failed to add rating: ${Ue(o)}`,"error")}finally{b(!1)}}},H=async l=>{try{await At(s,l,n),i("Rating deleted","success"),await N()}catch(o){i(`Failed to delete rating: ${Ue(o)}`,"error")}},f=l=>{O(o=>o===l?null:l)};if(c&&C)return e.jsx("div",{className:"reflections-tab",children:e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading evaluation..."})]})});const x=g&&g.totalTasksCompleted===0&&g.totalTasksFailed===0&&g.recentReflectionCount===0;return e.jsxs("div",{className:"reflections-tab",children:[e.jsxs("div",{className:"reflections-header",children:[e.jsxs("h3",{children:[e.jsx(is,{size:16}),"Performance, Reflections & Ratings"]}),e.jsx("button",{className:"btn btn-secondary",onClick:X,disabled:j,title:"Generate a manual reflection",children:j?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:14,className:"animate-spin"}),"Reflecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{size:14}),"Reflect Now"]})})]}),g&&!x&&e.jsxs("div",{className:"reflections-stats-grid",children:[e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Ds,{size:16,style:{color:"var(--color-success)"}}),g.totalTasksCompleted]}),e.jsx("div",{className:"stat-label",children:"Tasks Completed"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(ja,{size:16,style:{color:"var(--color-error)"}}),g.totalTasksFailed]}),e.jsx("div",{className:"stat-label",children:"Tasks Failed"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(Rt,{size:16,style:{color:"var(--in-progress)"}}),Is(g.avgDurationMs)]}),e.jsx("div",{className:"stat-label",children:"Avg Duration"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(is,{size:16,style:{color:g.successRate>=.8?"var(--color-success)":g.successRate>=.5?"var(--color-warning)":"var(--color-error)"}}),Na(g.successRate)]}),e.jsx("div",{className:"stat-label",children:"Success Rate"})]}),e.jsxs("div",{className:"reflections-stat-card",children:[e.jsxs("div",{className:"stat-value",children:[e.jsx(ms,{size:16,style:{color:"var(--color-info)"}}),g.recentReflectionCount]}),e.jsx("div",{className:"stat-label",children:"Reflections"})]})]}),x&&e.jsxs("div",{className:"reflections-no-data",children:[e.jsx(is,{size:24,opacity:.3}),e.jsx("p",{children:"No performance data yet"})]}),e.jsxs("div",{className:"reflections-ratings-section",children:[e.jsx("h4",{children:"User Ratings"}),C?e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading ratings..."})]}):e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:"rating-summary-card",children:[e.jsxs("div",{className:"rating-score-display",children:[e.jsx("span",{className:"rating-average",children:h.averageScore.toFixed(1)}),_s(Math.round(h.averageScore))]}),e.jsxs("div",{className:"rating-stats",children:[e.jsxs("span",{className:"rating-count",children:[h.totalRatings," ratings"]}),e.jsx("span",{className:`rating-trend-badge ${ka(h.trend)}`,children:Sa(h.trend)})]})]}),h&&Object.keys(h.categoryAverages).length>0&&e.jsxs("div",{className:"category-breakdown",children:[e.jsx("h4",{children:"Category Averages"}),Object.entries(h.categoryAverages).map(([l,o])=>e.jsxs("div",{className:"category-item",children:[e.jsx("span",{className:"category-name",children:l}),e.jsx("span",{className:"category-score",children:o.toFixed(1)})]},l))]}),e.jsxs("form",{className:"add-rating-form",onSubmit:P,children:[e.jsx("h4",{children:"Add Rating"}),e.jsx("div",{className:"star-selector",children:[1,2,3,4,5].map(l=>e.jsx("button",{type:"button",className:"star-btn touch-target",onClick:()=>T(l),title:`${l} star${l>1?"s":""}`,children:e.jsx(ut,{size:24,fill:l<=y?"currentColor":"none",className:l<=y?"star-filled":"star-empty"})},l))}),e.jsxs("select",{value:M,onChange:l=>_(l.target.value),className:"select add-rating-category-select",children:[e.jsx("option",{value:"",children:"Select category..."}),e.jsx("option",{value:"quality",children:"Quality"}),e.jsx("option",{value:"speed",children:"Speed"}),e.jsx("option",{value:"communication",children:"Communication"}),e.jsx("option",{value:"reliability",children:"Reliability"}),e.jsx("option",{value:"other",children:"Other"})]}),e.jsx("textarea",{value:z,onChange:l=>$(l.target.value),placeholder:"Optional comment...",className:"input add-rating-comment-input",rows:3}),e.jsx("button",{type:"submit",className:"btn btn-task-create",disabled:y===0||G,children:G?"Submitting...":"Submit Rating"})]}),e.jsxs("div",{className:"rating-history",children:[e.jsx("h4",{children:"Rating History"}),A.length===0?e.jsx("p",{className:"no-ratings",children:"No ratings yet"}):A.map(l=>e.jsxs("div",{className:"rating-history-item",children:[e.jsxs("div",{className:"rating-item-header",children:[_s(l.score),l.category&&e.jsx("span",{className:"rating-category-badge",children:l.category}),e.jsx("span",{className:"rating-time",children:Us(l.createdAt)}),e.jsx("button",{type:"button",className:"rating-delete-btn touch-target",onClick:()=>void H(l.id),title:"Delete rating",children:e.jsx(rs,{size:14})})]}),l.comment&&e.jsx("p",{className:"rating-comment",children:l.comment})]},l.id))]})]})]}),e.jsxs("div",{className:"reflections-list",children:[e.jsx("h4",{children:"Reflection History"}),c?e.jsxs("div",{className:"reflections-loading-indicator",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading reflections..."})]}):r.length===0?e.jsxs("div",{className:"reflection-empty",children:[e.jsx(ms,{size:32,opacity:.3}),e.jsx("p",{children:"No reflections yet"}),e.jsx("p",{className:"text-secondary",children:"Trigger a reflection to get started"})]}):e.jsx("div",{className:"reflection-cards",children:r.map(l=>{const o=m===l.id;return e.jsxs("div",{className:`reflection-card ${o?"reflection-card--expanded":""}`,onClick:()=>f(l.id),role:"button",tabIndex:0,onKeyDown:S=>S.key==="Enter"&&f(l.id),children:[e.jsxs("div",{className:"reflection-card-header",children:[e.jsx("span",{className:`reflection-trigger-badge reflection-trigger-${l.trigger}`,children:ya(l.trigger)}),e.jsx("span",{className:"reflection-timestamp",children:Us(l.timestamp)}),e.jsx("span",{className:"reflection-chevron",children:o?e.jsx(Gs,{size:16}):e.jsx(qs,{size:16})})]}),e.jsx("div",{className:"reflection-summary",children:l.summary}),o&&e.jsxs("div",{className:"reflection-details",children:[l.insights.length>0&&e.jsxs("div",{className:"reflection-insights",children:[e.jsxs("h5",{children:[e.jsx(ms,{size:14})," Insights"]}),e.jsx("ul",{children:l.insights.map((S,te)=>e.jsx("li",{children:S},te))})]}),l.suggestedImprovements.length>0&&e.jsxs("div",{className:"reflection-suggestions",children:[e.jsxs("h5",{children:[e.jsx(Ds,{size:14})," Suggested Improvements"]}),e.jsx("ul",{children:l.suggestedImprovements.map((S,te)=>e.jsx("li",{children:S},te))})]}),l.metrics&&e.jsxs("div",{className:"reflection-metrics",children:[e.jsx("h5",{children:"Metrics"}),e.jsxs("div",{className:"metrics-grid",children:[l.metrics.tasksCompleted!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Tasks:"}),e.jsx("span",{className:"metric-value",children:l.metrics.tasksCompleted})]}),l.metrics.tasksFailed!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Failed:"}),e.jsx("span",{className:"metric-value",children:l.metrics.tasksFailed})]}),l.metrics.avgDurationMs!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Avg Duration:"}),e.jsx("span",{className:"metric-value",children:Is(l.metrics.avgDurationMs)})]}),l.metrics.errorCount!==void 0&&e.jsxs("div",{className:"metric",children:[e.jsx("span",{className:"metric-label",children:"Errors:"}),e.jsx("span",{className:"metric-value",children:l.metrics.errorCount})]})]})]})]})]},l.id)})})]})]})}function ne(...s){return s.filter(Boolean).join(" ")}function $e(s){const n=Date.now(),i=new Date(s).getTime(),r=n-i;if(r<0){const d=Math.abs(r);return d<6e4?"in a moment":d<36e5?`in ${Math.floor(d/6e4)}m`:d<864e5?`in ${Math.floor(d/36e5)}h`:`in ${Math.floor(d/864e5)}d`}return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}const wa=[{id:"dashboard",label:"Dashboard",icon:va},{id:"logs",label:"Logs",icon:Ve},{id:"mail",label:"Mail",icon:$t},{id:"runs",label:"Runs",icon:ls},{id:"tasks",label:"Tasks",icon:st},{id:"employees",label:"Employees",icon:tt},{id:"soul",label:"Soul",icon:Dt},{id:"instructions",label:"Instructions",icon:zt},{id:"memory",label:"Agent Memory",icon:Ve},{id:"reflections",label:"Evaluation",icon:is},{id:"config",label:"Settings",icon:Ot}],Ss={idle:{bg:"var(--state-idle-bg)",text:"var(--state-idle-text)",border:"var(--state-idle-border)"},active:{bg:"var(--state-active-bg)",text:"var(--state-active-text)",border:"var(--state-active-border)"},running:{bg:"var(--state-active-bg)",text:"var(--state-active-text)",border:"var(--state-active-border)"},paused:{bg:"var(--state-paused-bg)",text:"var(--state-paused-text)",border:"var(--state-paused-border)"},error:{bg:"var(--state-error-bg)",text:"var(--state-error-text)",border:"var(--state-error-border)"}},os={completed:{icon:ue,color:"var(--color-success)"},failed:{icon:Gt,color:"var(--color-error)"},active:{icon:I,color:"var(--in-progress)"},terminated:{icon:Le,color:"var(--text-muted)"}},Vs={"long-term":"Long-term",daily:"Daily",dreams:"Dreams"},Ra={"long-term":"Curated durable decisions, conventions, constraints, and pitfalls for this specific agent.",daily:"Raw daily observations and open loops recorded by this agent.",dreams:"Synthesized patterns and emerging themes distilled from this agent's daily memory."},Ma=rt(js),Fa=700;function Aa(s,n){return s.some(i=>i.path===n)?n:s.find(i=>i.layer==="long-term")?.path??s[0]?.path??""}function Qa({agentId:s,projectId:n,onClose:i,addToast:r,onChildClick:d,inline:g=!1,showInlineBackButton:F=!1,initialTab:h,initialRunId:p,preferActiveRun:A=!1,onMutationSuccess:E}){const[c,k]=t.useState(null),{confirm:C}=Ys(),[L,j]=t.useState([]),[U,G]=t.useState(!0),[b,m]=t.useState(h??"dashboard"),[O,y]=t.useState(!1),[T,M]=t.useState(!1),[_,z]=t.useState(!1),[$,K]=t.useState(0),[N,X]=t.useState(null),[P,H]=t.useState(null),[f,x]=t.useState(!1),[l,o]=t.useState(null),S=t.useRef(null),te=t.useRef(!1);Tt(S,!g,"fusion:agent-detail-modal-size");const B=t.useRef(i),xe=t.useRef(r),ae=t.useRef(null),fe=t.useRef(!1),ee=t.useRef(null),w=t.useRef(0),ie=t.useRef(s),Ee=t.useRef(n);B.current=i,xe.current=r,ae.current=c;const oe=t.useCallback(async()=>{ae.current===null&&G(!0);try{const q=await Et(s,n);k(q)}catch(q){xe.current(`Failed to load agent: ${Y(q)}`,"error"),B.current()}finally{G(!1)}},[s,n]),Ye=t.useCallback(async()=>{const v=w.current,q=s,se=n,Z=()=>w.current!==v||s!==q||n!==se;try{if(c?.taskId){X(null),ee.current=null;const ke=await Pt(c.taskId,se,{limit:100});if(Z())return;j(ke.entries);return}const W=await Ks(q,1,se);if(Z())return;const re=W[0]??null;if(X(re),!re){ee.current=null,j([]);return}if(ee.current===re.id)return;const ce=await Zs(q,re.id,se);if(Z())return;j(ce),ee.current=re.id}catch(W){if(Z())return;console.error("Failed to load agent logs:",W)}},[c?.taskId,s,n]),be=t.useCallback(async()=>{x(!0),o(null);try{const v=await Lt(s,n);H(v)}catch(v){o(Y(v)),H(null)}finally{x(!1)}},[s,n]),Ke=t.useCallback(v=>{fe.current=v},[]),De=t.useCallback(async(v=!1)=>{await E?.({agentId:s,deleted:v})},[s,E]),Me=t.useCallback(async()=>{await oe(),await De(!1)},[oe,De]);t.useEffect(()=>{oe()},[oe]),t.useEffect(()=>{const v=setInterval(()=>{oe()},3e4);return()=>{clearInterval(v)}},[oe]),t.useEffect(()=>{c&&b==="logs"&&Ye()},[c,b,Ye]),t.useEffect(()=>{b!=="logs"&&(ee.current=null)},[b]),t.useEffect(()=>{c&&b==="mail"&&be()},[c,b,be]),t.useEffect(()=>{if(b!=="logs"||c?.taskId||!N||N.status!=="active")return;const v=w.current,q=s,se=N.id,Z=n?`?projectId=${encodeURIComponent(n)}`:"",W=ns(`/api/agents/${encodeURIComponent(q)}/runs/${encodeURIComponent(se)}/logs/stream${Z}`,{events:{"agent:log":re=>{if(w.current===v)try{const ce=JSON.parse(re.data);j(ke=>[...ke,ce])}catch{}}},onOpen:()=>{w.current===v&&y(!0)},onError:()=>{w.current===v&&y(!1)}});return()=>{W(),w.current===v&&y(!1)}},[b,c?.taskId,s,n,N]),t.useEffect(()=>{(ie.current!==s||Ee.current!==n)&&(ie.current=s,Ee.current=n,w.current++,j([]),y(!1),X(null),H(null),o(null),ee.current=null,fe.current=!1)},[s,n]),t.useEffect(()=>{const v=n?`?projectId=${encodeURIComponent(n)}`:"",q=w.current,se=Z=>{if(w.current===q)try{const W=JSON.parse(Z.data);if(!W||typeof W!="object"||W.agentId!==s)return;oe()}catch{}};return ns(`/api/events${v}`,{events:{"agent:updated":Z=>{if(w.current===q)try{const W=JSON.parse(Z.data);if(!W||typeof W!="object"||W.id!==s||fe.current)return;oe()}catch{}},"approval:requested":se,"approval:updated":se,"approval:decided":se}})},[s,n,oe]),t.useEffect(()=>{if(b!=="logs"||!c?.taskId){y(!1);return}const v=w.current,q=c.taskId,se=n?`?projectId=${encodeURIComponent(n)}`:"",Z=ns(`/api/tasks/${encodeURIComponent(q)}/logs/stream${se}`,{events:{"agent:log":W=>{if(w.current===v)try{const re=JSON.parse(W.data);j(ce=>[...ce,re])}catch{}}},onOpen:()=>{w.current===v&&y(!0)},onError:()=>{w.current===v&&y(!1)}});return()=>{Z(),w.current===v&&y(!1)}},[c?.taskId,b,n]);const ve=async v=>{if(T||!ae.current)return;const q=ae.current.state;if(q!==v){M(!0),k(se=>se&&{...se,state:v});try{await It(s,v,n),r(`Agent state updated to ${v}`,"success"),await Me()}catch(se){k(Z=>Z&&{...Z,state:q}),r(`Failed to update state: ${Y(se)}`,"error")}finally{M(!1)}}},ze=async()=>{if(!_){z(!0);try{await Ut(s,n,{source:"on_demand",triggerDetail:"Triggered from dashboard"}),r(`Heartbeat run started for ${c?.name??s}`,"success"),K(v=>v+1)}catch(v){r(`Failed to start heartbeat run: ${Y(v)}`,"error")}finally{z(!1)}}},ye=async()=>{if(!(!c||!await C({title:"Delete Agent",message:`Delete agent "${c.name}"? This cannot be undone.`,danger:!0})))try{await _t(s,n),r(`Agent "${c.name}" deleted`,"success"),await De(!0),i()}catch(q){r(`Failed to delete agent: ${Y(q)}`,"error")}},Oe=()=>c?Bt(c):{label:"Unknown",icon:e.jsx(ys,{size:14}),color:"var(--text-muted)",stateDerived:!1},Se=()=>{c&&(navigator.clipboard.writeText(c.id),r("Agent ID copied to clipboard","success"))};if(U)return g?e.jsx("div",{className:"agent-detail-inline-loading",role:"region","aria-label":"Agent detail loading",children:e.jsxs("div",{className:"agent-detail-loading",children:[e.jsx(I,{className:"animate-spin",size:24}),e.jsx("span",{children:"Loading agent..."})]})}):e.jsx("div",{className:"agent-detail-overlay",onMouseDown:v=>{v.target===v.currentTarget&&(te.current=!0)},onMouseUp:v=>{te.current&&v.target===v.currentTarget&&i(),te.current=!1},role:"dialog","aria-modal":"true",children:e.jsx("div",{className:"agent-detail-modal",ref:S,children:e.jsxs("div",{className:"agent-detail-loading",children:[e.jsx(I,{className:"animate-spin",size:24}),e.jsx("span",{children:"Loading agent..."})]})})});if(!c)return null;const Fe=Ss[c.state],pe=Oe(),Ze=g?"agent-detail-inline":"agent-detail-modal";return e.jsx("div",{className:g?"agent-detail-inline-shell":"agent-detail-overlay",onClick:v=>!g&&v.target===v.currentTarget&&i(),role:g?"region":"dialog","aria-label":g?"Agent detail":void 0,"aria-modal":g?void 0:"true",children:e.jsxs("div",{className:Ze,ref:S,children:[e.jsxs("div",{className:"agent-detail-header",children:[e.jsxs("div",{className:"agent-detail-identity",children:[g&&F?e.jsxs("button",{type:"button",className:"btn agent-detail-inline-back",onClick:i,"aria-label":"Back to agents",children:[e.jsx(Qs,{size:16}),"Agents"]}):null,e.jsx("div",{className:"agent-detail-icon",children:e.jsx(Xs,{agent:c,size:36})}),e.jsxs("div",{className:"agent-detail-info",children:[e.jsx("h2",{children:c.name}),e.jsxs("div",{className:"agent-detail-badges",children:[e.jsx("span",{className:"badge",style:{background:Fe.bg,color:Fe.text,border:`1px solid ${Fe.border}`},children:c.state}),e.jsxs("span",{className:"badge",style:{color:pe.color},title:pe.reason??pe.label,children:[pe.icon,!pe.stateDerived&&pe.label]})]})]})]}),e.jsxs("div",{className:"agent-detail-header-actions",children:[e.jsxs("div",{className:"agent-detail-controls",children:[c.state==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void ve("active"),disabled:T,children:[e.jsx(hs,{size:14}),"Start"]}),e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void ze(),"aria-label":`Run now for ${c.name}`,disabled:_||T,children:[e.jsx(ls,{size:14}),"Run Now"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:ye,children:[e.jsx(rs,{size:14}),"Delete"]})]}),c.state==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--compact agent-detail-mobile-icon-control",onClick:()=>void ve("paused"),disabled:T,"aria-label":"Pause",children:[e.jsx(zs,{size:14}),e.jsx("span",{className:"agent-detail-control-label",children:"Pause"})]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void ve("paused"),disabled:T,children:[e.jsx(Le,{size:14}),"Stop"]}),e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void ze(),"aria-label":`Run now for ${c.name}`,disabled:_||T,children:[e.jsx(ls,{size:14}),"Run Now"]})]}),c.state==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact agent-detail-mobile-icon-control",onClick:()=>void ve("active"),disabled:T,"aria-label":"Resume",children:[e.jsx(hs,{size:14}),e.jsx("span",{className:"agent-detail-control-label",children:"Resume"})]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:ye,children:[e.jsx(rs,{size:14}),"Delete"]})]}),c.state==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn--compact agent-detail-mobile-icon-control",onClick:()=>void ve("paused"),disabled:T,"aria-label":"Pause",children:[e.jsx(zs,{size:14}),e.jsx("span",{className:"agent-detail-control-label",children:"Pause"})]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void ve("paused"),disabled:T,children:[e.jsx(Le,{size:14}),"Stop"]})]}),c.state==="error"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn btn-task-create btn--compact",onClick:()=>void ve("active"),disabled:T,children:[e.jsx(hs,{size:14}),"Retry"]}),e.jsxs("button",{className:"btn btn--danger btn--compact",onClick:()=>void ve("paused"),disabled:T,children:[e.jsx(Le,{size:14}),"Stop"]})]})]}),e.jsxs("div",{className:"agent-detail-utility-actions",children:[e.jsx("button",{className:"btn-icon",onClick:()=>void oe(),title:"Refresh","aria-label":"Refresh",children:e.jsx(cs,{size:16})}),!g&&e.jsx("button",{className:"btn-icon",onClick:i,"aria-label":"Close",title:"Close",children:e.jsx(et,{size:20})})]})]})]}),e.jsx("div",{className:"agent-detail-tabs",children:wa.map(v=>e.jsxs("button",{className:ne("agent-detail-tab",b===v.id&&"active"),onClick:()=>m(v.id),children:[e.jsx(v.icon,{size:16}),v.label]},v.id))}),e.jsxs("div",{className:"agent-detail-content",children:[b==="dashboard"&&e.jsx(Ta,{agent:c,health:pe,onChildClick:d,projectId:n}),b==="logs"&&e.jsx(Ea,{logs:L,isStreaming:O,hasTask:!!c.taskId||L.length>0||N!==null,fallbackLabel:!c.taskId&&N?`Latest run · ${N.id.slice(0,8)}`:null}),b==="mail"&&e.jsx(La,{agent:c,mailbox:P,isLoading:f,error:l,projectId:n,addToast:r,onRefresh:()=>void be()}),b==="runs"&&e.jsx($a,{addToast:r,agentId:c.id,projectId:n,agentState:c.state,agentName:c.name,initialRunId:p,preferActiveRun:A,runNowRefreshToken:$}),b==="tasks"&&e.jsx(Ha,{agentId:c.id,projectId:n,addToast:r}),b==="employees"&&e.jsx(Wa,{agentId:c.id,projectId:n,onChildClick:d}),b==="soul"&&e.jsx(Ia,{agent:c,projectId:n,addToast:r,onSaved:Me}),b==="instructions"&&e.jsx(_a,{agent:c,projectId:n,addToast:r,onSaved:Me}),b==="memory"&&e.jsx(Ua,{agent:c,projectId:n,addToast:r,onSaved:Me}),b==="reflections"&&e.jsx(Ca,{agentId:c.id,projectId:n,addToast:r}),b==="config"&&e.jsx(Ja,{agent:c,projectId:n,addToast:r,onSaved:Me,onHasChangesChange:Ke,onDelete:ye,onAgentDraftApplied:v=>{k(q=>q&&{...q,...v})}},c.id)]}),!g&&e.jsxs("div",{className:"agent-detail-footer",children:[e.jsx("button",{className:"btn-icon",onClick:Se,title:"Copy Agent ID",children:e.jsx(Ht,{})}),e.jsx("span",{className:"agent-detail-id",onClick:Se,children:c.id}),c.taskId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"divider",children:"|"}),e.jsx("span",{className:"text-muted",children:"Working on:"}),e.jsxs("a",{href:`/tasks/${c.taskId}`,className:"link",children:[c.taskId,e.jsx(at,{size:12})]})]})]})]})})}function Ta({agent:s,health:n,onChildClick:i,projectId:r}){const d=Ss[s.state],[g,F]=t.useState([]),[h,p]=t.useState(!0),[A,E]=t.useState(null),[c,k]=t.useState([]),[C,L]=t.useState(null),[j,U]=t.useState(null),[G,b]=t.useState(!1),[m,O]=t.useState(null),y=typeof s.runtimeConfig?.runtimeHint=="string"?s.runtimeConfig.runtimeHint:"",T=(()=>{const f=s.runtimeConfig??{};if(y){const x=c.find(l=>l.runtimeId===y);return x?x.name:y}if(f.modelProvider&&f.modelId)return`${f.modelProvider}/${f.modelId}`;if(typeof f.model=="string"&&f.model.includes("/")){const x=f.model.indexOf("/");return f.model.slice(x+1)}return null})();t.useEffect(()=>{ps(s.id,r).then(E).catch(()=>E(null))},[s.id,r]),t.useEffect(()=>{nt(r).then(k).catch(()=>k([]))},[r]),t.useEffect(()=>{let f=!1;return p(!0),Vt(s.id,r).then(x=>{if(f)return;const l=x.length>0&&x[0]?.id===s.id?[...x].reverse():x;F(l)}).catch(()=>{f||F([])}).finally(()=>{f||p(!1)}),()=>{f=!0}},[s.id,r]);const M=t.useMemo(()=>{const f=s.completedRuns||[],x=new Date;x.setHours(0,0,0,0);const l=f.filter(S=>new Date(S.startedAt)>=x),o=f.filter(S=>S.status==="completed");return{totalRuns:f.length,todayRuns:l.length,successfulRuns:o.length,successRate:f.length>0?Math.round(o.length/f.length*100):0}},[s]),_=(s.completedRuns||[]).slice(0,5),z=Array.isArray(s.metadata?.skills)?s.metadata.skills:[],$=C?fs(C):null,K=t.useCallback(async f=>{b(!0),O(null),U(null);try{const x=await Jt(f,r);U(x)}catch(x){O(Y(x))}finally{b(!1)}},[r]),N=t.useCallback(f=>{if(C===f){L(null),U(null),O(null),b(!1);return}L(f),K(f)},[K,C]),X=s.state==="active"||s.state==="running",P=Wt(s.runtimeConfig?.heartbeatIntervalMs),H=X&&s.lastHeartbeatAt?new Date(new Date(s.lastHeartbeatAt).getTime()+P).toISOString():null;return e.jsxs("div",{className:"dashboard-tab dashboard-summary-layout",children:[A?.isOverBudget&&e.jsxs("div",{className:"budget-warning-banner",role:"alert",children:[e.jsx("span",{children:"⚠️"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Budget Exhausted:"})," This agent has exceeded its token budget and may operate with limited functionality."]})]}),e.jsxs("section",{className:"dashboard-summary-card dashboard-summary-hero",children:[e.jsxs("div",{className:"dashboard-summary-hero__heading",children:[e.jsx(ys,{}),e.jsx("h3",{children:"Overview"}),e.jsx("strong",{children:s.name}),e.jsx("span",{className:"inline-badge",style:{background:d.bg,color:d.text},children:s.state})]}),e.jsxs("div",{className:"dashboard-summary-hero__meta",children:[e.jsxs("span",{className:"dashboard-summary-hero__health",title:n.reason??n.label,children:[n.icon," ",n.label]}),(s.pendingApprovalCount??0)>0?e.jsxs("span",{className:"badge agent-detail-approval-badge",title:"Pending approvals",children:[e.jsx("span",{className:"status-dot status-dot--pending"}),s.pendingApprovalCount," pending approvals"]}):null,e.jsxs("span",{children:["Role: ",s.role]}),e.jsxs("span",{children:[e.jsx("span",{className:"dashboard-summary-label",children:y?"Runtime":"Model"}),e.jsxs("span",{children:[" ",T??"Auto"]})]}),z.length>0?e.jsxs("span",{className:"dashboard-summary-skills",children:[e.jsx("span",{className:"dashboard-summary-label",children:"Skills"}),e.jsx("span",{className:"dashboard-summary-skill-badges",role:"list","aria-label":"Assigned skills",children:z.map(f=>{const x=C===f;return e.jsx("button",{type:"button",className:ne("badge","badge-skill","dashboard-summary-skill-badge","dashboard-summary-skill-badge-btn",x&&"dashboard-summary-skill-badge--selected"),title:f,onClick:()=>N(f),"aria-expanded":x,"aria-label":`View details for ${fs(f)}`,children:fs(f)},f)})})]}):e.jsx("span",{children:"Skills: —"})]}),C?e.jsxs("div",{className:"dashboard-summary-skill-detail","data-testid":"agent-skill-detail",children:[e.jsxs("div",{className:"dashboard-summary-skill-detail-header",children:[e.jsx("span",{className:"dashboard-summary-skill-detail-title",children:$}),e.jsxs("button",{type:"button",className:"btn btn-sm",onClick:()=>N(C),children:[e.jsx(et,{size:14}),"Close"]})]}),G?e.jsxs("div",{className:"dashboard-summary-skill-detail-loading",role:"status","aria-live":"polite",children:[e.jsx(I,{size:14,className:"animate-spin"}),"Loading skill content..."]}):m?e.jsxs("div",{className:"dashboard-summary-skill-detail-error",role:"alert",children:[e.jsx(it,{size:14}),e.jsx("span",{children:m}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void K(C),children:"Retry"})]}):j?e.jsx("pre",{className:"dashboard-summary-skill-detail-content",children:j.skillMd||"(No SKILL.md found)"}):e.jsx("div",{className:"dashboard-summary-skill-detail-empty",children:"No skill content available"})]}):null]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Heartbeat & Health"}),e.jsxs("div",{className:"dashboard-summary-grid",children:[e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Last heartbeat"}),e.jsx("p",{children:s.lastHeartbeatAt?$e(s.lastHeartbeatAt):"Never"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Next expected"}),e.jsx("p",{children:H?$e(H):"Not scheduled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Interval"}),e.jsx("p",{children:rt(P)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"dashboard-summary-label",children:"Status"}),e.jsxs("p",{className:"dashboard-summary-health-row",children:[e.jsx("span",{className:ne("status-dot",s.state==="running"&&"status-dot--running")}),n.label,n.reason&&e.jsxs("span",{className:"text-secondary dashboard-summary-health-reason",title:n.reason,children:["(",n.reason,")"]})]})]})]})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Current Work"}),s.taskId?e.jsxs("div",{className:"current-task",children:[e.jsx("a",{href:`/tasks/${s.taskId}`,className:"task-badge",children:s.taskId}),e.jsxs("a",{href:`/tasks/${s.taskId}`,className:"btn btn-sm",children:["View Task ",e.jsx(at,{size:14})]})]}):e.jsx("p",{className:"text-muted",children:"No active assignment"})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Recent Runs"}),e.jsxs("p",{className:"dashboard-summary-label",children:[M.successfulRuns,"/",M.totalRuns," successful (",M.successRate,"%)"]}),_.length===0?e.jsx("p",{className:"text-muted",children:"No runs yet"}):e.jsx("div",{className:"runs-list",children:_.map(f=>{const x=os[f.status]||os.terminated,l=x.icon;return e.jsxs("div",{className:"run-item",children:[e.jsx(l,{size:14,style:{color:x.color}}),e.jsx("span",{children:$e(f.startedAt)}),e.jsxs("span",{className:"text-muted",children:[Math.max(0,Math.round((new Date(f.endedAt||f.startedAt).getTime()-new Date(f.startedAt).getTime())/1e3)),"s"]})]},f.id)})})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Throughput"}),e.jsxs("div",{className:"stats-grid",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-value",children:M.totalRuns}),e.jsx("div",{className:"stat-label",children:"Total Runs"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("div",{className:"stat-value",children:M.todayRuns}),e.jsx("div",{className:"stat-label",children:"Runs Today"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsxs("div",{className:"stat-value",children:[M.successRate,"%"]}),e.jsx("div",{className:"stat-label",children:"Success Rate"})]})]})]}),e.jsxs("section",{className:"dashboard-summary-card",children:[e.jsx("h3",{children:"Chain of Command"}),h?e.jsxs("div",{className:"chain-of-command-loading",role:"status","aria-live":"polite",children:[e.jsx(I,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Loading reporting chain..."})]}):g.length<=1?e.jsx("p",{className:"text-muted",children:"No reporting chain"}):e.jsx("div",{className:"chain-of-command-path","aria-label":"Chain of command",children:g.map((f,x)=>{const l=x===g.length-1,o=!l;return e.jsxs("div",{className:"chain-of-command-item",children:[e.jsx("button",{type:"button",className:`chain-of-command-node${l?" chain-of-command-node--current":""}`,onClick:()=>o&&i?.(f.id),disabled:!o||!i,title:l?"Current agent":`View ${f.name}`,children:f.name}),!l&&e.jsx("span",{className:"chain-of-command-separator","aria-hidden":"true",children:"→"})]},f.id)})})]})]})}function Ea({logs:s,isStreaming:n,hasTask:i,fallbackLabel:r}){return i?e.jsxs("div",{className:"logs-tab",children:[e.jsxs("div",{className:"logs-header",children:[e.jsxs("span",{className:"logs-count",children:[s.length," entries"]}),r&&e.jsx("span",{className:"text-muted logs-fallback-label",children:r}),n&&e.jsxs("span",{className:"streaming-indicator",children:[e.jsx("span",{className:"streaming-dot"}),"Live"]})]}),s.length===0?e.jsxs("div",{className:"logs-empty",children:[e.jsx(Ve,{size:48,opacity:.3}),e.jsx("p",{children:"No log entries yet"}),e.jsx("p",{className:"text-muted",children:n?"Waiting for activity...":"Logs will appear here when the agent is active"})]}):e.jsx(lt,{entries:s,loading:!1})]}):e.jsx("div",{className:"logs-tab",children:e.jsxs("div",{className:"logs-empty",children:[e.jsx(Ve,{size:48,opacity:.3}),e.jsx("p",{children:"No activity yet"}),e.jsx("p",{className:"text-muted",children:"Agent logs will appear here from the current task or most recent run"})]})})}function Pa(s){const n=new Date(s),r=new Date().getTime()-n.getTime(),d=Math.floor(r/6e4),g=Math.floor(r/36e5),F=Math.floor(r/864e5);return d<1?"Just now":d<60?`${d}m ago`:g<24?`${g}h ago`:F<7?`${F}d ago`:n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function as(s,n,i){if(n==="user")return s==="dashboard"?"You":`User: ${s}`;if(n==="agent"){const r=i?.get(s)?.trim();return!r||r===s?`Agent: ${s}`:`Agent: ${r}`}return"System"}function La({agent:s,mailbox:n,isLoading:i,error:r,projectId:d,addToast:g,onRefresh:F}){const[h,p]=t.useState("inbox"),[A,E]=t.useState([]);t.useEffect(()=>{let m=!1;return ot(void 0,d).then(O=>{m||E(O)}).catch(()=>{m||E([])}),()=>{m=!0}},[d]);const c=t.useMemo(()=>{const m=new Map;for(const y of A){if(!y.id)continue;const T=typeof y.name=="string"?y.name.trim():"";T.length>0&&m.set(y.id,T)}const O=typeof s.name=="string"?s.name.trim():"";return O.length>0&&m.set(s.id,O),m},[A,s.id,s.name]),[k,C]=t.useState(null),L=h==="inbox"?n?.inbox??[]:n?.outbox??[],j=k?L.find(m=>m.id===k)??null:null;t.useEffect(()=>{C(null)},[h,s.id]);const U=async m=>{if(C(m.id),!(h!=="inbox"||m.read))try{await ma(m.id,d),F()}catch(O){const y=`Failed to mark message as read: ${Y(O)}`;g?g(y,"error"):console.warn(y)}},G=()=>{C(null),F()},b=m=>e.jsxs("button",{type:"button",className:ne("mailbox-item","agent-mail-tab-message",h==="inbox"&&!m.read&&"unread",k===m.id&&"agent-mail-tab-message--selected"),onClick:()=>void U(m),"aria-pressed":k===m.id,children:[e.jsx("div",{className:"mailbox-item-avatar",children:(h==="inbox"?m.fromType:m.toType)==="agent"?e.jsx(ys,{size:16}):e.jsx(na,{size:16})}),e.jsxs("div",{className:"mailbox-item-content",children:[e.jsxs("div",{className:"mailbox-item-header",children:[h==="inbox"?e.jsx("span",{className:"mailbox-item-from",children:as(m.fromId,m.fromType,c)}):e.jsxs("span",{className:"mailbox-item-to",children:["To: ",as(m.toId,m.toType,c)]}),e.jsx("span",{className:"mailbox-item-time",children:Pa(m.createdAt)})]}),e.jsxs("div",{className:"mailbox-item-preview",children:[m.content.slice(0,80),m.content.length>80?"…":""]})]}),h==="inbox"&&!m.read?e.jsx("div",{className:"mailbox-item-unread-dot","aria-label":"Unread message"}):null]},m.id);return e.jsxs("div",{className:"agent-mail-tab",children:[e.jsxs("div",{className:"agent-mail-tab-header",children:[e.jsxs("h3",{children:[s.name," Mail"]}),e.jsxs("button",{className:"btn btn-sm",onClick:G,disabled:i,children:[e.jsx(cs,{size:14}),"Refresh"]})]}),e.jsxs("div",{className:"mailbox-agent-subtabs","data-testid":"agent-detail-mail-subtabs",children:[e.jsxs("button",{className:ne("btn","btn-sm","btn-secondary","mailbox-agent-subtab",h==="inbox"&&"active"),onClick:()=>p("inbox"),children:[e.jsx(Os,{size:12}),e.jsx("span",{children:"Inbox"}),(n?.unreadCount??0)>0?e.jsx("span",{className:"mailbox-tab-badge",children:n?.unreadCount}):null]}),e.jsxs("button",{className:ne("btn","btn-sm","btn-secondary","mailbox-agent-subtab",h==="outbox"&&"active"),onClick:()=>p("outbox"),children:[e.jsx(Hs,{size:12}),e.jsx("span",{children:"Outbox"})]})]}),i&&!n?e.jsxs("div",{className:"agent-detail-loading agent-detail-loading--inline",role:"status","aria-live":"polite",children:[e.jsx(I,{className:"animate-spin",size:16}),e.jsx("span",{children:"Loading mailbox..."})]}):null,!i&&r?e.jsxs("div",{className:"agent-mail-tab-error",role:"alert",children:[e.jsx(it,{size:16}),e.jsxs("span",{children:["Failed to load mailbox: ",r]})]}):null,!i&&!r?j?e.jsxs("div",{className:"agent-mail-tab-detail","data-testid":"agent-detail-mail-message",children:[e.jsxs("button",{type:"button",className:"btn btn-sm agent-mail-tab-back","data-testid":"agent-detail-mail-back",onClick:()=>C(null),children:[e.jsx(Qs,{size:14}),"Back to ",h==="inbox"?"Inbox":"Outbox"]}),e.jsxs("div",{className:"agent-mail-tab-detail-meta",children:[e.jsxs("div",{className:"agent-mail-tab-detail-row",children:[e.jsx("span",{className:"agent-mail-tab-detail-label",children:"From"}),e.jsx("span",{children:as(j.fromId,j.fromType,c)})]}),e.jsxs("div",{className:"agent-mail-tab-detail-row",children:[e.jsx("span",{className:"agent-mail-tab-detail-label",children:"To"}),e.jsx("span",{children:as(j.toId,j.toType,c)})]}),e.jsxs("div",{className:"agent-mail-tab-detail-row",children:[e.jsx("span",{className:"agent-mail-tab-detail-label",children:"Type"}),e.jsx("span",{children:j.type})]}),e.jsxs("div",{className:"agent-mail-tab-detail-row",children:[e.jsx("span",{className:"agent-mail-tab-detail-label",children:"Sent"}),e.jsx("span",{children:new Date(j.createdAt).toLocaleString()})]}),j.metadata?.replyTo?.messageId?e.jsxs("div",{className:"agent-mail-tab-reply-context",children:["↪ Replying to message ",j.metadata.replyTo.messageId]}):null]}),e.jsx("div",{className:"agent-mail-tab-detail-body",children:j.content})]}):e.jsx("div",{className:"mailbox-list","data-testid":"agent-detail-mail-list",children:L.length===0?e.jsxs("div",{className:"mailbox-empty","data-testid":"agent-detail-mail-empty",children:[h==="inbox"?e.jsx(Os,{size:32}):e.jsx(Hs,{size:32}),e.jsx("p",{children:h==="inbox"?"No received messages for this agent":"No sent messages for this agent"})]}):L.map(b)}):null]})}function $a({addToast:s,agentId:n,projectId:i,agentState:r,agentName:d,initialRunId:g,preferActiveRun:F,runNowRefreshToken:h}){const[p,A]=t.useState([]),{confirm:E}=Ys(),[c,k]=t.useState(!0),[C,L]=t.useState(null),[j,U]=t.useState([]),[G,b]=t.useState(!1),[m,O]=t.useState(null),[y,T]=t.useState(!1),M=t.useRef(!1),_=t.useRef(!1),z=t.useCallback(async()=>{try{const o=await Ks(n,50,i);A(o)}catch(o){s(`Failed to load runs: ${Y(o)}`,"error")}finally{k(!1)}},[n,i,s]);t.useEffect(()=>{z()},[z]),t.useEffect(()=>{if(!_.current){_.current=!0;return}k(!0),z()},[z,h]);const $=p.some(o=>o.status==="active"),K=C?p.find(o=>o.id===C)?.status:void 0;t.useEffect(()=>{if(!$)return;const o=setInterval(()=>{z()},5e3);return()=>clearInterval(o)},[$,z]),t.useEffect(()=>{if(!C||K!=="active")return;const o=i?`?projectId=${encodeURIComponent(i)}`:"";return ns(`/api/agents/${encodeURIComponent(n)}/runs/${encodeURIComponent(C)}/logs/stream${o}`,{events:{"agent:log":S=>{try{const te=JSON.parse(S.data);U(B=>[...B,te])}catch{}}}})},[C,K,n,i]);const N=t.useCallback(async o=>{if(C===o){L(null),U([]),O(null);return}L(o),b(!0),T(!0),U([]),O(null);try{const[S,te]=await Promise.all([Zs(n,o,i),qt(n,o,i)]);U(S),O(te)}catch(S){s(`Failed to load run details: ${Y(S)}`,"error"),U([]),O(null)}finally{b(!1),T(!1)}},[C,n,i,s]);t.useEffect(()=>{M.current=!1},[n,g,F]),t.useEffect(()=>{if(p.length===0||c||M.current)return;const o=g?p.find(S=>S.id===g):F?p.find(S=>S.status==="active"):null;M.current=!0,o&&N(o.id)},[g,F,p,c,N]);const X=async()=>{if(await E({title:"Stop Active Run",message:"Stop the active run? The agent's work will be interrupted.",danger:!0}))try{await ia(n,i),s("Run stopped","success"),k(!0),z()}catch(S){s(`Failed to stop run: ${Y(S)}`,"error")}};if(c&&p.length===0)return e.jsx("div",{className:"runs-tab",children:e.jsxs("div",{className:"runs-loading-row",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading runs..."})]})});if(p.length===0)return e.jsx("div",{className:"runs-tab",children:e.jsxs("div",{className:"runs-empty",children:[e.jsx(ls,{size:48,opacity:.3}),e.jsx("p",{children:"No runs yet"}),e.jsx("p",{className:"text-muted",children:"Heartbeat runs will appear here"})]})});const P=[...p].sort((o,S)=>new Date(S.startedAt).getTime()-new Date(o.startedAt).getTime()),H=P.filter(o=>o.status==="active"),f=P.filter(o=>o.status!=="active"),x=o=>o?e.jsxs("div",{className:"run-usage",children:[e.jsxs("span",{children:["Input: ",o.inputTokens.toLocaleString()]}),e.jsxs("span",{children:["Output: ",o.outputTokens.toLocaleString()]}),o.cachedTokens>0&&e.jsxs("span",{children:["Cached: ",o.cachedTokens.toLocaleString()]})]}):null,l=(o,S,te)=>{const B=os[o.status]||os.completed,xe=B.icon,ae=o.endedAt?Da(new Date(o.startedAt),new Date(o.endedAt)):"In progress",fe=C===o.id;return e.jsxs("div",{children:[e.jsxs("div",{className:ne("run-card",te&&"run-card--active",fe&&"run-card--selected","run-card--clickable"),onClick:()=>void N(o.id),role:"button",tabIndex:0,"aria-expanded":fe,"aria-label":`${te?"Active":""} run ${o.id.slice(0,8)}, ${o.status}`,onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),N(o.id))},children:[e.jsxs("div",{className:"run-header",children:[e.jsxs("div",{className:"run-header-group",children:[fe?e.jsx(Gs,{size:14}):e.jsx(qs,{size:14}),te?e.jsxs("span",{className:"run-live-indicator",children:[e.jsx("span",{className:"live-dot"}),"Live Run"]}):e.jsxs("span",{className:"run-id",children:["#",S+1," ",o.id.slice(0,8)]})]}),e.jsxs("div",{className:"run-header-group",children:[o.invocationSource&&e.jsx("span",{className:"badge run-badge--compact",children:o.invocationSource}),te&&e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:ee=>{ee.preventDefault(),ee.stopPropagation(),X()},"aria-label":"Stop active run",children:[e.jsx(Le,{size:12})," Stop"]}),e.jsxs("span",{className:ne("run-status",o.status),children:[e.jsx(xe,{size:14,style:{color:B.color}}),o.status]}),o.heartbeatProcedureSource==="custom"&&e.jsx("span",{className:"badge run-badge--compact",children:"Heartbeat: custom"})]})]}),e.jsxs("div",{className:"run-details",children:[e.jsxs("span",{children:["Started ",$e(o.startedAt)]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ae}),o.triggerDetail&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"text-muted",children:o.triggerDetail})]})]})]}),fe&&e.jsxs("div",{className:"run-logs-container",children:[y?e.jsxs("div",{className:"run-details-loading-state",children:[e.jsx(I,{size:14,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading details..."})]}):m&&e.jsxs("div",{className:"run-output-sections",children:[e.jsx("div",{className:"run-output-section",children:e.jsxs("details",{children:[e.jsx("summary",{className:"run-output-label run-output-summary",children:"System Prompt"}),m.systemPrompt?e.jsx("pre",{className:"run-output-panel",children:m.systemPrompt}):e.jsx("div",{className:"text-muted run-output-empty",children:"System prompt not captured for this run"})]})}),e.jsx("div",{className:"run-output-section",children:e.jsxs("details",{children:[e.jsx("summary",{className:"run-output-label run-output-summary",children:"Execution Prompt"}),m.executionPrompt?e.jsx("pre",{className:"run-output-panel",children:m.executionPrompt}):e.jsx("div",{className:"text-muted run-output-empty",children:"Execution prompt not captured for this run"})]})}),m.usageJson&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Token Usage"}),x(m.usageJson)]}),m.stdoutExcerpt&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Output"}),e.jsx("pre",{className:"run-output-panel",children:m.stdoutExcerpt.length>2e3?`${m.stdoutExcerpt.slice(0,2e3)}
17
-
18
- ... (truncated, ${m.stdoutExcerpt.length} chars total)`:m.stdoutExcerpt})]}),m.stderrExcerpt&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label run-output-label--error",children:"Errors"}),e.jsx(ra,{errorText:m.stderrExcerpt,summaryPrefix:"Run error",issueContext:{surface:"AgentDetailView runs",agentId:n,agentName:d,agentState:r,runId:m.id,taskId:void 0,timestamp:m.startedAt}})]}),m.resultJson&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Result"}),e.jsx("pre",{className:"run-output-panel",children:JSON.stringify(m.resultJson,null,2)})]}),m.contextSnapshot&&Object.keys(m.contextSnapshot).length>0&&e.jsxs("div",{className:"run-output-section",children:[e.jsx("div",{className:"run-output-label",children:"Context"}),e.jsx("div",{className:"run-context-grid",children:Object.entries(m.contextSnapshot).map(([ee,w])=>e.jsxs("span",{className:"run-context-item",children:[e.jsxs("span",{className:"text-muted",children:[ee,":"]})," ",e.jsx("span",{children:String(w)})]},ee))})]}),!m.stdoutExcerpt&&!m.stderrExcerpt&&!m.resultJson&&e.jsx("div",{className:"text-muted run-output-empty",children:"No output captured"})]}),e.jsxs("div",{className:"run-agent-logs-section",children:[e.jsx("div",{className:"run-output-label",children:"Agent Logs"}),G?e.jsxs("div",{className:"run-details-loading-state",children:[e.jsx(I,{size:14,className:"animate-spin"}),e.jsx("span",{className:"text-muted",children:"Loading logs..."})]}):j.length===0?e.jsx("div",{className:"text-muted run-output-empty",children:"No logs available for this run"}):e.jsx(lt,{entries:j,loading:!1})]})]})]},o.id)};return e.jsxs("div",{className:"runs-tab",children:[e.jsxs("div",{className:"runs-toolbar runs-toolbar--between",children:[e.jsxs("span",{className:"runs-toolbar-meta",children:[p.length," run",p.length!==1?"s":"",$&&e.jsxs("span",{className:"run-live-indicator run-live-indicator--with-margin",children:[e.jsx("span",{className:"live-dot"}),"Live"]})]}),e.jsx("div",{className:"run-header-group",children:$&&e.jsxs("button",{className:"btn btn--sm btn--danger",onClick:()=>void X(),"aria-label":`Stop active run for ${d??n}`,children:[e.jsx(Le,{size:14})," Stop Run"]})})]}),H.map((o,S)=>l(o,S,!0)),f.map((o,S)=>l(o,H.length+S,!1))]})}function Da(s,n){const i=Math.floor((n.getTime()-s.getTime())/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m ${i%60}s`:`${Math.floor(i/3600)}h ${Math.floor(i%3600/60)}m`}const za={triage:"Triage",todo:"Todo","in-progress":"In Progress","in-review":"In Review",done:"Done",archived:"Archived"};function Oa(s){const n=s.title?.trim()||s.description?.trim()||s.id;return n.length>80?`${n.slice(0,77)}...`:n}function Ha({agentId:s,projectId:n,addToast:i}){const[r,d]=t.useState([]),[g,F]=t.useState(!0);return t.useEffect(()=>{let h=!1;return F(!0),Yt(s,n).then(p=>{h||d(p)}).catch(p=>{h||(d([]),i(`Failed to load assigned tasks: ${Y(p)}`,"error"))}).finally(()=>{h||F(!1)}),()=>{h=!0}},[s,n,i]),g?e.jsxs("div",{className:"agent-tasks-empty",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("p",{children:"Loading assigned tasks..."})]}):r.length===0?e.jsxs("div",{className:"agent-tasks-empty",children:[e.jsx(st,{size:18}),e.jsx("p",{children:"No tasks assigned to this agent"})]}):e.jsx("div",{className:"agent-tasks-list",children:r.map(h=>e.jsxs("a",{className:"agent-task-item",href:`/tasks/${h.id}`,children:[e.jsxs("div",{className:"agent-task-row",children:[e.jsx("span",{className:"agent-task-id",children:h.id}),e.jsx("span",{className:`agent-task-column column-${h.column}`,children:za[h.column]})]}),e.jsx("div",{className:"agent-task-title",title:h.title||h.description||h.id,children:Oa(h)}),e.jsxs("div",{className:"agent-task-status",children:[h.status??"idle"," · Updated ",$e(h.updatedAt)]})]},h.id))})}const _e=[{key:"maxRetries",label:"Max Retries",type:"number",placeholder:"3",hint:"Maximum number of automatic retries on task failure (0–10, default 3)",min:0,max:10},{key:"timeoutMs",label:"Task Timeout (ms)",type:"number",placeholder:"600000",hint:"Maximum time in ms before a task is considered timed out (minimum 60000ms, default 600000ms)",min:6e4,max:864e5},{key:"logLevel",label:"Log Level",type:"select",hint:"Verbosity of agent log output",options:[{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warning"},{value:"error",label:"Error"}]}];function Ba(s){const n={};for(const i of _e){const r=s[i.key]?.trim();if(r){if(i.type==="number"){const d=Number(r);if(Number.isNaN(d)||!Number.isFinite(d)){n[i.key]=`"${i.label}" must be a valid number`;continue}i.min!==void 0&&d<i.min&&(n[i.key]=`"${i.label}" must be at least ${i.min.toLocaleString()}`),i.max!==void 0&&d>i.max&&(n[i.key]=`"${i.label}" must be at most ${i.max.toLocaleString()}`)}if(i.type==="select"){const d=i.options?.map(g=>g.value)??[];d.length>0&&!d.includes(r)&&(n[i.key]=`"${i.label}" must be one of: ${d.join(", ")}`)}}}return n}function Ia({agent:s,projectId:n,addToast:i,onSaved:r}){const[d,g]=t.useState(s.soul??""),[F,h]=t.useState(!1),[p,A]=t.useState(!1),[E,c]=t.useState(!1),k=t.useRef(null);t.useEffect(()=>{g(s.soul??""),A(!1),c(!1)},[s.id,s.soul]),t.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const C=d!==(s.soul??""),L=async()=>{if(d.length>1e4){i("Soul must be at most 10,000 characters","error");return}h(!0);try{await la(s.id,d,n),i("Soul saved","success"),A(!0),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>A(!1),3e3),await r()}catch(j){i(`Failed to save soul: ${Y(j)}`,"error")}finally{h(!1)}};return e.jsx("div",{className:"config-tab",children:e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Soul"}),e.jsx("p",{className:"config-description",children:"Define this agent's personality and identity."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-soul",children:"Agent Soul"}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${E?"":"btn-primary"}`,onClick:()=>c(!1),disabled:!E,"aria-label":"Edit mode",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${E?"btn-primary":""}`,onClick:()=>c(!0),disabled:E,"aria-label":"Preview mode",children:[e.jsx(We,{size:14}),"Preview"]})]})}),E?d.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:d})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No soul defined yet. Switch to Edit mode to define the agent's personality."}):e.jsx("textarea",{id:"agent-soul",className:"input config-textarea-mono",rows:12,placeholder:"Describe this agent's personality, tone, and behavioral traits...",value:d,onChange:j=>{g(j.target.value),A(!1)}}),!E&&e.jsx("span",{className:"config-hint",children:"Defines the agent's character and identity. Max 10,000 characters."})]})}),!E&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!C||F,onClick:()=>void L(),children:F?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save Soul"]})}),!C&&p&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ue,{size:14}),"Soul saved"]})]})]})})}function Ua({agent:s,projectId:n,addToast:i,onSaved:r}){const[d,g]=t.useState(s.memory??""),[F,h]=t.useState(!1),[p,A]=t.useState(!1),[E,c]=t.useState(!1),[k,C]=t.useState(!1),[L,j]=t.useState([]),[U,G]=t.useState(!1),[b,m]=t.useState(""),[O,y]=t.useState(""),[T,M]=t.useState(!1),[_,z]=t.useState(!1),[$,K]=t.useState(!1),[N,X]=t.useState(!1),[P,H]=t.useState(""),f=t.useRef(null),x=t.useRef(null),l=s.state==="running",o=d!==(s.memory??""),S=t.useMemo(()=>L.find(w=>w.path===b),[L,b]),te=S?Ra[S.layer]:"Select a memory file to view or edit.",B=t.useCallback(async w=>{z(!0);try{const ie=await Zt(s.id,w,n);m(ie.path),y(ie.content),M(!1),X(!1)}catch(ie){i(`Failed to load agent memory file: ${Y(ie)}`,"error")}finally{z(!1)}},[s.id,n,i]),xe=t.useCallback(async(w="")=>{G(!0);try{const{files:ie}=await Qt(s.id,n);if(j(ie),ie.length===0){m(""),y(""),M(!1);return}const Ee=Aa(ie,w);await B(Ee)}catch(ie){i(`Failed to load memory files: ${Y(ie)}`,"error"),j([]),m(""),y(""),M(!1)}finally{G(!1)}},[s.id,n,i,B]);t.useEffect(()=>{g(s.memory??""),A(!1),c(!1),C(!1),H(""),X(!1),xe()},[s.id,s.memory,xe]),t.useEffect(()=>()=>{f.current&&clearTimeout(f.current),x.current&&clearTimeout(x.current)},[]);const ae=async()=>{if(d.length>5e4){i("Memory must be at most 50,000 characters","error");return}h(!0);try{await ca(s.id,d,n),i("Memory saved","success"),A(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>A(!1),3e3),await r()}catch(w){i(`Failed to save memory: ${Y(w)}`,"error")}finally{h(!1)}},fe=async w=>{if(!(!w||w===b)){if(T){H("Save the current file before switching to another file.");return}H(""),await B(w)}},ee=async()=>{if(b){K(!0);try{await da(s.id,b,O,n),M(!1),X(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>X(!1),3e3),H(""),await xe(b),i("Agent memory file saved","success"),await r()}catch(w){i(`Failed to save agent memory file: ${Y(w)}`,"error")}finally{K(!1)}}};return e.jsx("div",{className:"config-tab",children:e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Agent Memory"}),e.jsx("p",{className:"config-description",children:"Store context that belongs to this agent only. Workspace memory, daily notes, dreams, and qmd search live in project settings under Project Memory."}),l&&e.jsx("p",{className:"config-hint config-hint--block-spacing",children:"Read-only while this agent is running."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-memory",children:"Inline Memory"}),e.jsx("span",{className:"config-hint config-hint--block",children:"Short-form memory stored directly on the agent record and injected into prompts."}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[!l&&e.jsxs("button",{className:`btn btn-sm ${E?"":"btn-primary"}`,onClick:()=>c(!1),disabled:!E,"aria-label":"Edit mode",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${E?"btn-primary":""}`,onClick:()=>c(!0),disabled:E,"aria-label":"Preview mode",children:[e.jsx(We,{size:14}),"Preview"]})]})}),E?d.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:d})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No agent memory defined yet. Switch to Edit mode to add memory content."}):e.jsx("textarea",{id:"agent-memory","aria-label":"Agent Memory",className:"input config-textarea-mono",rows:10,placeholder:"Durable preferences, operating habits, and context this agent should carry across tasks...",value:d,readOnly:l,onChange:w=>{g(w.target.value),A(!1)}}),!E&&e.jsx("span",{className:"config-hint",children:"This is the inline memory field on the agent JSON record. Max 50,000 characters."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-memory-file-select",children:"Memory Files"}),e.jsxs("span",{className:"config-hint config-hint--block",children:["Full OpenClaw memory files at ",e.jsxs("code",{children:["agent/",s.name||s.id,"/memory/"]})," (MEMORY.md, DREAMS.md, and daily notes)."]}),e.jsx("select",{id:"agent-memory-file-select",className:"select",value:b,disabled:U||_||$||L.length===0,onChange:w=>{fe(w.target.value)},children:L.length===0?e.jsx("option",{value:"",children:"No memory files found"}):L.map(w=>e.jsxs("option",{value:w.path,children:[Vs[w.layer]," • ",w.label]},w.path))}),U&&e.jsxs("span",{className:"config-hint config-hint--inline-loader",children:[e.jsx(I,{size:14,className:"animate-spin"}),"Loading memory files…"]}),S&&e.jsxs("div",{className:"config-hint config-hint--top-spacing",children:[e.jsx("strong",{children:Vs[S.layer]})," · ",te,e.jsx("br",{}),S.size.toLocaleString()," bytes · Updated ",$e(S.updatedAt)]}),e.jsx("div",{className:"agent-content-toolbar config-textarea-top-spacing",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[!l&&e.jsxs("button",{className:`btn btn-sm ${k?"":"btn-primary"}`,onClick:()=>C(!1),disabled:!k,"aria-label":"Memory file edit mode",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${k?"btn-primary":""}`,onClick:()=>C(!0),disabled:k,"aria-label":"Memory file preview mode",children:[e.jsx(We,{size:14}),"Preview"]})]})}),k?O.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:O})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No memory file content yet. Switch to Edit mode to add content."}):e.jsx("textarea",{className:"input config-textarea-mono",rows:14,placeholder:"Select a memory file to view and edit its content...",value:O,readOnly:l||!b||_,onChange:w=>{y(w.target.value),M(!0),X(!1),H("")}}),_&&e.jsxs("span",{className:"config-hint config-hint--inline-loader",children:[e.jsx(I,{size:14,className:"animate-spin"}),"Loading file content…"]}),P&&e.jsx("span",{className:"config-hint config-hint--top-spacing config-hint--block",children:P})]})]}),e.jsxs("div",{className:"config-actions",children:[!E&&e.jsx("button",{className:"btn btn-task-create",disabled:!o||F||l,onClick:()=>void ae(),children:F?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save Memory"]})}),!k&&e.jsx("button",{className:"btn",disabled:!T||$||!b||l,onClick:()=>void ee(),children:$?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving file…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save Memory File"]})}),!o&&p&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ue,{size:14}),"Memory saved"]}),!T&&N&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ue,{size:14}),"Memory file saved"]})]})]})})}function _a({agent:s,projectId:n,addToast:i,onSaved:r}){const[d,g]=t.useState(s.instructionsText??""),[F,h]=t.useState(s.instructionsPath??""),[p,A]=t.useState(!1),[E,c]=t.useState(""),[k,C]=t.useState(!1),[L,j]=t.useState(!1),[U,G]=t.useState(!1),[b,m]=t.useState(!1),[O,y]=t.useState(!1),[T,M]=t.useState(!1),_=t.useRef(null),z=t.useRef(null);t.useEffect(()=>{const P=F.trim();if(!P){c(""),j(!1);return}C(!0),ct("project",P).then(H=>{c(H.content),j(!1)}).catch(H=>{const f=Y(H);f.includes("ENOENT")||f.includes("Not found")||f.includes("not found")?(c(""),j(!1)):(i(`Failed to load instructions file: ${f}`,"error"),c(""))}).finally(()=>{C(!1)})},[F,i]),t.useEffect(()=>{g(s.instructionsText??""),h(s.instructionsPath??""),y(!1),M(!1),A(!1)},[s.id,s.instructionsText,s.instructionsPath]),t.useEffect(()=>()=>{_.current&&clearTimeout(_.current),z.current&&clearTimeout(z.current)},[]);const $=(()=>{const P=d??"",H=s.instructionsText??"",f=F?.trim()??"",x=s.instructionsPath?.trim()??"";return P!==H||f!==x})(),K=async()=>{G(!0);try{await oa(s.id,{instructionsText:d||void 0,instructionsPath:F.trim()||void 0},n),i("Instructions saved","success"),y(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>y(!1),3e3),await r()}catch(P){i(`Failed to save instructions: ${Y(P)}`,"error")}finally{G(!1)}},N=async()=>{const P=F.trim();if(!P){i("No instructions file path set","error");return}m(!0);try{await dt("project",P,E),i("Instructions file saved","success"),j(!1),M(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>M(!1),3e3),await r()}catch(H){i(`Failed to save instructions file: ${Y(H)}`,"error")}finally{m(!1)}},X=!!F.trim();return e.jsxs("div",{className:"config-tab",children:[e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Custom Instructions"}),e.jsx("p",{className:"config-description",children:"Append custom instructions to this agent's system prompt at execution time. Use this to customize behavior, coding style, or project conventions without modifying built-in prompts."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"instructions-text",children:"Inline Instructions"}),e.jsx("div",{className:"agent-content-toolbar",children:e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${p?"":"btn-primary"}`,onClick:()=>A(!1),disabled:!p,"aria-label":"Edit mode","data-testid":"instructions-edit-toggle",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${p?"btn-primary":""}`,onClick:()=>A(!0),disabled:p,"aria-label":"Preview mode","data-testid":"instructions-preview-toggle",children:[e.jsx(We,{size:14}),"Preview"]})]})}),p?d.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:d})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No inline instructions defined yet. Switch to Edit mode to add instructions."}):e.jsx("textarea",{id:"instructions-text",className:"input",rows:10,placeholder:"Enter custom instructions to append to this agent's system prompt...",value:d,onChange:P=>{g(P.target.value),y(!1)}}),!p&&e.jsx("span",{className:"config-hint",children:"Markdown formatting supported. Max 50,000 characters."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"instructions-path",children:"Instructions File Path"}),e.jsx("input",{id:"instructions-path",type:"text",className:"input",placeholder:"e.g., .fusion/agents/my-agent-instructions.md",value:F,onChange:P=>{h(P.target.value),y(!1)}}),e.jsx("span",{className:"config-hint",children:"Path to a .md file (relative to project root). Contents are read and appended at execution time."})]})]}),!p&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!$||U,onClick:()=>void K(),children:U?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save Instructions"]})}),!$&&O&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ue,{size:14}),"Instructions saved"]})]})]}),X&&e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Instructions File Editor"}),e.jsx("p",{className:"config-description",children:"Edit the instructions file directly. Changes are saved separately from the path configuration."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsxs("div",{className:"config-inline-header",children:[e.jsx("label",{htmlFor:"instructions-file-content",children:"File Content"}),k&&e.jsxs("span",{className:"config-hint config-hint--inline-tight",children:[e.jsx(I,{size:12,className:"animate-spin"}),"Loading..."]}),L&&!k&&e.jsx("span",{className:"config-hint config-hint--warning",children:"Unsaved changes"})]}),e.jsx("textarea",{id:"instructions-file-content",className:"input config-textarea-mono",rows:20,placeholder:"File content will appear here when loaded...",value:E,readOnly:k,onChange:P=>{c(P.target.value),j(!0),M(!1)}}),e.jsx("span",{className:"config-hint",children:"Edit the markdown file content directly. Save separately using the button below."})]})}),e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!L||b,onClick:()=>void N(),children:b?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save File"]})}),!L&&T&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ue,{size:14}),"File saved"]})]})]})]})}function Js(s){const n=s??{},i={};return n.heartbeatIntervalMs!==void 0&&n.heartbeatIntervalMs!==null&&(i.heartbeatIntervalMs=String(Number(n.heartbeatIntervalMs)/1e3)),n.heartbeatTimeoutMs!==void 0&&n.heartbeatTimeoutMs!==null&&(i.heartbeatTimeoutMs=String(Number(n.heartbeatTimeoutMs)/1e3)),n.maxConcurrentRuns!==void 0&&n.maxConcurrentRuns!==null&&(i.maxConcurrentRuns=String(n.maxConcurrentRuns)),(n.messageResponseMode==="immediate"||n.messageResponseMode==="on-heartbeat")&&(i.messageResponseMode=n.messageResponseMode),i}function gs(s){return s?.enabled!==!1}function xs(s){return s?.autoClaimRelevantTasks!==!1}function bs(s){return s?.runMissedHeartbeatOnStartup===!0}function vs(s){return s?.allowParallelExecution!==!1}function Ws(s){const n=(s??{}).budgetConfig,i={};return n&&(n.tokenBudget!==void 0&&n.tokenBudget!==null&&(i.tokenBudget=String(n.tokenBudget)),n.usageThreshold!==void 0&&n.usageThreshold!==null&&(i.usageThreshold=String(Number(n.usageThreshold)*100)),n.budgetPeriod!==void 0&&n.budgetPeriod!==null&&(i.budgetPeriod=String(n.budgetPeriod)),n.resetDay!==void 0&&n.resetDay!==null&&(i.resetDay=String(n.resetDay))),i}function Va({agent:s,projectId:n,addToast:i,onSaved:r}){const[d,g]=t.useState(!1),[F,h]=t.useState(!1),[p,A]=t.useState(!1),[E,c]=t.useState(!1),[k,C]=t.useState(!1),[L,j]=t.useState(""),[U,G]=t.useState(!1),[b,m]=t.useState(null),[O,y]=t.useState(!1),T=t.useRef(null),M=s.heartbeatProcedurePath?.trim(),_=`.fusion/agents/${s.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||s.id.toLowerCase().replace(/[^a-z0-9]+/g,"-")||"agent"}-${s.id.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent"}/HEARTBEAT.md`,z=`.fusion/agents/${s.id}/HEARTBEAT.md`,$=s.id.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent",K=!!(M&&(M===_||M===z||new RegExp(`^\\.fusion/agents/[^/]+-${$}/HEARTBEAT\\.md$`).test(M))),N=!!M,X=t.useCallback(async x=>{A(!0),m(null);try{const l=await ct("project",x,n);j(l.content),G(!1)}catch(l){const o=Y(l);m(o),i(`Failed to load heartbeat procedure file: ${o}`,"error")}finally{A(!1)}},[i,n]);t.useEffect(()=>{h(!1),C(!1),j(""),G(!1),m(null),A(!1),c(!1),y(!1)},[s.id,M]),t.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const P=async()=>{M&&(h(!0),await X(M))},H=async()=>{if(M){c(!0);try{await dt("project",M,L,n),G(!1),y(!0),i("Heartbeat procedure file saved","success"),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>y(!1),3e3),await r()}catch(x){i(`Failed to save heartbeat procedure file: ${Y(x)}`,"error")}finally{c(!1)}}},f=async()=>{g(!0);try{const x=await ha(s.id,n);i(x.procedureFileSeeded?`Heartbeat procedure file ready at ${x.heartbeatProcedurePath}`:`Heartbeat procedure path set to ${x.heartbeatProcedurePath}`,"success"),await r()}catch(x){i(`Failed to upgrade heartbeat procedure: ${Y(x)}`,"error")}finally{g(!1)}};return e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Heartbeat Procedure"}),e.jsxs("p",{className:"config-description",children:["The per-tick procedure this agent runs every wake. Defaults to a per-agent markdown file (for example ",e.jsx("code",{children:".fusion/agents/ceo-agent2736/HEARTBEAT.md"}),") that you can edit. Legacy id-only default paths remain valid. Resets on every tick — no need to restart the agent after editing."]}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsxs("span",{className:"config-hint",children:["Current path: ",e.jsx("code",{children:M||"(none — using built-in default)"})]}),N&&e.jsx("div",{className:"heartbeat-procedure-actions",children:e.jsx("button",{className:"btn btn-sm",onClick:()=>void P(),disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Loading file…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:16}),"View Heartbeat Markdown"]})})})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("button",{className:"btn",disabled:d||K,onClick:()=>void f(),"aria-label":"Upgrade agent to default heartbeat procedure file",children:d?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Upgrading…"]}):K?e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Already on default"]}):"Upgrade to Default Heartbeat Procedure"}),e.jsxs("span",{className:"config-hint",children:["Sets ",e.jsx("code",{children:"heartbeatProcedurePath"})," to"," ",e.jsx("code",{children:_})," ","and seeds the file from the built-in template if it doesn't exist. Each agent gets its own per-agent file, so edits stay scoped to this agent. Operator edits to the file are preserved."]})]})]}),F&&N&&M&&e.jsxs("div",{className:"config-fields heartbeat-procedure-viewer",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"heartbeat-procedure-file-content",children:"Heartbeat Procedure File"}),e.jsxs("div",{className:"agent-content-toolbar",children:[e.jsxs("div",{className:"agent-content-mode-toggle",children:[e.jsxs("button",{className:`btn btn-sm ${k?"":"btn-primary"}`,onClick:()=>C(!1),disabled:!k,"aria-label":"Heartbeat file edit mode",children:[e.jsx(Je,{size:14}),"Edit"]}),e.jsxs("button",{className:`btn btn-sm ${k?"btn-primary":""}`,onClick:()=>C(!0),disabled:k,"aria-label":"Heartbeat file preview mode",children:[e.jsx(We,{size:14}),"Preview"]})]}),p&&e.jsxs("span",{className:"config-hint heartbeat-procedure-status",children:[e.jsx(I,{size:12,className:"animate-spin"}),"Loading..."]}),U&&!p&&e.jsx("span",{className:"config-hint heartbeat-procedure-status heartbeat-procedure-status--warning",children:"Unsaved changes"})]}),k?L.trim()?e.jsx("div",{className:"agent-content-preview markdown-body",children:e.jsx(Ge,{remarkPlugins:[qe],children:L})}):e.jsx("div",{className:"agent-content-preview agent-content-placeholder",children:"No heartbeat procedure markdown content yet."}):e.jsx("textarea",{id:"heartbeat-procedure-file-content",className:"input",rows:16,value:L,readOnly:p,placeholder:"Heartbeat procedure markdown file content will appear here...",onChange:x=>{j(x.target.value),G(!0),y(!1)}}),b&&e.jsxs("span",{className:"config-error",children:["Failed to load file: ",b]}),e.jsxs("span",{className:"config-hint",children:["This editor writes directly to ",e.jsx("code",{children:M}),"."]})]}),!k&&e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!U||E||p,onClick:()=>void H(),children:E?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save Heartbeat File"]})}),!U&&O&&e.jsxs("span",{className:"config-saved-indicator",children:[e.jsx(ue,{size:14}),"File saved"]})]})]})]})}function Ja({agent:s,projectId:n,addToast:i,onSaved:r,onHasChangesChange:d,onDelete:g,onAgentDraftApplied:F}){const[h,p]=t.useState(s.name),[A,E]=t.useState(s.role),[c,k]=t.useState(s.title??""),[C,L]=t.useState(s.icon??""),[j,U]=t.useState(s.reportsTo??""),[G,b]=t.useState([]),[m,O]=t.useState(!1),[y,T]=t.useState(!1),[M,_]=t.useState(!1),z=t.useRef(null),[$,K]=t.useState(()=>{const a={};for(const u of _e){const R=s.metadata[u.key];R!=null&&(a[u.key]=String(R))}return a}),[N,X]=t.useState(()=>Js(s.runtimeConfig)),[P,H]=t.useState(()=>gs(s.runtimeConfig)),[f,x]=t.useState(()=>xs(s.runtimeConfig)),[l,o]=t.useState(()=>bs(s.runtimeConfig)),[S,te]=t.useState(()=>vs(s.runtimeConfig)),[B,xe]=t.useState(()=>Ws(s.runtimeConfig)),[ae,fe]=t.useState(s.bundleConfig?.mode??""),[ee,w]=t.useState(s.bundleConfig?.entryFile??"AGENTS.md"),[ie,Ee]=t.useState(s.bundleConfig?.externalPath??""),[oe,Ye]=t.useState(s.bundleConfig?.files??[]),[be,Ke]=t.useState(Array.isArray(s.metadata?.skills)?s.metadata.skills:[]),[De,Me]=t.useState([]),[ve,ze]=t.useState(!1),[ye,Oe]=t.useState([]),[Se,Fe]=t.useState([]),[pe,Ze]=t.useState([]),[v,q]=t.useState(!1),se=(()=>{const a=s.runtimeConfig??{};return a.modelProvider&&a.modelId?`${a.modelProvider}/${a.modelId}`:typeof a.model=="string"&&a.model.includes("/")?a.model:""})(),Z=typeof s.runtimeConfig?.runtimeHint=="string"?s.runtimeConfig.runtimeHint:"",[W,re]=t.useState(Z?"runtime":"model"),[ce,ke]=t.useState(se),[Ae,He]=t.useState(Z),Qe=j.trim(),ks=t.useMemo(()=>G.filter(a=>a.id!==s.id),[G,s.id]),mt=!!Qe&&!ks.some(a=>a.id===Qe),ht=t.useMemo(()=>({name:h,role:A,title:c||void 0,instructionsText:s.instructionsText,soul:s.soul,memory:s.memory,reportsTo:j||void 0,skills:be,model:ce||void 0,runtimeHint:W==="runtime"&&Ae||void 0,thinkingLevel:$.thinkingLevel??void 0,maxTurns:$.maxTurns?Number($.maxTurns):void 0,heartbeatIntervalMs:N.heartbeatIntervalMs?Number(N.heartbeatIntervalMs)*1e3:void 0,heartbeatTimeoutMs:N.heartbeatTimeoutMs?Number(N.heartbeatTimeoutMs)*1e3:void 0,maxConcurrentRuns:N.maxConcurrentRuns?Number(N.maxConcurrentRuns):void 0,messageResponseMode:N.messageResponseMode}),[s.instructionsText,s.memory,s.soul,$.maxTurns,$.thinkingLevel,N.heartbeatIntervalMs,N.heartbeatTimeoutMs,N.maxConcurrentRuns,N.messageResponseMode,ce,h,j,A,W,Ae,be,c]),ft=t.useCallback(a=>{p(a.name),E(a.role),k(a.title??""),L(a.icon??""),U(a.reportsTo??""),a.skills&&Ke(a.skills),a.thinkingLevel&&K(R=>({...R,thinkingLevel:a.thinkingLevel})),a.maxTurns!==void 0&&K(R=>({...R,maxTurns:String(a.maxTurns)})),a.runtimeHint!==void 0?(re("runtime"),He(a.runtimeHint??""),a.runtimeHint&&ke("")):a.model!==void 0&&(re("model"),ke(a.model??""),He(""));const u=Object.fromEntries(Object.entries({name:a.name,role:a.role,title:a.title,icon:a.icon,reportsTo:a.reportsTo,instructionsText:a.instructionsText,soul:a.soul,memory:a.memory}).filter(([,R])=>R!==void 0));F?.(u),_(!1),i("Interview draft applied. Review and save when ready.","success")},[i,F]);t.useEffect(()=>{let a=!1;return O(!0),ot(void 0,n).then(u=>{a||b(u)}).catch(()=>{a||b([])}).finally(()=>{a||O(!1)}),()=>{a=!0}},[n]),t.useEffect(()=>{ze(!0),Xt().then(a=>{Me(a.models),Oe(a.favoriteProviders),Fe(a.favoriteModels)}).catch(()=>{}).finally(()=>ze(!1))},[]);const gt=t.useCallback(async a=>{const u=ye,J=u.includes(a)?u.filter(de=>de!==a):[a,...u];Oe(J);try{await Bs({favoriteProviders:J,favoriteModels:Se})}catch{Oe(u)}},[ye,Se]),xt=t.useCallback(async a=>{const u=Se,J=u.includes(a)?u.filter(de=>de!==a):[a,...u];Fe(J);try{await Bs({favoriteProviders:ye,favoriteModels:J})}catch{Fe(u)}},[ye,Se]);t.useEffect(()=>{q(!0),nt(n).then(Ze).catch(()=>Ze([])).finally(()=>q(!1))},[n]);const[Ce,ds]=t.useState(null),[Cs,ws]=t.useState(!1);t.useEffect(()=>{ps(s.id,n).then(ds).catch(()=>ds(null))},[s.id,n]);const bt=async()=>{ws(!0);try{await ua(s.id,n),i("Budget usage reset successfully","success");const a=await ps(s.id,n);ds(a)}catch(a){i(`Failed to reset budget: ${Y(a)}`,"error")}finally{ws(!1)}},[we,Rs]=t.useState(!1),[V,Te]=t.useState({}),[vt,Pe]=t.useState(!1),[us,Xe]=t.useState(null),Ms=s.state==="idle"||s.state==="paused",Be=t.useRef(null),Fs=t.useRef(null),As=t.useRef(null),es=t.useRef(0);t.useEffect(()=>()=>{Be.current&&clearTimeout(Be.current)},[]);const ge=(()=>{if(h!==s.name||A!==s.role||c!==(s.title??"")||C!==(s.icon??"")||j!==(s.reportsTo??"")||ae!==(s.bundleConfig?.mode??"")||ee!==(s.bundleConfig?.entryFile??"AGENTS.md")||ie!==(s.bundleConfig?.externalPath??"")||JSON.stringify(oe)!==JSON.stringify(s.bundleConfig?.files??[]))return!0;for(const Q of _e){const he=$[Q.key]?.trim()??"",D=s.metadata[Q.key]!==void 0&&s.metadata[Q.key]!==null?String(s.metadata[Q.key]):"";if(he!==D)return!0}const a=s.runtimeConfig??{};if(P!==gs(s.runtimeConfig)||f!==xs(s.runtimeConfig)||l!==bs(s.runtimeConfig)||S!==vs(s.runtimeConfig))return!0;for(const Q of["heartbeatIntervalMs","heartbeatTimeoutMs","maxConcurrentRuns","messageResponseMode"]){const he=N[Q]?.trim()??"";let D=a[Q]!==void 0&&a[Q]!==null?String(a[Q]):"";if((Q==="heartbeatIntervalMs"||Q==="heartbeatTimeoutMs")&&D&&(D=String(Number(D)/1e3)),he!==D)return!0}const u=a.budgetConfig;for(const Q of["tokenBudget","budgetPeriod","resetDay"]){const he=B[Q]?.trim()??"",D=u?.[Q]!==void 0&&u?.[Q]!==null?String(u[Q]):"";if(he!==D)return!0}const R=B.usageThreshold?.trim()??"",J=u?.usageThreshold!==void 0&&u?.usageThreshold!==null?String(Number(u.usageThreshold)*100):"";if(R!==J)return!0;const de=Array.isArray(s.metadata?.skills)?s.metadata.skills:[];return JSON.stringify(be)!==JSON.stringify(de)||W!==(Z?"runtime":"model")||ce!==se||Ae!==Z})(),Ts=t.useRef(null);t.useEffect(()=>{d&&Ts.current!==ge&&(Ts.current=ge,d(ge))},[ge,d]),t.useEffect(()=>()=>{d?.(!1)},[d]),t.useEffect(()=>{const a={id:s.id,updatedAt:s.updatedAt},u=Fs.current;(!u||u.id!==a.id||u.updatedAt!==a.updatedAt)&&(ge||(Fs.current=a,X(Js(s.runtimeConfig)),H(gs(s.runtimeConfig)),x(xs(s.runtimeConfig)),o(bs(s.runtimeConfig)),te(vs(s.runtimeConfig)),xe(Ws(s.runtimeConfig)),ke(se),He(Z),re(Z?"runtime":"model")))},[s,ge,se,Z]);const Es=(a,u)=>{K(R=>({...R,[a]:u})),Pe(!1),V[a]&&Te(R=>{const J={...R};return delete J[a],J})},ss=(a,u)=>{X(R=>({...R,[a]:u})),Pe(!1),V[a]&&Te(R=>{const J={...R};return delete J[a],J})},pt=a=>{H(a),Pe(!1)},ts=(a,u)=>{xe(R=>({...R,[a]:u})),Pe(!1),V[a]&&Te(R=>{const J={...R};return delete J[a],J})},je=t.useMemo(()=>{const a=Ba($);for(const[D,Re]of Object.entries({heartbeatIntervalMs:{label:"Heartbeat Interval",min:1},heartbeatTimeoutMs:{label:"Heartbeat Timeout",min:5},maxConcurrentRuns:{label:"Max Concurrent Runs",min:1}})){const le=N[D]?.trim();if(!le)continue;const Ne=Number(le);Number.isNaN(Ne)||!Number.isFinite(Ne)?a[D]=`"${Re.label}" must be a valid number`:Ne<Re.min&&(a[D]=`"${Re.label}" must be at least ${Re.min.toLocaleString()}`)}const u=N.messageResponseMode?.trim();u&&!["immediate","on-heartbeat"].includes(u)&&(a.messageResponseMode='"Message Response Mode" must be either immediate or on-heartbeat');const R=B.tokenBudget?.trim();if(R){const D=Number(R);Number.isNaN(D)||!Number.isFinite(D)?a.tokenBudget='"Token Budget" must be a valid number':D<=0&&(a.tokenBudget='"Token Budget" must be greater than 0')}const J=B.usageThreshold?.trim();if(J){const D=Number(J);Number.isNaN(D)||!Number.isFinite(D)?a.usageThreshold='"Usage Threshold" must be a valid number':(D<1||D>100)&&(a.usageThreshold='"Usage Threshold" must be between 1 and 100')}const de=B.budgetPeriod?.trim();de&&!["daily","weekly","monthly","lifetime"].includes(de)&&(a.budgetPeriod='"Budget Period" must be one of: daily, weekly, monthly, lifetime');const Q=B.resetDay?.trim(),he=de||"lifetime";if(Q){const D=Number(Q);Number.isNaN(D)||!Number.isFinite(D)?a.resetDay='"Reset Day" must be a valid number':he==="weekly"?(D<0||D>6||!Number.isInteger(D))&&(a.resetDay='"Reset Day" must be between 0 (Sunday) and 6 (Saturday) for weekly period'):he==="monthly"&&(D<1||D>31||!Number.isInteger(D))&&(a.resetDay='"Reset Day" must be between 1 and 31 for monthly period')}return a},[$,N,B]),Ps=t.useCallback(()=>{if(Object.keys(je).length>0)return null;const a={...s.metadata};for(const le of _e){const Ne=$[le.key]?.trim();Ne?le.type==="number"?a[le.key]=Number(Ne):a[le.key]=Ne:delete a[le.key]}be.length>0?a.skills=be:delete a.skills;const u={...s.runtimeConfig};u.enabled=P,u.autoClaimRelevantTasks=f,u.runMissedHeartbeatOnStartup=l,u.allowParallelExecution=S;for(const le of["heartbeatIntervalMs","heartbeatTimeoutMs","maxConcurrentRuns"]){const Ne=N[le]?.trim();if(!Ne)delete u[le];else{const $s=Number(Ne);u[le]=le==="maxConcurrentRuns"?$s:$s*1e3}}const R=N.messageResponseMode?.trim();if(R?u.messageResponseMode=R:delete u.messageResponseMode,W==="runtime")Ae.trim()?u.runtimeHint=Ae.trim():delete u.runtimeHint,delete u.modelProvider,delete u.modelId,delete u.model;else if(delete u.runtimeHint,ce.trim()){const le=ce.indexOf("/");le!==-1&&(u.modelProvider=ce.slice(0,le),u.modelId=ce.slice(le+1),u.model=ce.trim())}else delete u.modelProvider,delete u.modelId,delete u.model;const J={},de=B.tokenBudget?.trim(),Q=B.usageThreshold?.trim(),he=B.budgetPeriod?.trim(),D=B.resetDay?.trim();de&&(J.tokenBudget=Number(de)),Q&&(J.usageThreshold=Number(Q)/100),he&&(J.budgetPeriod=he),D&&(J.resetDay=Number(D)),Object.keys(J).length>0?u.budgetConfig=J:delete u.budgetConfig;let Re;return ae&&(Re={mode:ae,entryFile:ee||"AGENTS.md",files:oe.length>0?oe:["AGENTS.md"]},ae==="external"&&ie.trim()&&(Re.externalPath=ie.trim())),{name:h.trim()||void 0,role:A,title:c.trim()||void 0,icon:C.trim()||void 0,reportsTo:j.trim()||void 0,metadata:a,runtimeConfig:u,bundleConfig:Re}},[s.metadata,s.runtimeConfig,S,f,B,ee,ie,oe,ae,$,P,N,C,ce,h,j,A,l,W,Ae,be,c,je]),Ie=t.useCallback(async(a,u)=>{const R=Ps();if(!R)return Te(je),a&&i("Please fix validation errors before saving","error"),u==="auto"&&Xe("Fix validation errors to save changes"),!1;const J=JSON.stringify(R);if(J===As.current)return!1;const de=++es.current;Te({}),Xe(null),Rs(!0);try{return await ea(s.id,R,n),de!==es.current?!1:(As.current=J,u==="manual"&&i("Settings saved","success"),Xe(null),Pe(!0),Be.current&&clearTimeout(Be.current),Be.current=setTimeout(()=>Pe(!1),3e3),await r(),!0)}catch(Q){if(de===es.current){const he=Y(Q);Xe(he),i(`Failed to save settings: ${he}`,"error")}return!1}finally{de===es.current&&Rs(!1)}},[i,s.id,Ps,r,n,je]),jt=async()=>{await Ie(!0,"manual")},me=t.useCallback(()=>{if(!(!ge||we)){if(Object.keys(je).length>0){Te(je);return}Ie(!1,"auto")}},[ge,we,Ie,je]);t.useEffect(()=>{if(!ge||we)return;if(Object.keys(je).length>0){Te(je);return}const a=setTimeout(()=>{Ie(!1,"auto")},Fa);return()=>clearTimeout(a)},[ge,we,Ie,je]);const Nt=t.useCallback(async a=>{T(!0);try{await sa(s.id,a,n),await r(),i("Avatar uploaded","success")}catch(u){i(Y(u),"error")}finally{T(!1),z.current&&(z.current.value="")}},[i,s.id,r,n]),yt=t.useCallback(async()=>{T(!0);try{await ta(s.id,n),await r(),i("Avatar removed","success")}catch(a){i(Y(a),"error")}finally{T(!1)}},[i,s.id,r,n]),Ls=we?"Saving changes…":us?`Save failed: ${us}`:!ge&&vt?"All changes saved":null;return e.jsxs("div",{className:"config-tab",children:[e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Agent Configuration"}),e.jsx("p",{className:"config-description",children:"Configure agent settings and behavior."}),e.jsx("div",{className:"config-actions-row",children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>_(!0),children:"AI Interview"})}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-name",children:"Name"}),e.jsx("input",{id:"agent-name",type:"text",className:"input",value:h,onChange:a=>p(a.target.value),onBlur:()=>{me()}})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-role",children:"Role"}),e.jsxs("select",{id:"agent-role",className:"select",value:A,onChange:a=>{E(a.target.value),me()},children:[e.jsx("option",{value:"triage",children:"Triage"}),e.jsx("option",{value:"executor",children:"Executor"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"merger",children:"Merger"}),e.jsx("option",{value:"scheduler",children:"Scheduler"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-title",children:"Title"}),e.jsx("input",{id:"agent-title",type:"text",className:"input",placeholder:"e.g. Senior Code Reviewer",value:c,onChange:a=>k(a.target.value),onBlur:()=>{me()}})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Avatar"}),e.jsxs("div",{className:"agent-avatar-editor",children:[e.jsx(Xs,{agent:s,size:64,className:"agent-avatar-editor-preview"}),e.jsxs("div",{className:"agent-avatar-editor-actions",children:[e.jsx("input",{ref:z,id:"agent-avatar-upload",type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"visually-hidden",disabled:y,onChange:a=>{const u=a.target.files?.[0];u&&Nt(u)}}),e.jsx("button",{type:"button",className:"btn btn-sm",disabled:y,onClick:()=>z.current?.click(),children:"Upload Avatar"}),s.imageUrl?e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void yt(),disabled:y,children:"Remove Avatar"}):null]})]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-icon",children:"Icon"}),e.jsx("input",{id:"agent-icon",type:"text",className:"input",placeholder:"e.g. 🤖",value:C,onChange:a=>L(a.target.value),onBlur:()=>{me()}})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-reports-to",children:"Reports To"}),e.jsxs("select",{id:"agent-reports-to",className:"select",value:j,onChange:a=>{U(a.target.value),me()},disabled:m,children:[e.jsx("option",{value:"",children:"No manager"}),mt&&e.jsxs("option",{value:Qe,children:["Unknown manager (",Qe,")"]}),ks.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.id,")"]},a.id))]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Skills"}),e.jsx("p",{className:"config-description",children:"Assign skills to this agent for specialized behavior."}),e.jsx("div",{className:"config-fields",children:e.jsx("div",{className:"config-field",children:e.jsx(fa,{id:"agent-skills",label:"Skills",value:be,onChange:a=>{Ke(a),me()},projectId:n})})})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Model"}),e.jsx("p",{className:"config-description",children:"Choose either a built-in model or a plugin runtime for this agent. These options are mutually exclusive."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Runtime Source"}),e.jsxs("div",{className:"config-runtime-tabs",role:"tablist","aria-label":"Runtime source",children:[e.jsx("button",{type:"button",className:`config-runtime-tab${W==="model"?" active":""}`,role:"tab","aria-selected":W==="model",tabIndex:W==="model"?0:-1,onClick:()=>{re("model"),He(""),me()},children:"Built-in Model"}),e.jsx("button",{type:"button",className:`config-runtime-tab${W==="runtime"?" active":""}`,role:"tab","aria-selected":W==="runtime",tabIndex:W==="runtime"?0:-1,onClick:()=>{re("runtime"),me()},children:"Plugin Runtime"})]})]}),W==="model"?e.jsx("div",{className:"config-field",children:e.jsx(aa,{models:De,value:ce,onChange:a=>{ke(a),me()},placeholder:"Use global default",label:"Agent Model",disabled:ve,favoriteProviders:ye,onToggleFavorite:gt,favoriteModels:Se,onToggleModelFavorite:xt})}):e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"agent-runtime-hint",children:"Runtime"}),v?e.jsx("span",{className:"config-hint",children:"Loading runtimes…"}):e.jsxs("select",{id:"agent-runtime-hint",className:"select",value:Ae,onChange:a=>{He(a.target.value),me()},children:[e.jsx("option",{value:"",children:pe.length>0?"Select a plugin runtime…":"No plugin runtimes available"}),pe.map(a=>e.jsx("option",{value:a.runtimeId,children:a.description?`${a.name} — ${a.description}`:a.name},`${a.pluginId}:${a.runtimeId}`))]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Heartbeat Settings"}),e.jsx("p",{className:"config-description",children:"Configure how this agent's heartbeat is monitored. Leave a field empty to use system defaults."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-enabled",children:[e.jsx("input",{id:"hb-enabled",type:"checkbox",checked:P,onChange:a=>{pt(a.target.checked),me()}}),"Heartbeat Enabled"]}),e.jsx("span",{className:"config-hint",children:"When enabled, this agent receives scheduled heartbeat runs based on its interval."})]}),e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-autoClaimRelevantTasks",children:[e.jsx("input",{id:"hb-autoClaimRelevantTasks",type:"checkbox",checked:f,onChange:a=>{x(a.target.checked),me()}}),"Auto-Claim Relevant Tasks"]}),e.jsx("span",{className:"config-hint",children:"When enabled (default), no-task heartbeats scan open unowned work and auto-claim tasks aligned with this agent's role and soul."})]}),e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-runMissedHeartbeatOnStartup",children:[e.jsx("input",{id:"hb-runMissedHeartbeatOnStartup",type:"checkbox",checked:l,onChange:a=>{o(a.target.checked),me()}}),"Run Missed Heartbeat On Startup"]}),e.jsx("span",{className:"config-hint",children:"When enabled, if the server was down across this agent's scheduled heartbeat tick, fire a single catch-up heartbeat at startup. Default: off."})]}),e.jsxs("div",{className:"config-field",children:[e.jsxs("label",{className:"checkbox-label",htmlFor:"hb-allowParallelExecution",children:[e.jsx("input",{id:"hb-allowParallelExecution",type:"checkbox",checked:S,onChange:a=>{te(a.target.checked),me()}}),"Allow Parallel Execution"]}),e.jsx("span",{className:"config-hint",children:"When disabled, the heartbeat and task execution paths serialize for this agent (heartbeat will not start while the agent's task is executing, and vice versa). Permanent agents only."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-heartbeatIntervalMs",children:"Heartbeat Interval (s)"}),e.jsx("input",{id:"hb-heartbeatIntervalMs",type:"text",inputMode:"numeric",className:ne("input",!!V.heartbeatIntervalMs&&"input--error"),placeholder:String(js/1e3),value:N.heartbeatIntervalMs??"",onChange:a=>ss("heartbeatIntervalMs",a.target.value)}),V.heartbeatIntervalMs?e.jsx("span",{className:"config-error",children:V.heartbeatIntervalMs}):e.jsxs("span",{className:"config-hint",children:["How often heartbeats are checked. Leave empty for system default (",js/1e3,"s / ",Ma,")."]})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-heartbeatTimeoutMs",children:"Heartbeat Timeout (s)"}),e.jsx("input",{id:"hb-heartbeatTimeoutMs",type:"text",inputMode:"numeric",className:ne("input",!!V.heartbeatTimeoutMs&&"input--error"),placeholder:"60",value:N.heartbeatTimeoutMs??"",onChange:a=>ss("heartbeatTimeoutMs",a.target.value)}),V.heartbeatTimeoutMs?e.jsx("span",{className:"config-error",children:V.heartbeatTimeoutMs}):e.jsx("span",{className:"config-hint",children:"Time without heartbeat before agent is considered unresponsive. Leave empty for system default (60s)"})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-maxConcurrentRuns",children:"Max Concurrent Runs"}),e.jsx("input",{id:"hb-maxConcurrentRuns",type:"text",inputMode:"numeric",className:ne("input",!!V.maxConcurrentRuns&&"input--error"),placeholder:"1",value:N.maxConcurrentRuns??"",onChange:a=>ss("maxConcurrentRuns",a.target.value)}),V.maxConcurrentRuns?e.jsx("span",{className:"config-error",children:V.maxConcurrentRuns}):e.jsx("span",{className:"config-hint",children:"Maximum simultaneous heartbeat runs for this agent. Leave empty for system default (1)."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"hb-messageResponseMode",children:"Message Response Mode"}),e.jsxs("select",{id:"hb-messageResponseMode",className:ne("select",!!V.messageResponseMode&&"input--error"),value:N.messageResponseMode??"",onChange:a=>ss("messageResponseMode",a.target.value),children:[e.jsx("option",{value:"",children:"System Default (On Heartbeat)"}),e.jsx("option",{value:"on-heartbeat",children:"On Heartbeat"}),e.jsx("option",{value:"immediate",children:"Immediate"})]}),V.messageResponseMode?e.jsx("span",{className:"config-error",children:V.messageResponseMode}):e.jsx("span",{className:"config-hint",children:"How this agent responds to incoming messages. 'Immediate' wakes the agent as soon as a message arrives. 'On Heartbeat' defers processing to the next scheduled heartbeat."})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Budget Settings"}),e.jsx("p",{className:"config-description",children:"Configure token budget limits for this agent. Leave all fields empty to disable budget tracking."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-tokenBudget",children:"Token Budget"}),e.jsx("input",{id:"budget-tokenBudget",type:"text",inputMode:"numeric",className:ne("input",!!V.tokenBudget&&"input--error"),placeholder:"No limit",value:B.tokenBudget??"",onChange:a=>ts("tokenBudget",a.target.value)}),V.tokenBudget?e.jsx("span",{className:"config-error",children:V.tokenBudget}):e.jsx("span",{className:"config-hint",children:"Total token cap (input + output) for this agent. Leave empty for no limit."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-usageThreshold",children:"Usage Threshold (%)"}),e.jsx("input",{id:"budget-usageThreshold",type:"text",inputMode:"numeric",className:ne("input",!!V.usageThreshold&&"input--error"),placeholder:"80",value:B.usageThreshold??"",onChange:a=>ts("usageThreshold",a.target.value)}),V.usageThreshold?e.jsx("span",{className:"config-error",children:V.usageThreshold}):e.jsx("span",{className:"config-hint",children:"Warning threshold as a percentage. Agent warns when usage reaches this level. Default: 80%."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-budgetPeriod",children:"Budget Period"}),e.jsxs("select",{id:"budget-budgetPeriod",className:ne("select",!!V.budgetPeriod&&"input--error"),value:B.budgetPeriod??"",onChange:a=>ts("budgetPeriod",a.target.value),children:[e.jsx("option",{value:"",children:"No reset (lifetime)"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]}),V.budgetPeriod?e.jsx("span",{className:"config-error",children:V.budgetPeriod}):e.jsx("span",{className:"config-hint",children:"How often the budget counter resets. Leave empty for lifetime budget."})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"budget-resetDay",children:"Reset Day"}),e.jsx("input",{id:"budget-resetDay",type:"text",inputMode:"numeric",className:ne("input",!!V.resetDay&&"input--error"),placeholder:"Auto",value:B.resetDay??"",onChange:a=>ts("resetDay",a.target.value)}),V.resetDay?e.jsx("span",{className:"config-error",children:V.resetDay}):e.jsx("span",{className:"config-hint",children:B.budgetPeriod==="weekly"?"Day of week (0=Sunday to 6=Saturday) for reset.":B.budgetPeriod==="monthly"?"Day of month (1-31) for reset.":"Day for reset (weekly: 0-6, monthly: 1-31). Leave empty for automatic."})]}),Ce?.budgetLimit!=null&&e.jsxs("div",{className:"config-field",children:[e.jsx("label",{children:"Current Usage"}),e.jsxs("div",{className:"budget-progress-container",children:[e.jsx("div",{className:"budget-progress-bar",children:e.jsx("div",{className:ne("budget-progress-bar__fill",(Ce.usagePercent??0)>=100?"budget-progress-bar__fill--red":(Ce.usagePercent??0)>=80?"budget-progress-bar__fill--amber":"budget-progress-bar__fill--green"),style:{width:`${Math.min(Ce.usagePercent??0,100)}%`}})}),e.jsxs("span",{className:"budget-progress-label",children:[(Ce.currentUsage??0).toLocaleString()," / ",(Ce.budgetLimit??0).toLocaleString()," tokens (",Math.round(Ce.usagePercent??0),"% used)"]})]})]}),Ce?.budgetLimit!=null&&e.jsx("div",{className:"config-field",children:e.jsx("button",{className:"btn btn-reset-budget",onClick:()=>void bt(),disabled:Cs,children:Cs?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:14,className:"animate-spin"}),"Resetting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{size:14}),"Reset Budget Usage"]})})})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Instruction Bundle"}),e.jsx("p",{className:"config-description",children:"Configure the agent's instruction bundle. Leave empty to use inline instructions only."}),e.jsxs("div",{className:"config-fields",children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-mode",children:"Bundle Mode"}),e.jsxs("select",{id:"bundle-mode",className:"select",value:ae,onChange:a=>fe(a.target.value),children:[e.jsx("option",{value:"",children:"None (use inline instructions)"}),e.jsx("option",{value:"managed",children:"Managed (system-managed directory)"}),e.jsx("option",{value:"external",children:"External (user-specified path)"})]}),e.jsxs("span",{className:"config-hint",children:[ae==="managed"&&"Files will be stored in a system-managed directory within .fusion/agents/",ae==="external"&&"Specify an external directory path for the instruction files",!ae&&"Select a mode to enable instruction bundling"]})]}),ae&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-entry-file",children:"Entry File"}),e.jsx("input",{id:"bundle-entry-file",type:"text",className:"input",placeholder:"AGENTS.md",value:ee,onChange:a=>w(a.target.value)}),e.jsx("span",{className:"config-hint",children:"Primary instructions file name (default: AGENTS.md)"})]}),ae==="external"&&e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-external-path",children:"External Path"}),e.jsx("input",{id:"bundle-external-path",type:"text",className:"input",placeholder:"e.g. .fusion/agents/my-agent",value:ie,onChange:a=>Ee(a.target.value)}),e.jsx("span",{className:"config-hint",children:"Absolute or relative path to the external directory"})]}),e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:"bundle-files",children:"Files (comma-separated)"}),e.jsx("input",{id:"bundle-files",type:"text",className:"input",placeholder:"AGENTS.md, PROMPTS.md",value:oe.join(", "),onChange:a=>Ye(a.target.value.split(",").map(u=>u.trim()).filter(Boolean))}),e.jsx("span",{className:"config-hint",children:"List of file names in the bundle directory"})]})]})]})]}),e.jsxs("div",{className:"config-section",children:[e.jsx("h3",{children:"Advanced Settings"}),e.jsx("p",{className:"config-description",children:"Advanced configuration options for this agent. Leave a field empty to use system defaults."}),e.jsx("div",{className:"config-fields",children:_e.map(a=>{const u=!!V[a.key];return e.jsxs("div",{className:"config-field",children:[e.jsx("label",{htmlFor:`adv-${a.key}`,children:a.label}),a.type==="select"?e.jsxs("select",{id:`adv-${a.key}`,className:ne("select",u&&"input--error"),value:$[a.key]??"",onChange:R=>Es(a.key,R.target.value),children:[e.jsx("option",{value:"",children:"System Default"}),a.options?.map(R=>e.jsx("option",{value:R.value,children:R.label},R.value))]}):e.jsx("input",{id:`adv-${a.key}`,type:"text",inputMode:a.type==="number"?"numeric":void 0,className:ne("input",u&&"input--error"),placeholder:a.placeholder,value:$[a.key]??"",onChange:R=>Es(a.key,R.target.value)}),u&&e.jsx("span",{className:"config-error",children:V[a.key]}),!u&&a.hint&&e.jsx("span",{className:"config-hint",children:a.hint})]},a.key)})}),e.jsxs("div",{className:"config-actions",children:[e.jsx("button",{className:"btn btn-task-create",disabled:!ge||we,onClick:()=>void jt(),children:we?e.jsxs(e.Fragment,{children:[e.jsx(I,{size:16,className:"animate-spin"}),"Saving…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Save Settings"]})}),Ls&&e.jsxs("span",{className:ne("config-saved-indicator",us&&"config-saved-indicator--error"),children:[we?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ue,{size:14}),Ls]})]})]}),e.jsx(Va,{agent:s,projectId:n,addToast:i,onSaved:r}),e.jsxs("div",{className:"config-section config-section--danger",children:[e.jsx("h3",{children:"Danger Zone"}),e.jsx("p",{className:"config-description",children:"Permanently delete this agent from the project."}),e.jsx("div",{className:"config-fields",children:e.jsxs("div",{className:"config-field",children:[e.jsxs("button",{className:"btn btn--danger",disabled:!Ms||!g,onClick:()=>void g?.(),children:[e.jsx(rs,{size:16}),"Delete Agent"]}),e.jsx("span",{className:"config-danger-note",children:Ms?"Deletion is permanent and cannot be undone.":`Agent deletion is only available when state is idle or paused (current state: ${s.state}).`})]})})]}),e.jsx(ga,{isOpen:M,onClose:()=>_(!1),onUseDraft:ft,projectId:n,existingAgents:G,mode:"edit",existingAgentConfig:ht})]})}function Wa({agentId:s,projectId:n,onChildClick:i}){const[r,d]=t.useState([]),[g,F]=t.useState(!0);return t.useEffect(()=>{F(!0),Kt(s,n).then(d).finally(()=>F(!1))},[s,n]),g?e.jsxs("div",{className:"detail-section",children:[e.jsx("div",{className:"detail-section-header",children:e.jsx("h3",{children:"Employees"})}),e.jsxs("div",{className:"detail-section-body detail-section-body--loading",children:[e.jsx(I,{size:16,className:"spin"}),e.jsx("span",{className:"text-muted",children:"Loading employees..."})]})]}):e.jsxs("div",{className:"detail-section",children:[e.jsxs("div",{className:"detail-section-header",children:[e.jsx("h3",{children:"Employees"}),e.jsxs("span",{className:"text-muted",children:["(",r.length,")"]})]}),e.jsx("div",{className:"detail-section-body",children:r.length===0?e.jsxs("div",{className:"agent-empty agent-empty--padded",children:[e.jsx(tt,{size:32,opacity:.3}),e.jsx("p",{children:"No employees"}),e.jsx("p",{className:"text-muted",children:"This agent has no employees"})]}):e.jsx("div",{className:"agent-tree__children",children:r.map(h=>{const p=Ss[h.state];return e.jsxs("div",{className:"agent-tree__node agent-is-child",onClick:()=>i?.(h.id),role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.key===" "&&A.preventDefault(),i?.(h.id))},style:{cursor:i?"pointer":"default"},children:[e.jsx("span",{className:"agent-tree__icon",children:h.icon??"🤖"}),e.jsx("span",{className:"agent-tree__name",children:h.name}),e.jsx("span",{className:"agent-tree__badge",style:{background:p?.bg??"var(--state-idle-bg)",color:p?.text??"var(--state-idle-text)",border:`1px solid ${p?.border??"var(--state-idle-border)"}`},children:h.state})]},h.id)})})})]})}export{Qa as AgentDetailView,$e as relativeTime};