@openrig/cli 0.6.11 → 0.6.12

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 (1182) hide show
  1. package/README.md +7 -4
  2. package/daemon/assets/claude-statusline-context.cjs +2 -0
  3. package/daemon/assets/guidance/openrig-start.md +2 -1
  4. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  6. package/daemon/assets/plugins/openrig-core/README.md +30 -7
  7. package/daemon/assets/plugins/openrig-core/hooks/claude.json +7 -7
  8. package/daemon/assets/plugins/openrig-core/hooks/codex.json +2 -2
  9. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +77 -0
  10. package/daemon/assets/plugins/openrig-core/hooks/scripts/compaction-restore-bridge.cjs +23 -0
  11. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus-health.cjs +4 -2
  12. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +69 -16
  13. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/precompact-hook.mjs +24 -0
  14. package/daemon/assets/plugins/openrig-core/skills/delegating-work/SKILL.md +25 -5
  15. package/daemon/assets/plugins/openrig-core/skills/forming-an-openrig-mental-model/SKILL.md +4 -2
  16. package/daemon/assets/plugins/openrig-core/skills/mission-slice-sop/SKILL.md +10 -1
  17. package/daemon/assets/plugins/openrig-core/skills/openrig-skills/SKILL.md +1 -1
  18. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +172 -11
  19. package/daemon/assets/plugins/openrig-core/skills/orienting-to-an-inherited-seat/SKILL.md +7 -4
  20. package/daemon/assets/plugins/openrig-core/skills/queue-handoff/SKILL.md +8 -0
  21. package/daemon/assets/plugins/openrig-core/skills/retiring-and-inheriting-a-seat/SKILL.md +5 -2
  22. package/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md +19 -0
  23. package/daemon/assets/skills/rigs/SKILL.md +55 -9
  24. package/daemon/context-packs/help/manifest.yaml +1 -1
  25. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  26. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +106 -37
  27. package/daemon/context-packs/reference/getting-started.md +39 -6
  28. package/daemon/context-packs/reference/manifest.yaml +1 -1
  29. package/daemon/context-packs/reference/rig-spec.md +64 -3
  30. package/daemon/context-packs/reference/whats-new.md +167 -146
  31. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/claude-compaction-restore/scripts/precompact-hook.mjs +24 -0
  36. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/openrig-skills/SKILL.md +1 -1
  45. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/openrig-software-factory/SKILL.md +0 -1
  47. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/core/openrig-software-factory/references/worked-example.md +7 -4
  49. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/SKILL.md +1 -1
  55. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/delegating-work/SKILL.md +25 -5
  58. package/daemon/context-packs/skills/delegating-work/manifest.yaml +3 -3
  59. package/daemon/context-packs/skills/forming-an-openrig-mental-model/SKILL.md +4 -2
  60. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/mission-slice-sop/SKILL.md +10 -1
  63. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/openrig-user/SKILL.md +172 -11
  66. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/SKILL.md +7 -4
  68. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/pods/orchestration-team/SKILL.md +1 -1
  78. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  79. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  87. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  88. package/daemon/context-packs/skills/queue-handoff/SKILL.md +8 -0
  89. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  90. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  91. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/SKILL.md +5 -2
  92. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  93. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  94. package/daemon/context-packs/skills/session-compaction-and-restore/SKILL.md +19 -0
  95. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  96. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  97. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  98. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  99. package/daemon/dist/adapters/bounded-probe-exec.d.ts +45 -0
  100. package/daemon/dist/adapters/bounded-probe-exec.d.ts.map +1 -0
  101. package/daemon/dist/adapters/bounded-probe-exec.js +204 -0
  102. package/daemon/dist/adapters/bounded-probe-exec.js.map +1 -0
  103. package/daemon/dist/adapters/claude-code-adapter.d.ts +17 -1
  104. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  105. package/daemon/dist/adapters/claude-code-adapter.js +173 -32
  106. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  107. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  108. package/daemon/dist/adapters/claude-resume.js +14 -3
  109. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  110. package/daemon/dist/adapters/codex-resume.d.ts +5 -0
  111. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  112. package/daemon/dist/adapters/codex-resume.js +17 -3
  113. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  114. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +38 -1
  115. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  116. package/daemon/dist/adapters/codex-runtime-adapter.js +137 -5
  117. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  118. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +46 -0
  119. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -0
  120. package/daemon/dist/adapters/community-harness-runtime-adapter.js +102 -0
  121. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -0
  122. package/daemon/dist/adapters/compose-services-adapter.d.ts.map +1 -1
  123. package/daemon/dist/adapters/compose-services-adapter.js +2 -1
  124. package/daemon/dist/adapters/compose-services-adapter.js.map +1 -1
  125. package/daemon/dist/adapters/kernel-authority.d.ts +8 -1
  126. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  127. package/daemon/dist/adapters/kernel-authority.js +35 -10
  128. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  129. package/daemon/dist/adapters/omp-rpc-frame.d.ts +51 -0
  130. package/daemon/dist/adapters/omp-rpc-frame.d.ts.map +1 -0
  131. package/daemon/dist/adapters/omp-rpc-frame.js +153 -0
  132. package/daemon/dist/adapters/omp-rpc-frame.js.map +1 -0
  133. package/daemon/dist/adapters/pi-openrouter-charge.d.ts +67 -0
  134. package/daemon/dist/adapters/pi-openrouter-charge.d.ts.map +1 -0
  135. package/daemon/dist/adapters/pi-openrouter-charge.js +228 -0
  136. package/daemon/dist/adapters/pi-openrouter-charge.js.map +1 -0
  137. package/daemon/dist/adapters/pi-readiness.d.ts +81 -5
  138. package/daemon/dist/adapters/pi-readiness.d.ts.map +1 -1
  139. package/daemon/dist/adapters/pi-readiness.js +193 -27
  140. package/daemon/dist/adapters/pi-readiness.js.map +1 -1
  141. package/daemon/dist/adapters/pi-resume.d.ts +4 -0
  142. package/daemon/dist/adapters/pi-resume.d.ts.map +1 -1
  143. package/daemon/dist/adapters/pi-resume.js +2 -0
  144. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  145. package/daemon/dist/adapters/pi-runner-protocol.d.ts +4 -0
  146. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  147. package/daemon/dist/adapters/pi-runner-protocol.js +5 -0
  148. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  149. package/daemon/dist/adapters/pi-runner.d.ts +67 -2
  150. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  151. package/daemon/dist/adapters/pi-runner.js +333 -13
  152. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  153. package/daemon/dist/adapters/pi-runtime-adapter.d.ts +16 -1
  154. package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
  155. package/daemon/dist/adapters/pi-runtime-adapter.js +17 -0
  156. package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
  157. package/daemon/dist/adapters/preflight-exec.d.ts +3 -0
  158. package/daemon/dist/adapters/preflight-exec.d.ts.map +1 -1
  159. package/daemon/dist/adapters/preflight-exec.js +15 -7
  160. package/daemon/dist/adapters/preflight-exec.js.map +1 -1
  161. package/daemon/dist/adapters/replace-file.d.ts +8 -0
  162. package/daemon/dist/adapters/replace-file.d.ts.map +1 -0
  163. package/daemon/dist/adapters/replace-file.js +32 -0
  164. package/daemon/dist/adapters/replace-file.js.map +1 -0
  165. package/daemon/dist/adapters/tmux-control.d.ts +119 -0
  166. package/daemon/dist/adapters/tmux-control.d.ts.map +1 -0
  167. package/daemon/dist/adapters/tmux-control.js +547 -0
  168. package/daemon/dist/adapters/tmux-control.js.map +1 -0
  169. package/daemon/dist/adapters/tmux-exec.d.ts +18 -4
  170. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  171. package/daemon/dist/adapters/tmux-exec.js +98 -17
  172. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  173. package/daemon/dist/adapters/tmux.d.ts +52 -15
  174. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  175. package/daemon/dist/adapters/tmux.js +232 -58
  176. package/daemon/dist/adapters/tmux.js.map +1 -1
  177. package/daemon/dist/build-info.js +3 -3
  178. package/daemon/dist/composer-prompts-surface.d.ts +2 -0
  179. package/daemon/dist/composer-prompts-surface.d.ts.map +1 -0
  180. package/daemon/dist/composer-prompts-surface.js +2 -0
  181. package/daemon/dist/composer-prompts-surface.js.map +1 -0
  182. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  183. package/daemon/dist/db/all-migrations.js +24 -0
  184. package/daemon/dist/db/all-migrations.js.map +1 -1
  185. package/daemon/dist/db/migrations/100_typing_guard_modes.d.ts +3 -0
  186. package/daemon/dist/db/migrations/100_typing_guard_modes.d.ts.map +1 -0
  187. package/daemon/dist/db/migrations/100_typing_guard_modes.js +10 -0
  188. package/daemon/dist/db/migrations/100_typing_guard_modes.js.map +1 -0
  189. package/daemon/dist/db/migrations/104_node_effort_choice.d.ts +3 -0
  190. package/daemon/dist/db/migrations/104_node_effort_choice.d.ts.map +1 -0
  191. package/daemon/dist/db/migrations/104_node_effort_choice.js +10 -0
  192. package/daemon/dist/db/migrations/104_node_effort_choice.js.map +1 -0
  193. package/daemon/dist/db/migrations/105_usage_samples_client_cost.d.ts +9 -0
  194. package/daemon/dist/db/migrations/105_usage_samples_client_cost.d.ts.map +1 -0
  195. package/daemon/dist/db/migrations/105_usage_samples_client_cost.js +14 -0
  196. package/daemon/dist/db/migrations/105_usage_samples_client_cost.js.map +1 -0
  197. package/daemon/dist/db/migrations/107_pi_usage_entries.d.ts +10 -0
  198. package/daemon/dist/db/migrations/107_pi_usage_entries.d.ts.map +1 -0
  199. package/daemon/dist/db/migrations/107_pi_usage_entries.js +38 -0
  200. package/daemon/dist/db/migrations/107_pi_usage_entries.js.map +1 -0
  201. package/daemon/dist/db/migrations/108_pi_usage_charges.d.ts +12 -0
  202. package/daemon/dist/db/migrations/108_pi_usage_charges.d.ts.map +1 -0
  203. package/daemon/dist/db/migrations/108_pi_usage_charges.js +39 -0
  204. package/daemon/dist/db/migrations/108_pi_usage_charges.js.map +1 -0
  205. package/daemon/dist/db/migrations/109_mode_posture_coexist.d.ts +5 -0
  206. package/daemon/dist/db/migrations/109_mode_posture_coexist.d.ts.map +1 -0
  207. package/daemon/dist/db/migrations/109_mode_posture_coexist.js +11 -0
  208. package/daemon/dist/db/migrations/109_mode_posture_coexist.js.map +1 -0
  209. package/daemon/dist/db/migrations/110_workflow_instance_scope.d.ts +10 -0
  210. package/daemon/dist/db/migrations/110_workflow_instance_scope.d.ts.map +1 -0
  211. package/daemon/dist/db/migrations/110_workflow_instance_scope.js +14 -0
  212. package/daemon/dist/db/migrations/110_workflow_instance_scope.js.map +1 -0
  213. package/daemon/dist/db/migrations/111_seat_env.d.ts +6 -0
  214. package/daemon/dist/db/migrations/111_seat_env.d.ts.map +1 -0
  215. package/daemon/dist/db/migrations/111_seat_env.js +11 -0
  216. package/daemon/dist/db/migrations/111_seat_env.js.map +1 -0
  217. package/daemon/dist/db/migrations/112_queue_transitions_ts_qitem.d.ts +3 -0
  218. package/daemon/dist/db/migrations/112_queue_transitions_ts_qitem.d.ts.map +1 -0
  219. package/daemon/dist/db/migrations/112_queue_transitions_ts_qitem.js +14 -0
  220. package/daemon/dist/db/migrations/112_queue_transitions_ts_qitem.js.map +1 -0
  221. package/daemon/dist/db/migrations/113_applied_launch_daemon_opt_out.d.ts +3 -0
  222. package/daemon/dist/db/migrations/113_applied_launch_daemon_opt_out.d.ts.map +1 -0
  223. package/daemon/dist/db/migrations/113_applied_launch_daemon_opt_out.js +9 -0
  224. package/daemon/dist/db/migrations/113_applied_launch_daemon_opt_out.js.map +1 -0
  225. package/daemon/dist/db/migrations/114_session_agent_app.d.ts +3 -0
  226. package/daemon/dist/db/migrations/114_session_agent_app.d.ts.map +1 -0
  227. package/daemon/dist/db/migrations/114_session_agent_app.js +11 -0
  228. package/daemon/dist/db/migrations/114_session_agent_app.js.map +1 -0
  229. package/daemon/dist/db/migrations/115_thread_seat_map_channel_key.d.ts +3 -0
  230. package/daemon/dist/db/migrations/115_thread_seat_map_channel_key.d.ts.map +1 -0
  231. package/daemon/dist/db/migrations/115_thread_seat_map_channel_key.js +28 -0
  232. package/daemon/dist/db/migrations/115_thread_seat_map_channel_key.js.map +1 -0
  233. package/daemon/dist/domain/activity-taxonomy.d.ts +13 -5
  234. package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
  235. package/daemon/dist/domain/activity-taxonomy.js +14 -2
  236. package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
  237. package/daemon/dist/domain/agent-activity-store.d.ts +2 -0
  238. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  239. package/daemon/dist/domain/agent-activity-store.js +14 -8
  240. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  241. package/daemon/dist/domain/agent-images/agent-image-library-service.js +1 -1
  242. package/daemon/dist/domain/agent-images/agent-image-library-service.js.map +1 -1
  243. package/daemon/dist/domain/agent-images/manifest-parser.js +1 -1
  244. package/daemon/dist/domain/agent-images/manifest-parser.js.map +1 -1
  245. package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
  246. package/daemon/dist/domain/agent-manifest.js +21 -3
  247. package/daemon/dist/domain/agent-manifest.js.map +1 -1
  248. package/daemon/dist/domain/applied-launch-observation-store.d.ts +2 -0
  249. package/daemon/dist/domain/applied-launch-observation-store.d.ts.map +1 -1
  250. package/daemon/dist/domain/applied-launch-observation-store.js +27 -3
  251. package/daemon/dist/domain/applied-launch-observation-store.js.map +1 -1
  252. package/daemon/dist/domain/bootstrap-orchestrator.d.ts +3 -0
  253. package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
  254. package/daemon/dist/domain/bootstrap-orchestrator.js +49 -16
  255. package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
  256. package/daemon/dist/domain/built-in-runtimes.d.ts +10 -0
  257. package/daemon/dist/domain/built-in-runtimes.d.ts.map +1 -0
  258. package/daemon/dist/domain/built-in-runtimes.js +14 -0
  259. package/daemon/dist/domain/built-in-runtimes.js.map +1 -0
  260. package/daemon/dist/domain/bundle-archive.d.ts +3 -1
  261. package/daemon/dist/domain/bundle-archive.d.ts.map +1 -1
  262. package/daemon/dist/domain/bundle-archive.js +5 -3
  263. package/daemon/dist/domain/bundle-archive.js.map +1 -1
  264. package/daemon/dist/domain/bundle-behaviour.d.ts +20 -0
  265. package/daemon/dist/domain/bundle-behaviour.d.ts.map +1 -1
  266. package/daemon/dist/domain/bundle-behaviour.js +57 -1
  267. package/daemon/dist/domain/bundle-behaviour.js.map +1 -1
  268. package/daemon/dist/domain/bundle-integrity.d.ts +5 -2
  269. package/daemon/dist/domain/bundle-integrity.d.ts.map +1 -1
  270. package/daemon/dist/domain/bundle-integrity.js +39 -8
  271. package/daemon/dist/domain/bundle-integrity.js.map +1 -1
  272. package/daemon/dist/domain/bundle-source-resolver.d.ts +3 -1
  273. package/daemon/dist/domain/bundle-source-resolver.d.ts.map +1 -1
  274. package/daemon/dist/domain/bundle-source-resolver.js +7 -2
  275. package/daemon/dist/domain/bundle-source-resolver.js.map +1 -1
  276. package/daemon/dist/domain/bundle-types.d.ts +6 -0
  277. package/daemon/dist/domain/bundle-types.d.ts.map +1 -1
  278. package/daemon/dist/domain/bundle-types.js +26 -0
  279. package/daemon/dist/domain/bundle-types.js.map +1 -1
  280. package/daemon/dist/domain/chat-repository.d.ts.map +1 -1
  281. package/daemon/dist/domain/chat-repository.js +3 -2
  282. package/daemon/dist/domain/chat-repository.js.map +1 -1
  283. package/daemon/dist/domain/claim-service.d.ts +6 -0
  284. package/daemon/dist/domain/claim-service.d.ts.map +1 -1
  285. package/daemon/dist/domain/claim-service.js +20 -1
  286. package/daemon/dist/domain/claim-service.js.map +1 -1
  287. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +63 -2
  288. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  289. package/daemon/dist/domain/claude-compaction-enforcer.js +154 -16
  290. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  291. package/daemon/dist/domain/claude-core-plugin-env.d.ts +26 -0
  292. package/daemon/dist/domain/claude-core-plugin-env.d.ts.map +1 -0
  293. package/daemon/dist/domain/claude-core-plugin-env.js +86 -0
  294. package/daemon/dist/domain/claude-core-plugin-env.js.map +1 -0
  295. package/daemon/dist/domain/claude-managed-launch.d.ts +13 -6
  296. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  297. package/daemon/dist/domain/claude-managed-launch.js +58 -5
  298. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  299. package/daemon/dist/domain/codex-thread-id.d.ts +22 -3
  300. package/daemon/dist/domain/codex-thread-id.d.ts.map +1 -1
  301. package/daemon/dist/domain/codex-thread-id.js +65 -16
  302. package/daemon/dist/domain/codex-thread-id.js.map +1 -1
  303. package/daemon/dist/domain/community-harness-presets.d.ts +38 -0
  304. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -0
  305. package/daemon/dist/domain/community-harness-presets.js +155 -0
  306. package/daemon/dist/domain/community-harness-presets.js.map +1 -0
  307. package/daemon/dist/domain/composer-prompts.d.ts +118 -0
  308. package/daemon/dist/domain/composer-prompts.d.ts.map +1 -0
  309. package/daemon/dist/domain/composer-prompts.js +165 -0
  310. package/daemon/dist/domain/composer-prompts.js.map +1 -0
  311. package/daemon/dist/domain/context-monitor.d.ts +3 -0
  312. package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
  313. package/daemon/dist/domain/context-monitor.js +14 -2
  314. package/daemon/dist/domain/context-monitor.js.map +1 -1
  315. package/daemon/dist/domain/context-packs/context-pack-library-service.js +2 -2
  316. package/daemon/dist/domain/context-packs/context-pack-library-service.js.map +1 -1
  317. package/daemon/dist/domain/context-packs/manifest-parser.js +1 -1
  318. package/daemon/dist/domain/context-packs/manifest-parser.js.map +1 -1
  319. package/daemon/dist/domain/context-usage-store.d.ts +4 -0
  320. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  321. package/daemon/dist/domain/context-usage-store.js +1 -0
  322. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  323. package/daemon/dist/domain/current-work.js +2 -2
  324. package/daemon/dist/domain/current-work.js.map +1 -1
  325. package/daemon/dist/domain/draft-aware-delivery.d.ts +32 -0
  326. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -0
  327. package/daemon/dist/domain/draft-aware-delivery.js +156 -0
  328. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -0
  329. package/daemon/dist/domain/event-bus.d.ts +10 -1
  330. package/daemon/dist/domain/event-bus.d.ts.map +1 -1
  331. package/daemon/dist/domain/event-bus.js +25 -0
  332. package/daemon/dist/domain/event-bus.js.map +1 -1
  333. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  334. package/daemon/dist/domain/execution-view.js +76 -10
  335. package/daemon/dist/domain/execution-view.js.map +1 -1
  336. package/daemon/dist/domain/frontmatter.d.ts +11 -0
  337. package/daemon/dist/domain/frontmatter.d.ts.map +1 -0
  338. package/daemon/dist/domain/frontmatter.js +20 -0
  339. package/daemon/dist/domain/frontmatter.js.map +1 -0
  340. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts +11 -0
  341. package/daemon/dist/domain/gateway/gateway-subsystem.d.ts.map +1 -1
  342. package/daemon/dist/domain/gateway/gateway-subsystem.js +7 -0
  343. package/daemon/dist/domain/gateway/gateway-subsystem.js.map +1 -1
  344. package/daemon/dist/domain/gateway/human-registry.d.ts +6 -1
  345. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  346. package/daemon/dist/domain/gateway/human-registry.js +7 -0
  347. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  348. package/daemon/dist/domain/gateway/slack/bot-inbox.d.ts +54 -0
  349. package/daemon/dist/domain/gateway/slack/bot-inbox.d.ts.map +1 -0
  350. package/daemon/dist/domain/gateway/slack/bot-inbox.js +86 -0
  351. package/daemon/dist/domain/gateway/slack/bot-inbox.js.map +1 -0
  352. package/daemon/dist/domain/gateway/slack/capabilities.d.ts.map +1 -1
  353. package/daemon/dist/domain/gateway/slack/capabilities.js +1 -0
  354. package/daemon/dist/domain/gateway/slack/capabilities.js.map +1 -1
  355. package/daemon/dist/domain/gateway/slack/channel-map.d.ts +11 -1
  356. package/daemon/dist/domain/gateway/slack/channel-map.d.ts.map +1 -1
  357. package/daemon/dist/domain/gateway/slack/channel-map.js +31 -6
  358. package/daemon/dist/domain/gateway/slack/channel-map.js.map +1 -1
  359. package/daemon/dist/domain/gateway/slack/config.d.ts +14 -0
  360. package/daemon/dist/domain/gateway/slack/config.d.ts.map +1 -1
  361. package/daemon/dist/domain/gateway/slack/config.js +28 -0
  362. package/daemon/dist/domain/gateway/slack/config.js.map +1 -1
  363. package/daemon/dist/domain/gateway/slack/forwarding.d.ts +32 -0
  364. package/daemon/dist/domain/gateway/slack/forwarding.d.ts.map +1 -0
  365. package/daemon/dist/domain/gateway/slack/forwarding.js +76 -0
  366. package/daemon/dist/domain/gateway/slack/forwarding.js.map +1 -0
  367. package/daemon/dist/domain/gateway/slack/inbound.d.ts +99 -1
  368. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  369. package/daemon/dist/domain/gateway/slack/inbound.js +325 -7
  370. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  371. package/daemon/dist/domain/gateway/slack/message.d.ts +28 -0
  372. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  373. package/daemon/dist/domain/gateway/slack/message.js +105 -4
  374. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  375. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +3 -0
  376. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
  377. package/daemon/dist/domain/gateway/slack/outbound-driver.js +1 -0
  378. package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
  379. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +1 -1
  380. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  381. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +10 -0
  382. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  383. package/daemon/dist/domain/gateway/slack/slack-api.js +13 -0
  384. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  385. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +2 -0
  386. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  387. package/daemon/dist/domain/gateway/slack/slack-delivery.js +12 -2
  388. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  389. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts +3 -0
  390. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  391. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +133 -20
  392. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  393. package/daemon/dist/domain/gateway/slack/state-store.d.ts +9 -2
  394. package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
  395. package/daemon/dist/domain/gateway/slack/state-store.js +24 -2
  396. package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
  397. package/daemon/dist/domain/gateway/slack/thread-routing.d.ts +3 -0
  398. package/daemon/dist/domain/gateway/slack/thread-routing.d.ts.map +1 -1
  399. package/daemon/dist/domain/gateway/slack/thread-routing.js +18 -7
  400. package/daemon/dist/domain/gateway/slack/thread-routing.js.map +1 -1
  401. package/daemon/dist/domain/gateway/slack/thread-seat-map.d.ts +17 -6
  402. package/daemon/dist/domain/gateway/slack/thread-seat-map.d.ts.map +1 -1
  403. package/daemon/dist/domain/gateway/slack/thread-seat-map.js +41 -23
  404. package/daemon/dist/domain/gateway/slack/thread-seat-map.js.map +1 -1
  405. package/daemon/dist/domain/history-query.d.ts.map +1 -1
  406. package/daemon/dist/domain/history-query.js +2 -1
  407. package/daemon/dist/domain/history-query.js.map +1 -1
  408. package/daemon/dist/domain/home-isolation.d.ts +18 -0
  409. package/daemon/dist/domain/home-isolation.d.ts.map +1 -0
  410. package/daemon/dist/domain/home-isolation.js +75 -0
  411. package/daemon/dist/domain/home-isolation.js.map +1 -0
  412. package/daemon/dist/domain/hosts/remote-daemon-http.d.ts +22 -0
  413. package/daemon/dist/domain/hosts/remote-daemon-http.d.ts.map +1 -1
  414. package/daemon/dist/domain/hosts/remote-daemon-http.js +43 -3
  415. package/daemon/dist/domain/hosts/remote-daemon-http.js.map +1 -1
  416. package/daemon/dist/domain/inbox-handler.d.ts.map +1 -1
  417. package/daemon/dist/domain/inbox-handler.js +34 -32
  418. package/daemon/dist/domain/inbox-handler.js.map +1 -1
  419. package/daemon/dist/domain/mission-control/notification-adapter-ntfy.js +12 -2
  420. package/daemon/dist/domain/mission-control/notification-adapter-ntfy.js.map +1 -1
  421. package/daemon/dist/domain/mission-control/notification-dispatcher.d.ts.map +1 -1
  422. package/daemon/dist/domain/mission-control/notification-dispatcher.js +2 -1
  423. package/daemon/dist/domain/mission-control/notification-dispatcher.js.map +1 -1
  424. package/daemon/dist/domain/model-divergence/current-generation-record.d.ts +63 -0
  425. package/daemon/dist/domain/model-divergence/current-generation-record.d.ts.map +1 -1
  426. package/daemon/dist/domain/model-divergence/current-generation-record.js +130 -1
  427. package/daemon/dist/domain/model-divergence/current-generation-record.js.map +1 -1
  428. package/daemon/dist/domain/model-divergence/effective-model-readers.d.ts +42 -0
  429. package/daemon/dist/domain/model-divergence/effective-model-readers.d.ts.map +1 -1
  430. package/daemon/dist/domain/model-divergence/effective-model-readers.js +160 -5
  431. package/daemon/dist/domain/model-divergence/effective-model-readers.js.map +1 -1
  432. package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts +8 -2
  433. package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts.map +1 -1
  434. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js +10 -5
  435. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js.map +1 -1
  436. package/daemon/dist/domain/native-process-lineage.d.ts +49 -0
  437. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  438. package/daemon/dist/domain/native-process-lineage.js +129 -15
  439. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  440. package/daemon/dist/domain/native-resume-probe.d.ts +3 -1
  441. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  442. package/daemon/dist/domain/native-resume-probe.js +43 -6
  443. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  444. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  445. package/daemon/dist/domain/node-inventory.js +26 -9
  446. package/daemon/dist/domain/node-inventory.js.map +1 -1
  447. package/daemon/dist/domain/node-launcher.d.ts +18 -0
  448. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  449. package/daemon/dist/domain/node-launcher.js +60 -2
  450. package/daemon/dist/domain/node-launcher.js.map +1 -1
  451. package/daemon/dist/domain/openrouter-charge.d.ts +42 -0
  452. package/daemon/dist/domain/openrouter-charge.d.ts.map +1 -0
  453. package/daemon/dist/domain/openrouter-charge.js +57 -0
  454. package/daemon/dist/domain/openrouter-charge.js.map +1 -0
  455. package/daemon/dist/domain/parked-query.d.ts +5 -0
  456. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  457. package/daemon/dist/domain/parked-query.js +9 -2
  458. package/daemon/dist/domain/parked-query.js.map +1 -1
  459. package/daemon/dist/domain/periodic-snapshot-scheduler.d.ts.map +1 -1
  460. package/daemon/dist/domain/periodic-snapshot-scheduler.js +27 -3
  461. package/daemon/dist/domain/periodic-snapshot-scheduler.js.map +1 -1
  462. package/daemon/dist/domain/permission-drift.d.ts +2 -0
  463. package/daemon/dist/domain/permission-drift.d.ts.map +1 -1
  464. package/daemon/dist/domain/permission-drift.js.map +1 -1
  465. package/daemon/dist/domain/permission-policy/policy-spec.d.ts.map +1 -1
  466. package/daemon/dist/domain/permission-policy/policy-spec.js +5 -7
  467. package/daemon/dist/domain/permission-policy/policy-spec.js.map +1 -1
  468. package/daemon/dist/domain/pi-usage-entries-store.d.ts +41 -0
  469. package/daemon/dist/domain/pi-usage-entries-store.d.ts.map +1 -0
  470. package/daemon/dist/domain/pi-usage-entries-store.js +173 -0
  471. package/daemon/dist/domain/pi-usage-entries-store.js.map +1 -0
  472. package/daemon/dist/domain/pi-usage-facts.d.ts +90 -0
  473. package/daemon/dist/domain/pi-usage-facts.d.ts.map +1 -0
  474. package/daemon/dist/domain/pi-usage-facts.js +165 -0
  475. package/daemon/dist/domain/pi-usage-facts.js.map +1 -0
  476. package/daemon/dist/domain/pod-bundle-assembler.d.ts +2 -0
  477. package/daemon/dist/domain/pod-bundle-assembler.d.ts.map +1 -1
  478. package/daemon/dist/domain/pod-bundle-assembler.js +4 -0
  479. package/daemon/dist/domain/pod-bundle-assembler.js.map +1 -1
  480. package/daemon/dist/domain/policies/artifact-pool-helpers.d.ts.map +1 -1
  481. package/daemon/dist/domain/policies/artifact-pool-helpers.js +6 -4
  482. package/daemon/dist/domain/policies/artifact-pool-helpers.js.map +1 -1
  483. package/daemon/dist/domain/profile-resolver.d.ts +2 -0
  484. package/daemon/dist/domain/profile-resolver.d.ts.map +1 -1
  485. package/daemon/dist/domain/profile-resolver.js +4 -0
  486. package/daemon/dist/domain/profile-resolver.js.map +1 -1
  487. package/daemon/dist/domain/progress/progress-indexer.js +1 -1
  488. package/daemon/dist/domain/progress/progress-indexer.js.map +1 -1
  489. package/daemon/dist/domain/project-lifecycle-compiler.d.ts +4 -0
  490. package/daemon/dist/domain/project-lifecycle-compiler.d.ts.map +1 -1
  491. package/daemon/dist/domain/project-lifecycle-compiler.js +63 -3
  492. package/daemon/dist/domain/project-lifecycle-compiler.js.map +1 -1
  493. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  494. package/daemon/dist/domain/proof/judgments.js +31 -2
  495. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  496. package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts +33 -0
  497. package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts.map +1 -0
  498. package/daemon/dist/domain/provider/claude-auth-status-reader.js +195 -0
  499. package/daemon/dist/domain/provider/claude-auth-status-reader.js.map +1 -0
  500. package/daemon/dist/domain/provider/claude-usage-windows.d.ts +68 -0
  501. package/daemon/dist/domain/provider/claude-usage-windows.d.ts.map +1 -0
  502. package/daemon/dist/domain/provider/claude-usage-windows.js +260 -0
  503. package/daemon/dist/domain/provider/claude-usage-windows.js.map +1 -0
  504. package/daemon/dist/domain/provider/codex-auth-reader.d.ts +14 -0
  505. package/daemon/dist/domain/provider/codex-auth-reader.d.ts.map +1 -1
  506. package/daemon/dist/domain/provider/codex-auth-reader.js +41 -12
  507. package/daemon/dist/domain/provider/codex-auth-reader.js.map +1 -1
  508. package/daemon/dist/domain/provider/codex-usage-reader.d.ts +2 -0
  509. package/daemon/dist/domain/provider/codex-usage-reader.d.ts.map +1 -1
  510. package/daemon/dist/domain/provider/codex-usage-reader.js +3 -1
  511. package/daemon/dist/domain/provider/codex-usage-reader.js.map +1 -1
  512. package/daemon/dist/domain/provider/codex-usage-windows.d.ts +10 -49
  513. package/daemon/dist/domain/provider/codex-usage-windows.d.ts.map +1 -1
  514. package/daemon/dist/domain/provider/codex-usage-windows.js +15 -173
  515. package/daemon/dist/domain/provider/codex-usage-windows.js.map +1 -1
  516. package/daemon/dist/domain/provider/provider-seat-accounts.d.ts +18 -0
  517. package/daemon/dist/domain/provider/provider-seat-accounts.d.ts.map +1 -0
  518. package/daemon/dist/domain/provider/provider-seat-accounts.js +159 -0
  519. package/daemon/dist/domain/provider/provider-seat-accounts.js.map +1 -0
  520. package/daemon/dist/domain/provider/provider-service-impl.d.ts +7 -2
  521. package/daemon/dist/domain/provider/provider-service-impl.d.ts.map +1 -1
  522. package/daemon/dist/domain/provider/provider-service-impl.js +20 -2
  523. package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
  524. package/daemon/dist/domain/provider/provider-service.d.ts +4 -2
  525. package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
  526. package/daemon/dist/domain/provider/provider-types.d.ts +72 -4
  527. package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
  528. package/daemon/dist/domain/provider/reactive-tap.js +2 -0
  529. package/daemon/dist/domain/provider/reactive-tap.js.map +1 -1
  530. package/daemon/dist/domain/provider/subscription-moves.d.ts +77 -0
  531. package/daemon/dist/domain/provider/subscription-moves.d.ts.map +1 -0
  532. package/daemon/dist/domain/provider/subscription-moves.js +140 -0
  533. package/daemon/dist/domain/provider/subscription-moves.js.map +1 -0
  534. package/daemon/dist/domain/provider/usage-across-hosts.d.ts +162 -0
  535. package/daemon/dist/domain/provider/usage-across-hosts.d.ts.map +1 -0
  536. package/daemon/dist/domain/provider/usage-across-hosts.js +563 -0
  537. package/daemon/dist/domain/provider/usage-across-hosts.js.map +1 -0
  538. package/daemon/dist/domain/provider/usage-windows.d.ts +88 -0
  539. package/daemon/dist/domain/provider/usage-windows.d.ts.map +1 -0
  540. package/daemon/dist/domain/provider/usage-windows.js +189 -0
  541. package/daemon/dist/domain/provider/usage-windows.js.map +1 -0
  542. package/daemon/dist/domain/queue-owner.d.ts +6 -0
  543. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  544. package/daemon/dist/domain/queue-owner.js +22 -0
  545. package/daemon/dist/domain/queue-owner.js.map +1 -1
  546. package/daemon/dist/domain/queue-repository.d.ts +89 -14
  547. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  548. package/daemon/dist/domain/queue-repository.js +331 -86
  549. package/daemon/dist/domain/queue-repository.js.map +1 -1
  550. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  551. package/daemon/dist/domain/queue-stuck-sweep.js +9 -21
  552. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  553. package/daemon/dist/domain/queue-transition-log.d.ts +23 -2
  554. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  555. package/daemon/dist/domain/queue-transition-log.js +98 -39
  556. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  557. package/daemon/dist/domain/queue-wake-ladder.d.ts +2 -2
  558. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  559. package/daemon/dist/domain/queue-wake-ladder.js +27 -8
  560. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  561. package/daemon/dist/domain/queue-wake-repository.d.ts +7 -1
  562. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  563. package/daemon/dist/domain/queue-wake-repository.js +54 -5
  564. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  565. package/daemon/dist/domain/reply-to-choice.d.ts +2 -0
  566. package/daemon/dist/domain/reply-to-choice.d.ts.map +1 -1
  567. package/daemon/dist/domain/reply-to-choice.js +2 -0
  568. package/daemon/dist/domain/reply-to-choice.js.map +1 -1
  569. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  570. package/daemon/dist/domain/restore-check-service.js +3 -2
  571. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  572. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  573. package/daemon/dist/domain/restore-orchestrator.js +78 -14
  574. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  575. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  576. package/daemon/dist/domain/restore-plan-preview.js +23 -19
  577. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  578. package/daemon/dist/domain/restore-policy.d.ts +26 -0
  579. package/daemon/dist/domain/restore-policy.d.ts.map +1 -0
  580. package/daemon/dist/domain/restore-policy.js +22 -0
  581. package/daemon/dist/domain/restore-policy.js.map +1 -0
  582. package/daemon/dist/domain/restore-preconditions.d.ts +2 -0
  583. package/daemon/dist/domain/restore-preconditions.d.ts.map +1 -1
  584. package/daemon/dist/domain/restore-preconditions.js +6 -1
  585. package/daemon/dist/domain/restore-preconditions.js.map +1 -1
  586. package/daemon/dist/domain/restore-runtime-compatibility.d.ts +3 -0
  587. package/daemon/dist/domain/restore-runtime-compatibility.d.ts.map +1 -0
  588. package/daemon/dist/domain/restore-runtime-compatibility.js +7 -0
  589. package/daemon/dist/domain/restore-runtime-compatibility.js.map +1 -0
  590. package/daemon/dist/domain/resume-metadata-refresher.d.ts +10 -5
  591. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  592. package/daemon/dist/domain/resume-metadata-refresher.js +109 -21
  593. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  594. package/daemon/dist/domain/resume-token-capture.d.ts +1 -1
  595. package/daemon/dist/domain/resume-token-capture.d.ts.map +1 -1
  596. package/daemon/dist/domain/resume-token-capture.js +7 -1
  597. package/daemon/dist/domain/resume-token-capture.js.map +1 -1
  598. package/daemon/dist/domain/review/compose.d.ts.map +1 -1
  599. package/daemon/dist/domain/review/compose.js +5 -4
  600. package/daemon/dist/domain/review/compose.js.map +1 -1
  601. package/daemon/dist/domain/review/gather.d.ts +2 -1
  602. package/daemon/dist/domain/review/gather.d.ts.map +1 -1
  603. package/daemon/dist/domain/review/gather.js +25 -17
  604. package/daemon/dist/domain/review/gather.js.map +1 -1
  605. package/daemon/dist/domain/rig-lifecycle-service.d.ts +31 -8
  606. package/daemon/dist/domain/rig-lifecycle-service.d.ts.map +1 -1
  607. package/daemon/dist/domain/rig-lifecycle-service.js +253 -98
  608. package/daemon/dist/domain/rig-lifecycle-service.js.map +1 -1
  609. package/daemon/dist/domain/rig-mode/rig-mode-store.d.ts +11 -1
  610. package/daemon/dist/domain/rig-mode/rig-mode-store.d.ts.map +1 -1
  611. package/daemon/dist/domain/rig-mode/rig-mode-store.js +69 -48
  612. package/daemon/dist/domain/rig-mode/rig-mode-store.js.map +1 -1
  613. package/daemon/dist/domain/rig-repository.d.ts +18 -0
  614. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  615. package/daemon/dist/domain/rig-repository.js +52 -1
  616. package/daemon/dist/domain/rig-repository.js.map +1 -1
  617. package/daemon/dist/domain/rig-teardown.d.ts +4 -1
  618. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  619. package/daemon/dist/domain/rig-teardown.js +40 -2
  620. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  621. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  622. package/daemon/dist/domain/rigspec-codec.js +7 -0
  623. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  624. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  625. package/daemon/dist/domain/rigspec-exporter.js +4 -0
  626. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  627. package/daemon/dist/domain/rigspec-instantiator.d.ts +3 -0
  628. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  629. package/daemon/dist/domain/rigspec-instantiator.js +28 -5
  630. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  631. package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
  632. package/daemon/dist/domain/rigspec-preflight.js +18 -5
  633. package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
  634. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  635. package/daemon/dist/domain/rigspec-schema.js +24 -2
  636. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  637. package/daemon/dist/domain/runtime-adapter.d.ts +11 -0
  638. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  639. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  640. package/daemon/dist/domain/runtime-verifier.d.ts +15 -1
  641. package/daemon/dist/domain/runtime-verifier.d.ts.map +1 -1
  642. package/daemon/dist/domain/runtime-verifier.js +28 -4
  643. package/daemon/dist/domain/runtime-verifier.js.map +1 -1
  644. package/daemon/dist/domain/scope/logical-checkbox.js +1 -1
  645. package/daemon/dist/domain/scope/logical-checkbox.js.map +1 -1
  646. package/daemon/dist/domain/scope/scope-view-projection.d.ts.map +1 -1
  647. package/daemon/dist/domain/scope/scope-view-projection.js +23 -10
  648. package/daemon/dist/domain/scope/scope-view-projection.js.map +1 -1
  649. package/daemon/dist/domain/seat-activity-service.d.ts +9 -2
  650. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  651. package/daemon/dist/domain/seat-activity-service.js +100 -15
  652. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  653. package/daemon/dist/domain/seat-attention-reconciler.d.ts +3 -0
  654. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  655. package/daemon/dist/domain/seat-attention-reconciler.js +114 -7
  656. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  657. package/daemon/dist/domain/seat-delivery-guard.d.ts +36 -1
  658. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  659. package/daemon/dist/domain/seat-delivery-guard.js +255 -22
  660. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  661. package/daemon/dist/domain/seat-effort.d.ts +115 -0
  662. package/daemon/dist/domain/seat-effort.d.ts.map +1 -0
  663. package/daemon/dist/domain/seat-effort.js +233 -0
  664. package/daemon/dist/domain/seat-effort.js.map +1 -0
  665. package/daemon/dist/domain/seat-env.d.ts +37 -0
  666. package/daemon/dist/domain/seat-env.d.ts.map +1 -0
  667. package/daemon/dist/domain/seat-env.js +94 -0
  668. package/daemon/dist/domain/seat-env.js.map +1 -0
  669. package/daemon/dist/domain/seat-handover-service.d.ts +5 -0
  670. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  671. package/daemon/dist/domain/seat-handover-service.js +22 -4
  672. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  673. package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
  674. package/daemon/dist/domain/seat-identity-reconciler.js +19 -2
  675. package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
  676. package/daemon/dist/domain/seat-lifecycle-service.d.ts +119 -5
  677. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  678. package/daemon/dist/domain/seat-lifecycle-service.js +318 -23
  679. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  680. package/daemon/dist/domain/seat-restart-in-place.d.ts +13 -2
  681. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  682. package/daemon/dist/domain/seat-restart-in-place.js +23 -4
  683. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  684. package/daemon/dist/domain/seat-structural-activity-service.d.ts +6 -2
  685. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  686. package/daemon/dist/domain/seat-structural-activity-service.js +45 -9
  687. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  688. package/daemon/dist/domain/session-registry.d.ts +13 -1
  689. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  690. package/daemon/dist/domain/session-registry.js +29 -2
  691. package/daemon/dist/domain/session-registry.js.map +1 -1
  692. package/daemon/dist/domain/session-transport.d.ts +108 -1
  693. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  694. package/daemon/dist/domain/session-transport.js +1116 -129
  695. package/daemon/dist/domain/session-transport.js.map +1 -1
  696. package/daemon/dist/domain/slices/slice-detail-projector.d.ts +2 -0
  697. package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
  698. package/daemon/dist/domain/slices/slice-detail-projector.js +16 -4
  699. package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
  700. package/daemon/dist/domain/slices/slice-indexer.d.ts +10 -0
  701. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  702. package/daemon/dist/domain/slices/slice-indexer.js +84 -4
  703. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  704. package/daemon/dist/domain/snapshot-repository.d.ts +3 -0
  705. package/daemon/dist/domain/snapshot-repository.d.ts.map +1 -1
  706. package/daemon/dist/domain/snapshot-repository.js +19 -2
  707. package/daemon/dist/domain/snapshot-repository.js.map +1 -1
  708. package/daemon/dist/domain/spec-library-workflow-scanner.d.ts +1 -1
  709. package/daemon/dist/domain/spec-library-workflow-scanner.d.ts.map +1 -1
  710. package/daemon/dist/domain/spec-library-workflow-scanner.js +24 -21
  711. package/daemon/dist/domain/spec-library-workflow-scanner.js.map +1 -1
  712. package/daemon/dist/domain/spec-validation-advisory.js +1 -1
  713. package/daemon/dist/domain/spec-validation-advisory.js.map +1 -1
  714. package/daemon/dist/domain/startup-orchestrator.d.ts +31 -3
  715. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  716. package/daemon/dist/domain/startup-orchestrator.js +218 -60
  717. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  718. package/daemon/dist/domain/startup-submission-evidence.d.ts +13 -3
  719. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  720. package/daemon/dist/domain/startup-submission-evidence.js +34 -25
  721. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  722. package/daemon/dist/domain/startup-validation.d.ts.map +1 -1
  723. package/daemon/dist/domain/startup-validation.js +3 -0
  724. package/daemon/dist/domain/startup-validation.js.map +1 -1
  725. package/daemon/dist/domain/successor-session-launcher.d.ts +7 -1
  726. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  727. package/daemon/dist/domain/successor-session-launcher.js +5 -1
  728. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  729. package/daemon/dist/domain/text-cut.d.ts +4 -0
  730. package/daemon/dist/domain/text-cut.d.ts.map +1 -0
  731. package/daemon/dist/domain/text-cut.js +7 -0
  732. package/daemon/dist/domain/text-cut.js.map +1 -0
  733. package/daemon/dist/domain/time-bound-advisory.d.ts +5 -0
  734. package/daemon/dist/domain/time-bound-advisory.d.ts.map +1 -0
  735. package/daemon/dist/domain/time-bound-advisory.js +25 -0
  736. package/daemon/dist/domain/time-bound-advisory.js.map +1 -0
  737. package/daemon/dist/domain/transcript-capture.d.ts +7 -0
  738. package/daemon/dist/domain/transcript-capture.d.ts.map +1 -1
  739. package/daemon/dist/domain/transcript-capture.js +22 -1
  740. package/daemon/dist/domain/transcript-capture.js.map +1 -1
  741. package/daemon/dist/domain/transcript-rotation.d.ts +12 -4
  742. package/daemon/dist/domain/transcript-rotation.d.ts.map +1 -1
  743. package/daemon/dist/domain/transcript-rotation.js +185 -23
  744. package/daemon/dist/domain/transcript-rotation.js.map +1 -1
  745. package/daemon/dist/domain/transcript-store.d.ts +1 -1
  746. package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  747. package/daemon/dist/domain/transcript-store.js +8 -4
  748. package/daemon/dist/domain/transcript-store.js.map +1 -1
  749. package/daemon/dist/domain/types.d.ts +53 -3
  750. package/daemon/dist/domain/types.d.ts.map +1 -1
  751. package/daemon/dist/domain/types.js.map +1 -1
  752. package/daemon/dist/domain/usage-samples-store.d.ts +8 -0
  753. package/daemon/dist/domain/usage-samples-store.d.ts.map +1 -1
  754. package/daemon/dist/domain/usage-samples-store.js +24 -5
  755. package/daemon/dist/domain/usage-samples-store.js.map +1 -1
  756. package/daemon/dist/domain/usage-series.d.ts +154 -2
  757. package/daemon/dist/domain/usage-series.d.ts.map +1 -1
  758. package/daemon/dist/domain/usage-series.js +208 -9
  759. package/daemon/dist/domain/usage-series.js.map +1 -1
  760. package/daemon/dist/domain/user-settings/settings-store.d.ts +1 -1
  761. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  762. package/daemon/dist/domain/user-settings/settings-store.js +37 -1
  763. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  764. package/daemon/dist/domain/watchdog-jobs-repository.d.ts +3 -1
  765. package/daemon/dist/domain/watchdog-jobs-repository.d.ts.map +1 -1
  766. package/daemon/dist/domain/watchdog-jobs-repository.js +13 -1
  767. package/daemon/dist/domain/watchdog-jobs-repository.js.map +1 -1
  768. package/daemon/dist/domain/watchdog-policy-engine.d.ts +1 -0
  769. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  770. package/daemon/dist/domain/watchdog-policy-engine.js +31 -2
  771. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  772. package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -1
  773. package/daemon/dist/domain/workflow-exception-escalation.js +3 -1
  774. package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -1
  775. package/daemon/dist/domain/workflow-exception-readiness.d.ts.map +1 -1
  776. package/daemon/dist/domain/workflow-exception-readiness.js +7 -3
  777. package/daemon/dist/domain/workflow-exception-readiness.js.map +1 -1
  778. package/daemon/dist/domain/workflow-instance-store.d.ts +11 -0
  779. package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
  780. package/daemon/dist/domain/workflow-instance-store.js +18 -4
  781. package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
  782. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  783. package/daemon/dist/domain/workflow-projector.js +5 -3
  784. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  785. package/daemon/dist/domain/workflow-rig-placeholder.d.ts +24 -0
  786. package/daemon/dist/domain/workflow-rig-placeholder.d.ts.map +1 -0
  787. package/daemon/dist/domain/workflow-rig-placeholder.js +43 -0
  788. package/daemon/dist/domain/workflow-rig-placeholder.js.map +1 -0
  789. package/daemon/dist/domain/workflow-runtime.d.ts +10 -1
  790. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  791. package/daemon/dist/domain/workflow-runtime.js +26 -13
  792. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  793. package/daemon/dist/domain/workflow-scope.d.ts +50 -0
  794. package/daemon/dist/domain/workflow-scope.d.ts.map +1 -0
  795. package/daemon/dist/domain/workflow-scope.js +129 -0
  796. package/daemon/dist/domain/workflow-scope.js.map +1 -0
  797. package/daemon/dist/domain/workflow-spec-cache.d.ts +10 -0
  798. package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
  799. package/daemon/dist/domain/workflow-spec-cache.js +13 -0
  800. package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
  801. package/daemon/dist/domain/workflow-types.d.ts +4 -0
  802. package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
  803. package/daemon/dist/domain/workflow-types.js.map +1 -1
  804. package/daemon/dist/domain/workflow-validator.d.ts.map +1 -1
  805. package/daemon/dist/domain/workflow-validator.js +3 -1
  806. package/daemon/dist/domain/workflow-validator.js.map +1 -1
  807. package/daemon/dist/domain/workspace/project-read.d.ts +2 -0
  808. package/daemon/dist/domain/workspace/project-read.d.ts.map +1 -1
  809. package/daemon/dist/domain/workspace/project-read.js +4 -0
  810. package/daemon/dist/domain/workspace/project-read.js.map +1 -1
  811. package/daemon/dist/index.d.ts.map +1 -1
  812. package/daemon/dist/index.js +10 -0
  813. package/daemon/dist/index.js.map +1 -1
  814. package/daemon/dist/lib/pane-envelope.js +1 -1
  815. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  816. package/daemon/dist/middleware/json-body-error.d.ts +4 -3
  817. package/daemon/dist/middleware/json-body-error.d.ts.map +1 -1
  818. package/daemon/dist/middleware/json-body-error.js +18 -4
  819. package/daemon/dist/middleware/json-body-error.js.map +1 -1
  820. package/daemon/dist/routes/activity.d.ts.map +1 -1
  821. package/daemon/dist/routes/activity.js +78 -0
  822. package/daemon/dist/routes/activity.js.map +1 -1
  823. package/daemon/dist/routes/bundles.d.ts.map +1 -1
  824. package/daemon/dist/routes/bundles.js +39 -16
  825. package/daemon/dist/routes/bundles.js.map +1 -1
  826. package/daemon/dist/routes/community-harnesses.d.ts +3 -0
  827. package/daemon/dist/routes/community-harnesses.d.ts.map +1 -0
  828. package/daemon/dist/routes/community-harnesses.js +18 -0
  829. package/daemon/dist/routes/community-harnesses.js.map +1 -0
  830. package/daemon/dist/routes/compaction.d.ts +3 -0
  831. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  832. package/daemon/dist/routes/compaction.js +14 -2
  833. package/daemon/dist/routes/compaction.js.map +1 -1
  834. package/daemon/dist/routes/events.js +26 -12
  835. package/daemon/dist/routes/events.js.map +1 -1
  836. package/daemon/dist/routes/gateway.d.ts +3 -0
  837. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  838. package/daemon/dist/routes/gateway.js +15 -0
  839. package/daemon/dist/routes/gateway.js.map +1 -1
  840. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  841. package/daemon/dist/routes/hosts.js +2 -1
  842. package/daemon/dist/routes/hosts.js.map +1 -1
  843. package/daemon/dist/routes/provider.d.ts +11 -1
  844. package/daemon/dist/routes/provider.d.ts.map +1 -1
  845. package/daemon/dist/routes/provider.js +182 -10
  846. package/daemon/dist/routes/provider.js.map +1 -1
  847. package/daemon/dist/routes/query-limit.d.ts +1 -0
  848. package/daemon/dist/routes/query-limit.d.ts.map +1 -1
  849. package/daemon/dist/routes/query-limit.js +1 -1
  850. package/daemon/dist/routes/query-limit.js.map +1 -1
  851. package/daemon/dist/routes/queue.d.ts.map +1 -1
  852. package/daemon/dist/routes/queue.js +44 -3
  853. package/daemon/dist/routes/queue.js.map +1 -1
  854. package/daemon/dist/routes/rig-mode.d.ts.map +1 -1
  855. package/daemon/dist/routes/rig-mode.js +66 -11
  856. package/daemon/dist/routes/rig-mode.js.map +1 -1
  857. package/daemon/dist/routes/scope-audit.d.ts.map +1 -1
  858. package/daemon/dist/routes/scope-audit.js +10 -0
  859. package/daemon/dist/routes/scope-audit.js.map +1 -1
  860. package/daemon/dist/routes/seat.d.ts.map +1 -1
  861. package/daemon/dist/routes/seat.js +63 -12
  862. package/daemon/dist/routes/seat.js.map +1 -1
  863. package/daemon/dist/routes/sessions.js +1 -1
  864. package/daemon/dist/routes/startup.d.ts.map +1 -1
  865. package/daemon/dist/routes/startup.js +9 -2
  866. package/daemon/dist/routes/startup.js.map +1 -1
  867. package/daemon/dist/routes/telemetry.d.ts.map +1 -1
  868. package/daemon/dist/routes/telemetry.js +13 -3
  869. package/daemon/dist/routes/telemetry.js.map +1 -1
  870. package/daemon/dist/routes/transcripts.d.ts.map +1 -1
  871. package/daemon/dist/routes/transcripts.js +14 -5
  872. package/daemon/dist/routes/transcripts.js.map +1 -1
  873. package/daemon/dist/routes/transport.d.ts.map +1 -1
  874. package/daemon/dist/routes/transport.js +13 -2
  875. package/daemon/dist/routes/transport.js.map +1 -1
  876. package/daemon/dist/routes/up.d.ts.map +1 -1
  877. package/daemon/dist/routes/up.js +4 -0
  878. package/daemon/dist/routes/up.js.map +1 -1
  879. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  880. package/daemon/dist/routes/workflow.js +50 -1
  881. package/daemon/dist/routes/workflow.js.map +1 -1
  882. package/daemon/dist/server.d.ts.map +1 -1
  883. package/daemon/dist/server.js +4 -1
  884. package/daemon/dist/server.js.map +1 -1
  885. package/daemon/dist/spec-validation-surface.d.ts +1 -1
  886. package/daemon/dist/spec-validation-surface.d.ts.map +1 -1
  887. package/daemon/dist/spec-validation-surface.js +1 -1
  888. package/daemon/dist/spec-validation-surface.js.map +1 -1
  889. package/daemon/dist/startup.d.ts +3 -1
  890. package/daemon/dist/startup.d.ts.map +1 -1
  891. package/daemon/dist/startup.js +140 -54
  892. package/daemon/dist/startup.js.map +1 -1
  893. package/daemon/dist/workflow-scope-surface.d.ts +2 -0
  894. package/daemon/dist/workflow-scope-surface.d.ts.map +1 -0
  895. package/daemon/dist/workflow-scope-surface.js +2 -0
  896. package/daemon/dist/workflow-scope-surface.js.map +1 -0
  897. package/daemon/docs/reference/agent-spec.md +4 -2
  898. package/daemon/docs/reference/agent-startup-guide.md +95 -6
  899. package/daemon/docs/reference/claude-status-line.md +69 -0
  900. package/daemon/docs/reference/getting-started.md +39 -6
  901. package/daemon/docs/reference/keeping-a-watch.md +102 -5
  902. package/daemon/docs/reference/project-workspace.md +70 -1
  903. package/daemon/docs/reference/publishing-a-rig-bundle.md +6 -1
  904. package/daemon/docs/reference/refocus-channel.md +41 -5
  905. package/daemon/docs/reference/rig-bundle.md +26 -2
  906. package/daemon/docs/reference/rig-spec.md +64 -3
  907. package/daemon/docs/reference/schemas/bundle-behaviour.v1.schema.json +105 -2
  908. package/daemon/docs/reference/scoped-operating-posture.md +12 -2
  909. package/daemon/docs/reference/sdlc-conventions.md +39 -1
  910. package/daemon/docs/reference/seat-delivery.md +127 -0
  911. package/daemon/docs/reference/slack-app-setup.md +141 -13
  912. package/daemon/docs/reference/topology-naming.md +9 -0
  913. package/daemon/docs/reference/whats-new.md +167 -146
  914. package/daemon/specs/agents/shared/skills/core/openrig-skills/SKILL.md +1 -1
  915. package/daemon/specs/agents/shared/skills/core/openrig-software-factory/SKILL.md +0 -1
  916. package/daemon/specs/agents/shared/skills/core/openrig-software-factory/references/worked-example.md +7 -4
  917. package/daemon/specs/agents/shared/skills/core/topology-mutation-and-seat-management/SKILL.md +1 -1
  918. package/daemon/specs/agents/shared/skills/pods/orchestration-team/SKILL.md +1 -1
  919. package/daemon/specs/rigs/launch/demo/CULTURE.md +1 -1
  920. package/daemon/specs/rigs/launch/factory/CULTURE.md +1 -1
  921. package/daemon/specs/rigs/launch/factory/topology/rig/CRAFT.md +2 -2
  922. package/daemon/specs/rigs/launch/first-project/CULTURE.md +2 -1
  923. package/daemon/specs/rigs/launch/first-project-claude/CULTURE.md +2 -1
  924. package/daemon/specs/rigs/launch/first-project-mixed/CULTURE.md +2 -1
  925. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +9 -2
  926. package/daemon/specs/rigs/launch/starter/CULTURE.md +2 -1
  927. package/daemon/specs/rigs/preview/product-team/CULTURE.md +1 -1
  928. package/dist/bin-wrapper.d.ts +2 -1
  929. package/dist/bin-wrapper.d.ts.map +1 -1
  930. package/dist/bin-wrapper.js +61 -4
  931. package/dist/bin-wrapper.js.map +1 -1
  932. package/dist/build-info.js +3 -3
  933. package/dist/bundle-behaviour.d.ts.map +1 -1
  934. package/dist/bundle-behaviour.js +22 -0
  935. package/dist/bundle-behaviour.js.map +1 -1
  936. package/dist/client.d.ts.map +1 -1
  937. package/dist/client.js +3 -3
  938. package/dist/client.js.map +1 -1
  939. package/dist/commands/add.d.ts.map +1 -1
  940. package/dist/commands/add.js +1 -1
  941. package/dist/commands/add.js.map +1 -1
  942. package/dist/commands/ask.d.ts.map +1 -1
  943. package/dist/commands/ask.js +16 -5
  944. package/dist/commands/ask.js.map +1 -1
  945. package/dist/commands/bootstrap.d.ts.map +1 -1
  946. package/dist/commands/bootstrap.js +9 -5
  947. package/dist/commands/bootstrap.js.map +1 -1
  948. package/dist/commands/bundle.d.ts.map +1 -1
  949. package/dist/commands/bundle.js +8 -0
  950. package/dist/commands/bundle.js.map +1 -1
  951. package/dist/commands/capture.d.ts +4 -0
  952. package/dist/commands/capture.d.ts.map +1 -1
  953. package/dist/commands/capture.js +15 -2
  954. package/dist/commands/capture.js.map +1 -1
  955. package/dist/commands/community-harness.d.ts +4 -0
  956. package/dist/commands/community-harness.d.ts.map +1 -0
  957. package/dist/commands/community-harness.js +48 -0
  958. package/dist/commands/community-harness.js.map +1 -0
  959. package/dist/commands/compact.d.ts.map +1 -1
  960. package/dist/commands/compact.js +8 -4
  961. package/dist/commands/compact.js.map +1 -1
  962. package/dist/commands/config.d.ts.map +1 -1
  963. package/dist/commands/config.js +8 -2
  964. package/dist/commands/config.js.map +1 -1
  965. package/dist/commands/crash-cart.d.ts.map +1 -1
  966. package/dist/commands/crash-cart.js +3 -5
  967. package/dist/commands/crash-cart.js.map +1 -1
  968. package/dist/commands/create.d.ts.map +1 -1
  969. package/dist/commands/create.js +7 -5
  970. package/dist/commands/create.js.map +1 -1
  971. package/dist/commands/down.d.ts.map +1 -1
  972. package/dist/commands/down.js +2 -1
  973. package/dist/commands/down.js.map +1 -1
  974. package/dist/commands/launch.d.ts +1 -0
  975. package/dist/commands/launch.d.ts.map +1 -1
  976. package/dist/commands/launch.js +61 -10
  977. package/dist/commands/launch.js.map +1 -1
  978. package/dist/commands/policy.d.ts +2 -1
  979. package/dist/commands/policy.d.ts.map +1 -1
  980. package/dist/commands/policy.js +66 -7
  981. package/dist/commands/policy.js.map +1 -1
  982. package/dist/commands/provider.d.ts +2 -0
  983. package/dist/commands/provider.d.ts.map +1 -1
  984. package/dist/commands/provider.js +336 -49
  985. package/dist/commands/provider.js.map +1 -1
  986. package/dist/commands/ps.d.ts +11 -0
  987. package/dist/commands/ps.d.ts.map +1 -1
  988. package/dist/commands/ps.js +40 -6
  989. package/dist/commands/ps.js.map +1 -1
  990. package/dist/commands/queue.d.ts.map +1 -1
  991. package/dist/commands/queue.js +59 -10
  992. package/dist/commands/queue.js.map +1 -1
  993. package/dist/commands/requirements.d.ts.map +1 -1
  994. package/dist/commands/requirements.js +8 -5
  995. package/dist/commands/requirements.js.map +1 -1
  996. package/dist/commands/restore.js +1 -1
  997. package/dist/commands/restore.js.map +1 -1
  998. package/dist/commands/rig-mode.d.ts.map +1 -1
  999. package/dist/commands/rig-mode.js +106 -18
  1000. package/dist/commands/rig-mode.js.map +1 -1
  1001. package/dist/commands/scope.d.ts.map +1 -1
  1002. package/dist/commands/scope.js +47 -9
  1003. package/dist/commands/scope.js.map +1 -1
  1004. package/dist/commands/seat.d.ts.map +1 -1
  1005. package/dist/commands/seat.js +131 -20
  1006. package/dist/commands/seat.js.map +1 -1
  1007. package/dist/commands/send.d.ts +2 -2
  1008. package/dist/commands/send.d.ts.map +1 -1
  1009. package/dist/commands/send.js +79 -12
  1010. package/dist/commands/send.js.map +1 -1
  1011. package/dist/commands/slack.d.ts.map +1 -1
  1012. package/dist/commands/slack.js +9 -4
  1013. package/dist/commands/slack.js.map +1 -1
  1014. package/dist/commands/start.d.ts +11 -0
  1015. package/dist/commands/start.d.ts.map +1 -1
  1016. package/dist/commands/start.js +77 -3
  1017. package/dist/commands/start.js.map +1 -1
  1018. package/dist/commands/status.d.ts.map +1 -1
  1019. package/dist/commands/status.js +60 -2
  1020. package/dist/commands/status.js.map +1 -1
  1021. package/dist/commands/up.d.ts.map +1 -1
  1022. package/dist/commands/up.js +58 -0
  1023. package/dist/commands/up.js.map +1 -1
  1024. package/dist/commands/usage.d.ts +12 -0
  1025. package/dist/commands/usage.d.ts.map +1 -1
  1026. package/dist/commands/usage.js +107 -0
  1027. package/dist/commands/usage.js.map +1 -1
  1028. package/dist/commands/watchdog.d.ts.map +1 -1
  1029. package/dist/commands/watchdog.js +20 -7
  1030. package/dist/commands/watchdog.js.map +1 -1
  1031. package/dist/commands/whoami.d.ts +36 -0
  1032. package/dist/commands/whoami.d.ts.map +1 -1
  1033. package/dist/commands/whoami.js +125 -7
  1034. package/dist/commands/whoami.js.map +1 -1
  1035. package/dist/commands/workflow.d.ts.map +1 -1
  1036. package/dist/commands/workflow.js +53 -5
  1037. package/dist/commands/workflow.js.map +1 -1
  1038. package/dist/config-store.d.ts +14 -1
  1039. package/dist/config-store.d.ts.map +1 -1
  1040. package/dist/config-store.js +50 -1
  1041. package/dist/config-store.js.map +1 -1
  1042. package/dist/daemon-lifecycle.d.ts +2 -2
  1043. package/dist/daemon-lifecycle.d.ts.map +1 -1
  1044. package/dist/daemon-lifecycle.js +5 -4
  1045. package/dist/daemon-lifecycle.js.map +1 -1
  1046. package/dist/host-registry.d.ts.map +1 -1
  1047. package/dist/host-registry.js +6 -3
  1048. package/dist/host-registry.js.map +1 -1
  1049. package/dist/index.d.ts +1 -0
  1050. package/dist/index.d.ts.map +1 -1
  1051. package/dist/index.js +4 -7
  1052. package/dist/index.js.map +1 -1
  1053. package/dist/lazy-program.d.ts +9 -0
  1054. package/dist/lazy-program.d.ts.map +1 -0
  1055. package/dist/lazy-program.js +111 -0
  1056. package/dist/lazy-program.js.map +1 -0
  1057. package/dist/lib/bundle-check.js +2 -2
  1058. package/dist/lib/bundle-check.js.map +1 -1
  1059. package/dist/lib/bundle-source.d.ts +1 -0
  1060. package/dist/lib/bundle-source.d.ts.map +1 -1
  1061. package/dist/lib/bundle-source.js +1 -0
  1062. package/dist/lib/bundle-source.js.map +1 -1
  1063. package/dist/lib/codex-auth.d.ts.map +1 -1
  1064. package/dist/lib/codex-auth.js +17 -1
  1065. package/dist/lib/codex-auth.js.map +1 -1
  1066. package/dist/lib/context-install.js +1 -1
  1067. package/dist/lib/context-install.js.map +1 -1
  1068. package/dist/lib/file-transfer.js +1 -1
  1069. package/dist/lib/file-transfer.js.map +1 -1
  1070. package/dist/lib/frontmatter.d.ts +11 -0
  1071. package/dist/lib/frontmatter.d.ts.map +1 -0
  1072. package/dist/lib/frontmatter.js +20 -0
  1073. package/dist/lib/frontmatter.js.map +1 -0
  1074. package/dist/lib/permission-policy/policy-spec.d.ts.map +1 -1
  1075. package/dist/lib/permission-policy/policy-spec.js +5 -7
  1076. package/dist/lib/permission-policy/policy-spec.js.map +1 -1
  1077. package/dist/lib/scope/logical-checkbox.js +1 -1
  1078. package/dist/lib/scope/logical-checkbox.js.map +1 -1
  1079. package/dist/lib/scope/scope-fs.d.ts +8 -0
  1080. package/dist/lib/scope/scope-fs.d.ts.map +1 -1
  1081. package/dist/lib/scope/scope-fs.js +50 -1
  1082. package/dist/lib/scope/scope-fs.js.map +1 -1
  1083. package/dist/lib/work-install.d.ts.map +1 -1
  1084. package/dist/lib/work-install.js +3 -13
  1085. package/dist/lib/work-install.js.map +1 -1
  1086. package/dist/mcp-server.d.ts.map +1 -1
  1087. package/dist/mcp-server.js +113 -0
  1088. package/dist/mcp-server.js.map +1 -1
  1089. package/dist/program-root.d.ts +5 -0
  1090. package/dist/program-root.d.ts.map +1 -0
  1091. package/dist/program-root.js +11 -0
  1092. package/dist/program-root.js.map +1 -0
  1093. package/dist/queue-read-compact.d.ts +29 -0
  1094. package/dist/queue-read-compact.d.ts.map +1 -0
  1095. package/dist/queue-read-compact.js +74 -0
  1096. package/dist/queue-read-compact.js.map +1 -0
  1097. package/dist/remote-host-ops.d.ts +21 -0
  1098. package/dist/remote-host-ops.d.ts.map +1 -1
  1099. package/dist/remote-host-ops.js +25 -12
  1100. package/dist/remote-host-ops.js.map +1 -1
  1101. package/package.json +1 -1
  1102. package/tui/dist/commands/registry.d.ts.map +1 -1
  1103. package/tui/dist/commands/registry.js +3 -0
  1104. package/tui/dist/commands/registry.js.map +1 -1
  1105. package/tui/dist/config/config-model.d.ts.map +1 -1
  1106. package/tui/dist/config/config-model.js +6 -1
  1107. package/tui/dist/config/config-model.js.map +1 -1
  1108. package/tui/dist/cost/cost-model.d.ts +12 -0
  1109. package/tui/dist/cost/cost-model.d.ts.map +1 -0
  1110. package/tui/dist/cost/cost-model.js +141 -0
  1111. package/tui/dist/cost/cost-model.js.map +1 -0
  1112. package/tui/dist/cost/cost-read.d.ts +19 -0
  1113. package/tui/dist/cost/cost-read.d.ts.map +1 -0
  1114. package/tui/dist/cost/cost-read.js +4 -0
  1115. package/tui/dist/cost/cost-read.js.map +1 -0
  1116. package/tui/dist/daemon-client.d.ts +13 -0
  1117. package/tui/dist/daemon-client.d.ts.map +1 -1
  1118. package/tui/dist/daemon-client.js +77 -1
  1119. package/tui/dist/daemon-client.js.map +1 -1
  1120. package/tui/dist/detail.d.ts +2 -0
  1121. package/tui/dist/detail.d.ts.map +1 -1
  1122. package/tui/dist/detail.js +5 -0
  1123. package/tui/dist/detail.js.map +1 -1
  1124. package/tui/dist/execution/execution-model.d.ts.map +1 -1
  1125. package/tui/dist/execution/execution-model.js +38 -18
  1126. package/tui/dist/execution/execution-model.js.map +1 -1
  1127. package/tui/dist/helper-cwd.d.ts +3 -0
  1128. package/tui/dist/helper-cwd.d.ts.map +1 -0
  1129. package/tui/dist/helper-cwd.js +16 -0
  1130. package/tui/dist/helper-cwd.js.map +1 -0
  1131. package/tui/dist/hydrate.d.ts.map +1 -1
  1132. package/tui/dist/hydrate.js +32 -1
  1133. package/tui/dist/hydrate.js.map +1 -1
  1134. package/tui/dist/input.d.ts.map +1 -1
  1135. package/tui/dist/input.js +2 -1
  1136. package/tui/dist/input.js.map +1 -1
  1137. package/tui/dist/local-reading.d.ts.map +1 -1
  1138. package/tui/dist/local-reading.js +2 -1
  1139. package/tui/dist/local-reading.js.map +1 -1
  1140. package/tui/dist/main.js +6 -5
  1141. package/tui/dist/main.js.map +1 -1
  1142. package/tui/dist/pulse/render-pulse.d.ts.map +1 -1
  1143. package/tui/dist/pulse/render-pulse.js +7 -1
  1144. package/tui/dist/pulse/render-pulse.js.map +1 -1
  1145. package/tui/dist/reading.js +1 -1
  1146. package/tui/dist/reading.js.map +1 -1
  1147. package/tui/dist/render.d.ts.map +1 -1
  1148. package/tui/dist/render.js +10 -1
  1149. package/tui/dist/render.js.map +1 -1
  1150. package/tui/dist/scopes/scopes-model.d.ts +6 -1
  1151. package/tui/dist/scopes/scopes-model.d.ts.map +1 -1
  1152. package/tui/dist/scopes/scopes-model.js +33 -13
  1153. package/tui/dist/scopes/scopes-model.js.map +1 -1
  1154. package/tui/dist/sections.d.ts.map +1 -1
  1155. package/tui/dist/sections.js +4 -1
  1156. package/tui/dist/sections.js.map +1 -1
  1157. package/tui/dist/socket-server.d.ts.map +1 -1
  1158. package/tui/dist/socket-server.js +2 -1
  1159. package/tui/dist/socket-server.js.map +1 -1
  1160. package/tui/dist/specs/launch.d.ts.map +1 -1
  1161. package/tui/dist/specs/launch.js +2 -1
  1162. package/tui/dist/specs/launch.js.map +1 -1
  1163. package/tui/dist/startup.js +1 -1
  1164. package/tui/dist/startup.js.map +1 -1
  1165. package/tui/dist/state.d.ts.map +1 -1
  1166. package/tui/dist/state.js +8 -4
  1167. package/tui/dist/state.js.map +1 -1
  1168. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  1169. package/tui/dist/terminals/open-window.js +2 -1
  1170. package/tui/dist/terminals/open-window.js.map +1 -1
  1171. package/tui/dist/types.d.ts +9 -0
  1172. package/tui/dist/types.d.ts.map +1 -1
  1173. package/tui/dist/usage/usage-hosts-model.d.ts +17 -0
  1174. package/tui/dist/usage/usage-hosts-model.d.ts.map +1 -0
  1175. package/tui/dist/usage/usage-hosts-model.js +73 -0
  1176. package/tui/dist/usage/usage-hosts-model.js.map +1 -0
  1177. package/tui/dist/usage/usage-model.d.ts +39 -0
  1178. package/tui/dist/usage/usage-model.d.ts.map +1 -0
  1179. package/tui/dist/usage/usage-model.js +161 -0
  1180. package/tui/dist/usage/usage-model.js.map +1 -0
  1181. package/ui/dist/assets/{index-DhmxKuZf.js → index-Cfbtfd9G.js} +2 -2
  1182. package/ui/dist/index.html +1 -1
@@ -583,13 +583,13 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
583
583
 
584
584
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
585
585
 
586
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return C.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},H_e="DialogDescriptionWarning",U_e=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${TV(H_e).contentName}}.`;return C.useEffect(()=>{var a;const r=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&r&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},V_e=gV,W_e=vV,G_e=bV,AV=_V,IV=wV,MV=jV,LV=kV,K_e=EV;const Dy=V_e,Y_e=W_e,Q_e=G_e,OV=C.forwardRef(({className:e,...t},n)=>i.jsx(AV,{ref:n,className:ce("fixed inset-0 z-50 bg-black/20 backdrop-blur-[8px]",e),...t}));OV.displayName=AV.displayName;const Ep=C.forwardRef(({className:e,children:t,hideCloseButton:n,...s},r)=>i.jsxs(Q_e,{children:[i.jsx(OV,{}),i.jsxs(IV,{ref:r,className:ce("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 vellum-heavy p-6 shadow-[0_20px_40px_rgba(46,52,46,0.06)] border border-outline-variant",e),...s,children:[t,!n&&i.jsxs(K_e,{className:"absolute right-4 top-4 opacity-70 transition-opacity duration-150 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:ring-offset-background disabled:pointer-events-none",children:[i.jsx(CE,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ep.displayName=IV.displayName;const $y=({className:e,...t})=>i.jsx("div",{className:ce("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});$y.displayName="DialogHeader";const By=({className:e,...t})=>i.jsx("div",{className:ce("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});By.displayName="DialogFooter";const Rp=C.forwardRef(({className:e,...t},n)=>i.jsx(MV,{ref:n,className:ce("text-lg font-semibold leading-none tracking-tight",e),...t}));Rp.displayName=MV.displayName;const Tp=C.forwardRef(({className:e,...t},n)=>i.jsx(LV,{ref:n,className:ce("text-sm text-foreground-muted",e),...t}));Tp.displayName=LV.displayName;function X_e(e){return Re({queryKey:["packages",e],queryFn:async()=>{const t=await fetch(`/api/packages/${e}`);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()},enabled:!!e})}function Z_e(e){return Re({queryKey:["packages",e,"installs"],queryFn:async()=>{const t=await fetch(`/api/packages/${e}/installs`);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()},enabled:!!e})}function J_e(e){return Re({queryKey:["installs",e,"journal"],queryFn:async()=>{const t=await fetch(`/api/packages/installs/${e}/journal`);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()},enabled:!!e})}function ewe(e){const t=mt();return Ht({mutationFn:async n=>{const s=await fetch(`/api/packages/${n}/rollback`,{method:"POST"});if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["packages",e,"installs"]}),t.invalidateQueries({queryKey:["installs"]})}})}function twe(e){switch(e){case"applied":return"bg-success";case"rolled_back":return"bg-warning";case"failed":return"bg-destructive";default:return"bg-foreground-muted"}}function nwe(e){switch(e){case"applied":return"APPLIED";case"rolled_back":return"ROLLED BACK";case"failed":return"FAILED";default:return e.toUpperCase()}}function swe({installId:e}){const{data:t,isPending:n,isError:s}=J_e(e);return n?i.jsx("div",{className:"pl-spacing-6 py-spacing-2 text-label-sm text-foreground-muted",children:"Loading journal..."}):s?i.jsx("div",{className:"pl-spacing-6 py-spacing-2 text-label-sm text-destructive","data-testid":"journal-error",children:"Failed to load journal entries"}):!t||t.length===0?i.jsx("div",{className:"pl-spacing-6 py-spacing-2 text-label-sm text-foreground-muted",children:"No journal entries"}):i.jsx("div",{className:"pl-spacing-6 py-spacing-2 space-y-spacing-1","data-testid":"journal-entries",children:t.map(r=>i.jsxs("div",{"data-testid":"journal-entry",className:"flex items-center gap-spacing-3 text-label-sm font-mono py-spacing-1 border-b border-foreground/6 last:border-0",children:[i.jsx("span",{className:"text-foreground-muted w-6 text-right",children:r.seq}),i.jsx("span",{className:"uppercase",children:r.action}),i.jsx("span",{className:"text-foreground-muted",children:r.exportType}),i.jsx("span",{className:"text-foreground-muted truncate max-w-[200px]",children:r.targetPath}),i.jsx("span",{className:"text-foreground-muted ml-auto",children:r.status})]},r.id))})}function rwe({install:e,onRollback:t}){const[n,s]=C.useState(!1);return i.jsxs("div",{"data-testid":"install-row",className:"card-dark p-spacing-4 mb-spacing-2",children:[i.jsxs("div",{className:"flex items-center gap-spacing-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-spacing-3 mb-spacing-1",children:[i.jsx("span",{className:"font-mono text-label-sm text-foreground-muted",children:e.createdAt}),i.jsx("span",{"data-testid":"install-status-badge",className:ce("inline-block px-spacing-2 py-px text-label-sm uppercase",twe(e.status)),children:nwe(e.status)})]}),i.jsx("div",{className:"text-label-sm font-mono text-foreground-muted-on-dark",children:e.targetRoot}),i.jsxs("div",{className:"flex items-center gap-spacing-3 mt-spacing-1 text-label-sm",children:[i.jsxs("span",{"data-testid":"applied-count",children:[i.jsx("span",{className:"font-mono",children:e.appliedCount})," applied"]}),i.jsx("span",{"data-testid":"deferred-placeholder",className:"text-foreground-muted",children:"— deferred"})]})]}),i.jsxs("div",{className:"flex items-center gap-spacing-2 shrink-0",children:[i.jsx(Se,{variant:"tactical",size:"sm","data-testid":"expand-btn",onClick:()=>s(!n),children:n?"COLLAPSE":"EXPAND"}),e.status==="applied"&&i.jsx(Se,{variant:"tactical",size:"sm","data-testid":"rollback-btn",onClick:()=>t(e.id),children:"ROLLBACK"})]})]}),n&&i.jsx(swe,{installId:e.id})]})}function iwe(){var b;const{packageId:e}=An({strict:!1}),{data:t,isPending:n,error:s}=X_e(e),{data:r,isPending:a,error:o}=Z_e(e),c=ewe(e),[d,h]=C.useState(null),[m,f]=C.useState(!1),g=_=>{h(_),f(!0)},x=()=>{d&&c.mutate(d,{onSuccess:()=>{f(!1),h(null)}})};if(n||a)return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"detail-loading",children:[i.jsx("div",{className:"h-8 w-48 shimmer mb-spacing-4"}),i.jsxs("div",{className:"card-dark p-spacing-6 mb-spacing-4",children:[i.jsx("div",{className:"h-6 w-64 shimmer-dark mb-spacing-3"}),i.jsx("div",{className:"h-4 w-full shimmer-dark"})]})]})});if(s)return i.jsx(ot,{children:i.jsx("div",{"data-testid":"detail-error",children:i.jsx("p",{className:"text-destructive",children:s.message})})});if(o)return i.jsx(ot,{children:i.jsx("div",{"data-testid":"installs-error",children:i.jsx("p",{className:"text-destructive",children:"Failed to load install history"})})});const y=r??[];return i.jsx(ot,{children:i.jsxs("div",{children:[t&&i.jsxs("div",{className:"card-dark p-spacing-6 mb-spacing-6","data-testid":"package-header",children:[i.jsxs("div",{className:"flex items-baseline justify-between mb-spacing-2",children:[i.jsxs("h2",{className:"text-headline-lg uppercase",children:[t.name," (Legacy)"]}),i.jsxs("span",{className:"text-label-md font-mono text-foreground-muted-on-dark",children:["v",t.version]})]}),i.jsxs("div",{className:"text-label-sm text-foreground-muted-on-dark mb-spacing-2",children:["SOURCE"," ",i.jsx("span",{className:"font-mono text-foreground-on-dark","data-testid":"package-source",children:t.sourceRef})]}),t.summary&&i.jsx("p",{className:"text-body-sm text-foreground-muted-on-dark",children:t.summary})]}),i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-4",children:"INSTALL HISTORY"}),y.length===0?i.jsx("div",{"data-testid":"empty-installs",className:"text-body-md text-foreground-muted",children:"No installs yet"}):i.jsx("div",{"data-testid":"install-list",children:y.map(_=>i.jsx(rwe,{install:_,onRollback:g},_.id))}),i.jsx(Dy,{open:m,onOpenChange:_=>{c.isPending||(f(_),_||c.reset())},children:i.jsxs(Ep,{"data-testid":"rollback-dialog",onPointerDownOutside:_=>{c.isPending&&_.preventDefault()},onEscapeKeyDown:_=>{c.isPending&&_.preventDefault()},hideCloseButton:c.isPending,children:[i.jsxs($y,{children:[i.jsx(Rp,{className:"text-headline-md uppercase",children:"CONFIRM ROLLBACK"}),i.jsx(Tp,{children:"This will roll back the install and restore previous file states. This action cannot be undone."})]}),c.isError&&i.jsxs("p",{className:"text-destructive text-label-sm","data-testid":"rollback-error",children:["Rollback failed: ",((b=c.error)==null?void 0:b.message)??"Unknown error"]}),i.jsxs(By,{children:[i.jsx(Se,{variant:"ghost",onClick:()=>{c.reset(),f(!1)},"data-testid":"rollback-cancel",disabled:c.isPending,children:"CANCEL"}),i.jsx(Se,{variant:"destructive",onClick:x,"data-testid":"rollback-confirm",disabled:c.isPending,children:c.isPending?"ROLLING BACK...":"ROLLBACK"})]})]})})]})})}function awe(e){switch(e){case"installed":return"bg-success";case"missing":return"bg-destructive";case"unsupported":return"bg-warning";case"unknown":return"bg-warning";default:return"bg-foreground-muted"}}function owe(e){switch(e){case"installed":return"OK";case"missing":return"MISSING";case"unsupported":return"MANUAL";case"unknown":return"UNKNOWN";default:return e.toUpperCase()}}function lwe({results:e}){return e.length===0?i.jsx("div",{className:"text-body-sm text-foreground-muted","data-testid":"no-requirements",children:"No requirements declared."}):i.jsx("div",{className:"space-y-spacing-1","data-testid":"requirements-panel",children:e.map(t=>i.jsxs("div",{"data-testid":"requirement-row",className:"flex items-center gap-spacing-3 py-spacing-1 text-label-sm font-mono",children:[i.jsx("span",{"data-testid":"requirement-dot",className:ce("w-2 h-2 shrink-0",awe(t.status))}),i.jsx("span",{"data-testid":"requirement-status",className:"w-16 uppercase",children:owe(t.status)}),i.jsx("span",{className:"text-foreground-muted w-24",children:t.kind}),i.jsx("span",{children:t.name}),t.detectedPath&&i.jsx("span",{className:"text-foreground-muted ml-auto truncate max-w-[200px]",children:t.detectedPath})]},`${t.kind}:${t.name}`))})}function PV(e,t){var s,r;const n=((s=e.stages)==null?void 0:s.flatMap(a=>{const o=a.detail;if(!o)return[];const c=[];return Array.isArray(o.errors)&&c.push(...o.errors.filter(d=>typeof d=="string")),typeof o.error=="string"&&c.push(o.error),c}))??[];return((r=e.errors)==null?void 0:r.find(a=>typeof a=="string"))??n[0]??e.error??`HTTP ${t}`}function cwe(){return Ht({mutationFn:async({sourceRef:e})=>{const t=await fetch("/api/bootstrap/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceRef:e})});if(!t.ok){const n=await t.json().catch(()=>({})),s=new Error(PV(n,t.status));throw s.data=n,s}return t.json()}})}function uwe(){const e=mt();return Ht({mutationFn:async({sourceRef:t,autoApprove:n,approvedActionKeys:s})=>{const r=await fetch("/api/bootstrap/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceRef:t,autoApprove:n,approvedActionKeys:s})}),a=await r.json();if(!r.ok){const o=new Error(PV(a,r.status));throw o.data=a,o}return a},onSuccess:()=>{e.invalidateQueries({queryKey:["rigs","summary"]})}})}const dwe=["ENTER","PLAN","REVIEW","APPLY"],hwe=dwe.map((e,t)=>({num:t+1,label:e}));function fwe(e){switch(e){case"enter":return 1;case"planning":return 2;case"planned":return 3;case"applying":return 4;case"done":case"error":return 4;default:return 1}}function pwe(){const e=Pt(),{bootstrapSourceRef:t,setBootstrapSourceRef:n}=op(),[s,r]=C.useState("enter"),[a,o]=C.useState(()=>t),[c,d]=C.useState(null),[h,m]=C.useState(new Set),[f,g]=C.useState(!1),[x,y]=C.useState(null),b=cwe(),_=uwe();C.useEffect(()=>{n(a)},[n,a]);const w=async()=>{if(a.trim()){r("planning");try{const q=await b.mutateAsync({sourceRef:a.trim()});d(q),m(new Set(q.actionKeys??[])),r("planned")}catch(q){y(q.message),r("error")}}},E=async()=>{r("applying");try{const q=await _.mutateAsync({sourceRef:a.trim(),autoApprove:f,approvedActionKeys:f?void 0:[...h]});d(q),r("done")}catch(q){y(q.message),r("error")}},N=()=>{r("enter"),o(""),d(null),m(new Set),g(!1),y(null),b.reset(),_.reset()},k=c==null?void 0:c.stages.find(q=>q.stage==="probe_requirements"),R=k==null?void 0:k.detail,A=(R==null?void 0:R.results)??[],T=c==null?void 0:c.stages.find(q=>q.stage==="build_install_plan"),I=T==null?void 0:T.detail,M=(I==null?void 0:I.actions)??[],P=(T==null?void 0:T.status)==="blocked",D=M.some(q=>q.classification!=="manual_only"&&q.commandPreview)&&h.size===0&&!f;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"bootstrap-wizard",className:"space-y-8",children:[i.jsx(wn,{eyebrow:"Bootstrap",title:"Bootstrap",description:"Plan environment requirements, approve install actions, then import the rig into a running topology."}),i.jsx(ZU,{"data-testid":"step-indicator",steps:hwe,currentStep:fwe(s)}),s==="enter"&&i.jsx(or,{title:"Source",description:"Provide a rig spec or bundle path. Bootstrap will inspect requirements before it imports anything.",children:i.jsxs("div",{"data-testid":"step-enter",children:[i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"SPEC OR BUNDLE PATH"}),i.jsx(_T,{"data-testid":"spec-input",type:"text",value:a,onChange:q=>o(q.target.value),placeholder:"/path/to/rig.yaml or /path/to/bundle.rigbundle",className:"font-mono text-body-md"}),i.jsxs("p",{className:"text-label-sm text-foreground-muted mt-spacing-1",children:["Accepts .yaml rig specs or .rigbundle archives."," ",i.jsx("span",{role:"link",tabIndex:0,className:"text-primary cursor-pointer","data-testid":"inspect-link",onClick:()=>e({to:"/bundles/inspect"}),onKeyDown:q=>{q.key==="Enter"&&e({to:"/bundles/inspect"})},children:"Inspect a bundle first →"})]}),i.jsx("div",{className:"mt-spacing-4",children:i.jsx(Se,{variant:"tactical",onClick:w,disabled:!a.trim(),"data-testid":"plan-btn",children:"PLAN"})})]})}),s==="planning"&&i.jsx("div",{"data-testid":"step-planning",className:"text-body-md text-foreground-muted",children:"Planning..."}),s==="planned"&&c&&i.jsx(or,{title:"Plan Review",description:"Review requirement probe results and approve the install actions that bootstrap should execute.",children:i.jsxs("div",{"data-testid":"step-planned",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"STAGES"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-6","data-testid":"stage-list",children:c.stages.map(q=>i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono","data-testid":"stage-row",children:[i.jsx("span",{className:q.status==="ok"?"text-success":q.status==="blocked"?"text-warning":"text-foreground-muted",children:q.status.toUpperCase()}),i.jsx("span",{children:q.stage})]},q.stage))}),A.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"REQUIREMENTS"}),i.jsx("div",{className:"mb-spacing-6",children:i.jsx(lwe,{results:A})})]}),M.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"ACTIONS"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4",children:M.map(q=>i.jsxs("label",{className:"flex items-center gap-spacing-3 text-label-sm font-mono cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:f||h.has(q.key),disabled:f||q.classification==="manual_only",onChange:B=>{const F=new Set(h);B.target.checked?F.add(q.key):F.delete(q.key),m(F)}}),i.jsx("span",{className:q.classification==="manual_only"?"text-warning":"",children:q.requirementName}),q.commandPreview&&i.jsx("span",{className:"text-foreground-muted",children:q.commandPreview})]},q.key))}),i.jsxs("label",{className:"flex items-center gap-spacing-2 text-label-sm mb-spacing-4",children:[i.jsx("input",{type:"checkbox",checked:f,onChange:q=>g(q.target.checked)}),"Auto-approve all trusted actions"]})]}),P&&i.jsx("div",{className:"text-warning text-label-sm mb-spacing-4","data-testid":"blocked-warning",children:"Manual requirements must be resolved before bootstrap can proceed."}),c.warnings.length>0&&i.jsx("div",{className:"mb-spacing-4",children:c.warnings.map((q,B)=>i.jsx("div",{className:"text-warning text-label-sm",children:q},B))}),i.jsx(Se,{variant:"tactical",onClick:E,disabled:P||D,title:P?"Manual requirements must be resolved":D?"Select actions to approve":void 0,"data-testid":"apply-btn",children:"APPLY"})]})}),s==="applying"&&c&&i.jsx(or,{title:"Applying",description:"Bootstrap is executing the approved actions and importing the rig.",children:i.jsxs("div",{"data-testid":"step-applying",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"APPLYING"}),i.jsxs("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"applying-checklist",children:[c.stages.map(q=>i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:q.stage})]},q.stage)),i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:"execute_external_installs"})]}),i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:"install_packages"})]}),i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:"import_rig"})]})]}),i.jsx("p",{className:"text-body-sm text-foreground-muted",children:"Bootstrapping..."})]})}),s==="done"&&c&&i.jsx(or,{title:"Result",description:"Bootstrap finished and returned the managed rig identity.",children:i.jsxs("div",{"data-testid":"step-done",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:c.status==="completed"?"BOOTSTRAP COMPLETE":"BOOTSTRAP PARTIAL"}),i.jsxs("div",{className:"text-label-sm font-mono space-y-spacing-1 mb-spacing-4",children:[i.jsxs("div",{children:["Status: ",i.jsx("span",{className:c.status==="completed"?"text-success":"text-warning",children:c.status.toUpperCase()})]}),c.rigId&&i.jsxs("div",{"data-testid":"result-rig-id",children:["Rig: ",c.rigId]})]}),c.rigId&&i.jsx(Se,{variant:"tactical","data-testid":"view-rig-btn",onClick:()=>e({to:"/rigs/$rigId",params:{rigId:c.rigId}}),children:"VIEW RIG"})]})}),s==="error"&&i.jsx(or,{title:"Bootstrap Error",description:"Bootstrap could not complete. Fix the issue and retry the plan.",children:i.jsxs("div",{"data-testid":"step-error",children:[i.jsx("p",{className:"text-destructive text-body-md mb-spacing-4",children:x}),i.jsx(Se,{variant:"tactical",onClick:N,"data-testid":"try-again-btn",children:"TRY AGAIN"})]})})]})})}function mwe(){const{currentAgentDraft:e,selectedAgentDraft:t,saveAgentDraft:n,rememberAgentDraft:s,clearSelectedAgentDraft:r}=op(),[a,o]=C.useState(()=>(t==null?void 0:t.yaml)??(e==null?void 0:e.yaml)??""),[c,d]=C.useState("idle"),[h,m]=C.useState([]);C.useEffect(()=>{n(a)},[n,a]),C.useEffect(()=>{t&&(o(t.yaml),r())},[r,t]);const f=async()=>{s(a),d("pending"),m([]);try{const g=await fetch("/api/agents/validate",{method:"POST",headers:{"Content-Type":"text/yaml"},body:a}),x=await g.json().catch(()=>({}));if(g.ok&&x.valid){d("valid");return}m(x.errors??["Validation failed"]),d("invalid")}catch{m(["Validation request failed"]),d("error")}};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"agent-spec-validate-flow",className:"space-y-8",children:[i.jsx(wn,{eyebrow:"Agent Spec Validation",title:"VALIDATE AGENT",description:"Check an AgentSpec before you use it in a rig."}),i.jsxs(or,{title:"Agent YAML",description:"Paste or refine an AgentSpec draft, then validate it against the daemon contract.",children:[i.jsx(wT,{"data-testid":"agent-spec-yaml-input",value:a,onChange:g=>o(g.target.value),placeholder:"Paste agent.yaml here...",rows:16,className:"bg-background font-mono text-body-sm"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:i.jsx(Se,{variant:"tactical","data-testid":"agent-spec-validate-btn",onClick:f,disabled:!a.trim()||c==="pending",children:c==="pending"?"VALIDATING...":"VALIDATE AGENTSPEC"})}),c==="valid"&&i.jsx(Xn,{className:"mt-spacing-1","data-testid":"agent-spec-valid",children:i.jsx(qn,{className:"text-primary",children:"AgentSpec valid."})}),(c==="invalid"||c==="error")&&i.jsx(Xn,{className:"mt-spacing-1","data-testid":"agent-spec-invalid",children:i.jsx(qn,{children:i.jsx("ul",{className:"list-disc pl-5",children:h.map(g=>i.jsx("li",{children:g},g))})})})]})]})})}async function gwe(e,t="draft"){var s;const n=await fetch("/api/specs/review/rig",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:e,sourceState:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(((s=r.errors)==null?void 0:s.join("; "))??`HTTP ${n.status}`)}return n.json()}async function xwe(e,t="draft"){var s;const n=await fetch("/api/specs/review/agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:e,sourceState:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(((s=r.errors)==null?void 0:s.join("; "))??`HTTP ${n.status}`)}return n.json()}function DV(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}function vwe(e,t="draft"){return Re({queryKey:["spec-review","rig",e?DV(e):null,t],queryFn:()=>gwe(e,t),enabled:!!e})}function ywe(e,t="draft"){return Re({queryKey:["spec-review","agent",e?DV(e):null,t],queryFn:()=>xwe(e,t),enabled:!!e})}const bwe=160,_we=48,t8=200,wwe=100;function Swe(e){switch(e){case"claude-code":return"#d4c4a8";case"codex":return"#b8c9d4";case"terminal":return"#c4c4c4";default:return"#e0ddd4"}}function jwe(e){const t=new Map,n=[];for(const a of e)a.pod?(t.has(a.pod)||t.set(a.pod,[]),t.get(a.pod).push(a)):n.push(a);const s=[];let r=0;for(const[,a]of t)a.forEach((o,c)=>{s.push({id:o.id,x:c*t8,y:r})}),r+=wwe;return n.forEach((a,o)=>{s.push({id:a.id,x:o*t8,y:r})}),s}function Nwe({graph:e,testId:t}){const n=e??{nodes:[],edges:[]},{nodes:s,edges:r}=C.useMemo(()=>{const a=jwe(n.nodes),o=new Map(a.map(h=>[h.id,h])),c=n.nodes.map(h=>{const m=o.get(h.id)??{x:0,y:0};return{id:h.id,type:"default",position:{x:m.x,y:m.y},data:{label:i.jsxs("div",{className:"flex h-full min-w-0 flex-col justify-center gap-1 font-mono leading-tight",children:[i.jsxs("div",{className:"truncate text-[10px] font-bold text-on-surface",children:[h.pod?`${h.pod} / `:"",h.label]}),i.jsx(Cs,{runtime:h.runtime,size:"xs",compact:!0,variant:"inline"})]})},style:{backgroundColor:Swe(h.runtime),border:"1px solid #8a8577",fontSize:11,fontFamily:"monospace",width:bwe,height:_we}}}),d=n.edges.map((h,m)=>({id:`e-${m}`,source:h.source,target:h.target,label:h.kind,labelStyle:{fontSize:9,fontFamily:"monospace"},style:{strokeDasharray:"4 4",stroke:"#8a8577"}}));return{nodes:c,edges:d}},[n]);return i.jsx("div",{"data-testid":t??"spec-topology-preview",className:"w-full h-[400px] bg-background border border-outline-variant",children:i.jsxs(gp,{nodes:s,edges:r,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[i.jsx(IR,{gap:20,size:.5,color:"#d4d0c8"}),i.jsx(xp,{showInteractive:!1})]})})}function kwe({data:e,children:t,className:n,style:s,testId:r}){const{setSelection:a}=Kv();return i.jsx("button",{type:"button","data-testid":r??"sub-spec-trigger",onClick:()=>a({type:"sub-spec",data:e}),className:n??"text-left",style:s,children:t})}function Cwe(e){const n=(e.startsWith("local:")?e.slice(6):e).replace(/^(builtin|user|fork):/,""),s=n.startsWith("agents/")?n.slice(7):n,r=s.split("@")[0]??s,a=e.startsWith("fork:")?"fork":e.startsWith("builtin:")?"builtin":"user_file";return{specName:r,source:a}}function kT({review:e,yaml:t,testIdPrefix:n="",yamlTestId:s,showEnvironmentTab:r,onMemberClick:a}){var y,b,_;const o=r&&!!(e!=null&&e.services),c=o?["topology","configuration","environment","yaml"]:["topology","configuration","yaml"],[d,h]=C.useState("topology"),m=(e==null?void 0:e.pods)??[],f=(e==null?void 0:e.nodes)??[],g=(e==null?void 0:e.edges)??[],x=n?`${n}-`:"";return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex gap-1 border-b border-outline-variant",children:c.map(w=>i.jsx("button",{"data-testid":`${x}tab-${w}`,onClick:()=>h(w),className:`px-3 py-1.5 font-mono text-[10px] uppercase tracking-wider transition-colors ${d===w?"border-b-2 border-on-surface text-on-surface font-bold":"text-on-surface-variant hover:text-on-surface"}`,children:w},w))}),d==="topology"&&e&&i.jsx(Nwe,{graph:e.graph,testId:`${x}topology-preview`}),d==="configuration"&&e&&i.jsxs("div",{"data-testid":`${x}config-tables`,className:"space-y-4",children:[e.format==="pod_aware"&&m.map(w=>i.jsxs("div",{className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:w.label??w.id}),i.jsxs("table",{className:"w-full font-mono text-[10px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-outline-variant text-on-surface-variant",children:[i.jsx("th",{className:"text-left py-1",children:"Member"}),i.jsx("th",{className:"text-left py-1",children:"Agent Ref"}),i.jsx("th",{className:"text-left py-1",children:"Runtime"}),i.jsx("th",{className:"text-left py-1",children:"Profile"})]})}),i.jsx("tbody",{children:w.members.map(E=>i.jsxs("tr",{className:"border-b border-outline-variant",children:[i.jsx("td",{className:"py-1",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:E.id}),a&&i.jsx(Se,{variant:"outline",size:"sm","data-testid":`${x}member-open-agent-${w.id}-${E.id}`,className:"h-6 px-2 font-mono text-[9px] uppercase tracking-[0.12em]",onClick:()=>a(w.id,E),children:"Agent Spec"})]})}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:(()=>{const N=Cwe(E.agentRef);return i.jsx(kwe,{data:{specKind:"agent",specName:N.specName,source:N.source},testId:`${x}member-sub-spec-${w.id}-${E.id}`,className:"text-on-surface-variant underline decoration-dotted decoration-outline hover:text-on-surface hover:decoration-on-surface",children:E.agentRef})})()}),i.jsx("td",{className:"py-1",children:i.jsx(Cs,{runtime:E.runtime,size:"xs",compact:!0,variant:"inline"})}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:E.profile??"—"})]},E.id))})]})]},w.id)),e.format==="legacy"&&f.length>0&&i.jsxs("div",{className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Nodes"}),i.jsxs("table",{className:"w-full font-mono text-[10px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-outline-variant text-on-surface-variant",children:[i.jsx("th",{className:"text-left py-1",children:"ID"}),i.jsx("th",{className:"text-left py-1",children:"Runtime"}),i.jsx("th",{className:"text-left py-1",children:"Role"})]})}),i.jsx("tbody",{children:f.map(w=>i.jsxs("tr",{className:"border-b border-outline-variant",children:[i.jsx("td",{className:"py-1",children:w.id}),i.jsx("td",{className:"py-1",children:i.jsx(Cs,{runtime:w.runtime,size:"xs",compact:!0,variant:"inline"})}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:w.role??"—"})]},w.id))})]})]}),g.length>0&&i.jsxs("div",{className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:e.format==="pod_aware"?"Cross-Pod Edges":"Edges"}),i.jsxs("table",{className:"w-full font-mono text-[10px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-outline-variant text-on-surface-variant",children:[i.jsx("th",{className:"text-left py-1",children:"From"}),i.jsx("th",{className:"text-left py-1",children:"To"}),i.jsx("th",{className:"text-left py-1",children:"Kind"})]})}),i.jsx("tbody",{children:g.map((w,E)=>i.jsxs("tr",{className:"border-b border-outline-variant",children:[i.jsx("td",{className:"py-1",children:w.from}),i.jsx("td",{className:"py-1",children:w.to}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:w.kind})]},E))})]})]})]}),d==="environment"&&o&&(e==null?void 0:e.services)&&i.jsxs("div",{className:"space-y-4","data-testid":`${x}env-details`,children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Services"}),(y=e.services.composePreview)==null?void 0:y.services.map(w=>i.jsxs("div",{className:"flex items-center justify-between border border-outline-variant px-3 py-2",children:[i.jsx("span",{className:"font-mono text-[11px] text-on-surface",children:w.name}),w.image&&i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:w.image})]},w.name))]}),e.services.waitFor.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Health Gates"}),e.services.waitFor.map((w,E)=>i.jsxs("div",{className:"font-mono text-[10px] text-on-surface-variant border border-outline-variant px-3 py-2",children:[w.url&&i.jsx("span",{children:w.url}),w.tcp&&i.jsxs("span",{children:["tcp: ",w.tcp]}),w.service&&i.jsxs("span",{children:["service: ",w.service,w.condition?` (${w.condition})`:""]})]},E))]}),e.services.surfaces&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Surfaces"}),(b=e.services.surfaces.urls)==null?void 0:b.map(w=>i.jsxs("div",{className:"flex items-center justify-between border border-outline-variant px-3 py-2",children:[i.jsx("span",{className:"text-[11px] text-on-surface",children:w.name}),i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:w.url})]},w.name)),(_=e.services.surfaces.commands)==null?void 0:_.map(w=>i.jsxs("div",{className:"flex items-center justify-between border border-outline-variant px-3 py-2",children:[i.jsx("span",{className:"text-[11px] text-on-surface",children:w.name}),i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:w.command})]},w.name))]})]}),d==="yaml"&&i.jsx(JU,{title:"YAML Preview",testId:s??`${x}spec-yaml`,children:t})]})}function Ewe(){const e=Pt(),{selectedRigDraft:t,currentRigDraft:n}=op(),s=t??n,{data:r,isLoading:a,error:o}=vwe((s==null?void 0:s.yaml)??null),c=(r==null?void 0:r.pods)??[],d=(r==null?void 0:r.nodes)??[],h=(r==null?void 0:r.edges)??[];return s?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"rig-spec-review",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Rig Spec Review",title:(r==null?void 0:r.name)??s.label,description:(r==null?void 0:r.summary)??"Review the spec structure before import or bootstrap.",actions:i.jsxs(i.Fragment,{children:[i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/import"}),children:"Open In Import"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/bootstrap"}),children:"Bootstrap"})]})}),r&&i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:r.format==="pod_aware"?"Pod-Aware":"Legacy",testId:"rig-spec-summary-format"}),i.jsx(st,{label:r.format==="pod_aware"?"Pods":"Nodes",value:r.format==="pod_aware"?c.length:d.length,testId:"rig-spec-summary-pods"}),i.jsx(st,{label:"Members",value:r.format==="pod_aware"?c.reduce((m,f)=>m+f.members.length,0):d.length,testId:"rig-spec-summary-members"}),i.jsx(st,{label:"Edges",value:h.length+(r.format==="pod_aware"?c.reduce((m,f)=>{var g;return m+(((g=f.edges)==null?void 0:g.length)??0)},0):0),testId:"rig-spec-summary-edges"})]}),a&&i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading review..."}),o&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 font-mono text-[10px] text-red-700",children:o.message}),i.jsx(kT,{review:r,yaml:s.yaml,yamlTestId:"rig-spec-yaml"})]})}):i.jsx(ot,{children:i.jsxs("div",{"data-testid":"rig-spec-review-empty",className:"space-y-5",children:[i.jsx(wn,{eyebrow:"Rig Spec Review",title:"No RigSpec Selected",description:"Choose a current or recent rig draft from the Library drawer to review it here before you import or bootstrap it."}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/import"}),children:"Open Import"})]})})}function ac({data:e,children:t,className:n,style:s,testId:r}){const{setSelection:a}=Kv();return i.jsx("button",{type:"button","data-testid":r??"file-reference-trigger",onClick:()=>a({type:"file",data:e}),className:n??"text-left",style:s,children:t})}function Rwe(e,t){if(!e||!t)return null;if(t.startsWith("/"))return t;const s=`${e.replace(/\/[^/]*$/,"")}/${t}`.split("/"),r=[];for(const a of s)if(!(!a||a===".")){if(a===".."){r.pop();continue}r.push(a)}return`/${r.join("/")}`}function n8({label:e,sourcePath:t,testId:n,children:s}){const r=Rwe(t,e);return r?i.jsx(ac,{data:{path:e,absolutePath:r},testId:n,className:"inline-block text-left",children:s}):i.jsx(i.Fragment,{children:s})}function CT({review:e,yaml:t,testIdPrefix:n="agent",sourcePath:s}){const r=(e==null?void 0:e.profiles)??[],a=(e==null?void 0:e.resources)??{skills:[],guidance:[],plugins:[]},o=(e==null?void 0:e.startup)??{files:[],actions:[]};return i.jsxs(i.Fragment,{children:[r.length>0&&i.jsxs("div",{"data-testid":`${n}-profiles-section`,className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Profiles"}),i.jsx("div",{className:"space-y-1",children:r.map(c=>i.jsxs("div",{className:"font-mono text-[10px] flex justify-between",children:[i.jsx("span",{className:"font-bold",children:c.name}),c.description&&i.jsx("span",{className:"text-on-surface-variant",children:c.description})]},c.name))})]}),i.jsxs("div",{"data-testid":`${n}-resources-section`,className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Resources"}),i.jsxs("div",{className:"space-y-2 font-mono text-[10px]",children:[a.skills.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Skills:"})," ",a.skills.map((c,d)=>i.jsxs("span",{className:"mr-1 mb-0.5 inline-flex items-center gap-1 bg-surface-low px-1.5 py-0.5",children:[i.jsx(ht,{tool:"file",size:"xs",decorative:!0}),c]},d))]}),a.guidance.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Guidance:"})," ",a.guidance.map((c,d)=>i.jsx(n8,{label:c,sourcePath:s,testId:`${n}-guidance-file-trigger-${c}`,children:i.jsxs("span",{className:"mr-1 mb-0.5 inline-flex items-center gap-1 bg-surface-low px-1.5 py-0.5 underline decoration-dotted decoration-outline",children:[i.jsx(ht,{tool:c,size:"xs",decorative:!0}),c]})},`${c}-${d}`))]}),a.plugins.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Plugins:"})," ",a.plugins.map((c,d)=>i.jsxs("span",{className:"mr-1 mb-0.5 inline-flex items-center gap-1 bg-surface-low px-1.5 py-0.5",children:[i.jsx(ht,{tool:"file",size:"xs",decorative:!0}),c]},`${c}-${d}`))]})]})]}),(o.files.length>0||o.actions.length>0)&&i.jsxs("div",{"data-testid":`${n}-startup-section`,className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Startup"}),o.files.length>0&&i.jsxs("div",{className:"mb-2",children:[i.jsx("div",{className:"font-mono text-[9px] text-on-surface-variant uppercase mb-1",children:"Files"}),o.files.map((c,d)=>i.jsxs("div",{className:"font-mono text-[10px]",children:[i.jsx(n8,{label:c.path,sourcePath:s,testId:`${n}-startup-file-trigger-${c.path}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1 underline decoration-dotted decoration-outline",children:[i.jsx(ht,{tool:c.path,size:"xs",decorative:!0}),c.path]})})," ",c.required&&i.jsx("span",{className:"text-red-500 text-[8px]",children:"REQUIRED"})]},d))]}),o.actions.length>0&&i.jsxs("div",{children:[i.jsx("div",{className:"font-mono text-[9px] text-on-surface-variant uppercase mb-1",children:"Actions"}),o.actions.map((c,d)=>i.jsxs("div",{className:"font-mono text-[10px]",children:[i.jsxs("span",{className:"inline-flex items-center gap-1 text-on-surface-variant",children:[i.jsx(ht,{tool:c.type.includes("command")?"terminal":c.type,size:"xs",decorative:!0}),c.type,":"]})," ",c.value]},d))]})]}),i.jsx(JU,{title:"YAML Preview",testId:`${n}-spec-yaml`,children:t})]})}function Twe(){const e=Pt(),{selectedAgentDraft:t,currentAgentDraft:n}=op(),s=t??n,{data:r,isLoading:a,error:o}=ywe((s==null?void 0:s.yaml)??null);return s?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"agent-spec-review",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Agent Spec Review",title:(r==null?void 0:r.name)??s.label,description:(r==null?void 0:r.description)??"Review the agent spec structure before validation.",actions:i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/agents/validate"}),children:"Open In Validate"})}),r&&i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:"AgentSpec",testId:"agent-spec-summary-format"}),i.jsx(st,{label:"Version",value:r.version,testId:"agent-spec-summary-version"}),i.jsx(st,{label:"Profiles",value:(r.profiles??[]).length,testId:"agent-spec-summary-profiles"}),i.jsx(st,{label:"Skills",value:(r.resources??{skills:[]}).skills.length,testId:"agent-spec-summary-skills"})]}),a&&i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading review..."}),o&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 font-mono text-[10px] text-red-700",children:o.message}),i.jsx(CT,{review:r,yaml:s.yaml,testIdPrefix:"agent"})]})}):i.jsx(ot,{children:i.jsxs("div",{"data-testid":"agent-spec-review-empty",className:"space-y-5",children:[i.jsx(wn,{eyebrow:"Agent Spec Review",title:"No AgentSpec Selected",description:"Choose a current or recent agent draft from the Library drawer to review it here before you validate it."}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/agents/validate"}),children:"Open Validate"})]})})}function Awe(){return Ht({mutationFn:async({bundlePath:e})=>{const t=await fetch("/api/bundles/inspect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundlePath:e})}),n=await t.json();if(n.error)throw new Error(n.error);if(!t.ok)throw new Error(`HTTP ${t.status}`);return n}})}function Iwe(){return Ht({mutationFn:async({bundlePath:e,plan:t,autoApprove:n,targetRoot:s})=>{const r=await fetch("/api/bundles/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundlePath:e,plan:t,autoApprove:n,targetRoot:s})}),a=await r.json();if(!r.ok)throw new Error(a.error??`HTTP ${r.status}`);return a}})}function Mwe(){var a,o;const[e,t]=C.useState(""),n=Awe(),s=()=>{e.trim()&&n.mutate({bundlePath:e.trim()})},r=n.data;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"bundle-inspector",children:[i.jsx("h2",{className:"text-headline-lg uppercase mb-spacing-4",children:"INSPECT BUNDLE"}),i.jsxs("div",{className:"mb-spacing-4",children:[i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"BUNDLE PATH"}),i.jsx("input",{"data-testid":"bundle-path-input",type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"/path/to/my-rig.rigbundle",className:"w-full bg-transparent border-b border-foreground/20 py-spacing-2 text-body-md font-mono focus:outline-none focus:border-primary"}),i.jsx(Se,{variant:"tactical",onClick:s,disabled:!e.trim()||n.isPending,className:"mt-spacing-3","data-testid":"inspect-btn",children:n.isPending?"INSPECTING...":"INSPECT"})]}),n.isError&&i.jsx("div",{className:"text-destructive text-body-md mb-spacing-4","data-testid":"inspect-error",children:n.error.message}),r&&i.jsxs("div",{"data-testid":"inspect-result",children:[i.jsxs("div",{className:"card-dark p-spacing-4 mb-spacing-4","data-testid":"manifest-summary",children:[i.jsxs("div",{className:"flex items-center gap-spacing-2 mb-spacing-2",children:[i.jsx("h3",{className:"text-headline-md uppercase",children:r.manifest.name}),i.jsxs("span",{className:"text-label-sm font-mono px-spacing-2 py-px bg-foreground/10","data-testid":"schema-badge",children:["v",r.manifest.schemaVersion??1]})]}),i.jsxs("div",{className:"text-label-sm font-mono text-foreground-muted-on-dark",children:["v",r.manifest.version]}),i.jsxs("div",{className:"text-label-sm font-mono text-foreground-muted-on-dark",children:["Spec: ",r.manifest.rigSpec]}),i.jsxs("div",{className:"mt-spacing-2 flex gap-spacing-3",children:[i.jsxs("span",{className:ce("text-label-sm",r.digestValid?"text-success":"text-destructive"),children:["DIGEST: ",r.digestValid?"VALID":"INVALID"]}),i.jsxs("span",{className:ce("text-label-sm",r.integrityResult.passed?"text-success":"text-destructive"),"data-testid":"integrity-status",children:["INTEGRITY: ",r.integrityResult.passed?"PASS":"FAIL"]})]})]}),r.manifest.schemaVersion===2&&r.manifest.agents?i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"AGENTS"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"agent-list",children:r.manifest.agents.map(c=>i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"agent-entry",children:[c.name," v",c.version," — ",c.path]},c.name))})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"PACKAGES"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"package-list",children:(r.manifest.packages??[]).map(c=>i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"package-entry",children:[c.name," v",c.version," — ",c.path]},c.name))})]}),r.manifest.provenance&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"PROVENANCE"}),i.jsxs("div",{className:"card-dark p-spacing-4 mb-spacing-4 space-y-spacing-1","data-testid":"provenance-block",children:[r.manifest.provenance.createdAt&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-createdAt",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Created: "}),r.manifest.provenance.createdAt]}),r.manifest.provenance.sourceHost&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-sourceHost",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Host: "}),r.manifest.provenance.sourceHost]}),r.manifest.provenance.authorSession&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-authorSession",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Author: "}),r.manifest.provenance.authorSession]}),r.manifest.provenance.sourceRigName&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-sourceRigName",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Rig: "}),r.manifest.provenance.sourceRigName,r.manifest.provenance.sourceRigId&&i.jsxs("span",{className:"text-foreground-muted-on-dark",children:[" (",r.manifest.provenance.sourceRigId,")"]})]}),(r.manifest.provenance.daemonVersion||r.manifest.provenance.cliVersion)&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-versions",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Built with: "}),r.manifest.provenance.daemonVersion&&i.jsxs(i.Fragment,{children:["daemon ",r.manifest.provenance.daemonVersion]}),r.manifest.provenance.daemonVersion&&r.manifest.provenance.cliVersion&&" / ",r.manifest.provenance.cliVersion&&i.jsxs(i.Fragment,{children:["cli ",r.manifest.provenance.cliVersion]})]}),r.manifest.provenance.notes&&i.jsxs("div",{className:"text-label-sm font-mono whitespace-pre-wrap mt-spacing-2","data-testid":"provenance-notes",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Notes: "}),r.manifest.provenance.notes]})]})]}),r.manifest.compatibility&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"COMPATIBILITY"}),i.jsxs("div",{className:"card-dark p-spacing-4 mb-spacing-4 space-y-spacing-1","data-testid":"compatibility-block",children:[r.manifest.compatibility.minDaemonVersion&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"compatibility-minDaemonVersion",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Min daemon: "}),r.manifest.compatibility.minDaemonVersion]}),r.manifest.compatibility.minCliVersion&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"compatibility-minCliVersion",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Min CLI: "}),r.manifest.compatibility.minCliVersion]}),r.manifest.compatibility.schemaVersion!==void 0&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"compatibility-schemaVersion",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Schema: "}),"v",r.manifest.compatibility.schemaVersion]})]})]}),r.integrityResult&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"FILE INTEGRITY"}),i.jsxs("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"file-integrity",children:[Object.keys((r.manifest.packages??r.manifest.agents??[]).length>0?((o=(a=r.manifest)==null?void 0:a.integrity)==null?void 0:o.files)??{}:{}).map(c=>{const d=r.integrityResult.mismatches.includes(c),h=r.integrityResult.missing.includes(c),m=d?"MISMATCH":h?"MISSING":"OK";return i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono","data-testid":"file-row",children:[i.jsx("span",{className:ce("w-2 h-2",m==="OK"?"bg-success":"bg-destructive"),"data-testid":"file-dot"}),i.jsx("span",{children:c}),i.jsx("span",{className:"text-foreground-muted ml-auto",children:m})]},c)}),r.integrityResult.extra.map(c=>i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono","data-testid":"file-row",children:[i.jsx("span",{className:"w-2 h-2 bg-warning","data-testid":"file-dot"}),i.jsx("span",{children:c}),i.jsx("span",{className:"text-foreground-muted ml-auto",children:"EXTRA"})]},c))]})]}),i.jsx(Se,{variant:"tactical","data-testid":"install-btn",onClick:()=>window.location.href=`/bundles/install?bundlePath=${encodeURIComponent(e)}`,children:"INSTALL THIS BUNDLE"})]})]})})}function Lwe(){const e=Pt(),[t,n]=C.useState("enter"),s=typeof window<"u"?new URLSearchParams(window.location.search):null,[r,a]=C.useState((s==null?void 0:s.get("bundlePath"))??""),[o,c]=C.useState(""),[d,h]=C.useState(null),[m,f]=C.useState(null),g=Iwe(),x=async()=>{if(r.trim()){n("planning");try{const b=await g.mutateAsync({bundlePath:r.trim(),plan:!0});h(b),n("planned")}catch(b){f(b.message),n("error")}}},y=async()=>{if(o.trim()){n("applying");try{const b=await g.mutateAsync({bundlePath:r.trim(),autoApprove:!0,targetRoot:o.trim()});h(b),n("done")}catch(b){f(b.message),n("error")}}};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"bundle-install-flow",children:[i.jsx("h2",{className:"text-headline-lg uppercase mb-spacing-4",children:"INSTALL BUNDLE"}),t==="enter"&&i.jsxs("div",{"data-testid":"step-enter",children:[i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"BUNDLE PATH"}),i.jsx("input",{"data-testid":"bundle-input",type:"text",value:r,onChange:b=>a(b.target.value),placeholder:"/path/to/my-rig.rigbundle",className:"w-full bg-transparent border-b border-foreground/20 py-spacing-2 text-body-md font-mono focus:outline-none focus:border-primary mb-spacing-4"}),i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"TARGET ROOT"}),i.jsx("input",{"data-testid":"target-input",type:"text",value:o,onChange:b=>c(b.target.value),placeholder:"/path/to/target/project",className:"w-full bg-transparent border-b border-foreground/20 py-spacing-2 text-body-md font-mono focus:outline-none focus:border-primary mb-spacing-4"}),i.jsx(Se,{variant:"tactical",onClick:x,disabled:!r.trim(),"data-testid":"plan-btn",children:"PLAN"})]}),t==="planning"&&i.jsx("div",{"data-testid":"step-planning",className:"text-foreground-muted",children:"Planning..."}),t==="planned"&&d&&i.jsxs("div",{"data-testid":"step-planned",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"PLAN"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4",children:d.stages.map(b=>i.jsxs("div",{className:"text-label-sm font-mono",children:[i.jsx("span",{className:b.status==="ok"?"text-success":"text-foreground-muted",children:b.status.toUpperCase()})," ",b.stage]},b.stage))}),i.jsx(Se,{variant:"tactical",onClick:y,disabled:!o.trim(),"data-testid":"apply-btn",children:"APPLY"})]}),t==="applying"&&i.jsx("div",{"data-testid":"step-applying",className:"text-foreground-muted",children:"Installing..."}),t==="done"&&d&&i.jsxs("div",{"data-testid":"step-done",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"COMPLETE"}),i.jsxs("div",{className:"text-label-sm font-mono",children:["Status: ",i.jsx("span",{className:"text-success",children:d.status.toUpperCase()}),d.stages.some(b=>{var _;return((_=b.detail)==null?void 0:_.source)==="pod_bundle"})?i.jsx("span",{className:"ml-spacing-2 text-primary","data-testid":"bundle-type-label",children:"Pod-aware bundle"}):i.jsx("span",{className:"ml-spacing-2 text-foreground-muted","data-testid":"bundle-type-label",children:"Legacy bundle"})]}),d.rigId&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"result-rig-id",children:["Rig: ",d.rigId]}),d.rigId&&i.jsx(Se,{variant:"tactical",className:"mt-spacing-3",onClick:()=>e({to:"/rigs/$rigId",params:{rigId:d.rigId}}),children:"VIEW RIG"})]}),t==="error"&&i.jsxs("div",{"data-testid":"step-error",children:[i.jsx("p",{className:"text-destructive text-body-md mb-spacing-4",children:m}),i.jsx(Se,{variant:"tactical",onClick:()=>{n("enter"),f(null),g.reset()},"data-testid":"try-again-btn",children:"TRY AGAIN"})]})]})})}const Owe=180,s8=56,Pwe=220,Dwe=110,$V="in-top",BV="out-bottom",qV="in-side",FV="out-side";function $we(e){const t=new Map;for(const a of e.edges)t.has(a.fromStepId)||t.set(a.fromStepId,[]),t.get(a.fromStepId).push(a.toStepId);const n=new Map,s=[];for(const a of e.nodes)a.isEntry&&(n.set(a.stepId,0),s.push({id:a.stepId,d:0}));for(;s.length>0;){const{id:a,d:o}=s.shift();for(const c of t.get(a)??[])n.has(c)||(n.set(c,o+1),s.push({id:c,d:o+1}))}let r=0;for(const a of e.nodes)n.has(a.stepId)||n.set(a.stepId,r++);return n}function Bwe(e,t,n){const s=n.get(e)??0;return(n.get(t)??0)>s?{sourceHandle:BV,targetHandle:$V}:{sourceHandle:FV,targetHandle:qV}}function qwe({data:e}){const t=e.isEntry?"#a8c8d4":e.isTerminal?"#d4b8a8":"#d4c4a8",n=!!(e.harness||e.host||e.gate);return i.jsxs("div",{style:{backgroundColor:e.isCurrent?"#e8dcb8":e.wasVisited?"#cfc3a4":t,border:e.isCurrent?"3px solid #7a5c10":"1px solid #8a8577",boxShadow:e.isCurrent?"0 0 0 3px rgba(122, 92, 16, 0.25)":void 0,borderRadius:0,width:Owe,height:n?s8+12:s8,padding:6,fontFamily:"monospace",fontSize:11},children:[i.jsx(hn,{type:"target",position:_e.Top,id:$V,className:"opacity-0"}),i.jsx(hn,{type:"source",position:_e.Bottom,id:BV,className:"opacity-0"}),i.jsx(hn,{type:"target",position:_e.Right,id:qV,className:"opacity-0"}),i.jsx(hn,{type:"source",position:_e.Right,id:FV,className:"opacity-0"}),i.jsxs("div",{className:"font-mono text-[10px] leading-tight",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 font-bold",children:[i.jsxs("span",{children:[e.isCurrent?i.jsx("span",{"aria-hidden":!0,children:"● "}):null,e.stepId]}),e.isTerminal?i.jsx(ht,{tool:"terminal",size:"xs",title:"Terminal step",decorative:!0}):null]}),i.jsx("div",{className:"text-on-surface-variant",children:e.role}),e.preferredTarget&&i.jsxs("div",{className:"text-[8px] text-on-surface-variant",children:["→ ",e.preferredTarget]}),n&&i.jsxs("div",{className:"text-[8px] text-on-surface-variant",children:[e.harness?i.jsxs("span",{"data-testid":`wf-node-harness-${e.stepId}`,children:["⌁ ",e.harness]}):null,e.host?i.jsxs("span",{"data-testid":`wf-node-host-${e.stepId}`,children:[e.harness?" · ":"","host: ",e.host]}):null,e.gate?i.jsxs("span",{"data-testid":`wf-node-gate-${e.stepId}`,children:[e.harness||e.host?" · ":"","⛨ gate: ",e.gate.target]}):null]})]})]})}const Fwe={workflowStep:qwe};function zV({topology:e,testId:t,currentStepId:n,visitedStepIds:s,takenEdgeKeys:r,heightClass:a}){const{nodes:o,edges:c}=C.useMemo(()=>{const d=$we(e),h=new Map;for(const b of e.nodes){const _=d.get(b.stepId)??0;h.has(_)||h.set(_,[]),h.get(_).push(b.stepId)}const m=new Map;for(const[b,_]of h)_.forEach((w,E)=>m.set(w,{x:E*Pwe,y:b*Dwe}));const f=new Set(s??[]),g=new Set(r??[]),x=e.nodes.map(b=>({id:b.stepId,type:"workflowStep",position:m.get(b.stepId)??{x:0,y:0},data:{stepId:b.stepId,role:b.role,preferredTarget:b.preferredTarget,isEntry:b.isEntry,isTerminal:b.isTerminal,harness:b.harness,host:b.host,gate:b.gate,isCurrent:n!=null&&b.stepId===n,wasVisited:f.has(b.stepId)}})),y=e.edges.map((b,_)=>{const w=b.routingType==="branch",E=g.has(`${b.fromStepId}→${b.toStepId}`),{sourceHandle:N,targetHandle:k}=Bwe(b.fromStepId,b.toStepId,d);return{id:`e-${_}`,source:b.fromStepId,target:b.toStepId,sourceHandle:N,targetHandle:k,label:w&&b.branchOn?`on ${b.branchOn}`:void 0,labelStyle:{fontFamily:"monospace",fontSize:9,fill:"#7a5c10"},labelBgStyle:{fill:"#f2ead6"},animated:E&&n!=null,style:{stroke:E?"#5c4a10":w?"#a8842c":"#8a8577",strokeWidth:E?2.5:1,strokeDasharray:w?"6 4":void 0}}});return{nodes:x,edges:y}},[e,n,s,r]);return i.jsx("div",{"data-testid":t??"workflow-topology-graph",className:`w-full ${a??"h-[400px]"} bg-background border border-outline-variant`,children:i.jsxs(gp,{nodes:o,edges:c,nodeTypes:Fwe,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[i.jsx(IR,{gap:20,size:.5,color:"#d4d0c8"}),i.jsx(xp,{showInteractive:!1})]})})}async function ET(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}`);return await t.json()}function HV(e){return Re({queryKey:["workflow","instances","all"],queryFn:()=>ET("/api/workflow/list"),staleTime:15e3})}function zwe(){return Re({queryKey:["workflow","specs"],queryFn:()=>ET("/api/workflow/specs"),staleTime:15e3})}function Hwe(e){return Re({queryKey:["workflow","trace",e],queryFn:()=>ET(`/api/workflow/${encodeURIComponent(e)}/trace`),enabled:!!e,staleTime:15e3})}function Zi(e){return e.status==="failed"?0:e.deadline.state!=="healthy"?1:e.status==="waiting"?2:e.status==="active"?3:4}function Uwe(e){return e.status==="failed"?{glyph:"▲",label:"FAILED",cls:"text-red-700"}:e.deadline.state!=="healthy"?{glyph:"▲",label:e.deadline.state.toUpperCase(),cls:"text-amber-700"}:e.status==="waiting"?{glyph:"◐",label:"WAITING",cls:"text-on-surface-variant"}:e.status==="active"?{glyph:"●",label:"ACTIVE",cls:"text-emerald-800"}:{glyph:"○",label:"COMPLETED",cls:"text-on-surface-variant"}}function Vwe(e){return`…${e.slice(-6)}`}function Wwe(e){const t=Math.max(0,Math.floor((Date.now()-Date.parse(e))/6e4));return t<60?`${t}m`:t<1440?`${Math.floor(t/60)}h`:`${Math.floor(t/1440)}d`}function Gwe(e){return e.currentStepId?`at ${e.currentStepId}`:e.status==="completed"?"closed":e.status==="failed"?"felled":"—"}function UV({instance:e}){const t=Uwe(e);return i.jsx("li",{children:i.jsxs(Ve,{to:"/workflow/instance/$instanceId",params:{instanceId:e.instanceId},"data-testid":`workflow-instance-row-${e.instanceId}`,className:"flex w-full items-center gap-2 px-2 py-1.5 text-left hover:bg-surface-variant/50",children:[i.jsx("span",{className:ce("font-mono text-[11px]",t.cls),"aria-hidden":!0,children:t.glyph}),i.jsx("span",{className:ce("font-mono text-[9px] uppercase w-32 shrink-0",t.cls),children:t.label}),i.jsx("span",{className:"font-mono text-[11px] text-on-surface",title:e.instanceId,children:Vwe(e.instanceId)}),i.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-on-surface",children:[Gwe(e),i.jsxs("span",{className:"text-on-surface-variant",children:[" · hop ",e.hopCount]}),e.resumeCount>0?i.jsxs("span",{className:"text-on-surface-variant",children:[" · resumed ",e.resumeCount,"×"]}):null]}),e.deadline.state!=="healthy"&&e.deadline.evidence?i.jsxs("span",{className:"hidden font-mono text-[10px] text-amber-800 md:inline truncate max-w-64",children:[e.deadline.evidence.ownerSession," · ",Math.floor(e.deadline.evidence.overdueBySeconds/60),"m over"]}):null,i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:Wwe(e.createdAt)}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant","aria-hidden":!0,children:"→"})]})})}function Kwe(e,t,n){return e.filter(s=>t?s.workflowName===t:!0).filter(s=>n?s.workflowVersion===n:!0).slice().sort((s,r)=>Zi(s)-Zi(r))}function Ywe({workflowName:e,workflowVersion:t,testId:n,quietWhenEmpty:s=!0}){const{data:r,isLoading:a}=HV(),o=Kwe(r??[],e,t);if(a||o.length===0)return s?null:i.jsx("p",{"data-testid":n?`${n}-empty`:void 0,className:"font-mono text-[11px] text-on-surface-variant",children:a?"Loading instances…":"0 instances — computed from /api/workflow/list"});const c=o.filter(h=>h.status==="active"||h.status==="waiting").length,d=o.filter(h=>Zi(h)<=1).length;return i.jsxs("div",{"data-testid":n??"workflow-instances-band",className:"space-y-2",children:[i.jsxs("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:["Instances",i.jsxs("span",{className:"ml-2 normal-case tracking-normal",children:[o.length," total · ",c," live",d>0?` · ${d} need attention`:""]})]}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:o.map(h=>i.jsx(UV,{instance:h},h.instanceId))})]})}function Qwe({entry:e}){const[t,n]=C.useState(!1),[s,r]=C.useState(null),[a,o]=C.useState(null),[c,d]=C.useState(null),[h,m]=C.useState(""),[f,g]=C.useState(null),x=mt(),y=Qf(),b=id(s),_=!e.sourceCwd,w=y.data??[],E=b.data??[],N=[...new Set(E.filter(T=>T.podId).map(T=>T.podNamespace??T.podId))],k=a?E.filter(T=>(T.podNamespace??T.podId)===a&&T.runtime===e.runtime&&!!T.agentRef&&!!T.profile):[],R=k.find(T=>T.logicalId===c),A=Ht({mutationFn:async()=>{var L,D,q,B,F,$,U,V,Y;if(!s||!a||!R||!h.trim())throw new Error("Missing required fields");const T={id:h.trim(),runtime:e.runtime,agent_ref:R.agentRef,profile:R.profile,cwd:e.sourceCwd,session_source:{mode:"agent_image",ref:{kind:"image_name",value:e.name}}};e.runtime==="codex"&&R.codexConfigProfile&&(T.codex_config_profile=R.codexConfigProfile);const I=await fetch(`/api/rigs/${encodeURIComponent(s)}/pods/${encodeURIComponent(a)}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({member:T})}),M=await I.json();if(!I.ok||!M.ok)throw new Error(M.message??((L=M.errors)==null?void 0:L.join("; "))??M.code??`HTTP ${I.status}`);const P=(q=(D=M.result)==null?void 0:D.node)==null?void 0:q.status;return P==="failed"||P==="attention_required"?{ok:!1,status:P,error:((F=(B=M.result)==null?void 0:B.node)==null?void 0:F.error)??`Launch ${P}`,logicalId:(U=($=M.result)==null?void 0:$.node)==null?void 0:U.logicalId}:{ok:!0,status:P??"launched",logicalId:((Y=(V=M.result)==null?void 0:V.node)==null?void 0:Y.logicalId)??h.trim()}},onSuccess:T=>{g(T),x.invalidateQueries({queryKey:["ps"]})},onError:T=>{g({ok:!1,error:T.message})}});return _?i.jsx("div",{"data-testid":"fork-now-disabled-no-cwd",className:"font-mono text-[9px] text-on-surface-variant",children:"Fork now unavailable: image lacks source cwd (pre-Finding-2 manifest)"}):i.jsxs(i.Fragment,{children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"fork-now-button",onClick:()=>{n(!0),g(null)},children:"Fork now"}),t&&i.jsxs("div",{"data-testid":"fork-now-modal",className:"border border-outline bg-surface-lowest px-3 py-3 space-y-3 mt-2",children:[i.jsxs("div",{className:"font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface",children:['Fork "',e.name,'" into a running rig']}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["Target rig",i.jsxs("select",{"data-testid":"fork-now-rig-select",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:s??"",onChange:T=>{r(T.target.value||null),o(null),d(null)},children:[i.jsx("option",{value:"",children:"Select rig…"}),w.map(T=>i.jsx("option",{value:T.rigId,children:T.name},T.rigId))]})]}),s&&i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["Target pod",i.jsxs("select",{"data-testid":"fork-now-pod-select",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:a??"",onChange:T=>{o(T.target.value||null),d(null)},children:[i.jsx("option",{value:"",children:"Select pod…"}),N.map(T=>i.jsx("option",{value:T,children:T},T))]})]}),a&&k.length===0&&i.jsxs("div",{"data-testid":"fork-now-no-sibling",className:"font-mono text-[9px] text-amber-600",children:["No ",e.runtime," member in this pod to clone identity from. Choose a different pod."]}),a&&k.length>0&&i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["Clone identity from (",e.runtime," member)",i.jsxs("select",{"data-testid":"fork-now-sibling-select",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:c??"",onChange:T=>d(T.target.value||null),children:[i.jsx("option",{value:"",children:"Select member…"}),k.map(T=>i.jsx("option",{value:T.logicalId,children:T.logicalId},T.logicalId))]})]}),c&&i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["New member ID (no dots)",i.jsx("input",{"data-testid":"fork-now-member-id",type:"text",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:h,onChange:T=>m(T.target.value.replace(/\./g,"")),placeholder:"e.g. forked-worker"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"fork-now-confirm",disabled:!c||!h.trim()||A.isPending,onClick:()=>A.mutate(),children:A.isPending?"Forking…":"Confirm fork"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"})]}),f&&i.jsx("div",{"data-testid":"fork-now-result",className:`font-mono text-[9px] ${f.ok?"text-green-700":"text-red-600"}`,children:f.ok?`Forked: ${f.logicalId??h} launched from image "${e.name}" (${f.status})`:`Fork failed: ${f.status?`[${f.status}] `:""}${f.error}`})]})]})}function Xwe(e){const t=[`Install and launch the "${e.name}" managed app using OpenRig.`,""];return e.summary&&t.push(`About: ${e.summary}`,""),t.push(`Source: ${e.sourcePath}`,"","Steps:",`1. Run: rig up ${e.name}`,`2. Monitor: rig ps --nodes --rig ${e.name}`,"3. Check env: rig env status <rig-name>"),t.join(`
586
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return C.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},H_e="DialogDescriptionWarning",U_e=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${TV(H_e).contentName}}.`;return C.useEffect(()=>{var a;const r=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&r&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},V_e=gV,W_e=vV,G_e=bV,AV=_V,IV=wV,MV=jV,LV=kV,K_e=EV;const Dy=V_e,Y_e=W_e,Q_e=G_e,OV=C.forwardRef(({className:e,...t},n)=>i.jsx(AV,{ref:n,className:ce("fixed inset-0 z-50 bg-black/20 backdrop-blur-[8px]",e),...t}));OV.displayName=AV.displayName;const Ep=C.forwardRef(({className:e,children:t,hideCloseButton:n,...s},r)=>i.jsxs(Q_e,{children:[i.jsx(OV,{}),i.jsxs(IV,{ref:r,className:ce("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 vellum-heavy p-6 shadow-[0_20px_40px_rgba(46,52,46,0.06)] border border-outline-variant",e),...s,children:[t,!n&&i.jsxs(K_e,{className:"absolute right-4 top-4 opacity-70 transition-opacity duration-150 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:ring-offset-background disabled:pointer-events-none",children:[i.jsx(CE,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ep.displayName=IV.displayName;const $y=({className:e,...t})=>i.jsx("div",{className:ce("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});$y.displayName="DialogHeader";const By=({className:e,...t})=>i.jsx("div",{className:ce("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});By.displayName="DialogFooter";const Rp=C.forwardRef(({className:e,...t},n)=>i.jsx(MV,{ref:n,className:ce("text-lg font-semibold leading-none tracking-tight",e),...t}));Rp.displayName=MV.displayName;const Tp=C.forwardRef(({className:e,...t},n)=>i.jsx(LV,{ref:n,className:ce("text-sm text-foreground-muted",e),...t}));Tp.displayName=LV.displayName;function X_e(e){return Re({queryKey:["packages",e],queryFn:async()=>{const t=await fetch(`/api/packages/${e}`);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()},enabled:!!e})}function Z_e(e){return Re({queryKey:["packages",e,"installs"],queryFn:async()=>{const t=await fetch(`/api/packages/${e}/installs`);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()},enabled:!!e})}function J_e(e){return Re({queryKey:["installs",e,"journal"],queryFn:async()=>{const t=await fetch(`/api/packages/installs/${e}/journal`);if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()},enabled:!!e})}function ewe(e){const t=mt();return Ht({mutationFn:async n=>{const s=await fetch(`/api/packages/${n}/rollback`,{method:"POST"});if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()},onSuccess:()=>{t.invalidateQueries({queryKey:["packages",e,"installs"]}),t.invalidateQueries({queryKey:["installs"]})}})}function twe(e){switch(e){case"applied":return"bg-success";case"rolled_back":return"bg-warning";case"failed":return"bg-destructive";default:return"bg-foreground-muted"}}function nwe(e){switch(e){case"applied":return"APPLIED";case"rolled_back":return"ROLLED BACK";case"failed":return"FAILED";default:return e.toUpperCase()}}function swe({installId:e}){const{data:t,isPending:n,isError:s}=J_e(e);return n?i.jsx("div",{className:"pl-spacing-6 py-spacing-2 text-label-sm text-foreground-muted",children:"Loading journal..."}):s?i.jsx("div",{className:"pl-spacing-6 py-spacing-2 text-label-sm text-destructive","data-testid":"journal-error",children:"Failed to load journal entries"}):!t||t.length===0?i.jsx("div",{className:"pl-spacing-6 py-spacing-2 text-label-sm text-foreground-muted",children:"No journal entries"}):i.jsx("div",{className:"pl-spacing-6 py-spacing-2 space-y-spacing-1","data-testid":"journal-entries",children:t.map(r=>i.jsxs("div",{"data-testid":"journal-entry",className:"flex items-center gap-spacing-3 text-label-sm font-mono py-spacing-1 border-b border-foreground/6 last:border-0",children:[i.jsx("span",{className:"text-foreground-muted w-6 text-right",children:r.seq}),i.jsx("span",{className:"uppercase",children:r.action}),i.jsx("span",{className:"text-foreground-muted",children:r.exportType}),i.jsx("span",{className:"text-foreground-muted truncate max-w-[200px]",children:r.targetPath}),i.jsx("span",{className:"text-foreground-muted ml-auto",children:r.status})]},r.id))})}function rwe({install:e,onRollback:t}){const[n,s]=C.useState(!1);return i.jsxs("div",{"data-testid":"install-row",className:"card-dark p-spacing-4 mb-spacing-2",children:[i.jsxs("div",{className:"flex items-center gap-spacing-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-spacing-3 mb-spacing-1",children:[i.jsx("span",{className:"font-mono text-label-sm text-foreground-muted",children:e.createdAt}),i.jsx("span",{"data-testid":"install-status-badge",className:ce("inline-block px-spacing-2 py-px text-label-sm uppercase",twe(e.status)),children:nwe(e.status)})]}),i.jsx("div",{className:"text-label-sm font-mono text-foreground-muted-on-dark",children:e.targetRoot}),i.jsxs("div",{className:"flex items-center gap-spacing-3 mt-spacing-1 text-label-sm",children:[i.jsxs("span",{"data-testid":"applied-count",children:[i.jsx("span",{className:"font-mono",children:e.appliedCount})," applied"]}),i.jsx("span",{"data-testid":"deferred-placeholder",className:"text-foreground-muted",children:"— deferred"})]})]}),i.jsxs("div",{className:"flex items-center gap-spacing-2 shrink-0",children:[i.jsx(Se,{variant:"tactical",size:"sm","data-testid":"expand-btn",onClick:()=>s(!n),children:n?"COLLAPSE":"EXPAND"}),e.status==="applied"&&i.jsx(Se,{variant:"tactical",size:"sm","data-testid":"rollback-btn",onClick:()=>t(e.id),children:"ROLLBACK"})]})]}),n&&i.jsx(swe,{installId:e.id})]})}function iwe(){var b;const{packageId:e}=An({strict:!1}),{data:t,isPending:n,error:s}=X_e(e),{data:r,isPending:a,error:o}=Z_e(e),c=ewe(e),[d,h]=C.useState(null),[m,f]=C.useState(!1),g=_=>{h(_),f(!0)},x=()=>{d&&c.mutate(d,{onSuccess:()=>{f(!1),h(null)}})};if(n||a)return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"detail-loading",children:[i.jsx("div",{className:"h-8 w-48 shimmer mb-spacing-4"}),i.jsxs("div",{className:"card-dark p-spacing-6 mb-spacing-4",children:[i.jsx("div",{className:"h-6 w-64 shimmer-dark mb-spacing-3"}),i.jsx("div",{className:"h-4 w-full shimmer-dark"})]})]})});if(s)return i.jsx(ot,{children:i.jsx("div",{"data-testid":"detail-error",children:i.jsx("p",{className:"text-destructive",children:s.message})})});if(o)return i.jsx(ot,{children:i.jsx("div",{"data-testid":"installs-error",children:i.jsx("p",{className:"text-destructive",children:"Failed to load install history"})})});const y=r??[];return i.jsx(ot,{children:i.jsxs("div",{children:[t&&i.jsxs("div",{className:"card-dark p-spacing-6 mb-spacing-6","data-testid":"package-header",children:[i.jsxs("div",{className:"flex items-baseline justify-between mb-spacing-2",children:[i.jsxs("h2",{className:"text-headline-lg uppercase",children:[t.name," (Legacy)"]}),i.jsxs("span",{className:"text-label-md font-mono text-foreground-muted-on-dark",children:["v",t.version]})]}),i.jsxs("div",{className:"text-label-sm text-foreground-muted-on-dark mb-spacing-2",children:["SOURCE"," ",i.jsx("span",{className:"font-mono text-foreground-on-dark","data-testid":"package-source",children:t.sourceRef})]}),t.summary&&i.jsx("p",{className:"text-body-sm text-foreground-muted-on-dark",children:t.summary})]}),i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-4",children:"INSTALL HISTORY"}),y.length===0?i.jsx("div",{"data-testid":"empty-installs",className:"text-body-md text-foreground-muted",children:"No installs yet"}):i.jsx("div",{"data-testid":"install-list",children:y.map(_=>i.jsx(rwe,{install:_,onRollback:g},_.id))}),i.jsx(Dy,{open:m,onOpenChange:_=>{c.isPending||(f(_),_||c.reset())},children:i.jsxs(Ep,{"data-testid":"rollback-dialog",onPointerDownOutside:_=>{c.isPending&&_.preventDefault()},onEscapeKeyDown:_=>{c.isPending&&_.preventDefault()},hideCloseButton:c.isPending,children:[i.jsxs($y,{children:[i.jsx(Rp,{className:"text-headline-md uppercase",children:"CONFIRM ROLLBACK"}),i.jsx(Tp,{children:"This will roll back the install and restore previous file states. This action cannot be undone."})]}),c.isError&&i.jsxs("p",{className:"text-destructive text-label-sm","data-testid":"rollback-error",children:["Rollback failed: ",((b=c.error)==null?void 0:b.message)??"Unknown error"]}),i.jsxs(By,{children:[i.jsx(Se,{variant:"ghost",onClick:()=>{c.reset(),f(!1)},"data-testid":"rollback-cancel",disabled:c.isPending,children:"CANCEL"}),i.jsx(Se,{variant:"destructive",onClick:x,"data-testid":"rollback-confirm",disabled:c.isPending,children:c.isPending?"ROLLING BACK...":"ROLLBACK"})]})]})})]})})}function awe(e){switch(e){case"installed":return"bg-success";case"missing":return"bg-destructive";case"unsupported":return"bg-warning";case"unknown":return"bg-warning";default:return"bg-foreground-muted"}}function owe(e){switch(e){case"installed":return"OK";case"missing":return"MISSING";case"unsupported":return"MANUAL";case"unknown":return"UNKNOWN";default:return e.toUpperCase()}}function lwe({results:e}){return e.length===0?i.jsx("div",{className:"text-body-sm text-foreground-muted","data-testid":"no-requirements",children:"No requirements declared."}):i.jsx("div",{className:"space-y-spacing-1","data-testid":"requirements-panel",children:e.map(t=>i.jsxs("div",{"data-testid":"requirement-row",className:"flex items-center gap-spacing-3 py-spacing-1 text-label-sm font-mono",children:[i.jsx("span",{"data-testid":"requirement-dot",className:ce("w-2 h-2 shrink-0",awe(t.status))}),i.jsx("span",{"data-testid":"requirement-status",className:"w-16 uppercase",children:owe(t.status)}),i.jsx("span",{className:"text-foreground-muted w-24",children:t.kind}),i.jsx("span",{children:t.name}),t.detectedPath&&i.jsx("span",{className:"text-foreground-muted ml-auto truncate max-w-[200px]",children:t.detectedPath})]},`${t.kind}:${t.name}`))})}function PV(e,t){var s,r;const n=((s=e.stages)==null?void 0:s.flatMap(a=>{const o=a.detail;if(!o)return[];const c=[];return Array.isArray(o.errors)&&c.push(...o.errors.filter(d=>typeof d=="string")),typeof o.error=="string"&&c.push(o.error),c}))??[];return((r=e.errors)==null?void 0:r.find(a=>typeof a=="string"))??n[0]??e.error??`HTTP ${t}`}function cwe(){return Ht({mutationFn:async({sourceRef:e})=>{const t=await fetch("/api/bootstrap/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceRef:e})});if(!t.ok){const n=await t.json().catch(()=>({})),s=new Error(PV(n,t.status));throw s.data=n,s}return t.json()}})}function uwe(){const e=mt();return Ht({mutationFn:async({sourceRef:t,autoApprove:n,approvedActionKeys:s})=>{const r=await fetch("/api/bootstrap/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceRef:t,autoApprove:n,approvedActionKeys:s})}),a=await r.json();if(!r.ok){const o=new Error(PV(a,r.status));throw o.data=a,o}return a},onSuccess:()=>{e.invalidateQueries({queryKey:["rigs","summary"]})}})}const dwe=["ENTER","PLAN","REVIEW","APPLY"],hwe=dwe.map((e,t)=>({num:t+1,label:e}));function fwe(e){switch(e){case"enter":return 1;case"planning":return 2;case"planned":return 3;case"applying":return 4;case"done":case"error":return 4;default:return 1}}function pwe(){const e=Pt(),{bootstrapSourceRef:t,setBootstrapSourceRef:n}=op(),[s,r]=C.useState("enter"),[a,o]=C.useState(()=>t),[c,d]=C.useState(null),[h,m]=C.useState(new Set),[f,g]=C.useState(!1),[x,y]=C.useState(null),b=cwe(),_=uwe();C.useEffect(()=>{n(a)},[n,a]);const w=async()=>{if(a.trim()){r("planning");try{const q=await b.mutateAsync({sourceRef:a.trim()});d(q),m(new Set(q.actionKeys??[])),r("planned")}catch(q){y(q.message),r("error")}}},E=async()=>{r("applying");try{const q=await _.mutateAsync({sourceRef:a.trim(),autoApprove:f,approvedActionKeys:f?void 0:[...h]});d(q),r("done")}catch(q){y(q.message),r("error")}},N=()=>{r("enter"),o(""),d(null),m(new Set),g(!1),y(null),b.reset(),_.reset()},k=c==null?void 0:c.stages.find(q=>q.stage==="probe_requirements"),R=k==null?void 0:k.detail,A=(R==null?void 0:R.results)??[],T=c==null?void 0:c.stages.find(q=>q.stage==="build_install_plan"),I=T==null?void 0:T.detail,M=(I==null?void 0:I.actions)??[],P=(T==null?void 0:T.status)==="blocked",D=M.some(q=>q.classification!=="manual_only"&&q.commandPreview)&&h.size===0&&!f;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"bootstrap-wizard",className:"space-y-8",children:[i.jsx(wn,{eyebrow:"Bootstrap",title:"Bootstrap",description:"Plan environment requirements, approve install actions, then import the rig into a running topology."}),i.jsx(ZU,{"data-testid":"step-indicator",steps:hwe,currentStep:fwe(s)}),s==="enter"&&i.jsx(or,{title:"Source",description:"Provide a rig spec or bundle path. Bootstrap will inspect requirements before it imports anything.",children:i.jsxs("div",{"data-testid":"step-enter",children:[i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"SPEC OR BUNDLE PATH"}),i.jsx(_T,{"data-testid":"spec-input",type:"text",value:a,onChange:q=>o(q.target.value),placeholder:"/path/to/rig.yaml or /path/to/bundle.rigbundle",className:"font-mono text-body-md"}),i.jsxs("p",{className:"text-label-sm text-foreground-muted mt-spacing-1",children:["Accepts .yaml rig specs or .rigbundle archives."," ",i.jsx("span",{role:"link",tabIndex:0,className:"text-primary cursor-pointer","data-testid":"inspect-link",onClick:()=>e({to:"/bundles/inspect"}),onKeyDown:q=>{q.key==="Enter"&&e({to:"/bundles/inspect"})},children:"Inspect a bundle first →"})]}),i.jsx("div",{className:"mt-spacing-4",children:i.jsx(Se,{variant:"tactical",onClick:w,disabled:!a.trim(),"data-testid":"plan-btn",children:"PLAN"})})]})}),s==="planning"&&i.jsx("div",{"data-testid":"step-planning",className:"text-body-md text-foreground-muted",children:"Planning..."}),s==="planned"&&c&&i.jsx(or,{title:"Plan Review",description:"Review requirement probe results and approve the install actions that bootstrap should execute.",children:i.jsxs("div",{"data-testid":"step-planned",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"STAGES"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-6","data-testid":"stage-list",children:c.stages.map(q=>i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono","data-testid":"stage-row",children:[i.jsx("span",{className:q.status==="ok"?"text-success":q.status==="blocked"?"text-warning":"text-foreground-muted",children:q.status.toUpperCase()}),i.jsx("span",{children:q.stage})]},q.stage))}),A.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"REQUIREMENTS"}),i.jsx("div",{className:"mb-spacing-6",children:i.jsx(lwe,{results:A})})]}),M.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"ACTIONS"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4",children:M.map(q=>i.jsxs("label",{className:"flex items-center gap-spacing-3 text-label-sm font-mono cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:f||h.has(q.key),disabled:f||q.classification==="manual_only",onChange:B=>{const F=new Set(h);B.target.checked?F.add(q.key):F.delete(q.key),m(F)}}),i.jsx("span",{className:q.classification==="manual_only"?"text-warning":"",children:q.requirementName}),q.commandPreview&&i.jsx("span",{className:"text-foreground-muted",children:q.commandPreview})]},q.key))}),i.jsxs("label",{className:"flex items-center gap-spacing-2 text-label-sm mb-spacing-4",children:[i.jsx("input",{type:"checkbox",checked:f,onChange:q=>g(q.target.checked)}),"Auto-approve all trusted actions"]})]}),P&&i.jsx("div",{className:"text-warning text-label-sm mb-spacing-4","data-testid":"blocked-warning",children:"Manual requirements must be resolved before bootstrap can proceed."}),c.warnings.length>0&&i.jsx("div",{className:"mb-spacing-4",children:c.warnings.map((q,B)=>i.jsx("div",{className:"text-warning text-label-sm",children:q},B))}),i.jsx(Se,{variant:"tactical",onClick:E,disabled:P||D,title:P?"Manual requirements must be resolved":D?"Select actions to approve":void 0,"data-testid":"apply-btn",children:"APPLY"})]})}),s==="applying"&&c&&i.jsx(or,{title:"Applying",description:"Bootstrap is executing the approved actions and importing the rig.",children:i.jsxs("div",{"data-testid":"step-applying",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"APPLYING"}),i.jsxs("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"applying-checklist",children:[c.stages.map(q=>i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:q.stage})]},q.stage)),i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:"execute_external_installs"})]}),i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:"install_packages"})]}),i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono",children:[i.jsx("span",{className:"text-foreground-muted",children:"○"}),i.jsx("span",{children:"import_rig"})]})]}),i.jsx("p",{className:"text-body-sm text-foreground-muted",children:"Bootstrapping..."})]})}),s==="done"&&c&&i.jsx(or,{title:"Result",description:"Bootstrap finished and returned the managed rig identity.",children:i.jsxs("div",{"data-testid":"step-done",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:c.status==="completed"?"BOOTSTRAP COMPLETE":"BOOTSTRAP PARTIAL"}),i.jsxs("div",{className:"text-label-sm font-mono space-y-spacing-1 mb-spacing-4",children:[i.jsxs("div",{children:["Status: ",i.jsx("span",{className:c.status==="completed"?"text-success":"text-warning",children:c.status.toUpperCase()})]}),c.rigId&&i.jsxs("div",{"data-testid":"result-rig-id",children:["Rig: ",c.rigId]})]}),c.rigId&&i.jsx(Se,{variant:"tactical","data-testid":"view-rig-btn",onClick:()=>e({to:"/rigs/$rigId",params:{rigId:c.rigId}}),children:"VIEW RIG"})]})}),s==="error"&&i.jsx(or,{title:"Bootstrap Error",description:"Bootstrap could not complete. Fix the issue and retry the plan.",children:i.jsxs("div",{"data-testid":"step-error",children:[i.jsx("p",{className:"text-destructive text-body-md mb-spacing-4",children:x}),i.jsx(Se,{variant:"tactical",onClick:N,"data-testid":"try-again-btn",children:"TRY AGAIN"})]})})]})})}function mwe(){const{currentAgentDraft:e,selectedAgentDraft:t,saveAgentDraft:n,rememberAgentDraft:s,clearSelectedAgentDraft:r}=op(),[a,o]=C.useState(()=>(t==null?void 0:t.yaml)??(e==null?void 0:e.yaml)??""),[c,d]=C.useState("idle"),[h,m]=C.useState([]);C.useEffect(()=>{n(a)},[n,a]),C.useEffect(()=>{t&&(o(t.yaml),r())},[r,t]);const f=async()=>{s(a),d("pending"),m([]);try{const g=await fetch("/api/agents/validate",{method:"POST",headers:{"Content-Type":"text/yaml"},body:a}),x=await g.json().catch(()=>({}));if(g.ok&&x.valid){d("valid");return}m(x.errors??["Validation failed"]),d("invalid")}catch{m(["Validation request failed"]),d("error")}};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"agent-spec-validate-flow",className:"space-y-8",children:[i.jsx(wn,{eyebrow:"Agent Spec Validation",title:"VALIDATE AGENT",description:"Check an AgentSpec before you use it in a rig."}),i.jsxs(or,{title:"Agent YAML",description:"Paste or refine an AgentSpec draft, then validate it against the daemon contract.",children:[i.jsx(wT,{"data-testid":"agent-spec-yaml-input",value:a,onChange:g=>o(g.target.value),placeholder:"Paste agent.yaml here...",rows:16,className:"bg-background font-mono text-body-sm"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:i.jsx(Se,{variant:"tactical","data-testid":"agent-spec-validate-btn",onClick:f,disabled:!a.trim()||c==="pending",children:c==="pending"?"VALIDATING...":"VALIDATE AGENTSPEC"})}),c==="valid"&&i.jsx(Xn,{className:"mt-spacing-1","data-testid":"agent-spec-valid",children:i.jsx(qn,{className:"text-primary",children:"AgentSpec valid."})}),(c==="invalid"||c==="error")&&i.jsx(Xn,{className:"mt-spacing-1","data-testid":"agent-spec-invalid",children:i.jsx(qn,{children:i.jsx("ul",{className:"list-disc pl-5",children:h.map(g=>i.jsx("li",{children:g},g))})})})]})]})})}async function gwe(e,t="draft"){var s;const n=await fetch("/api/specs/review/rig",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:e,sourceState:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(((s=r.errors)==null?void 0:s.join("; "))??`HTTP ${n.status}`)}return n.json()}async function xwe(e,t="draft"){var s;const n=await fetch("/api/specs/review/agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:e,sourceState:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(((s=r.errors)==null?void 0:s.join("; "))??`HTTP ${n.status}`)}return n.json()}function DV(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}function vwe(e,t="draft"){return Re({queryKey:["spec-review","rig",e?DV(e):null,t],queryFn:()=>gwe(e,t),enabled:!!e})}function ywe(e,t="draft"){return Re({queryKey:["spec-review","agent",e?DV(e):null,t],queryFn:()=>xwe(e,t),enabled:!!e})}const bwe=160,_we=48,t8=200,wwe=100;function Swe(e){switch(e){case"claude-code":return"#d4c4a8";case"codex":return"#b8c9d4";case"terminal":return"#c4c4c4";default:return"#e0ddd4"}}function jwe(e){const t=new Map,n=[];for(const a of e)a.pod?(t.has(a.pod)||t.set(a.pod,[]),t.get(a.pod).push(a)):n.push(a);const s=[];let r=0;for(const[,a]of t)a.forEach((o,c)=>{s.push({id:o.id,x:c*t8,y:r})}),r+=wwe;return n.forEach((a,o)=>{s.push({id:a.id,x:o*t8,y:r})}),s}function Nwe({graph:e,testId:t}){const n=e??{nodes:[],edges:[]},{nodes:s,edges:r}=C.useMemo(()=>{const a=jwe(n.nodes),o=new Map(a.map(h=>[h.id,h])),c=n.nodes.map(h=>{const m=o.get(h.id)??{x:0,y:0};return{id:h.id,type:"default",position:{x:m.x,y:m.y},data:{label:i.jsxs("div",{className:"flex h-full min-w-0 flex-col justify-center gap-1 font-mono leading-tight",children:[i.jsxs("div",{className:"truncate text-[10px] font-bold text-on-surface",children:[h.pod?`${h.pod} / `:"",h.label]}),i.jsx(Cs,{runtime:h.runtime,size:"xs",compact:!0,variant:"inline"})]})},style:{backgroundColor:Swe(h.runtime),border:"1px solid #8a8577",fontSize:11,fontFamily:"monospace",width:bwe,height:_we}}}),d=n.edges.map((h,m)=>({id:`e-${m}`,source:h.source,target:h.target,label:h.kind,labelStyle:{fontSize:9,fontFamily:"monospace"},style:{strokeDasharray:"4 4",stroke:"#8a8577"}}));return{nodes:c,edges:d}},[n]);return i.jsx("div",{"data-testid":t??"spec-topology-preview",className:"w-full h-[400px] bg-background border border-outline-variant",children:i.jsxs(gp,{nodes:s,edges:r,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[i.jsx(IR,{gap:20,size:.5,color:"#d4d0c8"}),i.jsx(xp,{showInteractive:!1})]})})}function kwe({data:e,children:t,className:n,style:s,testId:r}){const{setSelection:a}=Kv();return i.jsx("button",{type:"button","data-testid":r??"sub-spec-trigger",onClick:()=>a({type:"sub-spec",data:e}),className:n??"text-left",style:s,children:t})}function Cwe(e){const n=(e.startsWith("local:")?e.slice(6):e).replace(/^(builtin|user|fork):/,""),s=n.startsWith("agents/")?n.slice(7):n,r=s.split("@")[0]??s,a=e.startsWith("fork:")?"fork":e.startsWith("builtin:")?"builtin":"user_file";return{specName:r,source:a}}function kT({review:e,yaml:t,testIdPrefix:n="",yamlTestId:s,showEnvironmentTab:r,onMemberClick:a}){var y,b,_;const o=r&&!!(e!=null&&e.services),c=o?["topology","configuration","environment","yaml"]:["topology","configuration","yaml"],[d,h]=C.useState("topology"),m=(e==null?void 0:e.pods)??[],f=(e==null?void 0:e.nodes)??[],g=(e==null?void 0:e.edges)??[],x=n?`${n}-`:"";return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex gap-1 border-b border-outline-variant",children:c.map(w=>i.jsx("button",{"data-testid":`${x}tab-${w}`,onClick:()=>h(w),className:`px-3 py-1.5 font-mono text-[10px] uppercase tracking-wider transition-colors ${d===w?"border-b-2 border-on-surface text-on-surface font-bold":"text-on-surface-variant hover:text-on-surface"}`,children:w},w))}),d==="topology"&&e&&i.jsx(Nwe,{graph:e.graph,testId:`${x}topology-preview`}),d==="configuration"&&e&&i.jsxs("div",{"data-testid":`${x}config-tables`,className:"space-y-4",children:[e.format==="pod_aware"&&m.map(w=>i.jsxs("div",{className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:w.label??w.id}),i.jsxs("table",{className:"w-full font-mono text-[10px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-outline-variant text-on-surface-variant",children:[i.jsx("th",{className:"text-left py-1",children:"Member"}),i.jsx("th",{className:"text-left py-1",children:"Agent Ref"}),i.jsx("th",{className:"text-left py-1",children:"Runtime"}),i.jsx("th",{className:"text-left py-1",children:"Profile"})]})}),i.jsx("tbody",{children:w.members.map(E=>i.jsxs("tr",{className:"border-b border-outline-variant",children:[i.jsx("td",{className:"py-1",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:E.id}),a&&i.jsx(Se,{variant:"outline",size:"sm","data-testid":`${x}member-open-agent-${w.id}-${E.id}`,className:"h-6 px-2 font-mono text-[9px] uppercase tracking-[0.12em]",onClick:()=>a(w.id,E),children:"Agent Spec"})]})}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:(()=>{const N=Cwe(E.agentRef);return i.jsx(kwe,{data:{specKind:"agent",specName:N.specName,source:N.source},testId:`${x}member-sub-spec-${w.id}-${E.id}`,className:"text-on-surface-variant underline decoration-dotted decoration-outline hover:text-on-surface hover:decoration-on-surface",children:E.agentRef})})()}),i.jsx("td",{className:"py-1",children:i.jsx(Cs,{runtime:E.runtime,size:"xs",compact:!0,variant:"inline"})}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:E.profile??"—"})]},E.id))})]})]},w.id)),e.format==="legacy"&&f.length>0&&i.jsxs("div",{className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Nodes"}),i.jsxs("table",{className:"w-full font-mono text-[10px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-outline-variant text-on-surface-variant",children:[i.jsx("th",{className:"text-left py-1",children:"ID"}),i.jsx("th",{className:"text-left py-1",children:"Runtime"}),i.jsx("th",{className:"text-left py-1",children:"Role"})]})}),i.jsx("tbody",{children:f.map(w=>i.jsxs("tr",{className:"border-b border-outline-variant",children:[i.jsx("td",{className:"py-1",children:w.id}),i.jsx("td",{className:"py-1",children:i.jsx(Cs,{runtime:w.runtime,size:"xs",compact:!0,variant:"inline"})}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:w.role??"—"})]},w.id))})]})]}),g.length>0&&i.jsxs("div",{className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:e.format==="pod_aware"?"Cross-Pod Edges":"Edges"}),i.jsxs("table",{className:"w-full font-mono text-[10px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-outline-variant text-on-surface-variant",children:[i.jsx("th",{className:"text-left py-1",children:"From"}),i.jsx("th",{className:"text-left py-1",children:"To"}),i.jsx("th",{className:"text-left py-1",children:"Kind"})]})}),i.jsx("tbody",{children:g.map((w,E)=>i.jsxs("tr",{className:"border-b border-outline-variant",children:[i.jsx("td",{className:"py-1",children:w.from}),i.jsx("td",{className:"py-1",children:w.to}),i.jsx("td",{className:"py-1 text-on-surface-variant",children:w.kind})]},E))})]})]})]}),d==="environment"&&o&&(e==null?void 0:e.services)&&i.jsxs("div",{className:"space-y-4","data-testid":`${x}env-details`,children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Services"}),(y=e.services.composePreview)==null?void 0:y.services.map(w=>i.jsxs("div",{className:"flex items-center justify-between border border-outline-variant px-3 py-2",children:[i.jsx("span",{className:"font-mono text-[11px] text-on-surface",children:w.name}),w.image&&i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:w.image})]},w.name))]}),e.services.waitFor.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Health Gates"}),e.services.waitFor.map((w,E)=>i.jsxs("div",{className:"font-mono text-[10px] text-on-surface-variant border border-outline-variant px-3 py-2",children:[w.url&&i.jsx("span",{children:w.url}),w.tcp&&i.jsxs("span",{children:["tcp: ",w.tcp]}),w.service&&i.jsxs("span",{children:["service: ",w.service,w.condition?` (${w.condition})`:""]})]},E))]}),e.services.surfaces&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Surfaces"}),(b=e.services.surfaces.urls)==null?void 0:b.map(w=>i.jsxs("div",{className:"flex items-center justify-between border border-outline-variant px-3 py-2",children:[i.jsx("span",{className:"text-[11px] text-on-surface",children:w.name}),i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:w.url})]},w.name)),(_=e.services.surfaces.commands)==null?void 0:_.map(w=>i.jsxs("div",{className:"flex items-center justify-between border border-outline-variant px-3 py-2",children:[i.jsx("span",{className:"text-[11px] text-on-surface",children:w.name}),i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:w.command})]},w.name))]})]}),d==="yaml"&&i.jsx(JU,{title:"YAML Preview",testId:s??`${x}spec-yaml`,children:t})]})}function Ewe(){const e=Pt(),{selectedRigDraft:t,currentRigDraft:n}=op(),s=t??n,{data:r,isLoading:a,error:o}=vwe((s==null?void 0:s.yaml)??null),c=(r==null?void 0:r.pods)??[],d=(r==null?void 0:r.nodes)??[],h=(r==null?void 0:r.edges)??[];return s?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"rig-spec-review",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Rig Spec Review",title:(r==null?void 0:r.name)??s.label,description:(r==null?void 0:r.summary)??"Review the spec structure before import or bootstrap.",actions:i.jsxs(i.Fragment,{children:[i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/import"}),children:"Open In Import"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/bootstrap"}),children:"Bootstrap"})]})}),r&&i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:r.format==="pod_aware"?"Pod-Aware":"Legacy",testId:"rig-spec-summary-format"}),i.jsx(st,{label:r.format==="pod_aware"?"Pods":"Nodes",value:r.format==="pod_aware"?c.length:d.length,testId:"rig-spec-summary-pods"}),i.jsx(st,{label:"Members",value:r.format==="pod_aware"?c.reduce((m,f)=>m+f.members.length,0):d.length,testId:"rig-spec-summary-members"}),i.jsx(st,{label:"Edges",value:h.length+(r.format==="pod_aware"?c.reduce((m,f)=>{var g;return m+(((g=f.edges)==null?void 0:g.length)??0)},0):0),testId:"rig-spec-summary-edges"})]}),a&&i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading review..."}),o&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 font-mono text-[10px] text-red-700",children:o.message}),i.jsx(kT,{review:r,yaml:s.yaml,yamlTestId:"rig-spec-yaml"})]})}):i.jsx(ot,{children:i.jsxs("div",{"data-testid":"rig-spec-review-empty",className:"space-y-5",children:[i.jsx(wn,{eyebrow:"Rig Spec Review",title:"No RigSpec Selected",description:"Choose a current or recent rig draft from the Library drawer to review it here before you import or bootstrap it."}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/import"}),children:"Open Import"})]})})}function ac({data:e,children:t,className:n,style:s,testId:r}){const{setSelection:a}=Kv();return i.jsx("button",{type:"button","data-testid":r??"file-reference-trigger",onClick:()=>a({type:"file",data:e}),className:n??"text-left",style:s,children:t})}function Rwe(e,t){if(!e||!t)return null;if(t.startsWith("/"))return t;const s=`${e.replace(/\/[^/]*$/,"")}/${t}`.split("/"),r=[];for(const a of s)if(!(!a||a===".")){if(a===".."){r.pop();continue}r.push(a)}return`/${r.join("/")}`}function n8({label:e,sourcePath:t,testId:n,children:s}){const r=Rwe(t,e);return r?i.jsx(ac,{data:{path:e,absolutePath:r},testId:n,className:"inline-block text-left",children:s}):i.jsx(i.Fragment,{children:s})}function CT({review:e,yaml:t,testIdPrefix:n="agent",sourcePath:s}){const r=(e==null?void 0:e.profiles)??[],a=(e==null?void 0:e.resources)??{skills:[],guidance:[],plugins:[]},o=(e==null?void 0:e.startup)??{files:[],actions:[]};return i.jsxs(i.Fragment,{children:[r.length>0&&i.jsxs("div",{"data-testid":`${n}-profiles-section`,className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Profiles"}),i.jsx("div",{className:"space-y-1",children:r.map(c=>i.jsxs("div",{className:"font-mono text-[10px] flex justify-between",children:[i.jsx("span",{className:"font-bold",children:c.name}),c.description&&i.jsx("span",{className:"text-on-surface-variant",children:c.description})]},c.name))})]}),i.jsxs("div",{"data-testid":`${n}-resources-section`,className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Resources"}),i.jsxs("div",{className:"space-y-2 font-mono text-[10px]",children:[a.skills.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Skills:"})," ",a.skills.map((c,d)=>i.jsxs("span",{className:"mr-1 mb-0.5 inline-flex items-center gap-1 bg-surface-low px-1.5 py-0.5",children:[i.jsx(ht,{tool:"file",size:"xs",decorative:!0}),c]},d))]}),a.guidance.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Guidance:"})," ",a.guidance.map((c,d)=>i.jsx(n8,{label:c,sourcePath:s,testId:`${n}-guidance-file-trigger-${c}`,children:i.jsxs("span",{className:"mr-1 mb-0.5 inline-flex items-center gap-1 bg-surface-low px-1.5 py-0.5 underline decoration-dotted decoration-outline",children:[i.jsx(ht,{tool:c,size:"xs",decorative:!0}),c]})},`${c}-${d}`))]}),a.plugins.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Plugins:"})," ",a.plugins.map((c,d)=>i.jsxs("span",{className:"mr-1 mb-0.5 inline-flex items-center gap-1 bg-surface-low px-1.5 py-0.5",children:[i.jsx(ht,{tool:"file",size:"xs",decorative:!0}),c]},`${c}-${d}`))]})]})]}),(o.files.length>0||o.actions.length>0)&&i.jsxs("div",{"data-testid":`${n}-startup-section`,className:"border border-outline-variant p-3",children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Startup"}),o.files.length>0&&i.jsxs("div",{className:"mb-2",children:[i.jsx("div",{className:"font-mono text-[9px] text-on-surface-variant uppercase mb-1",children:"Files"}),o.files.map((c,d)=>i.jsxs("div",{className:"font-mono text-[10px]",children:[i.jsx(n8,{label:c.path,sourcePath:s,testId:`${n}-startup-file-trigger-${c.path}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1 underline decoration-dotted decoration-outline",children:[i.jsx(ht,{tool:c.path,size:"xs",decorative:!0}),c.path]})})," ",c.required&&i.jsx("span",{className:"text-red-500 text-[8px]",children:"REQUIRED"})]},d))]}),o.actions.length>0&&i.jsxs("div",{children:[i.jsx("div",{className:"font-mono text-[9px] text-on-surface-variant uppercase mb-1",children:"Actions"}),o.actions.map((c,d)=>i.jsxs("div",{className:"font-mono text-[10px]",children:[i.jsxs("span",{className:"inline-flex items-center gap-1 text-on-surface-variant",children:[i.jsx(ht,{tool:c.type.includes("command")?"terminal":c.type,size:"xs",decorative:!0}),c.type,":"]})," ",c.value]},d))]})]}),i.jsx(JU,{title:"YAML Preview",testId:`${n}-spec-yaml`,children:t})]})}function Twe(){const e=Pt(),{selectedAgentDraft:t,currentAgentDraft:n}=op(),s=t??n,{data:r,isLoading:a,error:o}=ywe((s==null?void 0:s.yaml)??null);return s?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"agent-spec-review",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Agent Spec Review",title:(r==null?void 0:r.name)??s.label,description:(r==null?void 0:r.description)??"Review the agent spec structure before validation.",actions:i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/agents/validate"}),children:"Open In Validate"})}),r&&i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:"AgentSpec",testId:"agent-spec-summary-format"}),i.jsx(st,{label:"Version",value:r.version,testId:"agent-spec-summary-version"}),i.jsx(st,{label:"Profiles",value:(r.profiles??[]).length,testId:"agent-spec-summary-profiles"}),i.jsx(st,{label:"Skills",value:(r.resources??{skills:[]}).skills.length,testId:"agent-spec-summary-skills"})]}),a&&i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading review..."}),o&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 font-mono text-[10px] text-red-700",children:o.message}),i.jsx(CT,{review:r,yaml:s.yaml,testIdPrefix:"agent"})]})}):i.jsx(ot,{children:i.jsxs("div",{"data-testid":"agent-spec-review-empty",className:"space-y-5",children:[i.jsx(wn,{eyebrow:"Agent Spec Review",title:"No AgentSpec Selected",description:"Choose a current or recent agent draft from the Library drawer to review it here before you validate it."}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/agents/validate"}),children:"Open Validate"})]})})}function Awe(){return Ht({mutationFn:async({bundlePath:e})=>{const t=await fetch("/api/bundles/inspect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundlePath:e})}),n=await t.json();if(n.error)throw new Error(n.error);if(!t.ok)throw new Error(`HTTP ${t.status}`);return n}})}function Iwe(){return Ht({mutationFn:async({bundlePath:e,plan:t,autoApprove:n,targetRoot:s})=>{const r=await fetch("/api/bundles/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bundlePath:e,plan:t,autoApprove:n,targetRoot:s})}),a=await r.json();if(!r.ok)throw new Error(a.error??`HTTP ${r.status}`);return a}})}function Mwe(){var a,o;const[e,t]=C.useState(""),n=Awe(),s=()=>{e.trim()&&n.mutate({bundlePath:e.trim()})},r=n.data;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"bundle-inspector",children:[i.jsx("h2",{className:"text-headline-lg uppercase mb-spacing-4",children:"INSPECT BUNDLE"}),i.jsxs("div",{className:"mb-spacing-4",children:[i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"BUNDLE PATH"}),i.jsx("input",{"data-testid":"bundle-path-input",type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"/path/to/my-rig.rigbundle",className:"w-full bg-transparent border-b border-foreground/20 py-spacing-2 text-body-md font-mono focus:outline-none focus:border-primary"}),i.jsx(Se,{variant:"tactical",onClick:s,disabled:!e.trim()||n.isPending,className:"mt-spacing-3","data-testid":"inspect-btn",children:n.isPending?"INSPECTING...":"INSPECT"})]}),n.isError&&i.jsx("div",{className:"text-destructive text-body-md mb-spacing-4","data-testid":"inspect-error",children:n.error.message}),r&&i.jsxs("div",{"data-testid":"inspect-result",children:[i.jsxs("div",{className:"card-dark p-spacing-4 mb-spacing-4","data-testid":"manifest-summary",children:[i.jsxs("div",{className:"flex items-center gap-spacing-2 mb-spacing-2",children:[i.jsx("h3",{className:"text-headline-md uppercase",children:r.manifest.name}),i.jsxs("span",{className:"text-label-sm font-mono px-spacing-2 py-px bg-foreground/10","data-testid":"schema-badge",children:["v",r.manifest.schemaVersion??1]})]}),i.jsxs("div",{className:"text-label-sm font-mono text-foreground-muted-on-dark",children:["v",r.manifest.version]}),i.jsxs("div",{className:"text-label-sm font-mono text-foreground-muted-on-dark",children:["Spec: ",r.manifest.rigSpec]}),i.jsxs("div",{className:"mt-spacing-2 flex gap-spacing-3",children:[i.jsxs("span",{className:ce("text-label-sm",r.digestValid?"text-success":"text-destructive"),children:["DIGEST: ",r.digestValid?"VALID":"INVALID"]}),i.jsxs("span",{className:ce("text-label-sm",r.integrityResult.passed?"text-success":"text-destructive"),"data-testid":"integrity-status",children:["INTEGRITY: ",r.integrityResult.passed?"PASS":"FAIL"]})]})]}),r.manifest.schemaVersion===2&&r.manifest.agents?i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"AGENTS"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"agent-list",children:r.manifest.agents.map(c=>i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"agent-entry",children:[c.name," v",c.version," — ",c.path]},c.name))})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"PACKAGES"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"package-list",children:(r.manifest.packages??[]).map(c=>i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"package-entry",children:[c.name," v",c.version," — ",c.path]},c.name))})]}),r.manifest.provenance&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"PROVENANCE"}),i.jsxs("div",{className:"card-dark p-spacing-4 mb-spacing-4 space-y-spacing-1","data-testid":"provenance-block",children:[r.manifest.provenance.createdAt&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-createdAt",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Created: "}),r.manifest.provenance.createdAt]}),r.manifest.provenance.sourceHost&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-sourceHost",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Host: "}),r.manifest.provenance.sourceHost]}),r.manifest.provenance.authorSession&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-authorSession",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Author: "}),r.manifest.provenance.authorSession]}),r.manifest.provenance.sourceRigName&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-sourceRigName",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Rig: "}),r.manifest.provenance.sourceRigName,r.manifest.provenance.sourceRigId&&i.jsxs("span",{className:"text-foreground-muted-on-dark",children:[" (",r.manifest.provenance.sourceRigId,")"]})]}),(r.manifest.provenance.daemonVersion||r.manifest.provenance.cliVersion)&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"provenance-versions",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Built with: "}),r.manifest.provenance.daemonVersion&&i.jsxs(i.Fragment,{children:["daemon ",r.manifest.provenance.daemonVersion]}),r.manifest.provenance.daemonVersion&&r.manifest.provenance.cliVersion&&" / ",r.manifest.provenance.cliVersion&&i.jsxs(i.Fragment,{children:["cli ",r.manifest.provenance.cliVersion]})]}),r.manifest.provenance.notes&&i.jsxs("div",{className:"text-label-sm font-mono whitespace-pre-wrap mt-spacing-2","data-testid":"provenance-notes",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Notes: "}),r.manifest.provenance.notes]})]})]}),r.manifest.compatibility&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"COMPATIBILITY"}),i.jsxs("div",{className:"card-dark p-spacing-4 mb-spacing-4 space-y-spacing-1","data-testid":"compatibility-block",children:[r.manifest.compatibility.minDaemonVersion&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"compatibility-minDaemonVersion",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Min daemon: "}),r.manifest.compatibility.minDaemonVersion]}),r.manifest.compatibility.minCliVersion&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"compatibility-minCliVersion",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Min CLI: "}),r.manifest.compatibility.minCliVersion]}),r.manifest.compatibility.schemaVersion!==void 0&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"compatibility-schemaVersion",children:[i.jsx("span",{className:"text-foreground-muted-on-dark",children:"Schema: "}),"v",r.manifest.compatibility.schemaVersion]})]})]}),r.integrityResult.errors.map(c=>i.jsx("p",{className:"text-destructive text-body-md mb-spacing-2",children:c},c)),(r.integrityResult.warnings??[]).map(c=>i.jsx("p",{className:"text-warning text-body-md mb-spacing-2",children:c},c)),r.integrityResult&&i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"FILE INTEGRITY"}),i.jsxs("div",{className:"space-y-spacing-1 mb-spacing-4","data-testid":"file-integrity",children:[Object.keys((r.manifest.packages??r.manifest.agents??[]).length>0?((o=(a=r.manifest)==null?void 0:a.integrity)==null?void 0:o.files)??{}:{}).map(c=>{const d=r.integrityResult.mismatches.includes(c),h=r.integrityResult.missing.includes(c),m=d?"MISMATCH":h?"MISSING":"OK";return i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono","data-testid":"file-row",children:[i.jsx("span",{className:ce("w-2 h-2",m==="OK"?"bg-success":"bg-destructive"),"data-testid":"file-dot"}),i.jsx("span",{children:c}),i.jsx("span",{className:"text-foreground-muted ml-auto",children:m})]},c)}),r.integrityResult.extra.map(c=>i.jsxs("div",{className:"flex items-center gap-spacing-3 text-label-sm font-mono","data-testid":"file-row",children:[i.jsx("span",{className:"w-2 h-2 bg-warning","data-testid":"file-dot"}),i.jsx("span",{children:c}),i.jsx("span",{className:"text-foreground-muted ml-auto",children:"EXTRA"})]},c))]})]}),i.jsx(Se,{variant:"tactical","data-testid":"install-btn",onClick:()=>window.location.href=`/bundles/install?bundlePath=${encodeURIComponent(e)}`,children:"INSTALL THIS BUNDLE"})]})]})})}function Lwe(){const e=Pt(),[t,n]=C.useState("enter"),s=typeof window<"u"?new URLSearchParams(window.location.search):null,[r,a]=C.useState((s==null?void 0:s.get("bundlePath"))??""),[o,c]=C.useState(""),[d,h]=C.useState(null),[m,f]=C.useState(null),g=Iwe(),x=async()=>{if(r.trim()){n("planning");try{const b=await g.mutateAsync({bundlePath:r.trim(),plan:!0});h(b),n("planned")}catch(b){f(b.message),n("error")}}},y=async()=>{if(o.trim()){n("applying");try{const b=await g.mutateAsync({bundlePath:r.trim(),autoApprove:!0,targetRoot:o.trim()});h(b),n("done")}catch(b){f(b.message),n("error")}}};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"bundle-install-flow",children:[i.jsx("h2",{className:"text-headline-lg uppercase mb-spacing-4",children:"INSTALL BUNDLE"}),t==="enter"&&i.jsxs("div",{"data-testid":"step-enter",children:[i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"BUNDLE PATH"}),i.jsx("input",{"data-testid":"bundle-input",type:"text",value:r,onChange:b=>a(b.target.value),placeholder:"/path/to/my-rig.rigbundle",className:"w-full bg-transparent border-b border-foreground/20 py-spacing-2 text-body-md font-mono focus:outline-none focus:border-primary mb-spacing-4"}),i.jsx("label",{className:"text-label-md uppercase block mb-spacing-2",children:"TARGET ROOT"}),i.jsx("input",{"data-testid":"target-input",type:"text",value:o,onChange:b=>c(b.target.value),placeholder:"/path/to/target/project",className:"w-full bg-transparent border-b border-foreground/20 py-spacing-2 text-body-md font-mono focus:outline-none focus:border-primary mb-spacing-4"}),i.jsx(Se,{variant:"tactical",onClick:x,disabled:!r.trim(),"data-testid":"plan-btn",children:"PLAN"})]}),t==="planning"&&i.jsx("div",{"data-testid":"step-planning",className:"text-foreground-muted",children:"Planning..."}),t==="planned"&&d&&i.jsxs("div",{"data-testid":"step-planned",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"PLAN"}),i.jsx("div",{className:"space-y-spacing-1 mb-spacing-4",children:d.stages.map(b=>i.jsxs("div",{className:"text-label-sm font-mono",children:[i.jsx("span",{className:b.status==="ok"?"text-success":"text-foreground-muted",children:b.status.toUpperCase()})," ",b.stage]},b.stage))}),i.jsx(Se,{variant:"tactical",onClick:y,disabled:!o.trim(),"data-testid":"apply-btn",children:"APPLY"})]}),t==="applying"&&i.jsx("div",{"data-testid":"step-applying",className:"text-foreground-muted",children:"Installing..."}),t==="done"&&d&&i.jsxs("div",{"data-testid":"step-done",children:[i.jsx("h3",{className:"text-headline-md uppercase mb-spacing-3",children:"COMPLETE"}),i.jsxs("div",{className:"text-label-sm font-mono",children:["Status: ",i.jsx("span",{className:"text-success",children:d.status.toUpperCase()}),d.stages.some(b=>{var _;return((_=b.detail)==null?void 0:_.source)==="pod_bundle"})?i.jsx("span",{className:"ml-spacing-2 text-primary","data-testid":"bundle-type-label",children:"Pod-aware bundle"}):i.jsx("span",{className:"ml-spacing-2 text-foreground-muted","data-testid":"bundle-type-label",children:"Legacy bundle"})]}),d.rigId&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"result-rig-id",children:["Rig: ",d.rigId]}),d.rigId&&i.jsx(Se,{variant:"tactical",className:"mt-spacing-3",onClick:()=>e({to:"/rigs/$rigId",params:{rigId:d.rigId}}),children:"VIEW RIG"})]}),t==="error"&&i.jsxs("div",{"data-testid":"step-error",children:[i.jsx("p",{className:"text-destructive text-body-md mb-spacing-4",children:m}),i.jsx(Se,{variant:"tactical",onClick:()=>{n("enter"),f(null),g.reset()},"data-testid":"try-again-btn",children:"TRY AGAIN"})]})]})})}const Owe=180,s8=56,Pwe=220,Dwe=110,$V="in-top",BV="out-bottom",qV="in-side",FV="out-side";function $we(e){const t=new Map;for(const a of e.edges)t.has(a.fromStepId)||t.set(a.fromStepId,[]),t.get(a.fromStepId).push(a.toStepId);const n=new Map,s=[];for(const a of e.nodes)a.isEntry&&(n.set(a.stepId,0),s.push({id:a.stepId,d:0}));for(;s.length>0;){const{id:a,d:o}=s.shift();for(const c of t.get(a)??[])n.has(c)||(n.set(c,o+1),s.push({id:c,d:o+1}))}let r=0;for(const a of e.nodes)n.has(a.stepId)||n.set(a.stepId,r++);return n}function Bwe(e,t,n){const s=n.get(e)??0;return(n.get(t)??0)>s?{sourceHandle:BV,targetHandle:$V}:{sourceHandle:FV,targetHandle:qV}}function qwe({data:e}){const t=e.isEntry?"#a8c8d4":e.isTerminal?"#d4b8a8":"#d4c4a8",n=!!(e.harness||e.host||e.gate);return i.jsxs("div",{style:{backgroundColor:e.isCurrent?"#e8dcb8":e.wasVisited?"#cfc3a4":t,border:e.isCurrent?"3px solid #7a5c10":"1px solid #8a8577",boxShadow:e.isCurrent?"0 0 0 3px rgba(122, 92, 16, 0.25)":void 0,borderRadius:0,width:Owe,height:n?s8+12:s8,padding:6,fontFamily:"monospace",fontSize:11},children:[i.jsx(hn,{type:"target",position:_e.Top,id:$V,className:"opacity-0"}),i.jsx(hn,{type:"source",position:_e.Bottom,id:BV,className:"opacity-0"}),i.jsx(hn,{type:"target",position:_e.Right,id:qV,className:"opacity-0"}),i.jsx(hn,{type:"source",position:_e.Right,id:FV,className:"opacity-0"}),i.jsxs("div",{className:"font-mono text-[10px] leading-tight",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 font-bold",children:[i.jsxs("span",{children:[e.isCurrent?i.jsx("span",{"aria-hidden":!0,children:"● "}):null,e.stepId]}),e.isTerminal?i.jsx(ht,{tool:"terminal",size:"xs",title:"Terminal step",decorative:!0}):null]}),i.jsx("div",{className:"text-on-surface-variant",children:e.role}),e.preferredTarget&&i.jsxs("div",{className:"text-[8px] text-on-surface-variant",children:["→ ",e.preferredTarget]}),n&&i.jsxs("div",{className:"text-[8px] text-on-surface-variant",children:[e.harness?i.jsxs("span",{"data-testid":`wf-node-harness-${e.stepId}`,children:["⌁ ",e.harness]}):null,e.host?i.jsxs("span",{"data-testid":`wf-node-host-${e.stepId}`,children:[e.harness?" · ":"","host: ",e.host]}):null,e.gate?i.jsxs("span",{"data-testid":`wf-node-gate-${e.stepId}`,children:[e.harness||e.host?" · ":"","⛨ gate: ",e.gate.target]}):null]})]})]})}const Fwe={workflowStep:qwe};function zV({topology:e,testId:t,currentStepId:n,visitedStepIds:s,takenEdgeKeys:r,heightClass:a}){const{nodes:o,edges:c}=C.useMemo(()=>{const d=$we(e),h=new Map;for(const b of e.nodes){const _=d.get(b.stepId)??0;h.has(_)||h.set(_,[]),h.get(_).push(b.stepId)}const m=new Map;for(const[b,_]of h)_.forEach((w,E)=>m.set(w,{x:E*Pwe,y:b*Dwe}));const f=new Set(s??[]),g=new Set(r??[]),x=e.nodes.map(b=>({id:b.stepId,type:"workflowStep",position:m.get(b.stepId)??{x:0,y:0},data:{stepId:b.stepId,role:b.role,preferredTarget:b.preferredTarget,isEntry:b.isEntry,isTerminal:b.isTerminal,harness:b.harness,host:b.host,gate:b.gate,isCurrent:n!=null&&b.stepId===n,wasVisited:f.has(b.stepId)}})),y=e.edges.map((b,_)=>{const w=b.routingType==="branch",E=g.has(`${b.fromStepId}→${b.toStepId}`),{sourceHandle:N,targetHandle:k}=Bwe(b.fromStepId,b.toStepId,d);return{id:`e-${_}`,source:b.fromStepId,target:b.toStepId,sourceHandle:N,targetHandle:k,label:w&&b.branchOn?`on ${b.branchOn}`:void 0,labelStyle:{fontFamily:"monospace",fontSize:9,fill:"#7a5c10"},labelBgStyle:{fill:"#f2ead6"},animated:E&&n!=null,style:{stroke:E?"#5c4a10":w?"#a8842c":"#8a8577",strokeWidth:E?2.5:1,strokeDasharray:w?"6 4":void 0}}});return{nodes:x,edges:y}},[e,n,s,r]);return i.jsx("div",{"data-testid":t??"workflow-topology-graph",className:`w-full ${a??"h-[400px]"} bg-background border border-outline-variant`,children:i.jsxs(gp,{nodes:o,edges:c,nodeTypes:Fwe,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[i.jsx(IR,{gap:20,size:.5,color:"#d4d0c8"}),i.jsx(xp,{showInteractive:!1})]})})}async function ET(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}`);return await t.json()}function HV(e){return Re({queryKey:["workflow","instances","all"],queryFn:()=>ET("/api/workflow/list"),staleTime:15e3})}function zwe(){return Re({queryKey:["workflow","specs"],queryFn:()=>ET("/api/workflow/specs"),staleTime:15e3})}function Hwe(e){return Re({queryKey:["workflow","trace",e],queryFn:()=>ET(`/api/workflow/${encodeURIComponent(e)}/trace`),enabled:!!e,staleTime:15e3})}function Zi(e){return e.status==="failed"?0:e.deadline.state!=="healthy"?1:e.status==="waiting"?2:e.status==="active"?3:4}function Uwe(e){return e.status==="failed"?{glyph:"▲",label:"FAILED",cls:"text-red-700"}:e.deadline.state!=="healthy"?{glyph:"▲",label:e.deadline.state.toUpperCase(),cls:"text-amber-700"}:e.status==="waiting"?{glyph:"◐",label:"WAITING",cls:"text-on-surface-variant"}:e.status==="active"?{glyph:"●",label:"ACTIVE",cls:"text-emerald-800"}:{glyph:"○",label:"COMPLETED",cls:"text-on-surface-variant"}}function Vwe(e){return`…${e.slice(-6)}`}function Wwe(e){const t=Math.max(0,Math.floor((Date.now()-Date.parse(e))/6e4));return t<60?`${t}m`:t<1440?`${Math.floor(t/60)}h`:`${Math.floor(t/1440)}d`}function Gwe(e){return e.currentStepId?`at ${e.currentStepId}`:e.status==="completed"?"closed":e.status==="failed"?"felled":"—"}function UV({instance:e}){const t=Uwe(e);return i.jsx("li",{children:i.jsxs(Ve,{to:"/workflow/instance/$instanceId",params:{instanceId:e.instanceId},"data-testid":`workflow-instance-row-${e.instanceId}`,className:"flex w-full items-center gap-2 px-2 py-1.5 text-left hover:bg-surface-variant/50",children:[i.jsx("span",{className:ce("font-mono text-[11px]",t.cls),"aria-hidden":!0,children:t.glyph}),i.jsx("span",{className:ce("font-mono text-[9px] uppercase w-32 shrink-0",t.cls),children:t.label}),i.jsx("span",{className:"font-mono text-[11px] text-on-surface",title:e.instanceId,children:Vwe(e.instanceId)}),i.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-on-surface",children:[Gwe(e),i.jsxs("span",{className:"text-on-surface-variant",children:[" · hop ",e.hopCount]}),e.resumeCount>0?i.jsxs("span",{className:"text-on-surface-variant",children:[" · resumed ",e.resumeCount,"×"]}):null]}),e.deadline.state!=="healthy"&&e.deadline.evidence?i.jsxs("span",{className:"hidden font-mono text-[10px] text-amber-800 md:inline truncate max-w-64",children:[e.deadline.evidence.ownerSession," · ",Math.floor(e.deadline.evidence.overdueBySeconds/60),"m over"]}):null,i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:Wwe(e.createdAt)}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant","aria-hidden":!0,children:"→"})]})})}function Kwe(e,t,n){return e.filter(s=>t?s.workflowName===t:!0).filter(s=>n?s.workflowVersion===n:!0).slice().sort((s,r)=>Zi(s)-Zi(r))}function Ywe({workflowName:e,workflowVersion:t,testId:n,quietWhenEmpty:s=!0}){const{data:r,isLoading:a}=HV(),o=Kwe(r??[],e,t);if(a||o.length===0)return s?null:i.jsx("p",{"data-testid":n?`${n}-empty`:void 0,className:"font-mono text-[11px] text-on-surface-variant",children:a?"Loading instances…":"0 instances — computed from /api/workflow/list"});const c=o.filter(h=>h.status==="active"||h.status==="waiting").length,d=o.filter(h=>Zi(h)<=1).length;return i.jsxs("div",{"data-testid":n??"workflow-instances-band",className:"space-y-2",children:[i.jsxs("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:["Instances",i.jsxs("span",{className:"ml-2 normal-case tracking-normal",children:[o.length," total · ",c," live",d>0?` · ${d} need attention`:""]})]}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:o.map(h=>i.jsx(UV,{instance:h},h.instanceId))})]})}function Qwe({entry:e}){const[t,n]=C.useState(!1),[s,r]=C.useState(null),[a,o]=C.useState(null),[c,d]=C.useState(null),[h,m]=C.useState(""),[f,g]=C.useState(null),x=mt(),y=Qf(),b=id(s),_=!e.sourceCwd,w=y.data??[],E=b.data??[],N=[...new Set(E.filter(T=>T.podId).map(T=>T.podNamespace??T.podId))],k=a?E.filter(T=>(T.podNamespace??T.podId)===a&&T.runtime===e.runtime&&!!T.agentRef&&!!T.profile):[],R=k.find(T=>T.logicalId===c),A=Ht({mutationFn:async()=>{var L,D,q,B,F,$,U,V,Y;if(!s||!a||!R||!h.trim())throw new Error("Missing required fields");const T={id:h.trim(),runtime:e.runtime,agent_ref:R.agentRef,profile:R.profile,cwd:e.sourceCwd,session_source:{mode:"agent_image",ref:{kind:"image_name",value:e.name}}};e.runtime==="codex"&&R.codexConfigProfile&&(T.codex_config_profile=R.codexConfigProfile);const I=await fetch(`/api/rigs/${encodeURIComponent(s)}/pods/${encodeURIComponent(a)}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({member:T})}),M=await I.json();if(!I.ok||!M.ok)throw new Error(M.message??((L=M.errors)==null?void 0:L.join("; "))??M.code??`HTTP ${I.status}`);const P=(q=(D=M.result)==null?void 0:D.node)==null?void 0:q.status;return P==="failed"||P==="attention_required"?{ok:!1,status:P,error:((F=(B=M.result)==null?void 0:B.node)==null?void 0:F.error)??`Launch ${P}`,logicalId:(U=($=M.result)==null?void 0:$.node)==null?void 0:U.logicalId}:{ok:!0,status:P??"launched",logicalId:((Y=(V=M.result)==null?void 0:V.node)==null?void 0:Y.logicalId)??h.trim()}},onSuccess:T=>{g(T),x.invalidateQueries({queryKey:["ps"]})},onError:T=>{g({ok:!1,error:T.message})}});return _?i.jsx("div",{"data-testid":"fork-now-disabled-no-cwd",className:"font-mono text-[9px] text-on-surface-variant",children:"Fork now unavailable: image lacks source cwd (pre-Finding-2 manifest)"}):i.jsxs(i.Fragment,{children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"fork-now-button",onClick:()=>{n(!0),g(null)},children:"Fork now"}),t&&i.jsxs("div",{"data-testid":"fork-now-modal",className:"border border-outline bg-surface-lowest px-3 py-3 space-y-3 mt-2",children:[i.jsxs("div",{className:"font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface",children:['Fork "',e.name,'" into a running rig']}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["Target rig",i.jsxs("select",{"data-testid":"fork-now-rig-select",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:s??"",onChange:T=>{r(T.target.value||null),o(null),d(null)},children:[i.jsx("option",{value:"",children:"Select rig…"}),w.map(T=>i.jsx("option",{value:T.rigId,children:T.name},T.rigId))]})]}),s&&i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["Target pod",i.jsxs("select",{"data-testid":"fork-now-pod-select",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:a??"",onChange:T=>{o(T.target.value||null),d(null)},children:[i.jsx("option",{value:"",children:"Select pod…"}),N.map(T=>i.jsx("option",{value:T,children:T},T))]})]}),a&&k.length===0&&i.jsxs("div",{"data-testid":"fork-now-no-sibling",className:"font-mono text-[9px] text-amber-600",children:["No ",e.runtime," member in this pod to clone identity from. Choose a different pod."]}),a&&k.length>0&&i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["Clone identity from (",e.runtime," member)",i.jsxs("select",{"data-testid":"fork-now-sibling-select",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:c??"",onChange:T=>d(T.target.value||null),children:[i.jsx("option",{value:"",children:"Select member…"}),k.map(T=>i.jsx("option",{value:T.logicalId,children:T.logicalId},T.logicalId))]})]}),c&&i.jsxs("label",{className:"block font-mono text-[9px] text-on-surface-variant",children:["New member ID (no dots)",i.jsx("input",{"data-testid":"fork-now-member-id",type:"text",className:"block w-full mt-0.5 border border-outline-variant bg-surface-lowest px-1 py-0.5 font-mono text-[10px]",value:h,onChange:T=>m(T.target.value.replace(/\./g,"")),placeholder:"e.g. forked-worker"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"fork-now-confirm",disabled:!c||!h.trim()||A.isPending,onClick:()=>A.mutate(),children:A.isPending?"Forking…":"Confirm fork"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"})]}),f&&i.jsx("div",{"data-testid":"fork-now-result",className:`font-mono text-[9px] ${f.ok?"text-green-700":"text-red-600"}`,children:f.ok?`Forked: ${f.logicalId??h} launched from image "${e.name}" (${f.status})`:`Fork failed: ${f.status?`[${f.status}] `:""}${f.error}`})]})]})}function Xwe(e){const t=[`Install and launch the "${e.name}" managed app using OpenRig.`,""];return e.summary&&t.push(`About: ${e.summary}`,""),t.push(`Source: ${e.sourcePath}`,"","Steps:",`1. Run: rig up ${e.name}`,`2. Monitor: rig ps --nodes --rig ${e.name}`,"3. Check env: rig env status <rig-name>"),t.join(`
587
587
  `)}function RT({sourcePath:e,sourceState:t}){return i.jsxs("div",{className:"font-mono text-[9px] text-on-surface-variant","data-testid":"library-provenance",children:["Source: ",e," · ",t]})}function Zwe({review:e}){const t=Pt(),n=e.profiles??[],s=e.resources??{skills:[]};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-agent",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Library — Agent Spec",title:e.name,description:e.description??"Agent spec from library.",actions:i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t({to:"/agents/validate"}),children:"Validate"})}),i.jsx(RT,{sourcePath:e.sourcePath,sourceState:e.sourceState}),i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:"AgentSpec",testId:"lib-agent-format"}),i.jsx(st,{label:"Version",value:e.version,testId:"lib-agent-version"}),i.jsx(st,{label:"Profiles",value:n.length,testId:"lib-agent-profiles"}),i.jsx(st,{label:"Skills",value:s.skills.length,testId:"lib-agent-skills"})]}),i.jsx(CT,{review:e,yaml:e.raw,testIdPrefix:"lib-agent",sourcePath:e.sourcePath})]})})}function Jwe({review:e}){const t=Pt(),[n,s]=C.useState(!1),{data:r=[]}=np("agent");new Map(r.map(h=>[h.name,h]));const a=e.pods??[],o=e.nodes??[],c=e.edges??[],d=h=>{if(!h.startsWith("local:"))return null;const m=h.slice(6),g=`${e.sourcePath.replace(/\/[^/]+$/,"")}/${m}`.split("/"),x=[];for(const b of g)b===".."?x.pop():b!=="."&&b!==""&&x.push(b);const y="/"+x.join("/");return r.find(b=>b.sourcePath.startsWith(y+"/"))??null};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-rig",className:"space-y-6",children:[i.jsx(wn,{eyebrow:e.services?"Library — Managed App":"Library — Rig Spec",title:e.name,description:e.summary??"Rig spec from library.",actions:i.jsxs("div",{className:"flex gap-2",children:[e.services&&i.jsx(Se,{variant:"outline",size:"sm","data-testid":"copy-setup-prompt",onClick:()=>void(async()=>{await ia(Xwe({name:e.name,summary:e.summary,sourcePath:e.sourcePath}))&&(s(!0),window.setTimeout(()=>s(!1),2e3))})(),children:n?"Copied":"Copy Setup Prompt"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t({to:"/import"}),children:"Import"})]})}),i.jsx(RT,{sourcePath:e.sourcePath,sourceState:e.sourceState}),i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:e.format==="pod_aware"?"Pod-Aware":"Legacy",testId:"lib-rig-format"}),e.services&&i.jsx(st,{label:"Type",value:"Agent-Managed App",testId:"lib-rig-type"}),e.services&&a.length>0&&(()=>{const h=a.find(m=>m.members.some(f=>f.id==="specialist"));return h?i.jsx(st,{label:"Specialist Agent",value:`${h.id}.specialist`,testId:"lib-rig-specialist"}):null})(),i.jsx(st,{label:e.format==="pod_aware"?"Pods":"Nodes",value:e.format==="pod_aware"?a.length:o.length,testId:"lib-rig-pods"}),i.jsx(st,{label:"Members",value:e.format==="pod_aware"?a.reduce((h,m)=>h+m.members.length,0):o.length,testId:"lib-rig-members"}),i.jsx(st,{label:"Edges",value:c.length+(e.format==="pod_aware"?a.reduce((h,m)=>{var f;return h+(((f=m.edges)==null?void 0:f.length)??0)},0):0),testId:"lib-rig-edges"})]}),i.jsx(kT,{review:e,yaml:e.raw,testIdPrefix:"lib",yamlTestId:"lib-rig-yaml",showEnvironmentTab:!!e.services,onMemberClick:(h,m)=>{const f=d(m.agentRef);f&&t({to:"/specs/library/$entryId",params:{entryId:f.id}})}})]})})}function e1e({entryId:e}){return e.startsWith("context-pack:")?i.jsx(s1e,{entryId:e}):e.startsWith("agent-image:")?i.jsx(i1e,{entryId:e}):i.jsx(t1e,{entryId:e})}function t1e({entryId:e}){const t=Pt(),{data:n,isLoading:s,error:r}=Rv(e);return s?i.jsx(ot,{children:i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading spec review..."})}):r||!n?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-error",className:"space-y-4",children:[i.jsx(wn,{eyebrow:"Library",title:"Spec Not Found",description:(r==null?void 0:r.message)??"Could not load spec."}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t({to:"/specs"}),children:"Back to Library"})]})}):n.kind==="agent"?i.jsx(Zwe,{review:n}):n.kind==="workflow"?i.jsx(n1e,{review:n}):i.jsx(Jwe,{review:n})}function n1e({review:e}){const t=Pt(),n=mt(),{data:s}=Qte(),[r,a]=C.useState(null),[o,c]=C.useState(!1),d=(s==null?void 0:s.specName)===e.name&&(s==null?void 0:s.specVersion)===e.version,h=async()=>{c(!0),a(null);try{await Xte(e.name,e.version),await n.invalidateQueries({queryKey:["spec-library","active-lens"]}),await n.invalidateQueries({queryKey:["slices"]})}catch(f){a(f.message)}finally{c(!1)}},m=async()=>{c(!0),a(null);try{await Zte(),await n.invalidateQueries({queryKey:["spec-library","active-lens"]}),await n.invalidateQueries({queryKey:["slices"]})}catch(f){a(f.message)}finally{c(!1)}};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-workflow",className:"space-y-6",children:[i.jsx(wn,{eyebrow:e.isBuiltIn?"Library — Workflow (Built-in)":"Library — Workflow",title:`${e.name} v${e.version}`,description:e.purpose??"Workflow spec from library.",actions:i.jsxs("div",{className:"flex gap-2 items-center",children:[d?i.jsx(Se,{variant:"outline",size:"sm","data-testid":"workflow-deactivate-lens",onClick:()=>void m(),disabled:o,children:o?"...":"Deactivate Lens"}):i.jsx(Se,{variant:"outline",size:"sm","data-testid":"workflow-activate-lens",onClick:()=>void h(),disabled:o,children:o?"...":"Activate as Lens"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t({to:"/specs"}),children:"Back"})]})}),i.jsx(RT,{sourcePath:e.sourcePath,sourceState:"library_item"}),r&&i.jsx("div",{"data-testid":"workflow-lens-error",className:"font-mono text-[10px] text-red-600",children:r}),i.jsxs(Do,{children:[i.jsx(st,{label:"Format",value:"WorkflowSpec",testId:"lib-wf-format"}),i.jsx(st,{label:"Version",value:e.version,testId:"lib-wf-version"}),i.jsx(st,{label:"Roles",value:e.rolesCount,testId:"lib-wf-roles"}),i.jsx(st,{label:"Steps",value:e.stepsCount,testId:"lib-wf-steps"}),i.jsx(st,{label:"Target Rig",value:e.targetRig??"(any)",testId:"lib-wf-target-rig"}),i.jsx(st,{label:"Source",value:e.isBuiltIn?"built-in":"user file",testId:"lib-wf-source"})]}),i.jsxs("div",{"data-testid":"workflow-terminal-rule",className:"flex items-center gap-2 border border-outline-variant/40 bg-surface-lowest/10 px-3 py-2 font-mono text-[10px] text-on-surface",children:[i.jsx(ht,{tool:"terminal",size:"xs",decorative:!0}),i.jsx("span",{className:"text-on-surface-variant uppercase tracking-[0.16em] text-[8px]",children:"Coordination Terminal Turn:"}),e.terminalTurnRule]}),i.jsx(zV,{topology:e.topology}),i.jsx(Ywe,{workflowName:e.name,workflowVersion:e.version,testId:"library-instances-band"}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Steps"}),i.jsx("div",{className:"space-y-1",children:e.steps.map(f=>i.jsxs("div",{"data-testid":`workflow-step-${f.stepId}`,className:"border border-outline-variant/40 bg-surface-lowest/5 px-3 py-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-mono text-[11px] font-bold text-on-surface",children:f.stepId}),i.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant",children:f.role})]}),f.objective&&i.jsx("div",{className:"mt-1 text-[10px] text-on-surface-variant leading-tight",children:f.objective}),f.allowedNextSteps.length>0&&i.jsxs("div",{className:"mt-1 font-mono text-[9px] text-on-surface-variant",children:["next: ",f.allowedNextSteps.map(g=>`${g.stepId} (${g.role})`).join(", ")]}),f.allowedExits.length>0&&i.jsxs("div",{className:"font-mono text-[9px] text-on-surface-variant",children:["exits: ",f.allowedExits.join(", ")]})]},f.stepId))})]})]})})}function s1e({entryId:e}){const t=Pt(),{data:n=[],isLoading:s,error:r}=UE(),a=n.find(d=>d.id===e)??null,{data:o,isLoading:c}=tne(a?a.relativePath:null);return s?i.jsx(ot,{children:i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading context pack…"})}):r||!a?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-error",className:"space-y-4",children:[i.jsx(wn,{eyebrow:"Library",title:"Context Pack Not Found",description:(r==null?void 0:r.message)??`No context pack with id ${e}.`}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t({to:"/specs"}),children:"Back to Library"})]})}):i.jsx(r1e,{entry:a,preview:o,previewLoading:c})}function r1e({entry:e,preview:t,previewLoading:n}){const s=Pt();return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-context-pack",className:"space-y-4",children:[i.jsx(wn,{eyebrow:`Library — Context Pack${e.sourceType==="builtin"?" (built-in)":""}`,title:e.name,description:e.purpose??"Operator-authored composable context bundle.",actions:i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>s({to:"/specs"}),children:"Back to Library"})}),i.jsxs(Do,{children:[i.jsx(st,{label:"Version",value:e.version,testId:"lib-pack-version"}),i.jsx(st,{label:"Files",value:e.files.length,testId:"lib-pack-files"}),i.jsx(st,{label:"Tokens (~)",value:String(e.derivedEstimatedTokens),testId:"lib-pack-tokens"}),i.jsx(st,{label:"Source",value:e.sourceType,testId:"lib-pack-source"})]}),i.jsxs("div",{"data-testid":"lib-pack-source-path",className:"font-mono text-[9px] text-on-surface-variant",children:["path: ",e.sourcePath]}),i.jsxs("section",{className:"border border-outline-variant/40 bg-surface-lowest/[0.08]",children:[i.jsx("header",{className:"border-b border-outline-variant bg-background px-3 py-2 font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface-variant",children:"Files"}),i.jsx("ul",{"data-testid":"lib-pack-file-list",className:"divide-y divide-outline-variant",children:e.files.map(r=>{const a=r.bytes===null;return i.jsx("li",{"data-testid":`lib-pack-file-${r.path}`,"data-missing":a?"true":"false",className:`font-mono text-[10px] ${a?"text-red-700":"text-on-surface"}`,children:i.jsxs(ac,{data:{path:r.path,absolutePath:r.absolutePath},testId:`lib-pack-file-trigger-${r.path}`,className:"block w-full px-3 py-2 text-left hover:bg-surface-low/60 transition-colors",children:[i.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[i.jsx("span",{className:"font-bold truncate underline decoration-dotted decoration-outline",children:r.path}),i.jsxs("span",{className:"font-mono text-[8px] text-on-surface-variant shrink-0",children:["role: ",r.role,a?" · MISSING":` · ${r.bytes}B · ~${r.estimatedTokens} tokens`]})]}),r.summary&&i.jsx("div",{className:"mt-0.5 text-on-surface-variant text-[9px]",children:r.summary})]})},r.path)})})]}),i.jsxs("section",{className:"border border-outline-variant/40 bg-surface-lowest/[0.08]",children:[i.jsx("header",{className:"border-b border-outline-variant bg-background px-3 py-2 font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface-variant",children:"Bundle preview"}),n&&i.jsx("div",{className:"px-3 py-2 font-mono text-[9px] text-on-surface-variant",children:"Loading bundle…"}),t&&i.jsxs(i.Fragment,{children:[t.missingFiles.length>0&&i.jsxs("div",{"data-testid":"lib-pack-missing-warning",className:"px-3 py-2 font-mono text-[9px] text-red-700 border-b border-outline-variant",children:["Warning: ",t.missingFiles.length," file",t.missingFiles.length===1?"":"s"," referenced by manifest but missing on disk."]}),i.jsx("pre",{"data-testid":"lib-pack-bundle-text",className:"font-mono text-[9px] text-on-surface bg-background px-3 py-2 max-h-96 overflow-y-auto whitespace-pre-wrap",children:t.bundleText})]})]})]})})}function i1e({entryId:e}){const t=Pt(),{data:n=[],isLoading:s,error:r}=VE(),a=n.find(d=>d.id===e)??null,{data:o,isLoading:c}=rne(a?e:null);return s?i.jsx(ot,{children:i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading agent image…"})}):r||!a?i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-error",className:"space-y-4",children:[i.jsx(wn,{eyebrow:"Library",title:"Agent Image Not Found",description:(r==null?void 0:r.message)??`No agent image with id ${e}.`}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t({to:"/specs"}),children:"Back to Library"})]})}):i.jsx(a1e,{entry:a,preview:o,previewLoading:c})}function a1e({entry:e,preview:t,previewLoading:n}){const s=Pt(),r=ine(),[a,o]=C.useState(!1),[c,d]=C.useState(null),h=async()=>{if(!(t!=null&&t.starterSnippet))return;await ia(t.starterSnippet)&&(o(!0),window.setTimeout(()=>o(!1),2e3))},m=async()=>{d(null);try{await r.mutateAsync({id:e.id,pin:!e.pinned})}catch(f){d(f.message)}};return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"library-review-agent-image",className:"space-y-4",children:[i.jsx(wn,{eyebrow:`Library — Agent Image${e.sourceType==="builtin"?" (built-in)":""}`,title:`${e.name} v${e.version}`,description:e.notes??`Snapshot of ${e.sourceSeat}.`,actions:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"agent-image-pin-toggle",onClick:()=>void m(),disabled:r.isPending,children:e.pinned?"Unpin":"Pin"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>s({to:"/specs"}),children:"Back to Library"})]})}),i.jsxs(Do,{children:[i.jsx(st,{label:"Runtime",value:i.jsx(Cs,{runtime:e.runtime,size:"sm",compact:!0,variant:"inline"}),testId:"lib-image-runtime"}),i.jsx(st,{label:"Forks",value:String(e.stats.forkCount),testId:"lib-image-forks"}),i.jsx(st,{label:"Tokens (~)",value:String(e.derivedEstimatedTokens),testId:"lib-image-tokens"}),i.jsx(st,{label:"Size",value:`${e.stats.estimatedSizeBytes}B`,testId:"lib-image-size"})]}),i.jsxs("div",{"data-testid":"lib-image-source",className:"font-mono text-[9px] text-on-surface-variant space-y-0.5",children:[i.jsxs("div",{children:["source seat: ",e.sourceSeat]}),i.jsxs("div",{"data-testid":"lib-image-source-cwd",children:["source cwd: ",e.sourceCwd??"(unknown — pre-Finding-2 manifest)"]}),i.jsxs("div",{children:["created: ",e.createdAt]}),i.jsxs("div",{children:["last used: ",e.stats.lastUsedAt??"never"]}),i.jsxs("div",{children:["path: ",e.sourcePath]}),i.jsxs("div",{"data-testid":"lib-image-pinned",className:e.pinned?"text-amber-700 font-bold":"",children:["pinned: ",String(e.pinned)]})]}),e.lineage.length>0&&i.jsxs("section",{"data-testid":"lib-image-lineage",className:"border border-outline-variant/40 bg-surface-lowest/[0.08]",children:[i.jsx("header",{className:"border-b border-outline-variant bg-background px-3 py-2 font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface-variant",children:"Lineage"}),i.jsxs("div",{className:"px-3 py-2 font-mono text-[10px] text-on-surface",children:[e.lineage.join(" → ")," → ",i.jsx("span",{className:"font-bold",children:e.name})]})]}),i.jsx(Qwe,{entry:e}),i.jsxs("section",{"data-testid":"lib-image-starter-snippet",className:"border border-outline bg-surface-lowest px-3 py-3 space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface",children:"Use as starter"}),i.jsx(Se,{variant:"outline",size:"sm","data-testid":"agent-image-copy-snippet",onClick:()=>void h(),disabled:!(t!=null&&t.starterSnippet),children:a?"Copied":"Copy snippet"})]}),i.jsx("div",{className:"font-mono text-[9px] text-on-surface-variant",children:"Paste into your agent.yaml's session_source. The instantiator resolves the image via the daemon AgentImageLibraryService at startup time."}),n&&i.jsx("div",{className:"font-mono text-[9px] text-on-surface-variant",children:"Loading snippet…"}),(t==null?void 0:t.starterSnippet)&&i.jsx("pre",{"data-testid":"lib-image-snippet-text",className:"font-mono text-[10px] bg-background border border-outline-variant px-2 py-1 whitespace-pre-wrap",children:t.starterSnippet})]}),c&&i.jsx("div",{"data-testid":"lib-image-pin-error",className:"font-mono text-[9px] text-red-600",children:c}),e.files.length>0&&i.jsxs("section",{className:"border border-outline-variant/40 bg-surface-lowest/[0.08]",children:[i.jsx("header",{className:"border-b border-outline-variant bg-background px-3 py-2 font-mono text-[10px] uppercase tracking-[0.10em] text-on-surface-variant",children:"Supplementary files"}),i.jsx("ul",{className:"divide-y divide-outline-variant",children:e.files.map(f=>i.jsx("li",{className:"font-mono text-[10px] text-on-surface","data-testid":`lib-image-file-${f.path}`,children:i.jsxs(ac,{data:{path:f.path,absolutePath:f.absolutePath},testId:`lib-image-file-trigger-${f.path}`,className:"block w-full px-3 py-2 text-left hover:bg-surface-low/60 transition-colors",children:[i.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[i.jsx("span",{className:"font-bold truncate underline decoration-dotted decoration-outline",children:f.path}),i.jsxs("span",{className:"font-mono text-[8px] text-on-surface-variant shrink-0",children:["role: ",f.role,f.bytes===null?" · MISSING":` · ${f.bytes}B`]})]}),f.summary&&i.jsx("div",{className:"mt-0.5 text-on-surface-variant text-[9px]",children:f.summary})]})},f.path))})]})]})})}async function o1e(e,t,n){const s=await fetch(ls(`/api/rigs/${encodeURIComponent(e)}/nodes/${encodeURIComponent(t)}`,n));if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}function l1e(e,t){const n=At();return Re({queryKey:["rig",e,"nodes",t,n],queryFn:()=>o1e(e,t,n),enabled:!!e&&!!t,refetchInterval:3e4,placeholderData:fi})}function c1e({pluginIds:e}){const{data:t=[]}=Av();if(e.length===0)return i.jsx("div",{className:"px-3 py-4",children:i.jsx(Ae,{label:"NO PLUGINS",description:"This agent's profile does not declare any plugins.",variant:"card",testId:"agent-plugins-empty"})});const n=new Map;for(const s of t)n.set(s.id,s);return i.jsx("ul",{"data-testid":"agent-plugins-list",className:"flex flex-col gap-2",children:e.map(s=>{const r=n.get(s);return i.jsx("li",{children:r?i.jsx(u1e,{entry:r}):i.jsx(d1e,{pluginId:s})},s)})})}function u1e({entry:e}){return i.jsxs(Ve,{to:"/plugins/$pluginId",params:{pluginId:e.id},"data-testid":`agent-plugin-chip-${e.id}`,className:"flex items-center justify-between gap-3 border border-outline-variant bg-surface-lowest/30 px-3 py-2 font-mono text-[11px] hover:bg-surface-low/50",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${e.name} plugin`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:e.name}),i.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:`v${e.version}`})]}),i.jsxs("span",{className:"flex shrink-0 items-center gap-2 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:[e.runtimes.map(t=>i.jsx("span",{className:"inline-block border border-outline-variant px-1.5 py-0.5 font-mono",children:t},t)),i.jsx("span",{title:e.path,children:e.sourceLabel})]})]})}function d1e({pluginId:e}){return i.jsxs(Ve,{to:"/plugins/$pluginId",params:{pluginId:e},"data-testid":`agent-plugin-chip-${e}`,className:"flex items-center justify-between gap-3 border border-dashed border-outline-variant bg-surface-lowest/20 px-3 py-2 font-mono text-[11px] hover:bg-surface-low/50",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${e} plugin (unresolved)`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:e})]}),i.jsx("span",{"data-testid":`agent-plugin-unresolved-${e}`,className:"shrink-0 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:"not discovered"})]})}function h1e(e){return e==null?i.jsx("span",{className:"text-on-surface-variant",children:"—"}):typeof e=="string"&&e.trim()===""?i.jsx("span",{className:"text-on-surface-variant",children:"—"}):e}function f1e(e,t){return e==="running"?"active":IE(e,t)}function p1e(e){return e==="active"?"active":e==="needs_input"?"needs input":e}function m1e({data:e,activityVisual:t}){var E,N,k;const n=AE(e.agentActivity)&&(t==null?void 0:t.state)!=="needs_input"&&(t==null?void 0:t.state)!=="blocked"?null:t,{state:s,source:r}=Xf(e.agentActivity,e.terminalActive),a=(n==null?void 0:n.state)??s,o=n?p1e(n.state):f1e(s,e.agentActivity),c=n?n.state==="active":s==="running",d=!!(n!=null&&n.recent),h=d?null:ME(e.agentActivity),m=!d&&r!=="hook"&&r!=="none"?" (activity-grade)":"",f=((E=e.contextUsage)==null?void 0:E.availability)==="known"&&typeof e.contextUsage.usedPercentage=="number"?`${e.contextUsage.usedPercentage}%`:null,g=Eo((N=e.contextUsage)==null?void 0:N.totalInputTokens,(k=e.contextUsage)==null?void 0:k.totalOutputTokens),x=wp(g),y=e.resolvedSpecName&&e.resolvedSpecVersion?`${e.resolvedSpecName}@${e.resolvedSpecVersion}`:e.resolvedSpecName??null,b=i.jsxs("span",{"data-testid":"seat-overview-activity-state","data-activity-state":a,"data-activity-source":d?"ring":r,className:c?"topology-table-active-shimmer text-emerald-600":"text-on-surface",children:[o,h?` ${h.label}`:"",m]}),_=[{key:"runtime",label:"runtime",value:e.runtime?i.jsx(Cs,{runtime:e.runtime,model:e.model,size:"xs",compact:!0,variant:"inline",className:"max-w-full"}):null},{key:"model",label:"model",value:e.model,mono:!0},{key:"profile",label:"profile",value:e.profile,mono:!0},{key:"spec",label:"spec",value:y,mono:!0},{key:"activity",label:"activity",value:b},{key:"context-percent",label:"context %",value:f,mono:!0},{key:"total-tokens",label:"tokens",value:x,mono:!0}],w=_.length-1;return i.jsx("section",{"data-testid":"seat-overview-table",className:"border border-outline-variant bg-surface-lowest/30",children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-left",children:[i.jsx("thead",{children:i.jsx("tr",{"data-testid":"seat-overview-header-row",className:"border-b border-outline-variant/55 bg-background/30",children:_.map((R,A)=>i.jsx("th",{scope:"col","data-testid":`seat-overview-header-${R.key}`,className:`px-3 py-1.5 text-left font-mono text-[10px] font-normal lowercase tracking-[0.04em] text-on-surface-variant ${A<w?"border-r border-outline-variant/55":""}`,children:R.label},R.key))})}),i.jsx("tbody",{children:i.jsx("tr",{"data-testid":"seat-overview-data-row","data-row-shape":"data",children:_.map((R,A)=>i.jsx("td",{"data-testid":`seat-overview-cell-${R.key}`,className:`min-w-0 px-3 py-1.5 align-middle ${R.mono?"font-mono text-[11px]":"text-[11px]"} text-on-surface ${A<w?"border-r border-outline-variant/55":""}`,children:i.jsx("div",{className:"truncate",children:h1e(R.value)})},R.key))})})]})})})}function g1e(e){return e==null?i.jsx("span",{className:"text-on-surface-variant",children:"—"}):typeof e=="string"&&e.trim()===""?i.jsx("span",{className:"text-on-surface-variant",children:"—"}):e}function x1e({data:e}){var s;const t=((s=e.currentQitems)==null?void 0:s[0])??null,n=t?i.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[i.jsx("span",{className:"shrink-0 font-mono text-[10px] text-on-surface-variant",children:t.qitemId}),i.jsx("span",{className:"min-w-0 truncate text-[11px] text-on-surface",children:t.bodyExcerpt})]}):null;return i.jsx("section",{"data-testid":"seat-overview-secondary",className:"border border-outline-variant bg-surface-lowest/30",children:i.jsxs("dl",{className:"divide-y divide-outline-variant/55",children:[i.jsx(r8,{fieldKey:"cwd",label:"cwd",value:e.cwd,mono:!0,titleAttr:e.cwd??void 0}),i.jsx(r8,{fieldKey:"current-work",label:"current work",value:n})]})})}function r8({fieldKey:e,label:t,value:n,mono:s,titleAttr:r}){return i.jsxs("div",{"data-testid":`seat-overview-secondary-row-${e}`,className:"flex min-w-0 items-baseline gap-3 px-3 py-1.5",title:r,children:[i.jsx("dt",{className:"shrink-0 font-mono text-[10px] lowercase tracking-[0.04em] text-on-surface-variant",children:t}),i.jsx("dd",{"data-testid":`seat-overview-secondary-cell-${e}`,className:`min-w-0 flex-1 truncate ${s?"font-mono text-[11px]":"text-[11px]"} text-on-surface`,children:g1e(n)})]})}function v1e(e){return e.startupStatus==="failed"?"Startup failed":e.startupStatus==="attention_required"?"Attention required":e.latestError?"Error":null}function y1e(e){return e.startupStatus==="failed"||e.latestError&&e.startupStatus!=="attention_required"?"destructive":"default"}function b1e({data:e}){const t=v1e(e);if(!t)return null;const n=!!e.latestError,s=!!e.recoveryGuidance;return i.jsxs(Xn,{"data-testid":"seat-notification-banner","data-startup-status":e.startupStatus??"unknown",variant:y1e(e),children:[i.jsx(K7,{"data-testid":"seat-notification-headline",className:"font-mono text-[11px] uppercase tracking-[0.08em]",children:t}),n?i.jsx(qn,{"data-testid":"seat-notification-error",className:"font-mono text-[10px]",children:e.latestError}):null,s&&e.recoveryGuidance?i.jsx(qn,{"data-testid":"seat-notification-guidance",className:"mt-1 font-mono text-[10px] text-on-surface",children:e.recoveryGuidance.summary}):null]})}function _1e(e){switch(e){case"resumed":return"text-success";case"rebuilt":return"text-success";case"fresh":return"text-foreground-muted";case"failed":return"text-destructive";case"checkpoint_written":return"text-success";case"fresh_no_checkpoint":return"text-foreground-muted";default:return"text-foreground-muted"}}const Ro="border border-outline-variant bg-surface-lowest/30 p-3";function w1e(e){switch(e){case"ready":return"text-green-600";case"pending":return"text-amber-600";case"attention_required":return"text-orange-600";case"failed":return"text-red-600";default:return"text-on-surface-variant"}}function S1e(e){switch(e){case"attention_required":return"attention required";default:return e??"stopped"}}function j1e(e){if(!e)return null;const t=e.match(/^local:agents\/([^/]+)$/);return(t==null?void 0:t[1])??null}function Er({label:e,value:t}){return t==null||t===""?null:i.jsxs("div",{className:"flex justify-between gap-3 font-mono text-[10px]",children:[i.jsx("span",{className:"text-on-surface-variant",children:e}),i.jsx("span",{className:"truncate text-right text-on-surface",children:t})]})}function N1e({data:e}){const t=j1e(e.agentRef),{data:n=[],isLoading:s}=np("agent"),r=t?n.filter(d=>d.name===t):[],a=r.length===1?r[0].id:null,{data:o,isLoading:c}=Rv(a);return i.jsxs("div",{"data-testid":"live-agent-spec-section",className:"space-y-4",children:[e.compactSpec.name&&i.jsxs("section",{"data-testid":"detail-compact-spec",className:Ro,children:[i.jsx("div",{className:"mb-2 font-mono text-[8px] uppercase tracking-wider text-on-surface-variant",children:"Resolved Agent Spec"}),i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(Er,{label:"Spec",value:e.compactSpec.name}),i.jsx(Er,{label:"Version",value:e.compactSpec.version}),i.jsx(Er,{label:"Profile",value:e.compactSpec.profile}),i.jsx(Er,{label:"Skills",value:e.compactSpec.skillCount}),i.jsx(Er,{label:"Guidance",value:e.compactSpec.guidanceCount})]})]}),t?s||c?i.jsx("div",{className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading agent spec..."}):r.length===0?i.jsx("div",{"data-testid":"agent-spec-unavailable",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"No agent spec available"}):r.length>1?i.jsxs("div",{"data-testid":"agent-spec-ambiguous",className:"p-4 font-mono text-[10px] text-amber-600",children:["Agent spec ambiguous (",r.length,' matches for "',t,'")']}):!o||o.kind!=="agent"?i.jsx("div",{"data-testid":"agent-spec-unavailable",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"No agent spec available"}):i.jsxs(i.Fragment,{children:[i.jsx(CT,{review:o,yaml:o.raw,testIdPrefix:"live-agent",sourcePath:o.sourcePath}),i.jsxs("section",{"data-testid":"live-agent-plugins-section",className:"border border-outline-variant bg-surface-lowest/30 p-3",children:[i.jsx("div",{className:"mb-2 font-mono text-[8px] uppercase tracking-wider text-on-surface-variant",children:"Plugins"}),i.jsx(c1e,{pluginIds:k1e(o)})]})]}):i.jsx("div",{"data-testid":"agent-spec-unavailable",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"No agent spec available"})]})}function k1e(e){if(!e||typeof e!="object")return[];const t=e.resources;if(!t||typeof t!="object")return[];const n=t.plugins;if(!Array.isArray(n))return[];const s=[];for(const r of n)r&&typeof r=="object"&&typeof r.id=="string"?s.push(r.id):typeof r=="string"&&s.push(r);return s}function C1e({rigId:e,logicalId:t,data:n}){const s=At()!==at,r=async()=>{n.tmuxAttachCommand&&await ia(n.tmuxAttachCommand)},a=async()=>{try{await YR({rigId:e,logicalId:t})}catch{}},o=async()=>{n.resumeCommand&&await ia(n.resumeCommand)};return s?i.jsx("div",{"data-testid":"live-node-actions-remote-readonly","data-remote-readonly":"true",className:"font-mono text-[9px] uppercase tracking-wide text-on-surface-variant",children:"read-only — remote host"}):i.jsxs("div",{"data-testid":"live-node-actions",className:"flex flex-wrap gap-2",children:[i.jsxs("button",{onClick:a,"data-testid":"detail-cmux-open",className:"inline-flex min-h-11 items-center gap-1.5 px-3 py-2 border border-outline-variant bg-surface-lowest/30 font-mono text-[10px] uppercase tracking-wide text-on-surface hover:bg-surface-low/60",children:[i.jsx(ht,{tool:"cmux",size:"sm"}),"Open CMUX"]}),n.tmuxAttachCommand&&i.jsxs("button",{onClick:r,"data-testid":"detail-copy-attach",className:"inline-flex min-h-11 items-center gap-1.5 px-3 py-2 border border-outline-variant bg-surface-lowest/30 font-mono text-[10px] uppercase tracking-wide text-on-surface hover:bg-surface-low/60",children:[i.jsx(ht,{tool:"tmux",size:"sm"}),"Copy tmux attach"]}),n.resumeCommand&&i.jsxs("button",{onClick:o,"data-testid":"detail-copy-resume",className:"inline-flex min-h-11 items-center gap-1.5 px-3 py-2 border border-outline-variant bg-surface-lowest/30 font-mono text-[10px] uppercase tracking-wide text-on-surface hover:bg-surface-low/60",children:[i.jsx(PZ,{"aria-hidden":"true",className:"h-4 w-4 shrink-0",strokeWidth:1.5}),"Copy resume command"]})]})}function E1e({data:e}){const t=e.startupStatus==="failed"||e.startupStatus==="attention_required"||!!e.latestError;return i.jsxs("section",{"data-testid":"live-node-status",className:"grid gap-2 border border-outline-variant bg-surface-lowest/30 p-3 sm:grid-cols-2",children:[i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"font-mono text-[8px] uppercase tracking-wider text-on-surface-variant",children:"Startup"}),i.jsx("span",{className:w1e(e.startupStatus),"data-testid":"detail-startup-status",children:S1e(e.startupStatus)})]}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"font-mono text-[8px] uppercase tracking-wider text-on-surface-variant",children:"Restore"}),i.jsx("span",{className:`font-mono text-xs font-bold ${_1e(e.restoreOutcome)}`,"data-testid":"detail-restore-outcome",children:e.restoreOutcome})]}),t&&i.jsxs("div",{className:`sm:col-span-2 mt-1 p-2 border ${e.startupStatus==="attention_required"?"bg-orange-50 border-orange-200":"bg-red-50 border-red-200"}`,"data-testid":"detail-failure-banner",children:[i.jsx("div",{className:`font-mono text-[9px] font-bold mb-1 ${e.startupStatus==="attention_required"?"text-orange-700":"text-red-700"}`,children:e.startupStatus==="attention_required"?"Attention Required":e.startupStatus==="failed"?"Startup Failed":"Error"}),e.latestError&&i.jsx("div",{className:`font-mono text-[9px] mb-1 ${e.startupStatus==="attention_required"?"text-orange-700":"text-red-600"}`,children:e.latestError}),i.jsx("div",{className:"font-mono text-[8px] text-on-surface-variant",children:e.startupStatus==="attention_required"?`Use rig capture ${e.canonicalSessionName??"<session>"} to inspect the prompt, then rig send ${e.canonicalSessionName??"<session>"} to clear it.`:e.startupStatus==="failed"?"Check logs with: rig ps --nodes --rig <name>, or restart with: rig up":"Try: rig restore <snapshotId>"}),e.recoveryGuidance&&i.jsxs("div",{className:"mt-2 border-t border-outline-variant pt-2","data-testid":"detail-recovery-guidance",children:[i.jsx("div",{className:"font-mono text-[8px] font-bold text-on-surface mb-1",children:"Recovery"}),i.jsx("div",{className:"font-mono text-[8px] text-on-surface-variant mb-1",children:e.recoveryGuidance.summary}),i.jsx("div",{className:"space-y-0.5 mb-1",children:e.recoveryGuidance.commands.map((n,s)=>i.jsx("code",{className:"font-mono text-[8px] text-on-surface bg-surface-low px-1 py-0.5 block",children:n},`${n}-${s}`))}),i.jsx("div",{className:"space-y-0.5",children:e.recoveryGuidance.notes.map((n,s)=>i.jsx("div",{className:"font-mono text-[8px] text-on-surface-variant",children:n},`${n}-${s}`))})]})]})]})}function R1e({data:e}){return!e.recentEvents||e.recentEvents.length===0?null:i.jsxs("section",{"data-testid":"live-node-recent-events",className:Ro,children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-wider text-on-surface-variant mb-2",children:"Recent Events"}),i.jsx("div",{className:"space-y-0.5",children:e.recentEvents.slice(0,10).map((t,n)=>i.jsxs("div",{className:"font-mono text-[9px] flex justify-between gap-3",children:[i.jsx("span",{className:"text-on-surface truncate",children:t.type}),i.jsx("span",{className:"text-on-surface-variant ml-2 shrink-0",children:t.createdAt})]},`${t.type}-${n}`))})]})}function T1e({data:e}){const{outgoing:t,incoming:n}=e.edges;return t.length===0&&n.length===0?null:i.jsxs("section",{"data-testid":"detail-edges",className:Ro,children:[i.jsx("div",{className:"font-mono text-[8px] text-on-surface-variant uppercase tracking-wider mb-2",children:"Edges"}),i.jsxs("div",{className:"space-y-0.5 font-mono text-[10px]",children:[t.map((s,r)=>{var a;return i.jsxs("div",{className:"flex gap-1",children:[i.jsx("span",{className:"text-on-surface-variant",children:"->"}),i.jsx("span",{className:"text-on-surface-variant",children:s.kind}),i.jsx("span",{className:"text-on-surface",children:((a=s.to)==null?void 0:a.logicalId)??"?"})]},`out-${r}`)}),n.map((s,r)=>{var a;return i.jsxs("div",{className:"flex gap-1",children:[i.jsx("span",{className:"text-on-surface-variant",children:"<-"}),i.jsx("span",{className:"text-on-surface-variant",children:s.kind}),i.jsx("span",{className:"text-on-surface",children:((a=s.from)==null?void 0:a.logicalId)??"?"})]},`in-${r}`)})]})]})}function A1e({data:e}){return e.peers.length===0?null:i.jsxs("section",{"data-testid":"detail-peers",className:Ro,children:[i.jsx("div",{className:"font-mono text-[8px] text-on-surface-variant uppercase tracking-wider mb-2",children:"Peers"}),i.jsx("div",{className:"space-y-1 font-mono text-[10px]",children:e.peers.map(t=>i.jsxs("div",{className:"space-y-0",children:[i.jsxs("div",{className:"flex justify-between gap-3",children:[i.jsx("span",{className:"text-on-surface",children:t.logicalId}),i.jsx("span",{className:"text-on-surface-variant",children:t.runtime??"-"})]}),t.canonicalSessionName&&i.jsx("div",{className:"text-[9px] text-on-surface-variant truncate",children:t.canonicalSessionName})]},t.logicalId))})]})}function I1e({data:e}){var n,s,r;const t=e.contextUsage;return i.jsxs("section",{"data-testid":"detail-context-usage",className:Ro,children:[i.jsx("div",{className:"font-mono text-[8px] text-on-surface-variant uppercase tracking-wider mb-2",children:"Context"}),(t==null?void 0:t.availability)==="known"?i.jsxs("div",{className:"space-y-0.5 font-mono text-[10px]",children:[i.jsx(Er,{label:"Used",value:t.usedPercentage!=null?`${t.usedPercentage}%`:null}),i.jsx(Er,{label:"Remaining",value:t.remainingPercentage!=null?`${t.remainingPercentage}%`:null}),i.jsx(Er,{label:"Window",value:(n=t.contextWindowSize)==null?void 0:n.toLocaleString()}),i.jsx(Er,{label:"Input tokens",value:(s=t.totalInputTokens)==null?void 0:s.toLocaleString()}),i.jsx(Er,{label:"Output tokens",value:(r=t.totalOutputTokens)==null?void 0:r.toLocaleString()}),i.jsx(Er,{label:"Sampled",value:t.sampledAt}),t.fresh===!1&&i.jsx("div",{className:"font-mono text-[9px] text-amber-600 mt-1",children:"Stale sample"})]}):i.jsxs("div",{className:"font-mono text-[10px] text-on-surface-variant",children:["unknown",t!=null&&t.reason?` (${t.reason})`:""]})]})}function M1e({data:e,activityVisual:t}){return i.jsxs("div",{"data-testid":"live-overview-section",className:"space-y-4",children:[i.jsx(b1e,{data:e}),i.jsx(m1e,{data:e,activityVisual:t}),i.jsx(x1e,{data:e}),i.jsx(O1e,{data:e}),i.jsx(R1e,{data:e})]})}function L1e({rigId:e,logicalId:t,data:n,isAgent:s}){return i.jsxs("div",{"data-testid":"live-details-section",className:"space-y-4",children:[i.jsx(P1e,{rigId:e,logicalId:t,data:n}),s?i.jsx(N1e,{data:n}):null,i.jsx(T1e,{data:n}),i.jsx(A1e,{data:n}),i.jsx(I1e,{data:n}),i.jsx(D1e,{data:n})]})}function O1e({data:e}){return At()!==at?i.jsx("div",{"data-testid":"node-detail-terminal-remote-gated",className:"font-mono text-[10px] text-on-surface-variant p-4",children:"Terminal not available for remote hosts — terminal streams are this host's local sessions. Viewing a remote host is read-only."}):e.canonicalSessionName?i.jsx("div",{"data-testid":"live-terminal-shell",className:"bg-stone-950/65 text-stone-50 backdrop-blur-sm h-[500px]",children:i.jsx(Oo,{sessionName:e.canonicalSessionName,terminalKey:`node-detail:${e.canonicalSessionName}`,testIdPrefix:"node-detail-terminal",fit:"contain"})}):i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant p-4",children:"No canonical session name; terminal preview unavailable."})}function P1e({rigId:e,logicalId:t,data:n}){return i.jsxs("div",{"data-testid":"live-startup-section",className:"space-y-4",children:[i.jsx(E1e,{data:n}),n.infrastructureStartupCommand&&i.jsxs("section",{"data-testid":"live-node-infra-startup",className:Ro,children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-wider text-on-surface-variant mb-2",children:"Startup Command"}),i.jsx("code",{className:"font-mono text-[9px] text-on-surface bg-surface-low px-2 py-1 block",children:n.infrastructureStartupCommand})]}),n.startupActions.length>0&&i.jsxs("section",{"data-testid":"live-startup-actions",className:Ro,children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-wider text-on-surface-variant mb-2",children:"Startup Actions"}),i.jsx("div",{className:"space-y-1",children:n.startupActions.map((s,r)=>i.jsxs("div",{className:"font-mono text-[10px] text-on-surface",children:[i.jsxs("span",{className:"text-on-surface-variant",children:[s.type,":"]})," ",s.value]},`${s.type}-${s.value}-${r}`))})]}),n.startupFiles.length>0?i.jsxs("section",{className:"border border-outline-variant bg-surface-lowest/30",children:[i.jsx("div",{className:"px-3 py-2 border-b border-outline-variant font-mono text-xs font-bold",children:"Startup Files"}),i.jsx("ul",{className:"divide-y divide-outline-variant",children:n.startupFiles.map((s,r)=>i.jsx("li",{"data-testid":`live-startup-file-${s.path}`,children:i.jsxs(ac,{data:{path:s.path,absolutePath:s.absolutePath},testId:`live-startup-file-trigger-${s.path}`,className:"block w-full px-3 py-2 text-left hover:bg-surface-low/60 transition-colors font-mono text-[10px]",children:[i.jsx("span",{className:"font-bold underline decoration-dotted decoration-outline",children:s.path}),i.jsxs("span",{className:"text-on-surface-variant ml-2",children:["(",s.deliveryHint,")"]}),s.required&&i.jsx("span",{className:"text-red-500 text-[8px] ml-1",children:"REQUIRED"})]})},`${s.path}-${r}`))})]}):i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant p-4",children:"No startup files declared"})]})}function D1e({data:e}){return e.transcript.enabled?i.jsx("div",{"data-testid":"live-transcript-section",className:"space-y-4",children:i.jsxs("section",{"data-testid":"detail-transcript",className:Ro,children:[i.jsx("div",{className:"font-mono text-xs font-bold mb-2",children:"Transcript"}),i.jsx("div",{className:"font-mono text-[10px] text-on-surface",children:e.transcript.path??"enabled"}),e.transcript.tailCommand&&i.jsx("button",{type:"button",onClick:()=>ia(e.transcript.tailCommand),className:"mt-2 w-full border border-outline-variant bg-surface-lowest/40 px-2 py-1 text-left font-mono text-[8px] uppercase text-on-surface hover:bg-surface-low",children:"Copy tail command"})]})}):i.jsx("div",{"data-testid":"live-transcript-section",className:"font-mono text-[10px] text-on-surface-variant p-4",children:"Transcript capture not enabled"})}function $1e({tabs:e,activeTab:t,onSelect:n}){return i.jsx("div",{className:"flex gap-1 border-b border-outline-variant",role:"tablist","data-testid":"live-node-tabs",children:e.map(s=>i.jsx("button",{role:"tab","aria-selected":t===s,"data-testid":`live-tab-${s}`,onClick:()=>n(s),className:`min-h-11 px-3 py-2 font-mono text-[10px] uppercase tracking-wider transition-colors ${t===s?"border-b-2 border-on-surface text-on-surface font-bold -mb-px":"text-on-surface-variant hover:text-on-surface"}`,children:s.replace("-"," ")},s))})}function VV({rigId:e,logicalId:t}){const{data:n,isLoading:s,error:r}=l1e(e,t),a=C.useMemo(()=>Ry(n?[{nodeId:`${n.rigId}::${n.logicalId}`,rigId:n.rigId,rigName:n.rigName,logicalId:n.logicalId,canonicalSessionName:n.canonicalSessionName,agentActivity:n.agentActivity??null,currentQitems:n.currentQitems??null,startupStatus:n.startupStatus,terminalActive:n.terminalActive,hasAssignedWork:n.hasAssignedWork??!1,pendingWorkCount:n.pendingWorkCount??0}]:[]),[n]),o=Ty(a),c=n?o.getNodeActivity(`${n.rigId}::${n.logicalId}`,{agentActivity:n.agentActivity??null,currentQitems:n.currentQitems??null,startupStatus:n.startupStatus,terminalActive:n.terminalActive,hasAssignedWork:n.hasAssignedWork??!1,pendingWorkCount:n.pendingWorkCount??0}):null,[d,h]=C.useState("overview"),m=n?n.nodeKind!=="infrastructure":!0,f=["overview","details"];return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"live-node-details",className:"space-y-4",children:[i.jsx(wn,{eyebrow:"Live Node Details",title:(n==null?void 0:n.canonicalSessionName)??t,description:`${(n==null?void 0:n.rigName)??e} / ${(n==null?void 0:n.podNamespace)??ii(t)??_u((n==null?void 0:n.podId)??null)} / ${t}`,actions:n?i.jsx(Cs,{runtime:n.runtime,model:n.model,size:"sm",compact:!0,className:"bg-surface-lowest/40 backdrop-blur-sm"}):null}),s&&i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading..."}),r&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 font-mono text-[10px] text-red-700",children:r.message}),n&&i.jsxs(i.Fragment,{children:[i.jsx(C1e,{rigId:e,logicalId:t,data:n}),i.jsx($1e,{tabs:f,activeTab:d,onSelect:h}),i.jsxs("div",{"data-testid":"live-node-tab-body",className:"space-y-4",children:[d==="overview"&&i.jsx(M1e,{data:n,activityVisual:c}),d==="details"&&i.jsx(L1e,{rigId:e,logicalId:t,data:n,isAgent:m})]})]})]})})}function B1e(e){return`'${e.replace(/'/g,"'\\''")}'`}function q1e(e){const t=e.tmuxWindow?`${e.tmuxSession}:${e.tmuxWindow}`:e.tmuxSession;return`tmux attach -t ${B1e(t)}`}function i8({label:e,activeLabel:t,onClick:n,testId:s,tool:r}){const[a,o]=C.useState(!1),c=C.useRef(null);C.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const d=async()=>{await n()&&(o(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{o(!1),c.current=null},900))};return i.jsxs("button",{type:"button","data-testid":s,"aria-label":e,onClick:()=>{d()},className:ce("inline-flex items-center gap-1.5 px-spacing-2 py-1 border font-mono text-[10px] uppercase transition-colors duration-150 ease-tactical",a?"bg-inverse-surface text-background border-on-surface":"bg-surface-lowest text-on-surface border-outline-variant hover:bg-surface-low"),children:[r?i.jsx(ht,{tool:r,size:"sm"}):null,i.jsx("span",{children:a?t:e})]})}function F1e({session:e,onAdopt:t}){return i.jsx("div",{"data-testid":"discovered-node",className:ce("border-dashed border border-foreground/20 bg-[hsl(var(--surface-container-lowest)/0.72)] px-spacing-4 py-spacing-3 mb-spacing-2 shadow-[0_10px_28px_rgba(20,20,20,0.04)] backdrop-blur-sm"),children:i.jsxs("div",{className:"flex flex-col gap-spacing-3 lg:flex-row lg:items-center lg:justify-between",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-x-spacing-3 gap-y-spacing-1",children:[i.jsx("span",{"data-testid":"runtime-badge",children:i.jsx(Cs,{runtime:e.runtimeHint,size:"sm",compact:!0})}),i.jsx("div",{"data-testid":"session-name",className:"font-mono text-[13px] leading-5 text-foreground",title:e.tmuxSession,children:e.tmuxSession}),e.confidence==="medium"?i.jsx("div",{"data-testid":"runtime-inferred-note",className:"text-[10px] uppercase tracking-[0.08em] text-foreground-muted",children:"runtime inferred"}):null]}),e.cwd?i.jsxs("div",{className:"mt-spacing-2 min-w-0",children:[i.jsx("div",{className:"text-[10px] uppercase tracking-[0.08em] text-foreground-muted",children:"cwd"}),i.jsx("div",{className:"font-mono text-[12px] leading-5 text-foreground-muted truncate",title:e.cwd,children:e.cwd})]}):null]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-spacing-2 lg:justify-end",children:[i.jsx(i8,{label:"copy tmux",activeLabel:"copied",testId:"copy-tmux-btn",tool:"tmux",onClick:async()=>await ia(q1e(e))}),e.cwd?i.jsx(i8,{label:"copy cwd",activeLabel:"copied",testId:"copy-cwd-btn",onClick:async()=>await ia(e.cwd??"")}):null,i.jsx(Se,{variant:"tactical",size:"sm","data-testid":"adopt-btn",onClick:()=>t(e.id),children:"ADOPT"})]})]})})}function z1e(){const[e,t]=C.useState(null),[n,s]=C.useState(!1),r=C.useCallback(async()=>{s(!0);try{const a=await fetch("/api/discovery/draft-rig",{method:"POST"});if(!a.ok){t(`# Error: draft generation failed (HTTP ${a.status})`);return}const o=await a.text();t(o)}catch{t("# Error: failed to reach daemon")}finally{s(!1)}},[]);return i.jsxs("div",{className:"mt-spacing-4 border-t border-foreground/10 pt-spacing-4","data-testid":"generate-draft-section",children:[i.jsx(Se,{variant:"tactical",onClick:r,disabled:n,"data-testid":"generate-draft-btn",className:"mb-spacing-3",children:n?"GENERATING...":"GENERATE RIG SPEC"}),e&&(()=>{const a=e.split(`
588
588
  `),o=a.filter(d=>d.startsWith("# WARNING:")).map(d=>d.replace(/^# WARNING:\s*/,"")),c=a.filter(d=>!d.startsWith("# WARNING:")).join(`
589
589
  `).trim();return i.jsxs("div",{className:"relative",children:[o.length>0&&i.jsx("div",{className:"mb-spacing-2 p-spacing-2 bg-warning/10 border border-warning/30 text-label-sm","data-testid":"draft-warnings",children:o.map((d,h)=>i.jsx("div",{className:"text-warning font-mono",children:d},h))}),i.jsx("pre",{className:"bg-surface-low p-spacing-3 text-label-sm font-mono overflow-x-auto max-h-64 border border-foreground/10","data-testid":"draft-yaml",children:c}),i.jsx("button",{onClick:()=>{var d;return(d=navigator.clipboard)==null?void 0:d.writeText(e)},className:"absolute top-2 right-2 text-label-sm text-foreground-muted hover:text-foreground","data-testid":"copy-draft-btn",children:"COPY"})]})})()]})}function H1e(){var E,N;const{data:e=[]}=YE({status:"active",runtimeHint:["claude-code","codex"],minConfidence:"medium"}),t=oz(),{data:n=[]}=Dr(),s=cse(),r=e,[a,o]=C.useState(null),[c,d]=C.useState(!1),[h,m]=C.useState(""),[f,g]=C.useState(""),x=k=>{o(k),d(!0),m(""),g(""),s.reset()},y=()=>{d(!1),o(null)},b=()=>{!a||!h||!f.trim()||s.mutate({discoveredId:a,rigId:h,logicalId:f.trim()},{onSuccess:y})},_=((E=s.error)==null?void 0:E.message)??null,w=s.isPending;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"discovery-overlay",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex flex-col gap-spacing-4 border-b border-foreground/10 pb-spacing-5 sm:flex-row sm:items-end sm:justify-between",children:[i.jsxs("div",{className:"max-w-[620px]",children:[i.jsx("h2",{className:"text-headline-lg uppercase",children:"DISCOVERY"}),i.jsx("p",{className:"mt-spacing-1 text-body-md text-foreground-muted",children:"Running agent sessions currently visible on this machine. Copy a tmux attach command, review the working directory, or adopt the session into a rig."})]}),i.jsx(Se,{variant:"ghost",size:"sm","data-testid":"scan-now-btn",disabled:t.isPending,onClick:()=>t.mutate(),children:t.isPending?"SCANNING...":"SCAN NOW"})]}),t.isError?i.jsxs("div",{className:"mt-spacing-4 text-label-sm text-destructive","data-testid":"scan-error",children:["Discovery scan failed: ",(N=t.error)==null?void 0:N.message]}):null,r.length===0?i.jsx("div",{className:"py-spacing-8","data-testid":"discovery-empty",children:i.jsx("p",{className:"text-body-md text-foreground-muted",children:"No running Claude or Codex sessions are currently visible."})}):i.jsxs("div",{className:"mt-spacing-6 space-y-spacing-3","data-testid":"discovery-active-section",children:[i.jsxs("div",{className:"mb-spacing-2",children:[i.jsx("h3",{className:"text-headline-sm uppercase",children:"Running agents"}),i.jsxs("p",{className:"text-label-md text-foreground-muted",children:[r.length," session",r.length!==1?"s":""," available to inspect or adopt"]})]}),r.map(k=>i.jsx(F1e,{session:k,onAdopt:x},k.id))]}),i.jsx(z1e,{})]}),i.jsx(Dy,{open:c,onOpenChange:d,children:i.jsxs(Ep,{"data-testid":"adopt-dialog",children:[i.jsxs($y,{children:[i.jsx(Rp,{className:"text-headline-md uppercase",children:"ADOPT SESSION"}),i.jsx(Tp,{children:"Bind this session to an existing logical node in the rig."})]}),i.jsxs("div",{className:"space-y-spacing-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-label-sm uppercase block mb-spacing-1",children:"RIG"}),i.jsxs("select",{"data-testid":"adopt-rig-input",value:h,onChange:k=>m(k.target.value),className:"w-full bg-surface-lowest border-b border-outline py-spacing-1 text-body-md font-mono focus:outline-none focus:border-on-surface appearance-none cursor-pointer",children:[i.jsx("option",{value:"",children:"Select a rig..."}),n.map(k=>i.jsxs("option",{value:k.id,children:[k.name," (",k.nodeCount," nodes)"]},k.id))]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-label-sm uppercase block mb-spacing-1",children:"LOGICAL ID (required)"}),i.jsx("input",{"data-testid":"adopt-logical-input",type:"text",value:f,onChange:k=>g(k.target.value),className:"w-full bg-transparent border-b border-foreground/20 py-spacing-1 text-body-md font-mono focus:outline-none focus:border-primary"}),i.jsx("p",{className:"mt-spacing-1 text-label-sm text-foreground-muted",children:"Enter the logical ID of an existing node in the target rig. For pod placement, use the Discovery drawer instead."})]})]}),_&&i.jsx("p",{className:"text-destructive text-label-sm","data-testid":"adopt-error",children:_}),i.jsxs(By,{children:[i.jsx(Se,{variant:"ghost",onClick:()=>d(!1),children:"CANCEL"}),i.jsx(Se,{variant:"tactical",onClick:b,disabled:!h||!f.trim()||w,"data-testid":"adopt-confirm",children:w?"ADOPTING...":"ADOPT"})]})]})})]})})}async function U1e(e){const t=new URLSearchParams;e.qitemId&&t.set("qitem_id",e.qitemId),e.actionVerb&&t.set("action_verb",e.actionVerb),e.actorSession&&t.set("actor_session",e.actorSession),e.since&&t.set("since",e.since),e.until&&t.set("until",e.until),e.limit!==void 0&&t.set("limit",String(e.limit)),e.beforeId&&t.set("before_id",e.beforeId);const n=t.toString(),s=`/api/mission-control/audit${n?`?${n}`:""}`,r=await fetch(s);if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}function WV(e){return Re({queryKey:["mission-control","audit",e],queryFn:()=>U1e(e)})}const GV=["approve","deny","route","annotate","hold","drop","handoff"];async function V1e(e){const t=await fetch("/api/mission-control/action",{method:"POST",headers:{"Content-Type":"application/json",...EE()},body:JSON.stringify(e)}),n=await t.json();if(!t.ok){const s=new Error(typeof n=="object"&&n&&"message"in n?String(n.message):`HTTP ${t.status}`);throw typeof n=="object"&&n&&"error"in n&&(s.code=String(n.error)),s.details=n,s}return n}function W1e(){const e=mt();return Ht({mutationFn:V1e,onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["mission-control","view"]}),e.invalidateQueries({queryKey:["mission-control","audit"]}),e.invalidateQueries({queryKey:["queue","item",n.qitemId]}),t.createdQitemId&&e.invalidateQueries({queryKey:["queue","item",t.createdQitemId]}),e.invalidateQueries({queryKey:["slices"]})}})}function Xa(e){return typeof window>"u"?"":new URL(window.location.href).searchParams.get(e)??""}function G1e(){var E,N,k,R;const[e,t]=C.useState(()=>Xa("qitem_id")||Xa("qitem")),[n,s]=C.useState(()=>Xa("action_verb")||Xa("verb")),[r,a]=C.useState(()=>Xa("actor_session")||Xa("actor")),[o,c]=C.useState(()=>Xa("since")),[d,h]=C.useState(()=>Xa("until")),[m]=C.useState(50),[f,g]=C.useState([]),x={qitemId:e||void 0,actionVerb:n||void 0,actorSession:r||void 0,since:o||void 0,until:d||void 0,limit:m,beforeId:f[f.length-1]},y=WV(x);function b(){g([])}function _(){var A;(A=y.data)!=null&&A.nextBeforeId&&g([...f,y.data.nextBeforeId])}function w(){g(f.slice(0,-1))}return i.jsxs("div",{"data-testid":"mc-view-audit-history",className:"space-y-3 p-3",children:[i.jsxs("header",{className:"space-y-0.5",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-on-surface-variant",children:"audit-history"}),i.jsx("h2",{className:"font-headline text-lg text-on-surface",children:"Audit history"}),i.jsxs("p",{className:"text-xs text-on-surface-variant",children:["Browse ",i.jsx("code",{children:"mission_control_actions"})," by qitem, verb, actor, and time range. Read-only."]})]}),i.jsxs("div",{"data-testid":"mc-audit-filters",className:"grid grid-cols-1 gap-2 border border-outline-variant bg-background p-2 sm:grid-cols-2",children:[i.jsx("input",{type:"text","data-testid":"mc-audit-filter-qitem-id",placeholder:"qitem_id (exact)",value:e,onChange:A=>t(A.target.value),className:"border border-outline-variant px-2 py-1 font-mono text-xs"}),i.jsxs("select",{"data-testid":"mc-audit-filter-action-verb",value:n,onChange:A=>s(A.target.value),className:"border border-outline-variant px-2 py-1 font-mono text-xs",children:[i.jsx("option",{value:"",children:"all verbs"}),GV.map(A=>i.jsx("option",{value:A,children:A},A))]}),i.jsx("input",{type:"text","data-testid":"mc-audit-filter-actor-session",placeholder:"actor_session (e.g., operator-alex@kernel)",value:r,onChange:A=>a(A.target.value),className:"border border-outline-variant px-2 py-1 font-mono text-xs"}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("input",{type:"datetime-local","data-testid":"mc-audit-filter-since",value:o,onChange:A=>c(A.target.value),className:"flex-1 border border-outline-variant px-2 py-1 font-mono text-[11px]",title:"since"}),i.jsx("input",{type:"datetime-local","data-testid":"mc-audit-filter-until",value:d,onChange:A=>h(A.target.value),className:"flex-1 border border-outline-variant px-2 py-1 font-mono text-[11px]",title:"until"})]}),i.jsx("button",{type:"button","data-testid":"mc-audit-filter-apply",onClick:b,className:"border border-on-surface bg-inverse-surface px-2 py-1 font-mono text-[10px] uppercase tracking-[0.12em] text-background",children:"Apply filters"})]}),y.isLoading?i.jsx("div",{"data-testid":"mc-audit-loading",className:"font-mono text-[10px] text-on-surface-variant",children:"loading..."}):y.isError?i.jsxs("div",{"data-testid":"mc-audit-error",className:"font-mono text-[11px] text-red-700",children:["error: ",y.error.message]}):((E=y.data)==null?void 0:E.rows.length)===0?i.jsx("div",{"data-testid":"mc-audit-empty",className:"font-mono text-[11px] text-on-surface-variant",children:"No audit entries match these filters."}):i.jsx("ul",{"data-testid":"mc-audit-rows",className:"space-y-1",children:(N=y.data)==null?void 0:N.rows.map(A=>i.jsxs("li",{"data-testid":"mc-audit-row","data-action-id":A.actionId,className:"border border-outline-variant bg-surface-lowest p-2 text-[11px]",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"font-mono uppercase tracking-[0.1em] text-on-surface",children:A.actionVerb}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:A.actedAt})]}),i.jsxs("div",{className:"mt-1 text-on-surface",children:["qitem: ",i.jsx("span",{className:"font-mono",children:A.qitemId??"—"})]}),i.jsxs("div",{className:"text-on-surface",children:["actor: ",i.jsx("span",{className:"font-mono",children:A.actorSession})]}),A.reason?i.jsxs("div",{className:"text-on-surface",children:["reason: ",i.jsx("span",{className:"italic",children:A.reason})]}):null,A.annotation?i.jsxs("div",{className:"text-on-surface",children:["annotation: ",i.jsx("span",{className:"italic",children:A.annotation})]}):null]},A.actionId))}),i.jsxs("footer",{"data-testid":"mc-audit-pagination",className:"flex items-center justify-between font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:[i.jsx("button",{type:"button","data-testid":"mc-audit-prev-page",onClick:w,disabled:f.length===0,className:"border border-outline-variant px-2 py-0.5 disabled:opacity-50",children:"← prev"}),i.jsxs("span",{children:["rows: ",((k=y.data)==null?void 0:k.rows.length)??0]}),i.jsx("button",{type:"button","data-testid":"mc-audit-next-page",onClick:_,disabled:!((R=y.data)!=null&&R.hasMore),className:"border border-outline-variant px-2 py-0.5 disabled:opacity-50",children:"next →"})]})]})}async function K1e(){const e=await fetch("/api/health-summary/version");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}function Y1e(){return Re({queryKey:["health-summary","version"],queryFn:K1e,staleTime:1/0})}const a8={active:"bg-success",running:"bg-success",stopped:"bg-outline-variant",warning:"bg-warning",error:"bg-tertiary",info:"bg-secondary"},Q1e={active:"border-success text-success",running:"border-success text-success",stopped:"border-outline text-on-surface-variant",warning:"border-warning text-warning",error:"border-tertiary text-tertiary",info:"border-secondary text-secondary"};function To({status:e,label:t,variant:n="dot",className:s,labelClassName:r,testId:a}){const o=t??e;return n==="pill"?i.jsxs("span",{"data-testid":a,className:ce("inline-flex items-center gap-1 px-1.5 py-0.5 border font-mono text-[9px] uppercase tracking-wide",Q1e[e],s),role:"status","aria-label":o,children:[i.jsx("span",{className:ce("w-1.5 h-1.5 rounded-full",a8[e]),"aria-hidden":"true"}),i.jsx("span",{className:r,children:o})]}):i.jsxs("span",{"data-testid":a,className:ce("inline-flex items-center gap-1.5",s),role:"status","aria-label":o,children:[i.jsx("span",{className:ce("w-2 h-2 rounded-full",a8[e]),"aria-hidden":"true"}),t?i.jsx("span",{className:ce("font-mono text-[9px] uppercase tracking-wide text-on-surface-variant",r),children:t}):null]})}const KV={up:"running",partial:"warning",down:"stopped",blocked:"error",unknown:"info"},YV={up:"border-success text-success",partial:"border-warning text-warning",down:"border-stone-400 text-stone-500",blocked:"border-tertiary text-tertiary",unknown:"border-stone-300 text-stone-400"},QV={up:"All managed seats are running.",partial:"Some seats running, some stopped / detached / attention-required.",down:"No seats running — recoverable from snapshot.",blocked:"Restore cannot proceed without operator action (missing token / auth / spec).",unknown:"Daemon/API cannot confidently compute the state."};function Fk({rigId:e,rigName:t,isKernel:n=!1,status:s,seatsRunning:r,seatsTotal:a,recoverable:o,src:c,primaryLabel:d,onPrimary:h,primaryDisabled:m,testId:f}){const g=KV[s],x=m??s==="up";return i.jsxs("div",{"data-testid":f??`rig-status-card-${e}`,"data-status":s,className:"bg-white border border-stone-900 hard-shadow relative",children:[i.jsxs("div",{className:"bg-stone-900 text-white px-4 py-1.5 font-mono text-[10px] flex justify-between items-center",children:[i.jsx("span",{children:n?"KERNEL RIG":`RIG: ${t.toUpperCase()}`}),n?i.jsx(ZZ,{className:"h-3 w-3"}):i.jsx(aF,{className:"h-3 w-3"})]}),i.jsxs("div",{className:"p-4 space-y-3",children:[i.jsxs("div",{className:"flex justify-between items-end border-b border-stone-100 pb-2",children:[i.jsx("span",{className:"font-headline font-bold text-lg tracking-tight uppercase",children:t}),i.jsxs("span",{"data-testid":`rig-status-badge-${e}`,className:ce("px-2 py-0.5 border font-mono text-[9px] uppercase tracking-wide inline-flex items-center gap-1.5",YV[s]),children:[i.jsx(To,{status:g}),s]})]}),i.jsx("p",{className:"font-mono text-[9px] leading-relaxed text-secondary",children:QV[s]}),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex justify-between font-mono text-[9px] text-secondary",children:[i.jsx("span",{children:"SEATS RUNNING"}),i.jsxs("span",{"data-testid":`seats-${e}`,children:[r,"/",a]})]}),i.jsxs("div",{className:"flex justify-between font-mono text-[9px] text-secondary",children:[i.jsx("span",{children:"RECOVERABLE"}),i.jsx("span",{children:o?"yes":"no — needs operator"})]})]}),i.jsx("div",{className:"pt-1",children:i.jsx(Se,{variant:s==="blocked"?"destructive":"default",size:"sm",disabled:x,onClick:h,"data-testid":`rig-primary-action-${e}`,className:"w-full font-mono text-[10px] tracking-widest",children:s==="up"?"RUNNING":d})}),i.jsxs("p",{"data-testid":`rig-status-src-${e}`,className:"font-mono text-[8px] leading-snug text-stone-400 border-t border-stone-100 pt-2",children:["src: ",c.join(" · ")]})]})]})}async function X1e(e,t){const n=await fetch(`/api/rigs/${encodeURIComponent(e)}/launch-plan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{freshLogicalIds:t}:{})});if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.error??`Launch plan failed (HTTP ${n.status})`)}return n.json()}function Z1e(e){return Ht({mutationFn:t=>X1e(e,t)})}const J1e={"resume-original":"running","fresh-primed":"info","awaiting-decision":"warning"},eSe={present:"text-success",missing:"text-tertiary font-bold",stale:"text-warning font-bold",unverified:"text-warning"};function o8({policy:e,label:t,selected:n,warn:s,sub:r,onSelect:a}){return i.jsxs("button",{type:"button","data-testid":`launch-policy-${e}`,"aria-pressed":n,onClick:a,className:ce("flex-1 border px-3 py-2 text-left",n?"border-stone-900 bg-stone-900 text-white":"border-outline bg-white text-stone-700",s&&!n&&"border-tertiary/50"),children:[i.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-wide",children:[n?i.jsx(EZ,{className:"h-3 w-3"}):null,t,e==="restore-original"?i.jsx("span",{className:ce("ml-auto text-[8px]",n?"text-white/70":"text-secondary"),children:"default"}):null]}),i.jsx("div",{className:ce("mt-1 font-mono text-[8px] leading-snug",n?"text-white/75":s?"text-tertiary":"text-secondary"),children:r})]})}function XV({rigId:e,rigName:t,open:n,onOpenChange:s}){var b;const r=Z1e(e),a=Fbe(e),[o,c]=C.useState("restore-original"),d=((b=r.data)==null?void 0:b.nodes)??[],h=d.map(_=>_.logicalId);C.useEffect(()=>{n&&(c("restore-original"),a.reset(),r.mutate(void 0))},[n,e]);function m(_){_!==o&&(c(_),r.mutate(_==="fresh"?d.map(w=>w.logicalId):void 0))}const f=d.filter(_=>_.intendedAction==="awaiting-decision"),g=o==="restore-original"&&f.length>0,x=!g&&d.length>0&&!r.isPending&&!a.isPending;function y(){a.mutate(o==="fresh"?h:void 0,{onSuccess:()=>s(!1)})}return i.jsx(Dy,{open:n,onOpenChange:s,children:i.jsxs(Ep,{hideCloseButton:!0,className:"max-w-3xl border-stone-900","data-testid":"launch-recovery-modal",children:[i.jsxs($y,{children:[i.jsxs(Rp,{className:"font-headline uppercase tracking-tight flex items-center gap-2",children:[i.jsx(rF,{className:"h-4 w-4"}),"Restore ",t]}),i.jsx(Tp,{className:"font-mono text-[10px] text-secondary",children:"Plan before action — this is a READ-ONLY preview. No changes made yet."})]}),i.jsxs("div",{className:"flex gap-2","data-testid":"launch-policy-picker",children:[i.jsx(o8,{policy:"restore-original",label:"Restore original",selected:o==="restore-original",sub:"Resume original sessions only. If a seat can't resume, fail loudly — never fresh-prime silently.",onSelect:()=>m("restore-original")}),i.jsx(o8,{policy:"fresh",label:"Fresh",selected:o==="fresh",warn:!0,sub:"⚠ Identity/context-changing — creates NEW sessions for ALL seats. Previous conversation context is NOT restored.",onSelect:()=>m("fresh")})]}),g?i.jsxs("div",{"data-testid":"launch-blocked-banner",className:"border border-tertiary bg-tertiary/10 px-3 py-2 flex items-start gap-2",children:[i.jsx(bE,{className:"h-3.5 w-3.5 text-tertiary shrink-0"}),i.jsxs("div",{className:"font-mono text-[9px] leading-relaxed text-tertiary",children:[i.jsx("span",{className:"font-bold uppercase",children:"restore-original blocked"})," — ",f.length," seat(s) need a decision. restore-original will NOT silently fresh-prime. Resolve each seat below, or switch to"," ",i.jsx("span",{className:"underline",children:"fresh"})," (identity-changing) for the whole rig."]})]}):null,r.isPending?i.jsx("p",{"data-testid":"launch-plan-loading",className:"font-mono text-[10px] text-secondary py-4",children:"Fetching read-only plan…"}):r.isError?i.jsxs("p",{"data-testid":"launch-plan-error",className:"font-mono text-[10px] text-tertiary py-4",children:["Could not fetch plan: ",r.error.message]}):i.jsxs(i.Fragment,{children:[i.jsxs(Ay,{"data-testid":"launch-plan-table",children:[i.jsx(Iy,{children:i.jsxs(Gl,{children:[i.jsx(Ir,{className:"font-mono text-[9px]",children:"Seat"}),i.jsx(Ir,{className:"font-mono text-[9px]",children:"Token"}),i.jsx(Ir,{className:"font-mono text-[9px]",children:"Plan"}),i.jsx(Ir,{className:"font-mono text-[9px]",children:"Prompt / note"})]})}),i.jsx(My,{children:d.map(_=>i.jsxs(Gl,{"data-testid":`plan-row-${_.logicalId}`,children:[i.jsx(Mr,{className:"py-2 font-mono text-[10px] font-medium",children:_.logicalId}),i.jsx(Mr,{className:"py-2 font-mono text-[9px]","data-testid":`plan-token-${_.logicalId}`,children:i.jsx("span",{className:ce(eSe[_.tokenState]),children:_.tokenState})}),i.jsx(Mr,{className:"py-2","data-testid":`plan-verdict-${_.logicalId}`,children:i.jsx(To,{status:J1e[_.intendedAction],variant:"pill",label:_.intendedAction})}),i.jsx(Mr,{className:"py-2 font-mono text-[9px] text-secondary",children:_.runtimePrompt??_.reason??"—"})]},_.logicalId))})]}),a.isError?i.jsx("p",{"data-testid":"launch-execute-error",className:"font-mono text-[9px] text-tertiary",children:a.error.message}):null]}),i.jsxs(By,{className:"items-center gap-2",children:[i.jsx("p",{className:"mr-auto font-mono text-[8px] text-stone-400 leading-snug",children:"src: composed from /api/rigs/:id/launch-plan (read-only forecast · mutated:false)"}),i.jsx(Se,{variant:"secondary",size:"sm",className:"font-mono text-[10px]",onClick:()=>s(!1),"data-testid":"launch-cancel",children:"Cancel"}),i.jsx(Se,{variant:o==="fresh"?"destructive":"default",size:"sm",disabled:!x,onClick:y,"data-testid":"launch-execute",className:"font-mono text-[10px] tracking-widest",children:g?"Resolve blockers to restore":o==="fresh"?"Fresh-prime all seats ▸":"Restore original ▸"})]})]})})}function tSe(e){return!!e&&"error"in e}async function nSe(){const e=await fetch("/api/kernel/status");if(e.status===503)return e.json();if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}function sSe(){return Re({queryKey:["kernel","status"],queryFn:nSe,refetchInterval:1e4})}function rSe(e){switch(e){case"ready":return"up";case"booting":case"partial_ready":case"degraded":return"partial";case"auth_blocked":case"spec_missing":case"bootstrap_failed":return"blocked";default:return"unknown"}}function iSe(){const{data:e,isLoading:t}=sSe(),{data:n}=Dr(),[s,r]=C.useState(!1),a=n==null?void 0:n.find(f=>f.name==="kernel");if(t||!e)return i.jsx(Fk,{rigId:"kernel",rigName:"kernel",isKernel:!0,status:"unknown",seatsRunning:0,seatsTotal:0,recoverable:!1,src:["kernel-status: loading…"],primaryLabel:"Restore kernel ▸",primaryDisabled:!0,testId:"kernel-status-card"});if(tSe(e))return i.jsx(Fk,{rigId:(a==null?void 0:a.id)??"kernel",rigName:"kernel",isKernel:!0,status:"unknown",seatsRunning:0,seatsTotal:0,recoverable:!1,src:[`kernel-status: unavailable (${e.error})`],primaryLabel:"Restore kernel ▸",primaryDisabled:!0,testId:"kernel-status-card"});const o=rSe(e.kernel_state),c=Array.isArray(e.agents)?e.agents:[],d=c.filter(f=>f.startup_status==="ready").length,h=[`kernel-status.kernel_state=${e.kernel_state??"unknown"}`,...e.variant?[`variant=${e.variant}`]:[],`agents ${d}/${c.length} ready`,...e.detail?[e.detail]:[]],m=!a||o==="up";return i.jsxs(i.Fragment,{children:[i.jsx(Fk,{rigId:(a==null?void 0:a.id)??"kernel",rigName:"kernel",isKernel:!0,status:o,seatsRunning:d,seatsTotal:c.length,recoverable:o==="down"||o==="partial",src:h,primaryLabel:"Restore kernel ▸",primaryDisabled:m,onPrimary:()=>r(!0),testId:"kernel-status-card"}),a?i.jsx(XV,{rigId:a.id,rigName:"kernel",open:s,onOpenChange:r}):null]})}function l8(e,t){var s;const n=(s=e==null?void 0:e.settings)==null?void 0:s[t];return typeof(n==null?void 0:n.value)=="string"?n.value:""}function aSe(e){return e.transport==="ssh"?e.target??"—":e.url??"—"}function oSe(){var R,A,T;const{data:e}=mr(),{data:t,error:n}=Pr(),s=Nv(),r=zJ(),[a,o]=C.useState(!1),[c,d]=C.useState(""),[h,m]=C.useState(""),[f,g]=C.useState(null),x=HJ(f),y=l8(e,"host.name")||(t==null?void 0:t.ownName)||"localhost",b=l8(e,"host.selected")||(t==null?void 0:t.selected)||"local",_=(t==null?void 0:t.hosts)??[],w=(R=x.data)==null?void 0:R.status,E=((A=x.data)==null?void 0:A.code)??((T=r.data)==null?void 0:T.code);async function N(){const I=h.trim();if(I)try{const M=await r.mutateAsync({url:I});g(M.pairId)}catch{}}function k(){g(null),m(""),r.reset()}return i.jsxs("section",{"data-testid":"dashboard-host-config",className:"df-hosts",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-secondary mb-2",children:"Hosts"}),i.jsx("div",{className:"df-hosts-own","data-testid":"host-config-own",children:a?i.jsxs("form",{className:"df-hosts-rename",onSubmit:I=>{I.preventDefault();const M=c.trim();M&&s.mutateAsync({key:"host.name",value:M}),o(!1)},children:[i.jsx("input",{"data-testid":"host-rename-input",className:"df-hosts-input",value:c,onChange:I=>d(I.target.value),autoFocus:!0}),i.jsx("button",{type:"submit",className:"df-hosts-btn",children:"Save"}),i.jsx("button",{type:"button",className:"df-hosts-btn",onClick:()=>o(!1),children:"Cancel"})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{"data-testid":"host-own-name",className:"df-hosts-name",children:y}),i.jsx("span",{className:"df-hosts-tag",children:"this host"}),b==="local"?i.jsx("span",{"data-testid":"host-selected-marker-local",className:"df-hosts-selected",children:"selected"}):i.jsx("button",{type:"button",className:"df-hosts-btn","data-testid":"host-select-local",onClick:()=>void s.mutateAsync({key:"host.selected",value:"local"}),children:"Select"}),i.jsx("button",{type:"button",className:"df-hosts-btn","data-testid":"host-rename-button",onClick:()=>{d(y),o(!0)},children:"Rename"})]})}),n?i.jsxs("div",{className:"df-hosts-empty",children:["host registry unreadable: ",String(n.message)]}):_.length===0?i.jsx("div",{"data-testid":"host-config-empty",className:"df-hosts-empty",children:"No remote hosts yet. Paste an address below and pair — one approval on the target, done."}):i.jsx("ul",{className:"df-hosts-list","data-testid":"host-config-rows",children:_.map(I=>i.jsxs("li",{className:"df-hosts-row",children:[i.jsx("span",{className:"df-hosts-marker",children:I.selected?"*":""}),i.jsx("span",{className:"df-hosts-id",children:I.id}),i.jsx("span",{className:"df-hosts-addr",children:aSe(I)}),i.jsx("span",{className:"df-hosts-transport",children:I.transport}),i.jsx("span",{className:`df-hosts-status df-hosts-status-${I.status}`,children:I.status}),I.selected?i.jsx("span",{className:"df-hosts-selected","data-testid":`host-selected-marker-${I.id}`,children:"selected"}):i.jsx("button",{type:"button",className:"df-hosts-btn","data-testid":`host-select-${I.id}`,onClick:()=>void s.mutateAsync({key:"host.selected",value:I.id}),children:"Select"})]},I.id))}),b!=="local"?i.jsxs("div",{className:"df-hosts-banner","data-testid":"host-selection-banner",children:["Selected host: ",b," — flagless CLI commands run against it (rig host select local returns)."]}):null,f===null?i.jsxs("form",{className:"df-hosts-add",onSubmit:I=>{I.preventDefault(),N()},children:[i.jsx("input",{"data-testid":"host-pair-input",className:"df-hosts-input",placeholder:"http://host:7433 — pair a new host",value:h,onChange:I=>m(I.target.value)}),i.jsx("button",{type:"submit",className:"df-hosts-btn","data-testid":"host-pair-button",disabled:r.isPending,children:"Pair"}),r.error?i.jsx("span",{className:"df-hosts-error","data-testid":"host-pair-error",children:r.error.message}):null]}):i.jsx("div",{className:"df-hosts-pairing","data-testid":"host-pairing",children:w==="approved"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"Paired."}),i.jsx("button",{type:"button",className:"df-hosts-btn",onClick:k,children:"Done"})]}):w==="denied"||w==="expired"?i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-testid":"host-pair-outcome",children:["Pairing ",w," — nothing was persisted."]}),i.jsx("button",{type:"button",className:"df-hosts-btn",onClick:k,children:"Dismiss"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-testid":"host-pair-code",children:["Code ",E??"…"," — waiting for approval on the target."]}),i.jsx("button",{type:"button",className:"df-hosts-btn",onClick:k,children:"Cancel"})]})})]})}class nd extends C.Component{constructor(){super(...arguments);cn(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,s){var r,a;console.error(`[ErrorBoundary${this.props.label?`: ${this.props.label}`:""}]`,n,s.componentStack),(a=(r=this.props).onError)==null||a.call(r,n,s)}render(){return this.state.error?this.props.fallback!==void 0?this.props.fallback:i.jsxs("div",{"data-testid":"error-boundary-fallback",role:"alert",className:"border border-outline-variant bg-surface-low px-3 py-6 text-center font-mono text-xs text-on-surface-variant",children:[this.props.label?`${this.props.label} failed to render.`:"This view failed to render."," ","The rest of the page is still usable."]}):this.props.children}}function lSe(){return i.jsxs("svg",{viewBox:"0 0 60 60",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("rect",{x:"22",y:"6",width:"16",height:"8"}),i.jsx("rect",{x:"6",y:"28",width:"14",height:"8"}),i.jsx("rect",{x:"40",y:"28",width:"14",height:"8"}),i.jsx("rect",{x:"6",y:"48",width:"14",height:"6"}),i.jsx("rect",{x:"22",y:"48",width:"14",height:"6"}),i.jsx("rect",{x:"40",y:"48",width:"14",height:"6"}),i.jsx("line",{x1:"30",y1:"14",x2:"13",y2:"28"}),i.jsx("line",{x1:"30",y1:"14",x2:"47",y2:"28"}),i.jsx("line",{x1:"13",y1:"36",x2:"13",y2:"48"}),i.jsx("line",{x1:"47",y1:"36",x2:"47",y2:"48"}),i.jsx("line",{x1:"13",y1:"44",x2:"29",y2:"48"}),i.jsx("line",{x1:"47",y1:"44",x2:"29",y2:"48"})]})}function cSe(){return i.jsxs("svg",{viewBox:"0 0 60 60",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("path",{d:"M2 26 Q 18 18 30 22 T 58 18"}),i.jsx("path",{d:"M2 36 Q 18 28 30 32 T 58 28",strokeDasharray:"2 2"}),i.jsx("path",{d:"M2 46 Q 18 40 30 42 T 58 38",strokeDasharray:"2 2"}),i.jsx("circle",{cx:"30",cy:"22",r:"2",fill:"currentColor"}),i.jsx("line",{x1:"30",y1:"22",x2:"30",y2:"10"})]})}function uSe(){return i.jsxs("svg",{viewBox:"0 0 60 60",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"30",cy:"30",r:"12"}),i.jsx("circle",{cx:"30",cy:"30",r:"20",strokeDasharray:"2 3"}),i.jsx("circle",{cx:"30",cy:"30",r:"27",strokeDasharray:"2 4"}),i.jsx("line",{x1:"30",y1:"0",x2:"30",y2:"60",strokeDasharray:"2 3"}),i.jsx("line",{x1:"0",y1:"30",x2:"60",y2:"30",strokeDasharray:"2 3"}),i.jsx("circle",{className:"df-amf",cx:"30",cy:"30",r:"4"})]})}function dSe(){return i.jsxs("svg",{viewBox:"0 0 60 60",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"30",cy:"30",r:"26"}),i.jsx("ellipse",{cx:"30",cy:"30",rx:"26",ry:"9"}),i.jsx("ellipse",{cx:"30",cy:"30",rx:"9",ry:"26"}),i.jsx("line",{x1:"0",y1:"30",x2:"60",y2:"30",strokeDasharray:"2 3"}),i.jsx("line",{x1:"30",y1:"0",x2:"30",y2:"60",strokeDasharray:"2 3"}),i.jsx("circle",{cx:"30",cy:"30",r:"3",fill:"currentColor"})]})}function hSe(){return i.jsxs("svg",{viewBox:"0 0 60 60",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("path",{d:"M10 18 V10 H18"}),i.jsx("path",{d:"M42 10 H50 V18"}),i.jsx("path",{d:"M10 42 V50 H18"}),i.jsx("path",{d:"M42 50 H50 V42"}),i.jsx("circle",{cx:"27",cy:"27",r:"11"}),i.jsx("line",{x1:"22",y1:"27",x2:"32",y2:"27"}),i.jsx("line",{x1:"27",y1:"22",x2:"27",y2:"32"}),i.jsx("line",{x1:"35",y1:"35",x2:"44",y2:"44"})]})}function fSe(){return i.jsxs("svg",{viewBox:"0 0 60 60",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"30",cy:"30",r:"18"}),i.jsx("circle",{cx:"30",cy:"30",r:"6"}),i.jsx("circle",{cx:"30",cy:"30",r:"2",fill:"currentColor"}),i.jsx("line",{x1:"36",y1:"30",x2:"53",y2:"30"}),i.jsx("line",{x1:"24",y1:"30",x2:"7",y2:"30"}),i.jsx("line",{x1:"30",y1:"36",x2:"30",y2:"53"}),i.jsx("line",{x1:"30",y1:"24",x2:"30",y2:"7"}),i.jsx("line",{x1:"34.2",y1:"34.2",x2:"46.3",y2:"46.3"}),i.jsx("line",{x1:"25.8",y1:"25.8",x2:"13.7",y2:"13.7"}),i.jsx("line",{x1:"34.2",y1:"25.8",x2:"46.3",y2:"13.7"}),i.jsx("line",{x1:"25.8",y1:"34.2",x2:"13.7",y2:"46.3"})]})}function pSe(){return i.jsxs("svg",{viewBox:"0 0 72 72",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"36",cy:"36",r:"26"}),i.jsx("ellipse",{cx:"36",cy:"36",rx:"9",ry:"26"}),i.jsx("ellipse",{cx:"36",cy:"36",rx:"19",ry:"26"}),i.jsx("line",{x1:"10",y1:"36",x2:"62",y2:"36"}),i.jsx("line",{x1:"14",y1:"22",x2:"58",y2:"22"}),i.jsx("line",{x1:"14",y1:"50",x2:"58",y2:"50"}),i.jsx("line",{x1:"36",y1:"2",x2:"36",y2:"70",strokeDasharray:"2 3"}),i.jsx("line",{x1:"2",y1:"36",x2:"70",y2:"36",strokeDasharray:"2 3"})]})}function mSe({kind:e}){return e==="cross"?i.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:i.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})}):e==="square"?i.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:i.jsx("rect",{className:"df-cap-fill",x:"3",y:"3",width:"6",height:"6"})}):i.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:i.jsx("circle",{cx:"6",cy:"6",r:"3"})})}const gSe=[{num:"01",to:"/topology",label:"TOPOLOGY",caption:"VIEW RIG GRAPH",glyph:i.jsx(lSe,{}),captionGlyph:"cross"},{num:"02",to:"/project",label:"PROJECT",caption:"BROWSE PROJECTS",glyph:i.jsx(cSe,{}),captionGlyph:"square"},{num:"03",to:"/for-you",label:"FOR YOU",caption:"PRIORITIZED FOR YOU",glyph:i.jsx(uSe,{}),captionGlyph:"square",amber:!0},{num:"04",to:"/specs",label:"LIBRARY",caption:"SPECS & ARTIFACTS",glyph:i.jsx(dSe,{}),captionGlyph:"cross"},{num:"05",to:"/search",label:"SEARCH & AUDIT",caption:"FIND & VERIFY",glyph:i.jsx(hSe,{}),captionGlyph:"circle"},{num:"06",to:"/settings",label:"SETTINGS",caption:"CONFIGURE · STATUS",glyph:i.jsx(fSe,{}),captionGlyph:"circle"}];function c8(e){return String(Math.max(0,e)).padStart(2,"0")}function xSe(e,t){var s,r;const n=(r=(s=e==null?void 0:e.settings)==null?void 0:s[t])==null?void 0:r.value;return typeof n=="string"?n:""}function vSe(){const{data:e}=Dr(),{data:t,isError:n}=Qf(),{data:s}=mr(),{data:r}=Y1e(),a=(e==null?void 0:e.length)??0,o=(t==null?void 0:t.reduce((y,b)=>y+b.nodeCount,0))??0,d=(typeof window>"u"?"localhost":window.location.hostname||"localhost").toUpperCase(),h=!n&&t!==void 0,m=xSe(s,"agents.operator_session"),f=tp(m),g=f.kind==="canonical"?f.member.toUpperCase():"OPERATOR",x=((r==null?void 0:r.version)??"").toUpperCase()||"—";return i.jsxs("div",{"data-testid":"dashboard-surface",className:"df-root",children:[i.jsxs("div",{className:"df-main",children:[i.jsxs("div",{className:"df-head",children:[i.jsxs("div",{className:"df-eyebrow",children:[i.jsxs("span",{className:"df-eyebrow-l",children:[i.jsx("span",{className:"df-gd","aria-hidden":"true"}),"OPERATOR"]}),i.jsx("span",{className:"df-eyebrow-r",children:"DASHBOARD · LAUNCHER · CONFIGSTORE-BACKED"})]}),i.jsx("h1",{"data-testid":"dashboard-greeting",className:"df-h1",children:"Welcome back, operator."}),i.jsxs("div",{className:"df-sub",children:["STATION ",d," IS ",i.jsxs("b",{children:["[ ",h?"ONLINE":"CONNECTING"," ]"]})]}),i.jsx(ySe,{station:d,operatorId:g,rigs:a,agents:o,version:x}),i.jsx("div",{className:"df-reg","aria-hidden":"true"})]}),i.jsxs("section",{"data-testid":"dashboard-kernel-section",className:"mb-6 max-w-md",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-secondary mb-2",children:"Host / kernel"}),i.jsx(nd,{label:"Kernel status",children:i.jsx(iSe,{})})]}),i.jsx(nd,{label:"Hosts",children:i.jsx(oSe,{})}),i.jsx("div",{className:"df-grid","data-testid":"dashboard-launcher-grid",children:gSe.map(y=>i.jsx(bSe,{dest:y},y.num))})]}),i.jsx(_Se,{})]})}function ySe({station:e,operatorId:t,rigs:n,agents:s,version:r}){const a=[{k:"STATION ID",v:e},{k:"OPERATOR ID",v:t},{k:"RIGS",v:c8(n)},{k:"AGENTS",v:c8(s)},{k:"VERSION",v:r}];return i.jsxs("section",{"data-testid":"dashboard-field-environment",className:"df-fieldenv","aria-label":"Field environment",children:[i.jsxs("div",{className:"df-feh",children:[i.jsx("span",{children:"FIELD ENVIRONMENT"}),i.jsx("span",{className:"df-feh-mark","aria-hidden":"true"})]}),i.jsxs("div",{className:"df-fe-body",children:[i.jsx("div",{className:"df-fe-list",children:a.map(o=>i.jsxs("div",{className:"df-fe-row",children:[i.jsx("span",{className:"df-k",children:o.k}),i.jsx("span",{className:"df-dots","aria-hidden":"true"}),i.jsx("span",{className:"df-v",children:o.v})]},o.k))}),i.jsx("div",{className:"df-fe-globe","aria-hidden":"true",children:i.jsx(pSe,{})})]})]})}function bSe({dest:e}){return i.jsxs("div",{className:"df-cell",children:[i.jsxs(Ve,{to:e.to,"data-testid":`dashboard-card-${e.num}`,"aria-label":e.label,className:"df-card",children:[i.jsx("span",{className:"df-plus","aria-hidden":"true"}),i.jsxs("span",{className:"df-idx",children:[e.num," ",i.jsx("i",{className:"df-idx-sq","aria-hidden":"true"})]}),i.jsx("span",{className:"df-glyph","aria-hidden":"true",children:e.glyph}),i.jsx("span",{className:"df-clabel",children:e.label}),i.jsx("span",{className:"df-half","aria-hidden":"true"}),i.jsxs("span",{className:"df-crop","aria-hidden":"true",children:[i.jsx("i",{className:"df-crop-tl"}),i.jsx("i",{className:"df-crop-br"})]})]}),i.jsxs("div",{className:`df-cap${e.amber?" df-cap--amber":""}`,children:[i.jsx("span",{className:"df-cap-glyph","aria-hidden":"true",children:i.jsx(mSe,{kind:e.captionGlyph})}),i.jsx("span",{className:"df-lead","aria-hidden":"true"}),e.caption]})]})}function _Se(){const e=[{left:6,top:14,w:4,h:1},{left:16,top:9,w:1,h:1},{left:24,top:16,w:3,h:1},{left:34,top:6,w:1,h:1},{left:30,top:13,w:1,h:1},{left:46,top:11,w:5,h:1},{left:58,top:7,w:1,h:1},{left:66,top:15,w:2,h:1},{left:78,top:10,w:1,h:1},{left:90,top:13,w:4,h:1}];return i.jsxs("div",{className:"df-foot","data-testid":"dashboard-footer",children:[i.jsxs("div",{className:"df-foot-fl",children:[i.jsx("span",{className:"df-foot-sq","aria-hidden":"true"}),"[ LOG ] .0001 · A SOLO BUILD, DELIBERATE, YEAR OVER YEAR"]}),i.jsx("span",{className:"df-plus2","aria-hidden":"true"}),i.jsx("span",{className:"df-foot-dots","aria-hidden":"true"}),i.jsx("div",{className:"df-dissolve","aria-hidden":"true",children:i.jsx("span",{className:"df-dissolve-blk"})}),i.jsx("div",{className:"df-arts","aria-hidden":"true",children:e.map((t,n)=>i.jsx("i",{style:{left:`${t.left}px`,top:`${t.top}px`,width:`${t.w}px`,height:`${t.h}px`}},n))}),i.jsxs("div",{className:"df-sqs","aria-hidden":"true",children:[i.jsx("span",{className:"df-sq-o"}),i.jsx("span",{className:"df-sq-b"})]}),i.jsx("span",{className:"df-plus2","aria-hidden":"true"})]})}async function wSe(e){const t=new URLSearchParams({attention:"1"});e!==void 0&&t.set("limit",String(e));const n=await fetch(`/api/queue/list?${t.toString()}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}async function SSe(e){const t=await fetch("/api/queue/attention-aggregate");if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.json(),s=Array.isArray(n.items)?n.items:[];return{items:e!==void 0?s.slice(0,e):s,hosts:Array.isArray(n.hosts)?n.hosts:[]}}function jSe(e=50,t=!1){return Re({queryKey:["attention-items",e,t],queryFn:t?()=>SSe(e):async()=>({items:await wSe(e),hosts:[]}),staleTime:15e3,refetchOnWindowFocus:"always"})}function V2(e){return typeof e=="string"&&e.length>0?e:void 0}function Cn(e,...t){for(const n of t){const s=V2(e[n]);if(s)return s}}function NSe(e){if(e)return e.length<=28?e:`${e.slice(0,18)}...${e.slice(-6)}`}function kSe(e){switch(e){case"queue.created":case"queue.item.created":return"Queue item created";case"queue.updated":case"queue.item.updated":return"Queue item updated";case"queue.handed_off":return"Queue item handed off";case"queue.claimed":return"Queue item claimed";case"queue.unclaimed":return"Queue item unclaimed";case"qitem.fallback_routed":return"Queue item fallback routed";case"qitem.closure_overdue":return"Queue item closure overdue";case"inbox.absorbed":return"Inbox item absorbed";case"inbox.denied":return"Inbox item denied";default:return e}}function CSe(e){return e==="queue.created"||e==="queue.updated"||e==="queue.claimed"||e==="queue.unclaimed"||e==="queue.handed_off"||e==="queue.item.created"||e==="queue.item.updated"||e==="qitem.fallback_routed"||e==="qitem.closure_overdue"||e==="inbox.absorbed"||e==="inbox.denied"}function ESe(e,t,n){return e.startsWith("queue.")&&e.endsWith(".closed")?"shipped":e==="qitem.closure_overdue"||e==="inbox.denied"?"action-required":n==="human-gate"?"approval":t==="pending-approval"?"action-required":t==="closeout-pending-ratify"?"approval":t==="done"||t==="closed"||t==="completed"||t==="shipped"?"shipped":"progress"}function RSe(e){const t=Cn(e,"sourceSession","source_session","fromSession"),n=Cn(e,"destinationSession","destination_session","toSession","destination"),s=t&&n?`${t} -> ${n}`:t?`Source: ${t}`:n?`Destination: ${n}`:void 0,r=[Cn(e,"priority")?`priority=${Cn(e,"priority")}`:void 0,Cn(e,"tier")?`tier=${Cn(e,"tier")}`:void 0,Cn(e,"state","toState")?`state=${Cn(e,"state","toState")}`:void 0,Cn(e,"closureReason")?`closure=${Cn(e,"closureReason")}`:void 0].filter(a=>!!a);return[s,r.length>0?r.join(" / "):void 0].filter(a=>!!a).join(`
590
590
  `)||void 0}function ZV(e){return OF(e??"")}function TSe(e){const t=e.payload??{},n=Cn(t,"actor_session","actorSession","source_session","sourceSession","fromSession","sender"),s=Cn(t,"rig_id","rigId"),r=Cn(t,"summary","body","title"),a={id:`${e.type}-${e.seq}`,title:r??e.type,body:V2(t.body),authorSession:n,rigId:s,receivedAt:e.receivedAt,createdAt:e.createdAt,source:e};if(e.type.startsWith("queue.")&&e.type.endsWith(".closed"))return{...a,kind:"shipped"};if(CSe(e.type)){const o=Cn(t,"qitemId","qitem_id"),c=Cn(t,"destinationSession","destination_session","toSession","destination"),d=Cn(t,"state","toState"),h=Cn(t,"tier"),m=ESe(e.type,d,h),f=m==="approval"?"approval":ZV(c)?"action-required":m,g=Cn(t,"summary","title"),x=f==="shipped"&&e.type==="queue.updated"?"Queue item shipped":kSe(e.type),y=g??[x,NSe(o)].filter(b=>!!b).join(": ");return{...a,title:y,body:V2(t.body)??RSe(t),kind:f}}return e.type.startsWith("workflow.")?{...a,kind:"progress"}:e.type.startsWith("stream.")||e.type.startsWith("watchdog.")?{...a,kind:"observation"}:e.type.startsWith("lifecycle.")||e.type.startsWith("git.")?{...a,kind:"shipped"}:{...a,kind:"observation"}}function ASe(e){return e.map(TSe).filter(n=>n!==null).sort((n,s)=>s.receivedAt-n.receivedAt)}const u8=new Set(["action-required","approval"]);function ISe(e){const t=(r,a)=>a.receivedAt-r.receivedAt,n=e.filter(r=>u8.has(r.kind)).sort(t),s=e.filter(r=>!u8.has(r.kind)).sort(t);return[...n,...s]}function MSe(e){return e.tier==="human-gate"?"approval":(OF(e.destinationSession??""),"action-required")}function LSe(e){const t=MSe(e),n=`queue-attention-${e.qitemId}`,s=Date.parse(e.tsUpdated)||Date.now(),r=e.tsUpdated||e.tsCreated||new Date().toISOString(),a={seq:-1,type:"queue.attention.synthetic",payload:{qitemId:e.qitemId,destinationSession:e.destinationSession,sourceSession:e.sourceSession,tier:e.tier,state:e.state,body:e.body},createdAt:r,receivedAt:s},o=e.summary??(t==="approval"?`Approval needed: ${e.qitemId.slice(0,24)}`:`Action required: ${e.qitemId.slice(0,24)}`),c=(e.tags??[]).find(d=>d.startsWith("slice:"));return{id:n,kind:t,title:o,body:e.body,authorSession:e.sourceSession,receivedAt:s,createdAt:r,source:a,evidenceRef:e.evidenceRef??null,reviewSlice:c?c.slice(6):null,reviewAnchor:c?e.qitemId:null,...e.hostId!==void 0?{hostId:e.hostId}:{}}}function OSe(e,t){const n=new Set;for(const r of t){const a=d8(r);a&&n.add(a)}const s=e.filter(r=>{if(r.kind!=="action-required"&&r.kind!=="approval")return!0;const a=d8(r);return a?!n.has(a):!0});return[...t,...s]}const PSe="queue-attention-",DSe="activity-needs-input-";function hv(e){return e.id.startsWith(PSe)||e.id.startsWith(DSe)}function $Se(e){return e.filter(t=>!hv(t)).map(t=>t.source.seq)}function d8(e){const t=e.source.payload??{};return typeof t.qitemId=="string"&&t.qitemId.length>0?t.qitemId:typeof t.qitem_id=="string"&&t.qitem_id.length>0?t.qitem_id:null}function BSe(e){const t=`activity-needs-input-${e.rigId??"unknown"}-${e.logicalId}`,n=e.eventAt??e.sampledAt??new Date().toISOString(),s=Date.parse(n)||Date.now(),r={seq:-1,type:"activity.needs_input.synthetic",payload:{logicalId:e.logicalId,sessionName:e.sessionName,source:e.source,rigId:e.rigId},createdAt:n,receivedAt:s};return{id:t,kind:"action-required",title:`${e.logicalId} needs input${e.source!=="hook"?" (activity-grade)":""}`,body:e.sessionName??void 0,rigId:e.rigId,source:r,receivedAt:s,createdAt:n}}function qSe(){return Re({queryKey:["needs-input-seats"],queryFn:async()=>{var s,r;const e=await fetch("/api/ps");if(!e.ok)return[];const t=await e.json(),n=[];for(const a of t){let o;try{const c=await fetch(`/api/rigs/${encodeURIComponent(a.rigId)}/nodes?full=true`);if(!c.ok)continue;o=await c.json()}catch{continue}for(const c of o){const{state:d,source:h}=Xf(c.agentActivity,c.terminalActive);d==="needs_input"&&n.push({logicalId:c.logicalId,sessionName:c.canonicalSessionName,source:h,eventAt:(s=c.agentActivity)==null?void 0:s.eventAt,sampledAt:(r=c.agentActivity)==null?void 0:r.sampledAt,rigId:a.rigId})}}return n},staleTime:5e3,refetchInterval:1e4})}const FSe=["all-activity","highlights","needs-you"],zSe={"all-activity":"level-control-option-all-activity",highlights:"level-control-option-highlights","needs-you":"level-control-option-needs-you"};function HSe({level:e}){return e==="needs-you"?i.jsxs(i.Fragment,{children:[i.jsx("b",{className:"text-on-surface",children:"Just what needs you"})," · ",i.jsx("span",{className:"text-amber-700",children:"action items"})," only"]}):e==="all-activity"?i.jsxs(i.Fragment,{children:[i.jsx("b",{className:"text-on-surface",children:"All activity"})," · ",i.jsx("span",{className:"text-amber-700",children:"what needs you"})," + everything, incl. audit log"]}):e==="highlights"?i.jsxs(i.Fragment,{children:[i.jsx("b",{className:"text-on-surface",children:"Highlights"})," · ",i.jsx("span",{className:"text-amber-700",children:"what needs you"})," + approvals + ships + progress · ",i.jsx("span",{className:"text-on-surface-variant",children:"audit hidden"})]}):i.jsxs(i.Fragment,{children:[i.jsx("b",{className:"text-on-surface",children:"Custom"})," · set via the individual toggles below"]})}function USe(){const{state:e,setLevel:t,isMutating:n,unavailable:s}=WE(),r=Ine(e),a=!s&&!n;return i.jsxs("div",{"data-testid":"level-control",className:"border border-outline-variant bg-background",children:[i.jsxs("div",{className:"flex items-center justify-between bg-inverse-surface text-background font-mono text-[8px] tracking-[0.16em] uppercase px-2.5 py-1.5",children:[i.jsx("span",{children:"Show me"}),i.jsx("span",{className:"text-on-surface-variant",children:"action items always on"})]}),i.jsx("div",{className:"flex px-2.5 pt-2.5 pb-1",children:FSe.map(o=>{const c=r===o;return i.jsx("button",{type:"button",role:"radio","aria-checked":c,disabled:!a,"data-testid":zSe[o],"data-active":c?"true":"false",onClick:()=>t(o),className:"flex-1 -ml-px first:ml-0 border px-1 py-2 font-mono text-[9px] uppercase tracking-[0.06em] whitespace-nowrap "+(c?"bg-inverse-surface text-background border-on-surface relative z-10":"bg-transparent text-on-surface-variant border-outline-variant")+(a&&!c?" hover:bg-surface-low":"")+(a?"":" opacity-60 cursor-not-allowed"),children:Mne[o]},o)})}),i.jsx("div",{"data-testid":"level-control-readout",className:"font-mono text-[8px] tracking-[0.04em] text-on-surface-variant leading-relaxed px-2.5 pb-2.5 pt-1.5",children:i.jsx(HSe,{level:r})}),s?i.jsx("p",{"data-testid":"level-control-unavailable",className:"font-mono text-[8px] text-on-surface-variant italic px-2.5 pb-2.5",children:"Settings endpoint unreachable (legacy daemon). Showing canonical defaults."}):null]})}const JV="forYou.dismissedSeqs";function VSe(){try{const e=localStorage.getItem(JV);if(!e)return new Set;const t=JSON.parse(e);if(!Array.isArray(t))return new Set;const n=t.filter(s=>typeof s=="number"&&Number.isFinite(s));return new Set(n)}catch{return new Set}}function zk(e){try{localStorage.setItem(JV,JSON.stringify(Array.from(e)))}catch{}}function WSe(e){const[t,n]=C.useState(()=>VSe()),s=C.useMemo(()=>{if(e.length===0)return null;let o=e[0];for(const c of e)c<o&&(o=c);return o},[e]);C.useEffect(()=>{if(s===null)return;let o=!1;const c=new Set;for(const d of t)d>=s?c.add(d):o=!0;o&&(n(c),zk(c))},[s,t]);const r=C.useCallback(o=>{n(c=>{if(c.has(o))return c;const d=new Set(c);return d.add(o),zk(d),d})},[]),a=C.useCallback(o=>{n(c=>{if(!c.has(o))return c;const d=new Set(c);return d.delete(o),zk(d),d})},[]);return{dismissedSeqs:t,dismiss:r,undismiss:a}}const eW="forYou.dismissedCardIds";function GSe(){try{const e=localStorage.getItem(eW);if(!e)return new Set;const t=JSON.parse(e);if(!Array.isArray(t))return new Set;const n=t.filter(s=>typeof s=="string"&&s.length>0);return new Set(n)}catch{return new Set}}function Hk(e){try{localStorage.setItem(eW,JSON.stringify(Array.from(e)))}catch{}}function KSe(e){const[t,n]=C.useState(()=>GSe()),s=C.useMemo(()=>new Set(e),[e]);C.useEffect(()=>{if(s.size===0)return;let o=!1;const c=new Set;for(const d of t)s.has(d)?c.add(d):o=!0;o&&(n(c),Hk(c))},[s,t]);const r=C.useCallback(o=>{n(c=>{if(c.has(o))return c;const d=new Set(c);return d.add(o),Hk(d),d})},[]),a=C.useCallback(o=>{n(c=>{if(!c.has(o))return c;const d=new Set(c);return d.delete(o),Hk(d),d})},[]);return{dismissedIds:t,dismiss:r,undismiss:a}}function YSe(){const e=[{pos:"top-[18%] left-[36%]",text:"▪ 03°",size:"text-[10px]"},{pos:"top-[24%] right-[34%]",text:"**",size:"text-base"},{pos:"top-[44%] left-[44%]",text:"+",size:"text-sm"},{pos:"top-[52%] right-[36%]",text:"(A)",size:"text-[10px]"},{pos:"bottom-[34%] left-[20%]",text:"[?]",size:"text-sm"},{pos:"bottom-[42%] right-[24%]",text:"▪ 06°",size:"text-[10px]"},{pos:"bottom-[18%] left-[58%]",text:"+",size:"text-sm"}];return i.jsx(i.Fragment,{children:e.map((t,n)=>i.jsx("span",{className:`absolute ${t.pos} ${t.size??"text-xs"} font-mono text-on-surface leading-none`,children:t.text},n))})}function QSe({tier:e="mid"}){const t=e==="mid"?"text-base":"text-2xl",n=[{pos:"top-[22%] left-[58%]",text:"■ 03°"},{pos:"top-[60%] left-[18%]",text:"+"},{pos:"bottom-[26%] right-[40%]",text:"■ 06°"},{pos:"top-[68%] right-[22%]",text:"▣"},{pos:"top-[72%] left-[8%]",text:"**"},{pos:"top-[86%] right-[5%]",text:"(A)"}];return i.jsx(i.Fragment,{children:n.map((s,r)=>i.jsx("span",{className:`absolute ${s.pos} ${t} font-mono text-on-surface leading-none`,children:s.text},r))})}function XSe({hostname:e="127.0.0.1"}={}){return i.jsxs("div",{"data-testid":"mid-layer","aria-hidden":"true",className:"absolute inset-0 z-[10] overflow-hidden pointer-events-none select-none",children:[i.jsxs("div",{className:"absolute top-[64%] left-[3%] font-mono text-[11px] text-on-surface leading-tight max-w-[180px]",children:[i.jsx("div",{className:"font-bold uppercase",children:"▪ 06° Field Report"}),i.jsxs("div",{className:"text-on-surface mt-1",children:["Operator session captured at field station ",e," — release 0.3.1; daemon trace nominal."]})]}),i.jsxs("div",{className:"absolute bottom-[8%] left-[6%] font-mono text-[11px] text-on-surface leading-tight max-w-[180px]",children:[i.jsx("div",{className:"font-bold uppercase",children:"Data Streams ⚠⚠"}),i.jsxs("div",{className:"text-on-surface mt-1 text-[10px]",children:["x-axis(1) y-axis(2) z-axis(3) — synchronized at ",e]})]}),i.jsx(QSe,{tier:"mid"})]})}function ZSe({hostname:e="127.0.0.1",totalRigs:t=1,totalAgents:n=4,activeAgents:s=4}={}){return i.jsxs("div",{"data-testid":"top-layer",className:"absolute inset-0 z-20 pointer-events-none select-none",children:[i.jsx("div",{"data-testid":"dashboard-classification",className:"absolute top-0 inset-x-0 border-b border-on-surface/40 bg-background/40 backdrop-blur-[6px]",children:i.jsxs("div",{className:"mx-auto max-w-[1180px] px-6 py-2 flex items-center justify-between gap-4 font-mono text-[10px] uppercase tracking-[0.32em] text-on-surface",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"inline-block w-1.5 h-1.5 bg-success rounded-none"}),"Operator"]}),i.jsx("span",{className:"hidden sm:inline",children:"▪ OpenRig · 0.3.1"}),i.jsxs("span",{className:"hidden md:inline",children:["▪ Field Station ",e]}),i.jsx("span",{className:"hidden md:inline",children:"▪ Session 04°"}),i.jsx("span",{className:"text-on-surface-variant",children:"04°"})]})}),i.jsxs("div",{className:"absolute top-[44px] left-[5%] right-[5%] z-20 pointer-events-none",children:[i.jsxs("h1",{"data-testid":"dashboard-greeting",className:"font-headline text-[44px] font-black tracking-tight uppercase text-on-surface leading-[0.95] inky-display",children:["Welcome back",i.jsx("sup",{className:"text-[22px] tracking-tight align-super",children:"(s*)"})]}),i.jsxs("div",{"data-testid":"dashboard-stats",className:"font-mono text-xs text-on-surface mt-2 flex flex-wrap items-baseline gap-x-4 gap-y-1",children:[i.jsxs("span",{"data-testid":"stat-rigs",className:"inline-flex items-baseline gap-1.5",children:[i.jsx("span",{className:"text-on-surface font-bold tabular-nums text-sm",children:String(t).padStart(2,"0")}),i.jsx("span",{className:"uppercase tracking-[0.12em] text-[10px]",children:"rigs"})]}),i.jsx("span",{"aria-hidden":"true",className:"text-on-surface-variant",children:"·"}),i.jsxs("span",{"data-testid":"stat-agents",className:"inline-flex items-baseline gap-1.5",children:[i.jsx("span",{className:"text-on-surface font-bold tabular-nums text-sm",children:String(n).padStart(2,"0")}),i.jsx("span",{className:"uppercase tracking-[0.12em] text-[10px]",children:"agents"}),i.jsx("span",{className:"ml-1 text-on-surface-variant",children:"("}),i.jsx("span",{className:"text-success font-bold tabular-nums",children:String(s).padStart(2,"0")}),i.jsx("span",{className:"uppercase tracking-[0.12em] text-[10px] text-success",children:"active"}),i.jsx("span",{className:"text-on-surface-variant",children:")"})]})]})]}),i.jsx("div",{className:"absolute bottom-8 right-10 rotate-[-4deg] origin-bottom-right",children:i.jsx("span",{className:"font-headline font-black text-[13px] tracking-[0.02em] text-on-surface uppercase inky-text",children:"Eyes Everywhere"})}),i.jsx(YSe,{}),i.jsx("div",{className:"absolute left-2 top-[42%] font-mono text-[9px] uppercase tracking-[0.2em] text-on-surface-variant rotate-[-90deg] origin-top-left whitespace-nowrap",children:"▪ Author redacted · entry 04°"}),i.jsx("div",{"data-testid":"dashboard-footer-marginalia",className:"absolute bottom-0 inset-x-0 border-t border-on-surface/40 bg-background/40 backdrop-blur-[6px]",children:i.jsxs("div",{className:"mx-auto max-w-[1180px] px-6 py-2 flex items-center justify-between gap-4 font-mono text-[10px] uppercase tracking-[0.24em] text-on-surface",children:[i.jsx("span",{children:"▪▪▪ End Surface · Dashboard · 01°"}),i.jsx("span",{className:"hidden sm:inline",children:"Operator-Grade · ConfigStore-Backed"}),i.jsx("span",{children:"OpenRig · 0.3.1"})]})})]})}function lr({position:e}){const t={tl:"top-1.5 left-1.5",tr:"top-1.5 right-1.5",bl:"bottom-1.5 left-1.5",br:"bottom-1.5 right-1.5"}[e],n={tl:"M 10 0 L 0 0 L 0 10",tr:"M 0 0 L 10 0 L 10 10",bl:"M 0 0 L 0 10 L 10 10",br:"M 10 0 L 10 10 L 0 10"}[e];return i.jsx("svg",{className:`absolute ${t} w-2.5 h-2.5 text-on-surface pointer-events-none select-none`,viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:i.jsx("path",{d:n})})}function iu(e){const{to:t,num:n,big:s,label:r,icon:a,body:o,graphic:c,positionClass:d,accent:h,washed:m,layout:f="numeral",callouts:g,tint:x="white",shadow:y="none"}=e,b=m?"inky-display":"",_=m?"inky-text":"",w={white:"bg-surface-lowest/30",cream:"bg-amber-50/45",stone:"bg-surface-low/45",rose:"bg-rose-50/45",slate:"bg-slate-50/50",sepia:"bg-yellow-50/45",mint:"bg-emerald-50/40"},E={none:{},soft:{boxShadow:"0 4px 12px rgba(0, 0, 0, 0.08)"},hard:{boxShadow:"3px 3px 0px #2e342e"},paper:{boxShadow:"0 2px 6px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.07)"},long:{boxShadow:"6px 6px 18px rgba(0, 0, 0, 0.1)"},inset:{boxShadow:"inset 0 1px 2px rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.04)"},halo:{boxShadow:"0 0 24px rgba(0, 0, 0, 0.12)"},ambient:{boxShadow:["0 2px 4px rgba(0, 0, 0, 0.14)","0 8px 20px rgba(0, 0, 0, 0.16)","0 0 40px rgba(0, 0, 0, 0.12)"].join(", ")}},N=s??n;return i.jsx(Ve,{to:t,"data-testid":`dashboard-card-${n}`,className:`absolute ${d} w-[28%] h-[220px] pointer-events-auto group block`,children:i.jsxs("article",{"data-testid":`destination-${n}`,style:E[y],className:`relative h-full ${w[x]} backdrop-blur-[10px] overflow-hidden transition-transform duration-300 ease-tactical group-hover:-translate-y-0.5 motion-reduce:transition-none motion-reduce:group-hover:translate-y-0`,children:[i.jsx(lr,{position:"tl"}),i.jsx(lr,{position:"tr"}),i.jsx(lr,{position:"bl"}),i.jsx(lr,{position:"br"}),i.jsxs("span",{className:"absolute top-2 right-6 font-mono text-[9px] uppercase tracking-[0.18em] text-on-surface select-none",children:["■ ",n,"°"]}),f==="headline"&&i.jsx(eje,{label:r,icon:a,body:o,graphic:c,to:t,accent:h,textClass:_}),f==="stat"&&i.jsx(tje,{label:r,num:n,icon:a,body:o,graphic:c,to:t,accent:h,textClass:_}),f==="coordinate"&&i.jsx(nje,{label:r,num:n,icon:a,body:o,graphic:c,to:t,accent:h,textClass:_}),f==="schematic"&&i.jsx(sje,{label:r,num:n,icon:a,body:o,graphic:c,to:t,accent:h,textClass:_,callouts:g,washed:m}),(f==="numeral"||!f)&&i.jsx(JSe,{big:N,numClass:b,graphic:c,body:o,label:r,icon:a,to:t,accent:h,textClass:_}),h&&i.jsxs("div",{className:"absolute bottom-[88px] right-[-14px] w-[156px] border border-tertiary text-tertiary font-mono text-[7.5px] uppercase tracking-[0.18em] px-1.5 py-[2px] flex items-center gap-1 bg-background/30",children:[i.jsx("span",{className:"inline-block w-[3px] h-[3px] bg-tertiary rounded-full"}),"Warning · Operator Live"]})]})})}function JSe({big:e,numClass:t,graphic:n,body:s,label:r,icon:a,to:o,accent:c,textClass:d}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`absolute top-7 left-3 font-headline font-black text-[110px] leading-[0.82] tracking-[-0.06em] text-on-surface select-none ${t}`,children:[e[0],i.jsx("sup",{className:"text-[55px] tracking-tight align-super",children:e[1]})]}),i.jsx("div",{className:"absolute top-7 right-7 w-[58px] h-[58px]",children:n}),i.jsx("p",{className:`absolute bottom-12 right-1 w-[140px] font-mono text-[8.5px] leading-[1.35] uppercase text-on-surface ${d}`,children:s}),i.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex items-baseline gap-2",children:[i.jsx("span",{className:c?"text-tertiary":"text-on-surface",children:a}),i.jsx("h2",{className:`font-headline font-black text-[17px] leading-none uppercase tracking-tight ${d} ${c?"text-tertiary":"text-on-surface"}`,children:r}),i.jsxs("span",{className:`ml-auto font-mono text-[9px] tracking-tight text-on-surface-variant ${d}`,children:["[",o,"] →"]})]})]})}function eje({label:e,icon:t,body:n,graphic:s,to:r,accent:a,textClass:o}){return i.jsxs(i.Fragment,{children:[i.jsx("h2",{className:`absolute top-6 left-3 right-3 font-headline font-black text-[40px] leading-[0.95] uppercase tracking-tight text-on-surface ${o} ${a?"text-tertiary":""}`,children:e}),i.jsx("div",{className:"absolute top-[88px] left-3 right-3 h-px bg-inverse-surface/30"}),i.jsx("div",{className:"absolute top-[100px] left-3 w-[60px] h-[60px]",children:s}),i.jsx("p",{className:`absolute top-[100px] left-[80px] right-1 font-mono text-[8.5px] leading-[1.35] uppercase text-on-surface ${o}`,children:n}),i.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex items-baseline gap-2",children:[i.jsx("span",{className:a?"text-tertiary":"text-on-surface",children:t}),i.jsx("span",{className:`font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface ${o}`,children:"Destination · 01°"}),i.jsxs("span",{className:`ml-auto font-mono text-[9px] tracking-tight text-on-surface-variant ${o}`,children:["[",r,"] →"]})]})]})}function tje({label:e,num:t,icon:n,body:s,graphic:r,to:a,accent:o,textClass:c}){return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"absolute top-3 left-3 font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface select-none",children:["▪ ",e," · ",t,"°"]}),i.jsx("div",{className:"absolute top-9 right-9 w-[36px] h-[36px]",children:r}),i.jsxs("div",{className:"absolute top-[44px] left-3 flex items-baseline gap-3",children:[i.jsx("span",{className:`font-headline font-black text-[64px] leading-[0.82] tracking-[-0.04em] text-on-surface tabular-nums ${c}`,children:"38"}),i.jsxs("div",{className:"flex flex-col leading-tight",children:[i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface",children:"Active"}),i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface",children:"Artifacts"})]})]}),i.jsxs("div",{className:"absolute top-[120px] left-3 right-3 grid grid-cols-3 gap-0",children:[i.jsx(Uk,{big:"12",small:"Specs"}),i.jsx(Uk,{big:"08",small:"Plugins"}),i.jsx(Uk,{big:"18",small:"Skills"})]}),i.jsx("p",{className:`absolute bottom-12 left-3 right-1 font-mono text-[8px] leading-[1.3] uppercase text-on-surface ${c}`,children:s}),i.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex items-baseline gap-2",children:[i.jsx("span",{className:o?"text-tertiary":"text-on-surface",children:n}),i.jsx("h2",{className:`font-headline font-black text-[15px] leading-none uppercase tracking-tight ${o?"text-tertiary":"text-on-surface"}`,children:e}),i.jsxs("span",{className:"ml-auto font-mono text-[9px] tracking-tight text-on-surface-variant",children:["[",a,"] →"]})]})]})}function Uk({big:e,small:t}){return i.jsxs("div",{className:"border-l border-on-surface/30 first:border-l-0 pl-2",children:[i.jsx("div",{className:"font-mono text-[14px] font-bold tabular-nums text-on-surface leading-none",children:e}),i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-wide text-on-surface-variant mt-0.5",children:t})]})}function nje({label:e,num:t,icon:n,body:s,graphic:r,to:a,accent:o,textClass:c}){const d=Array.from({length:12});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"absolute top-3 left-3 font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface select-none",children:["▪ ",e," · ",t,"°"]}),i.jsx("div",{className:"absolute top-7 left-6 right-6 flex justify-between",children:d.map((h,m)=>i.jsx("span",{className:`w-px h-[6px] ${m%3===0?"bg-inverse-surface":"bg-inverse-surface/40"}`},m))}),i.jsx("div",{className:"absolute bottom-12 left-6 right-6 flex justify-between",children:d.map((h,m)=>i.jsx("span",{className:`w-px h-[6px] ${m%3===0?"bg-inverse-surface":"bg-inverse-surface/40"}`},m))}),i.jsx("div",{className:"absolute top-12 bottom-16 left-3 flex flex-col justify-between",children:Array.from({length:8}).map((h,m)=>i.jsx("span",{className:`h-px w-[6px] ${m%2===0?"bg-inverse-surface":"bg-inverse-surface/40"}`},m))}),i.jsx("div",{className:"absolute top-12 bottom-16 right-3 flex flex-col justify-between",children:Array.from({length:8}).map((h,m)=>i.jsx("span",{className:`h-px w-[6px] ${m%2===0?"bg-inverse-surface":"bg-inverse-surface/40"}`},m))}),i.jsx("div",{className:"absolute top-[40px] left-1/2 -translate-x-1/2 w-[72px] h-[72px]",children:r}),i.jsx("div",{className:"absolute top-[76px] left-6 right-6 h-px bg-inverse-surface/30"}),i.jsx("div",{className:"absolute top-[40px] bottom-[80px] left-1/2 w-px bg-inverse-surface/30"}),i.jsx("span",{className:"absolute top-[120px] left-1/2 ml-1 font-mono text-[8px] text-on-surface",children:"⟨x: 24, y: 18⟩"}),i.jsx("p",{className:`absolute bottom-[60px] left-6 right-6 font-mono text-[8px] leading-[1.3] uppercase text-on-surface text-center ${c}`,children:s}),i.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex items-baseline gap-2",children:[i.jsx("span",{className:o?"text-tertiary":"text-on-surface",children:n}),i.jsx("h2",{className:"font-headline font-black text-[15px] leading-none uppercase tracking-tight text-on-surface",children:e}),i.jsxs("span",{className:"ml-auto font-mono text-[9px] tracking-tight text-on-surface-variant",children:["[",a,"] →"]})]})]})}function sje({label:e,num:t,icon:n,body:s,graphic:r,to:a,accent:o,textClass:c,callouts:d,washed:h}){const m=d??["A","B","C","D"];return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"absolute top-3 left-3 font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface select-none",children:["▪ ",e," · ",t,"°"]}),i.jsx("div",{className:"absolute top-7 left-1/2 -translate-x-1/2 w-[110px] h-[110px]",children:r}),i.jsx(Kg,{num:".01",label:m[0],positionClass:"top-[42px] left-3",align:"left"}),i.jsx(Kg,{num:".02",label:m[1],positionClass:"top-[42px] right-3",align:"right"}),i.jsx(Kg,{num:".03",label:m[2],positionClass:"top-[98px] left-3",align:"left"}),i.jsx(Kg,{num:".04",label:m[3],positionClass:"top-[98px] right-3",align:"right"}),i.jsx("p",{className:`absolute bottom-12 left-3 right-3 font-mono text-[8px] leading-[1.3] uppercase text-on-surface text-center ${c}`,children:s}),i.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex items-baseline gap-2",children:[i.jsx("span",{className:o?"text-tertiary":"text-on-surface",children:n}),i.jsx("h2",{className:`font-headline font-black text-[15px] leading-none uppercase tracking-tight ${h?"inky-text":""} ${o?"text-tertiary":"text-on-surface"}`,children:e}),i.jsxs("span",{className:"ml-auto font-mono text-[9px] tracking-tight text-on-surface-variant",children:["[",a,"] →"]})]})]})}function Kg({num:e,label:t,positionClass:n,align:s}){return i.jsxs("div",{className:`absolute ${n} font-mono text-[8px] text-on-surface ${s==="right"?"text-right":"text-left"}`,children:[i.jsx("span",{className:"block",children:e}),i.jsx("span",{className:"block tabular-nums text-on-surface",children:t})]})}function rje(){return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[i.jsx("path",{d:"M2 26 Q 18 18 30 22 T 58 18"}),i.jsx("path",{d:"M2 36 Q 18 28 30 32 T 58 28",strokeDasharray:"2 2"}),i.jsx("path",{d:"M2 46 Q 18 40 30 42 T 58 38",strokeDasharray:"2 2"}),i.jsx("circle",{cx:"30",cy:"22",r:"2",fill:"currentColor"}),i.jsx("line",{x1:"30",y1:"22",x2:"30",y2:"10"}),i.jsx("text",{x:"34",y:"12",fontSize:"6",fontFamily:"monospace",fill:"currentColor",fontWeight:"bold",children:"[01]"})]})}function ije(){return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[i.jsx("rect",{x:"22",y:"6",width:"16",height:"8"}),i.jsx("rect",{x:"6",y:"28",width:"14",height:"8"}),i.jsx("rect",{x:"40",y:"28",width:"14",height:"8"}),i.jsx("rect",{x:"6",y:"48",width:"14",height:"6"}),i.jsx("rect",{x:"22",y:"48",width:"14",height:"6"}),i.jsx("rect",{x:"40",y:"48",width:"14",height:"6"}),i.jsx("line",{x1:"30",y1:"14",x2:"13",y2:"28"}),i.jsx("line",{x1:"30",y1:"14",x2:"47",y2:"28"}),i.jsx("line",{x1:"13",y1:"36",x2:"13",y2:"48"}),i.jsx("line",{x1:"47",y1:"36",x2:"47",y2:"48"}),i.jsx("line",{x1:"13",y1:"44",x2:"29",y2:"48"}),i.jsx("line",{x1:"47",y1:"44",x2:"29",y2:"48"})]})}function aje(){return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[i.jsx("circle",{cx:"30",cy:"30",r:"4",fill:"currentColor"}),i.jsx("circle",{cx:"30",cy:"30",r:"12"}),i.jsx("circle",{cx:"30",cy:"30",r:"20",strokeDasharray:"2 3"}),i.jsx("circle",{cx:"30",cy:"30",r:"27",strokeDasharray:"2 4"}),i.jsx("line",{x1:"30",y1:"0",x2:"30",y2:"60",strokeDasharray:"2 3"}),i.jsx("line",{x1:"0",y1:"30",x2:"60",y2:"30",strokeDasharray:"2 3"})]})}function oje(){return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[i.jsx("circle",{cx:"30",cy:"30",r:"26"}),i.jsx("ellipse",{cx:"30",cy:"30",rx:"26",ry:"9"}),i.jsx("ellipse",{cx:"30",cy:"30",rx:"9",ry:"26"}),i.jsx("line",{x1:"0",y1:"30",x2:"60",y2:"30",strokeDasharray:"2 3"}),i.jsx("line",{x1:"30",y1:"0",x2:"30",y2:"60",strokeDasharray:"2 3"}),i.jsx("circle",{cx:"30",cy:"30",r:"3",fill:"currentColor"})]})}function lje(){return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:[i.jsx("circle",{cx:"24",cy:"24",r:"14"}),i.jsx("line",{x1:"20",y1:"24",x2:"28",y2:"24"}),i.jsx("line",{x1:"24",y1:"20",x2:"24",y2:"28"}),i.jsx("line",{x1:"34",y1:"34",x2:"52",y2:"52",strokeWidth:"1.6"}),i.jsx("line",{x1:"48",y1:"48",x2:"55",y2:"48"}),i.jsx("line",{x1:"48",y1:"48",x2:"48",y2:"55"})]})}function cje(){return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[i.jsx("circle",{cx:"30",cy:"30",r:"20"}),i.jsx("circle",{cx:"30",cy:"30",r:"12"}),i.jsx("circle",{cx:"30",cy:"30",r:"3",fill:"currentColor"}),i.jsx("line",{x1:"30",y1:"6",x2:"30",y2:"11",strokeWidth:"1.5"}),i.jsx("line",{x1:"30",y1:"49",x2:"30",y2:"54",strokeWidth:"1.5"}),i.jsx("line",{x1:"6",y1:"30",x2:"11",y2:"30",strokeWidth:"1.5"}),i.jsx("line",{x1:"49",y1:"30",x2:"54",y2:"30",strokeWidth:"1.5"}),i.jsx("line",{x1:"13",y1:"13",x2:"17",y2:"17",strokeWidth:"1.5"}),i.jsx("line",{x1:"43",y1:"13",x2:"47",y2:"17",strokeWidth:"1.5"}),i.jsx("line",{x1:"13",y1:"47",x2:"17",y2:"43",strokeWidth:"1.5"}),i.jsx("line",{x1:"43",y1:"47",x2:"47",y2:"43",strokeWidth:"1.5"})]})}function uje({librarySize:e}={}){const t=e&&e>0?`Specs · Plugins · Skills · Context packs. Field catalog 0.3.1 — ${e} active artifacts.`:"Specs · Plugins · Skills · Context packs. Field catalog 0.3.1 — 38 active artifacts.";return i.jsxs("div",{"data-testid":"destinations-layer",className:"absolute inset-0 z-[18] pointer-events-none",children:[i.jsx(iu,{to:"/topology",num:"01",big:"01",label:"Topology",icon:i.jsx(jE,{className:"h-4 w-4"}),body:"Host · Rig · Pod · Seat tree — live edges + runtimes; drill into any rig's pod graph.",positionClass:"top-[22%] left-[5%]",graphic:i.jsx(ije,{}),layout:"numeral",callouts:["HOST","RIG","POD","SEAT"],tint:"stone",shadow:"ambient"}),i.jsx(iu,{to:"/project",num:"02",big:"02",label:"Project",icon:i.jsx(wE,{className:"h-4 w-4"}),body:"Workspace · Mission · Slice. Browse all in-flight work by what agents are doing, not by repo.",positionClass:"top-[22%] left-[36%]",graphic:i.jsx(rje,{}),layout:"numeral",callouts:["WORKSPACE","MISSION","SLICE","TASK"],washed:!0,tint:"stone",shadow:"ambient"}),i.jsx(iu,{to:"/for-you",num:"03",big:"03",label:"For You",icon:i.jsx(kE,{className:"h-4 w-4"}),body:"Action feed → what needs you · what shipped · what's in flight. Prioritized for the operator.",positionClass:"top-[22%] left-[67%]",graphic:i.jsx(aje,{}),layout:"numeral",callouts:["NEEDS YOU","SHIPPED","IN-FLIGHT","BLOCKED"],accent:!0,tint:"stone",shadow:"ambient"}),i.jsx(iu,{to:"/specs",num:"04",big:"04",label:"Library",icon:i.jsx(nF,{className:"h-4 w-4"}),body:t,positionClass:"top-[55%] left-[5%]",graphic:i.jsx(oje,{}),layout:"numeral",callouts:["SPECS","PLUGINS","SKILLS","PACKS"],tint:"stone",shadow:"ambient"}),i.jsx(iu,{to:"/search",num:"05",big:"05",label:"Search & Audit",icon:i.jsx(_J,{className:"h-4 w-4"}),body:"Audit history · full artifact explorer. V1 placeholder; the full surface ships in V2.",positionClass:"top-[55%] left-[36%]",graphic:i.jsx(lje,{}),layout:"numeral",callouts:["AUDIT","HISTORY","QUERY","FILTER"],tint:"stone",shadow:"ambient"}),i.jsx(iu,{to:"/settings",num:"06",big:"06",label:"Settings",icon:i.jsx(tF,{className:"h-4 w-4"}),body:"Config · Policy · Log · Status. Operator-grade controls; ConfigStore-backed; reversible.",positionClass:"top-[55%] left-[67%]",graphic:i.jsx(cje,{}),layout:"numeral",callouts:["CONFIG","POLICY","LOG","STATUS"],tint:"stone",shadow:"ambient"})]})}function dje(e){const t=tp(e);return t.kind!=="canonical"?{logicalId:e,rigId:null}:{logicalId:t.member,rigId:t.rig}}function hje({authorSession:e,rigId:t,className:n,testId:s}){const r=dje(e),a=t??r.rigId,o=QR(),c=qF(e);return a?i.jsxs(Ve,{to:"/topology/seat/$rigId/$logicalId",params:{rigId:a,logicalId:encodeURIComponent(r.logicalId)},"data-testid":s??"author-agent-tag",onClick:d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.button!==0||o.mutate({rigId:a,logicalId:r.logicalId})},className:n??"inline-flex items-center gap-1 font-mono text-[10px] text-on-surface-variant hover:text-on-surface hover:underline",children:[c?i.jsx(Bx,{actor:e,size:"xs"}):null,i.jsx("span",{children:e})]}):i.jsxs("span",{"data-testid":s??"author-agent-tag",className:n??"inline-flex items-center gap-1 font-mono text-[10px] text-on-surface-variant",children:[c?i.jsx(Bx,{actor:e,size:"xs"}):null,i.jsx("span",{children:e})]})}const fje="openrig:topology-terminal-preview";function pje({cardId:e,sessionName:t}){if(!t)return i.jsx("button",{type:"button",disabled:!0,"data-testid":`feed-card-drill-${e}`,title:"No session resolved for this card — live terminal unavailable",className:"inline-flex items-center gap-1 font-mono text-[10px] uppercase tracking-wide text-on-surface-variant cursor-not-allowed",children:"live terminal"});const n=`${e}:${t}`,s=r=>{r.stopPropagation(),window.dispatchEvent(new CustomEvent(fje,{detail:{key:n}}))};return i.jsxs("span",{className:"inline-flex items-center",children:[i.jsx("button",{type:"button","data-testid":`feed-card-drill-${e}`,onClick:s,title:`Open live terminal for ${t}`,className:"font-mono text-[10px] uppercase tracking-wide text-on-surface hover:text-on-surface underline",children:"live terminal"}),i.jsx(uy,{rigId:e,logicalId:t,sessionName:t,renderTrigger:!1,testIdPrefix:`feed-card-drill-${e}`})]})}function Ap({data:e,children:t,className:n,style:s,testId:r}){const{setSelection:a}=Kv();return i.jsx("button",{type:"button","data-testid":r??"queue-item-trigger",onClick:()=>a({type:"qitem",data:e}),className:n??"text-left",style:s,children:t})}async function mje(){const e=await fetch("/api/mission-control/destinations");if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}function gje(e){return Re({queryKey:["mission-control","destinations"],queryFn:mje,enabled:e,staleTime:3e4})}const vu={approve:{label:"Approve",outcomeLabel:"Approved",description:"Accept the work and let it close or continue.",tone:"success",icon:vf},deny:{label:"Deny",outcomeLabel:"Denied",description:"Reject this request and leave a reason if needed.",tone:"danger",icon:CJ},route:{label:"Route",outcomeLabel:"Routed",description:"Send this to another session for follow-up.",tone:"info",icon:iF},annotate:{label:"Annotate",outcomeLabel:"Annotated",description:"Add context without changing ownership.",tone:"neutral",icon:WZ},hold:{label:"Hold",outcomeLabel:"Held",description:"Pause this item until more context is available.",tone:"warning",icon:fJ},drop:{label:"Drop",outcomeLabel:"Dropped",description:"Remove this item from the active path.",tone:"neutral",icon:AJ},handoff:{label:"Handoff",outcomeLabel:"Handed off",description:"Transfer active ownership to another session.",tone:"info",icon:wv}};function xje(e,t="action"){const n=vu[e];return{label:t==="outcome"?n.outcomeLabel:n.label,tone:n.tone,icon:n.icon}}const vje=new Set(["approve"]);function yje(e){return e instanceof Error?e.message:typeof e=="string"?e:"Action failed."}const h8={approve:{idle:"border-success text-success hover:bg-success hover:text-white",active:"border-success bg-success text-white"},deny:{idle:"border-tertiary text-tertiary hover:bg-tertiary hover:text-white",active:"border-tertiary bg-tertiary text-white"},route:{idle:"border-on-surface text-on-surface hover:bg-inverse-surface hover:text-background",active:"border-on-surface bg-inverse-surface text-background"},annotate:{idle:"border-on-surface text-on-surface hover:bg-inverse-surface hover:text-background",active:"border-on-surface bg-inverse-surface text-background"},hold:{idle:"border-warning text-warning hover:bg-warning hover:text-white",active:"border-warning bg-warning text-white"},drop:{idle:"border-on-surface text-on-surface hover:bg-inverse-surface hover:text-background",active:"border-on-surface bg-inverse-surface text-background"},handoff:{idle:"border-on-surface text-on-surface hover:bg-inverse-surface hover:text-background",active:"border-on-surface bg-inverse-surface text-background"}};function bje({qitemId:e,actorSession:t,bare:n=!1,hostId:s,enabledVerbs:r=[...GV],oneClickVerbs:a,onSettled:o,onOptimisticOutcome:c}){var V;const d=W1e(),[h,m]=C.useState(null),[f,g]=C.useState(""),[x,y]=C.useState(!1),[b,_]=C.useState(""),[w,E]=C.useState(""),[N,k]=C.useState(null),R=h==="route"||h==="handoff",A=h==="annotate",T=h==="hold"||h==="drop";function I(){m(null),g(""),y(!1),_(""),E(""),k(null)}function M(Y){m(Y),g(""),y(!1),_(""),E(""),k(null)}function P(Y,Q){const{dest:z,annotationText:G,reasonText:ee}=Q;d.mutate({verb:Y,qitemId:e,actorSession:t,destinationSession:z,annotation:G,reason:ee,...s&&s!=="local"?{hostId:s}:{}},{onSuccess:()=>{c==null||c({verb:Y,actorSession:t,actedAt:new Date().toISOString(),destinationSession:z??null,reason:ee??null}),I(),o==null||o()},onError:W=>{k(yje(W))}})}function L(){h&&P(h,{dest:R?f:void 0,annotationText:A?b:void 0,reasonText:T?w:void 0})}function D(Y){return!!(a!=null&&a.includes(Y))&&vje.has(Y)}const q=gje(R),B=((V=q.data)==null?void 0:V.destinations)??[],F=R&&q.isLoading,$=R&&(B.length>0||F),U=R&&(x||q.isError||q.isFetched&&B.length===0);return i.jsxs("div",{"data-testid":"mc-verb-actions",className:"space-y-2",children:[n?null:i.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 border border-outline-variant bg-surface-lowest/40 px-2 py-1.5 backdrop-blur-sm",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface",children:"Choose response"}),i.jsx("div",{className:"mt-0.5 font-mono text-[10px] leading-relaxed text-on-surface-variant",children:"Pick the next move for this queue item."})]}),h?i.jsxs("div",{className:"font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:["Selected: ",i.jsx("span",{className:"text-on-surface",children:vu[h].label})]}):null]}),i.jsx("div",{className:"flex flex-wrap gap-1",children:r.map(Y=>{const Q=vu[Y],z=Q.icon,G=D(Y);return i.jsxs("button",{type:"button","data-testid":`mc-verb-${Y}`,"data-one-click":G?"true":void 0,onClick:()=>{if(G){k(null),P(Y,{});return}M(Y)},disabled:d.isPending,title:G?`${Q.description} (records immediately)`:Q.description,className:ce("inline-flex min-h-[44px] items-center gap-1 border px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] transition-colors disabled:opacity-50",h===Y?h8[Y].active:h8[Y].idle),children:[i.jsx(z,{className:"h-3 w-3",strokeWidth:1.7}),Q.label]},Y)})}),h&&i.jsxs("div",{className:"space-y-1 border border-outline-variant bg-background p-2",children:[i.jsx("div",{"data-testid":"mc-verb-guidance",className:"font-mono text-[10px] leading-relaxed text-on-surface-variant",children:vu[h].description}),R&&i.jsxs("div",{className:"space-y-1",children:[$?i.jsxs("select",{"data-testid":"mc-verb-destination-select","aria-label":"Destination session",value:x?"__manual__":f,disabled:F,onChange:Y=>{if(Y.target.value==="__manual__"){y(!0),g("");return}y(!1),g(Y.target.value)},className:"w-full border border-outline-variant bg-surface-lowest px-2 py-1 font-mono text-xs",children:[i.jsx("option",{value:"",children:F?"loading destinations...":"choose destination"}),B.map(Y=>i.jsx("option",{value:Y.sessionName,children:Y.label},Y.sessionName)),i.jsx("option",{value:"__manual__",children:"manual entry"})]}):null,U?i.jsx("input",{type:"text","data-testid":"mc-verb-destination-input",value:f,onChange:Y=>g(Y.target.value),placeholder:"destination session (member@rig)",className:"w-full border border-outline-variant px-2 py-1 font-mono text-xs"}):null,q.isError?i.jsx("div",{className:"font-mono text-[10px] text-amber-700",children:"destination list unavailable"}):null]}),A&&i.jsx("textarea",{"data-testid":"mc-verb-annotation-input",value:b,onChange:Y=>_(Y.target.value),placeholder:"annotation",rows:2,className:"w-full border border-outline-variant px-2 py-1 font-mono text-xs"}),T&&i.jsx("input",{type:"text","data-testid":"mc-verb-reason-input",value:w,onChange:Y=>E(Y.target.value),placeholder:`${h} reason`,className:"w-full border border-outline-variant px-2 py-1 font-mono text-xs"}),i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx("button",{type:"button",onClick:I,"data-testid":"mc-verb-cancel",className:"border border-outline-variant px-2 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Cancel"}),i.jsx("button",{type:"button",onClick:L,"data-testid":"mc-verb-submit",disabled:d.isPending||R&&!f||A&&!b||T&&!w,className:"border border-on-surface bg-inverse-surface px-2 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-background disabled:opacity-50",children:d.isPending?"...":`Confirm ${vu[h].label}`})]})]}),N?i.jsx("div",{"data-testid":"mc-verb-error",role:"alert",className:"truncate border border-tertiary bg-background/40 px-3 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-tertiary",title:N,children:N}):null]})}const _je="user message begins here: ";function qy(e){return`[review ${e.itemRef}] Standing contract: when this conversation reaches an outcome, record it durably against the referenced item (resolve with the decision text, an adjudication proof-drop, or a routed qitem back to delivery) — a conversation is not a resolution. `+_je}function wje({sliceName:e,relPath:t,onClose:n,testId:s="proof-image-viewer",imageTestId:r="proof-image-viewer-image",closeTestId:a="proof-image-viewer-close"}){return t?i.jsx("div",{role:"dialog","aria-label":"Screenshot preview","data-testid":s,className:"fixed bottom-0 right-0 top-14 z-[1000] flex items-center justify-center bg-stone-950/20 p-6 backdrop-blur-[2px] lg:left-[21rem]",onClick:n,children:i.jsxs("div",{className:"max-h-full max-w-[92vw] border border-white/20 bg-stone-950/70 p-2 backdrop-blur-sm",onClick:o=>o.stopPropagation(),children:[i.jsx("img",{src:AF(e,t),alt:t,"data-testid":r,className:"max-h-[78vh] max-w-full object-contain"}),i.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3 font-mono text-[10px] text-stone-50",children:[i.jsx("span",{className:"truncate",children:t}),i.jsx("button",{type:"button","data-testid":a,onClick:n,className:"inline-flex h-7 w-7 items-center justify-center border border-white/30 text-stone-50 hover:bg-white/10","aria-label":"Close screenshot preview",children:i.jsx(CE,{className:"h-3.5 w-3.5",strokeWidth:1.5})})]})]})}):null}const Sje={"action-required":"bg-tertiary",approval:"bg-warning",shipped:"bg-success",progress:"bg-secondary",observation:"bg-outline"},TT={neutral:"bg-outline",info:"bg-secondary",success:"bg-success",warning:"bg-warning",danger:"bg-tertiary"},jje={"action-required":"feed-card-action",approval:"feed-card-approval",shipped:"feed-card-shipped",progress:"feed-card-progress",observation:"feed-card-observation"},Nje={"action-required":{label:"Action required",tone:"danger",icon:Co},approval:{label:"Needs approval",tone:"warning",icon:Co},shipped:{label:"Shipped",tone:"success",icon:NE},progress:{label:"Progress",tone:"info",icon:bu},observation:{label:"Observation",tone:"neutral",icon:yf}},kje={neutral:"text-on-surface-variant",info:"text-secondary",success:"text-success",warning:"text-warning",danger:"text-tertiary"};function Cje(e,t,n){return e==="action-required"||e==="approval"?t:n??t}const Eje="relative bg-surface-low/45 backdrop-blur-[10px] overflow-hidden group",Rje={boxShadow:["0 2px 4px rgba(0, 0, 0, 0.14)","0 8px 20px rgba(0, 0, 0, 0.16)","0 0 40px rgba(0, 0, 0, 0.12)"].join(", ")};function Sr(e){return typeof e=="string"&&e.length>0?e:void 0}function Tje(e){const t=e.source.payload??{},n=Sr(t.qitem_id)??Sr(t.qitemId);if(!n)return null;const s=t.tags,r=Array.isArray(s)?s.filter(a=>typeof a=="string"):void 0;return{qitemId:n,source:Sr(t.source_session)??Sr(t.sourceSession)??Sr(t.fromSession),destination:Sr(t.destination)??Sr(t.destination_session)??Sr(t.destinationSession)??Sr(t.toSession),state:Sr(t.state),tags:r,createdAt:e.createdAt,body:Sr(t.body)??e.body}}function Aje(e,t){const n=Tje(e);return t?{qitemId:t.qitemId,source:t.sourceSession,destination:t.destinationSession,state:t.state,tags:t.tags??void 0,createdAt:t.tsCreated,body:t.body||(n==null?void 0:n.body)||e.body}:n}function Ije(e){if(!e)return;const t=e.trim();return t.length<=520?t:`${t.slice(0,520).trimEnd()}
591
591
  ...`}const Mje=new Set(["done","closed","completed","shipped","canceled","cancelled","denied","failed","handed-off"]);function tW(e){return e?Mje.has(e.state.toLowerCase()):!1}function Lje(e,t,n){return!(e!=="action-required"&&e!=="approval"||n||tW(t))}function Oje(e,t){if(e!=="action-required"&&e!=="approval"||!t||!tW(t))return null;const n=t.closureReason??null,s=t.handedOffTo??t.closureTarget??null;return{verb:n==="denied"?"deny":n==="handed_off_to"?"route":n==="canceled"?"drop":"approve",actorSession:t.destinationSession,actedAt:t.tsUpdated,state:t.state,destinationSession:s,reason:n==="no-follow-on"?null:t.closureTarget??n}}function Pje(e){return xje(e.verb,"outcome")}function f8({token:e}){return i.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface",children:[i.jsx("span",{"aria-hidden":"true",className:ce("inline-block w-1.5 h-1.5 rounded-full shrink-0",TT[e.tone])}),e.label]})}function nW({value:e}){return i.jsxs("time",{dateTime:e??void 0,className:"inline-flex items-center gap-1 font-mono text-[10px] text-on-surface-variant",children:[i.jsx(_E,{className:"h-3 w-3",strokeWidth:1.5}),FE(e)]})}function W2({session:e}){return i.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 font-mono text-[10px] text-on-surface-variant",children:[i.jsx(Bx,{actor:e,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate",children:VF(e)})]})}function sW({source:e,destination:t}){return!e&&!t?null:i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[i.jsx(W2,{session:e??"unknown source"}),i.jsx(Dx,{className:"h-3.5 w-3.5 text-on-surface-variant",strokeWidth:1.4}),i.jsx(W2,{session:t??"unresolved target"})]})}function Dje(e){switch(e.verb){case"approve":return`Approved by ${e.actorSession}.`;case"deny":return`Denied by ${e.actorSession}${e.reason?`: ${e.reason}.`:"."}`;case"route":case"handoff":return e.destinationSession?`Routed by ${e.actorSession} to ${e.destinationSession}.`:`Routed by ${e.actorSession}.`;case"hold":return`Held by ${e.actorSession}${e.reason?`: ${e.reason}.`:"."}`;case"drop":return`Dropped by ${e.actorSession}${e.reason?`: ${e.reason}.`:"."}`;case"annotate":return`Annotated by ${e.actorSession}.`}}function $je({outcome:e}){const t=vu[e.verb],n=t.icon;return i.jsxs("div",{"data-testid":"feed-card-action-outcome",className:"mt-3 bg-background/40 px-3 py-2",children:[i.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[i.jsx("span",{"aria-hidden":"true",className:ce("mt-2 inline-block w-1.5 h-1.5 rounded-full shrink-0",TT[t.tone])}),i.jsx("span",{className:"mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-lowest/55 text-on-surface",children:i.jsx(n,{className:"h-4 w-4",strokeWidth:1.8})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-on-surface",children:t.outcomeLabel}),i.jsx("div",{className:"mt-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Decision recorded"})]})]}),i.jsx(nW,{value:e.actedAt})]}),i.jsx("p",{className:"mt-3 font-body text-[12px] leading-relaxed text-on-surface",children:Dje(e)}),i.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[i.jsx(W2,{session:e.actorSession}),e.reason?i.jsx(Uu,{tag:e.reason}):null]}),(e.verb==="route"||e.verb==="handoff")&&e.destinationSession?i.jsx("div",{className:"mt-2",children:i.jsx(sW,{source:e.actorSession,destination:e.destinationSession})}):null]})}const Bje=.5;function qje({card:e,queueItem:t,proofPreview:n,actionOutcome:s,onDismiss:r,onOptimisticOutcome:a}){const[o,c]=C.useState(null),[d,h]=C.useState(!1),m=C.useRef(null),f=P=>{r&&P.target===P.currentTarget&&(P.key==="Backspace"||P.key==="Delete")&&(P.preventDefault(),r(e))},g=P=>{if(!r)return;const L=P.touches[0];L&&(m.current={startX:L.clientX,pointerId:L.identifier,isTouch:!0})},x=P=>{const L=m.current;if(m.current=null,!r||!L)return;const D=P.changedTouches[0];if(!D)return;const q=D.clientX-L.startX;if(q<=0)return;const F=P.currentTarget.getBoundingClientRect();F.width<=0||q/F.width>=Bje&&r(e)},y=P=>{P.stopPropagation(),r&&r(e)},b=Aje(e,t),_=Ije((t==null?void 0:t.body)||e.body),w=(t==null?void 0:t.tags)??(b==null?void 0:b.tags)??[],E=(b==null?void 0:b.source)??e.authorSession,N=b==null?void 0:b.destination,k=N!=null&&N.startsWith("human")?N:"human@host",R=s??Oje(e.kind,t),A=R?Pje(R):Nje[e.kind],T=R?TT[A.tone]:Sje[e.kind],I=A.icon,M=Cje(e.kind,E,N);return i.jsxs("article",{"data-testid":jje[e.kind],style:Rje,className:ce(Eje,"mb-3"),...r?{tabIndex:0,onKeyDown:f,onTouchStart:g,onTouchEnd:x}:{},children:[i.jsx(lr,{position:"tl"}),i.jsx(lr,{position:"tr"}),i.jsx(lr,{position:"bl"}),i.jsx(lr,{position:"br"}),i.jsxs("div",{className:"px-4 py-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0 space-y-2",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[i.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-on-surface",children:[I?i.jsx(I,{"aria-hidden":"true",strokeWidth:1.7,className:ce("h-3.5 w-3.5 shrink-0",kje[A.tone])}):i.jsx("span",{"aria-hidden":"true",className:ce("inline-block w-1.5 h-1.5 rounded-full shrink-0",T)}),A.label]}),hv(e)?null:i.jsx(f8,{token:zF(e.source.type)}),b!=null&&b.state?i.jsx(f8,{token:HF(b.state)}):null,e.hostId&&e.hostId!=="local"?i.jsx("span",{"data-testid":"feed-card-host-chip",className:"px-1 border border-outline-variant font-mono text-[9px] uppercase tracking-wide text-on-surface-variant",children:e.hostId}):null]}),i.jsx("h3",{className:"font-headline text-[16px] font-bold leading-tight text-on-surface truncate",children:e.title})]}),i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(nW,{value:e.createdAt}),r?i.jsx("button",{type:"button","data-testid":"feed-card-dismiss","aria-label":"Dismiss card",onClick:y,className:"opacity-0 group-hover:opacity-100 focus:opacity-100 focus:outline-none focus:ring-1 focus:ring-outline transition-opacity inline-flex h-5 w-5 items-center justify-center border border-outline-variant bg-surface-lowest/80 text-on-surface-variant hover:text-on-surface hover:border-outline",children:i.jsx(CE,{className:"h-3 w-3",strokeWidth:1.8})}):null]})]}),_?i.jsx("p",{className:"mt-3 font-body text-[12px] leading-relaxed text-on-surface whitespace-pre-line",children:_}):null,i.jsx("div",{className:"mt-3",children:i.jsx(sW,{source:E,destination:N})}),w.length>0?i.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:w.slice(0,6).map(P=>i.jsx(Uu,{tag:P},P))}):null,n&&n.screenshots.length>0?i.jsxs("div",{"data-testid":`feed-card-proof-preview-${e.id}`,className:"mt-3 bg-background/40 p-2",children:[i.jsx(Dte,{title:`Proof packet · ${n.displayName}`,badge:n.passFailBadge}),i.jsx("div",{className:"mt-2",children:i.jsx(Pte,{sliceName:n.sliceName,screenshots:n.screenshots,onSelect:c,testIdPrefix:"feed-card-proof-screenshot"})})]}):null,R?i.jsx($je,{outcome:R}):null,b&&Lje(e.kind,t,R)?i.jsxs("div",{"data-testid":`feed-card-actions-${e.id}`,className:"mt-3 bg-background/40 p-3",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(bje,{qitemId:b.qitemId,actorSession:k,bare:!0,hostId:e.hostId,enabledVerbs:["approve"],oneClickVerbs:["approve"],onOptimisticOutcome:a?P=>a(b.qitemId,P):void 0}),i.jsx("button",{type:"button","data-testid":`feed-card-chat-${e.id}`,disabled:!M,title:M?`Chat with ${M}`:"No owning agent resolves for this card",onClick:()=>h(P=>!P),className:"border border-outline px-3 py-1 font-mono text-[11px] uppercase hover:bg-surface-variant disabled:opacity-50",children:"⌨ Chat"})]}),d&&M?i.jsx("div",{className:"mt-2 border border-outline-variant",children:i.jsx(Oo,{sessionName:M,terminalKey:`feed-chat:${e.id}`,initialText:qy({itemRef:b.qitemId})})}):null]}):null,i.jsx("div",{className:"mt-3 flex items-center justify-between gap-3 font-mono text-[10px] text-on-surface-variant",children:i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.authorSession?i.jsx(hje,{authorSession:e.authorSession,rigId:e.rigId}):null,b?i.jsx(Ap,{data:b,testId:`feed-card-show-context-${e.id}`,className:"font-mono text-[10px] uppercase tracking-wide text-on-surface hover:text-on-surface underline",children:"show context"}):null,i.jsx(pje,{cardId:e.id,sessionName:M}),e.evidenceRef?i.jsxs("span",{"data-testid":`feed-card-evidence-${e.id}`,title:e.evidenceRef,className:"max-w-48 truncate font-mono text-[10px] text-on-surface-variant",children:["evidence: ",e.evidenceRef]}):null,e.reviewSlice?i.jsx(Ve,{to:"/project/slice/$sliceId",params:{sliceId:e.reviewSlice},hash:e.reviewAnchor?`needs-you-${e.reviewAnchor}`:void 0,"data-testid":`feed-card-review-link-${e.id}`,className:"font-mono text-[10px] uppercase tracking-wide underline text-on-surface hover:text-on-surface-variant",children:"review →"}):null]})})]}),n?i.jsx(wje,{sliceName:n.sliceName,relPath:o,onClose:()=>c(null)}):null]})}function Fje({label:e,onUndo:t,onExpire:n,durationMs:s}){const r=C.useRef(!1);C.useEffect(()=>{const o=window.setTimeout(()=>{r.current||(r.current=!0,n())},s);return()=>window.clearTimeout(o)},[s,n]);const a=()=>{r.current||(r.current=!0,t())};return i.jsxs("div",{"data-testid":"undo-toast",role:"status","aria-live":"polite",className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-50 flex items-center gap-3 border border-stone-700 bg-stone-900/95 px-4 py-2 font-mono text-[11px] uppercase tracking-wide text-stone-50 backdrop-blur-sm shadow-lg",children:[i.jsx("span",{children:e}),i.jsx("button",{type:"button","data-testid":"undo-toast-button",onClick:a,className:"border border-stone-500 px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide text-stone-50 hover:bg-stone-800 focus:outline-none focus:ring-1 focus:ring-stone-300",children:"Undo"})]})}const zje=[{id:"all",label:"All"},{id:"action-required",label:"Action req"},{id:"approval",label:"Approvals"},{id:"shipped",label:"Shipped"},{id:"progress",label:"Progress"},{id:"observation",label:"Audit"}],Hje=50,p8={all:{label:"All caught up",description:"Nothing needs you right now. New human tasks, approvals, shipped proof, and progress updates will appear here."},"action-required":{label:"No actions waiting",description:"When a queue item needs your response, it will appear here with one-tap approve and chat with the owning agent."},approval:{label:"No approvals waiting",description:"Closeout and ratification requests will collect here when work needs an explicit decision."},shipped:{label:"No shipped proof yet",description:"Completed work with proof packets and screenshots will appear here when slices close."},progress:{label:"No progress cards",description:"Fresh queue movement and project updates will appear here as work advances."},observation:{label:"No audit cards",description:"Observation events are quiet right now. Turn the audit subscription on to watch more verbose activity."}};function m8(e){return typeof e=="string"&&e.length>0?e:void 0}function Uje(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Yg(e){const t=e.source.payload??{};return m8(t.qitemId)??m8(t.qitem_id)??null}const Vje=new Set(["approve","deny","route","handoff","hold","drop"]);function Lh(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.length>0?n:null}function Wje(e){if(!e.qitemId)return null;const t=e.actionVerb;if(!Vje.has(t))return null;const n=Lh(e.afterState,"handedOffTo")??(Lh(e.afterState,"closureReason")==="handed_off_to"?Lh(e.afterState,"closureTarget"):null);return{verb:t,actorSession:e.actorSession,actedAt:e.actedAt,state:Lh(e.afterState,"state"),destinationSession:n,reason:e.reason??Lh(e.afterState,"closureTarget")}}function Gje(e){const t=new Map;for(const n of e){if(!n.qitemId||t.has(n.qitemId))continue;const s=Wje(n);s&&t.set(n.qitemId,s)}return t}function Kje(e,t){const n=e.source.payload??{};return[...Uje(n.tags),...(t==null?void 0:t.tags)??[]]}function Yje(e,t,n){if(n&&(e.kind==="action-required"||e.kind==="approval"))return"approval";if(!t)return e.kind;if(t.tier==="human-gate")return"approval";const s=t.state.toLowerCase();return s==="done"||s==="closed"||s==="completed"?"shipped":ZV(t.destinationSession)?"action-required":e.kind}function g8(e,t,n){const s=new Set(Kje(e,t));for(const a of n)if(s.has(a.name))return a.name;const r=[e.title,e.body,t==null?void 0:t.body,...(t==null?void 0:t.tags)??[]].filter(a=>!!a).join(`
592
- `);for(const a of n)if(r.includes(a.name))return a.name;return null}function Qje(e){const t=(e==null?void 0:e.tests.proofPackets.find(n=>n.screenshots.length>0))??(e==null?void 0:e.tests.proofPackets[0]);return!e||!t||t.screenshots.length===0?null:{sliceName:e.name,displayName:e.displayName||e.name,passFailBadge:t.passFailBadge,screenshots:t.screenshots}}function Xje(){var W;const{events:e}=KE(),[t,n]=C.useState("all"),s=WE(),[r,a]=C.useState(()=>new Map),o=C.useCallback((K,X)=>{a(ne=>{const se=new Map(ne);return se.set(K,X),se})},[]),c=s.anyRemoteEnabled,[d,h]=C.useState(null),m=jSe(50,c),f=C.useMemo(()=>{var K;return((K=m.data)==null?void 0:K.hosts)??[]},[m.data]),g=C.useMemo(()=>{var K;return(((K=m.data)==null?void 0:K.items)??[]).map(LSe)},[m.data]),x=qSe(),y=C.useMemo(()=>(x.data??[]).map(BSe),[x.data]),b=C.useMemo(()=>ASe(e).slice(0,Hje),[e]),_=C.useMemo(()=>[...g,...y],[g,y]),w=C.useMemo(()=>ISe(OSe(b,_)),[b,_]),E=C.useMemo(()=>$Se(w),[w]),N=C.useMemo(()=>w.map(K=>K.id),[w]),{dismissedSeqs:k,dismiss:R,undismiss:A}=WSe(E),{dismissedIds:T,dismiss:I,undismiss:M}=KSe(N),[P,L]=C.useState(null),D=C.useCallback(K=>{hv(K)?(I(K.id),L({kind:"id",id:K.id})):(R(K.source.seq),L({kind:"seq",seq:K.source.seq}))},[R,I]),q=C.useCallback(()=>{P!==null&&(P.kind==="seq"?A(P.seq):M(P.id),L(null))},[P,A,M]),B=C.useCallback(()=>{L(null)},[]),F=C.useMemo(()=>w.map(Yg).filter(K=>!!K),[w]),$=LE(F),U=WV({limit:200}),V=C.useMemo(()=>{var K;return Gje(((K=U.data)==null?void 0:K.rows)??[])},[(W=U.data)==null?void 0:W.rows]),Y=C.useMemo(()=>{const X=w.map(ie=>{const ge=Yg(ie),ye=ge?$.itemsById.get(ge):void 0,be=ge?V.get(ge):void 0,me=Yje(ie,ye,be);return me===ie.kind?ie:{...ie,kind:me}}).filter(ie=>Lne(ie.kind,s.state)),ne=t==="all"?X:X.filter(ie=>ie.kind===t);return(d===null?ne:ne.filter(ie=>(ie.hostId??"local")===d)).filter(ie=>hv(ie)?!T.has(ie.id):!k.has(ie.source.seq))},[w,t,d,$.itemsById,V,s.state,k,T]),Q=Zf("all"),z=C.useMemo(()=>!Q.data||"unavailable"in Q.data?[]:Q.data.slices,[Q.data]),G=C.useMemo(()=>{const K=new Set;for(const X of Y){if(X.kind!=="shipped")continue;const ne=Yg(X),se=ne?$.itemsById.get(ne):void 0,ie=g8(X,se,z);ie&&K.add(ie)}return Array.from(K)},[Y,$.itemsById,z]),ee=TF(G);return i.jsxs("div",{"data-testid":"for-you-feed",className:"mx-auto w-full max-w-[720px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Attention"}),i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface mt-1",children:"For You"})]}),i.jsx("div",{"data-testid":"feed-level-control",className:"mb-4",children:i.jsx(USe,{})}),i.jsx("div",{"data-testid":"feed-lens-chips",role:"toolbar","aria-label":"Feed filters",className:"flex flex-wrap gap-1 mb-4",children:zje.map(K=>i.jsx("button",{type:"button","data-testid":`feed-lens-${K.id}`,"data-active":t===K.id,onClick:()=>n(K.id),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",t===K.id?"border-on-surface bg-inverse-surface text-background":"border-outline-variant text-on-surface-variant hover:bg-surface-low"),children:K.label},K.id))}),f.length>0&&i.jsxs("div",{"data-testid":"feed-host-chips",role:"toolbar","aria-label":"Host filter",className:"flex flex-wrap gap-1 mb-2",children:[i.jsx("button",{type:"button","data-testid":"feed-host-all","data-active":d===null,onClick:()=>h(null),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",d===null?"border-on-surface bg-inverse-surface text-background":"border-outline-variant text-on-surface-variant hover:bg-surface-low"),children:"ALL HOSTS"}),f.map(K=>i.jsxs("button",{type:"button","data-testid":`feed-host-${K.hostId}`,"data-active":d===K.hostId,"data-host-status":K.status,onClick:()=>h(d===K.hostId?null:K.hostId),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",d===K.hostId?"border-on-surface bg-inverse-surface text-background":"border-outline-variant text-on-surface-variant hover:bg-surface-low",K.status!=="ok"&&"opacity-60"),children:[K.hostId,K.status!=="ok"?` · ${K.status}`:""]},K.hostId))]}),f.filter(K=>K.status!=="ok").map(K=>i.jsxs("div",{"data-testid":`feed-host-status-${K.hostId}`,className:"mb-2 border border-outline-variant px-2 py-1 font-mono text-[9px] text-on-surface-variant",children:[K.hostId,": ",K.status,K.error?` — ${K.error}`:""," (other hosts' items unaffected)"]},`status-${K.hostId}`)),Y.length===0?i.jsx(Ae,{label:p8[t].label,description:p8[t].description,variant:"card",testId:"for-you-empty"}):i.jsx("div",{"data-testid":"for-you-feed-cards",children:Y.map(K=>{const X=Yg(K),ne=X?$.itemsById.get(X):void 0,se=K.kind==="shipped"?g8(K,ne,z):null,ie=se?Qje(ee.itemsByName.get(se)):null,ge=X?r.get(X)??V.get(X)??null:null;return i.jsx(qje,{card:K,queueItem:ne,proofPreview:ie,actionOutcome:ge,onDismiss:D,onOptimisticOutcome:o},K.id)})}),P!==null?i.jsx(Fje,{label:"Card dismissed",onUndo:q,onExpire:B,durationMs:5e3},P.kind==="seq"?`seq-${P.seq}`:`id-${P.id}`):null]})}const Zje=[{label:"+ Add spec",to:"/specs/rig",testId:"specs-toolbar-add"},{label:"Import",to:"/import",testId:"specs-toolbar-import"},{label:"Discover",to:"/search",testId:"specs-toolbar-discover"},{label:"Create rig",to:"/specs/rig",testId:"specs-toolbar-create-rig"},{label:"Generate workflow",to:"/specs/agent",testId:"specs-toolbar-gen-workflow"}];function Qg(e){return e.status==="error"?{id:e.id,label:e.name,meta:e.errorMessage??"Invalid workflow YAML",status:"error"}:{id:e.id,label:e.name,entryId:e.id}}function Jje(e){return{id:e.id,label:e.name,entryId:e.id}}function eNe(e){const t=[`v${e.version}`];return e.derivedEstimatedTokens>0&&t.push(`~${e.derivedEstimatedTokens} tok`),e.stats.forkCount>0&&t.push(`forks: ${e.stats.forkCount}`),e.stats.lastUsedAt&&t.push(`used: ${tNe(e.stats.lastUsedAt)}`),{id:e.id,label:e.name,meta:t.join(" · "),entryId:e.id}}function tNe(e){const t=Date.now()-new Date(e).getTime();if(t<0)return"just now";const n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function cl({id:e,title:t,rows:n,isLoading:s,emptyLabel:r,badge:a}){return i.jsxs("section",{"data-testid":`library-section-${e}`,className:"border border-outline-variant bg-surface-lowest/25 hard-shadow",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2",children:[i.jsx(ct,{tone:"default",children:t}),i.jsx("span",{"data-testid":`library-section-${e}-badge`,className:"shrink-0 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:s?"loading":a??`${n.length} items`})]}),n.length>0?i.jsx("ul",{className:"divide-y divide-outline-variant",children:n.map(o=>i.jsx("li",{children:o.entryId?i.jsx(Ve,{to:"/specs/library/$entryId",params:{entryId:o.entryId},"data-testid":`library-row-${e}-${o.id}`,className:"block px-3 py-2 hover:bg-surface-low/50",children:i.jsx(x8,{row:o})}):i.jsx("div",{"data-testid":`library-row-${e}-${o.id}`,"data-status":o.status,className:`px-3 py-2 ${o.status==="error"?"bg-red-50/40 text-red-900":""}`,children:i.jsx(x8,{row:o})})},o.id))}):i.jsx("div",{className:"px-3 py-4 font-mono text-[10px] text-on-surface-variant",children:s?"Loading...":r??"No entries."})]})}function nNe(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024))),s=e/Math.pow(1024,n);return`${n===0?s:s.toFixed(s>=100||n===0?0:1)} ${t[n]}`}function x8({row:e}){return i.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3 font-mono",children:[i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:e.label}),e.meta?i.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:e.meta}):null]})}function sNe({plugins:e,isLoading:t}){return i.jsxs("section",{id:"library-plugins","data-testid":"library-section-plugins",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2",children:[i.jsx(ct,{tone:"default",children:"Plugins"}),i.jsx("span",{className:"shrink-0 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${e.length} plugins`})]}),e.length===0?i.jsx("div",{className:"px-3 py-4",children:i.jsx(Ae,{label:t?"LOADING":"NO PLUGINS DISCOVERED",description:t?"Loading plugins...":"Install a Claude Code or Codex plugin (or wait for openrig-core to vendor) to see it appear here.",variant:"card",testId:"library-plugins-empty"})}):i.jsx("ul",{className:"divide-y divide-outline-variant",children:e.map(n=>i.jsx("li",{children:i.jsx(Ve,{to:"/plugins/$pluginId",params:{pluginId:n.id},"data-testid":`library-plugin-${n.id}`,className:"flex items-center gap-3 px-3 py-2 font-mono hover:bg-surface-low/50",children:i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${n.name} plugin`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:n.name})]})})},n.id))})]})}function rNe({skills:e,isLoading:t}){return i.jsxs("section",{id:"library-skills","data-testid":"library-section-skills",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2",children:[i.jsx(ct,{tone:"default",children:"Skills"}),i.jsx("span",{className:"shrink-0 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${e.length} folders`})]}),e.length===0?i.jsx("div",{className:"px-3 py-4",children:i.jsx(Ae,{label:t?"LOADING":"NO SKILLS FOUND",description:t?"Loading skill folders...":"No .openrig/skills or packaged OpenRig skill folders are visible through configured file roots.",variant:"card",testId:"library-skills-empty"})}):i.jsx("ul",{className:"divide-y divide-outline-variant",children:e.map(n=>i.jsx("li",{children:i.jsxs("a",{href:pne(n.id),"data-testid":`library-skill-${n.name}`,className:"flex items-center justify-between gap-3 px-3 py-2 font-mono hover:bg-surface-low/50",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${n.name} skill`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:n.name})]}),i.jsxs("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:[n.files.length," files"]})]})},n.id))})]})}function rW(){const{data:e=[],isLoading:t}=np(),{data:n=[],isLoading:s}=UE(),{data:r=[],isLoading:a}=VE(),{data:o=[],isLoading:c}=Tv(),{data:d=[],isLoading:h}=Av(),m=C.useMemo(()=>{const x=e.filter(w=>w.kind==="rig"&&!w.hasServices).map(Qg),y=e.filter(w=>w.kind==="workflow").map(Qg),b=e.filter(w=>w.kind==="agent").map(Qg),_=e.filter(w=>w.kind==="rig"&&w.hasServices).map(Qg);return{rigSpecs:x,workflowSpecs:y,agentSpecs:b,applications:_}},[e]),f=C.useMemo(()=>{const x=r.length,y=r.reduce((b,_)=>{var w;return b+(((w=_.stats)==null?void 0:w.estimatedSizeBytes)??0)},0);return`${x} ${x===1?"image":"images"} · ${nNe(y)}`},[r]),g=m.rigSpecs.length+m.workflowSpecs.length+m.agentSpecs.length+m.applications.length+n.length+r.length+o.length;return i.jsxs("div",{"data-testid":"specs-library-page",className:"h-full overflow-y-auto bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"mb-5 flex items-start justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx(ct,{tone:"muted",children:"Library"}),i.jsx("h1",{className:"mt-1 font-headline text-2xl font-bold tracking-tight text-on-surface",children:"Library"}),i.jsx("p",{className:"mt-1 max-w-3xl text-sm text-on-surface-variant",children:"Specs, context packs, agent images, applications, and skill folders."})]}),i.jsx("nav",{"aria-label":"Library actions",className:"flex flex-wrap justify-end gap-2",children:Zje.map(x=>i.jsx(Ve,{to:x.to,"data-testid":x.testId,className:"border border-outline-variant bg-surface-lowest/25 px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hard-shadow hover:bg-surface-lowest/40",children:x.label},x.testId))})]}),i.jsxs("div",{className:"mb-4 font-mono text-[10px] uppercase tracking-[0.14em] text-on-surface-variant",children:[g," library entries visible through current sources"]}),i.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[i.jsx(cl,{id:"rig-specs",title:"Rig Specs",rows:m.rigSpecs,isLoading:t,emptyLabel:"No rig specs found."}),i.jsx(cl,{id:"workspace-specs",title:"Workspace Specs",rows:[],emptyLabel:"No workspace specs source is wired yet."}),i.jsx(cl,{id:"workflow-specs",title:"Workflow Specs",rows:m.workflowSpecs,isLoading:t,emptyLabel:"No workflow specs found."}),i.jsx(cl,{id:"context-packs",title:"Context Packs",rows:n.map(Jje),isLoading:s,emptyLabel:"No context packs found."}),i.jsx(cl,{id:"agent-specs",title:"Agent Specs",rows:m.agentSpecs,isLoading:t,emptyLabel:"No agent specs found."}),i.jsx(cl,{id:"agent-images",title:"Agent Images",rows:r.map(eNe),isLoading:a,emptyLabel:"No agent images found.",badge:f}),i.jsx(cl,{id:"applications",title:"Applications",rows:m.applications,isLoading:t,emptyLabel:"No application specs found."})]}),i.jsxs("div",{className:"mt-4 space-y-4",children:[i.jsx(sNe,{plugins:d,isLoading:h}),i.jsx(rNe,{skills:o,isLoading:c})]})]})}async function iNe(e,t){const n=await fetch(`/api/skills/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}async function aNe(e,t){const n=await fetch(`/api/skills/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}function oNe(e,t){return Re({queryKey:["skill-files","list",e,t],queryFn:()=>iNe(e,t??""),enabled:!!e,staleTime:15e3})}function lNe(e,t){return Re({queryKey:["skill-files","read",e,t],queryFn:()=>aNe(e,t),enabled:!!e&&!!t,staleTime:15e3})}const cNe=new Set([".md",".mdx",".txt",".log",".yaml",".yml",".json",".js",".jsx",".ts",".tsx",".py",".sh",".bash",".css",".html"]);function uNe(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t).toLowerCase()}function v8(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function dNe(e,t){return e?`${e}/${t}`:t}function iW({skillToken:e,fileToken:t}){var x;const{data:n=[],isLoading:s}=Tv(),r=ZF(e),a=r?n.find(y=>y.id===r)??null:null,[o,c]=C.useState(""),[d,h]=C.useState(null),[m,f]=C.useState(!1);C.useEffect(()=>{if(!t||!a)return;const y=JF(t);y&&(c(v8(y)),h(y),f(!0))},[t,a]);const g=oNe((a==null?void 0:a.id)??null,o);return C.useEffect(()=>{if(m||o!==""||!g.data)return;const y=g.data.entries.find(b=>b.type==="file"&&/^skill\.md$/i.test(b.name));y&&h(y.name),f(!0)},[g.data,o,m]),s?i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"LOADING SKILL",description:"Loading skill files from the daemon skill library.",variant:"card",testId:"skill-detail-loading"})}):a?i.jsxs("div",{"data-testid":"skill-detail-page",className:"h-full overflow-hidden bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"mb-4",children:[i.jsx(ct,{tone:"muted",children:"Skill"}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-baseline gap-3",children:[i.jsx("h1",{className:"font-headline text-2xl font-bold tracking-tight text-on-surface",children:a.name}),i.jsx("span",{"data-testid":"skill-detail-source",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:a.source})]}),i.jsx("div",{"data-testid":"skill-detail-absolute-path",className:"mt-1 font-mono text-[10px] text-on-surface-variant truncate",title:a.absolutePath,children:a.absolutePath})]}),i.jsxs("div",{"data-testid":"skill-detail-docs-browser",className:"flex h-[calc(100%-5rem)] flex-col border border-outline-variant bg-surface-lowest/25 hard-shadow sm:flex-row",children:[i.jsxs("aside",{"data-testid":"skill-detail-tree",className:"w-full max-h-48 shrink-0 overflow-y-auto border-b border-outline-variant bg-surface-lowest/30 sm:w-64 sm:max-h-none sm:border-b-0 sm:border-r",children:[i.jsx(hNe,{testId:"skill-detail-breadcrumbs",skillName:a.name,path:o,onNavigate:y=>{c(y),h(null)}}),g.isLoading?i.jsx("div",{"data-testid":"skill-detail-tree-loading",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):g.isError?i.jsx("div",{"data-testid":"skill-detail-tree-error",className:"p-3 font-mono text-[10px] text-red-600",children:((x=g.error)==null?void 0:x.message)??"Error loading directory."}):!g.data||g.data.entries.length===0?i.jsx("div",{"data-testid":"skill-detail-tree-empty",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Empty directory."}):i.jsxs("ul",{className:"p-1",children:[o&&i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":"skill-detail-tree-up",onClick:()=>{c(v8(o)),h(null)},className:"block w-full px-2 py-1 text-left font-mono text-[10px] text-on-surface-variant hover:bg-surface-low",children:".."})}),g.data.entries.map(y=>{const b=dNe(o,y.name),_=y.type==="file",w=d===b;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`skill-detail-tree-entry-${b}`,"data-type":y.type,"data-active":w,onClick:()=>{_?h(b):y.type==="dir"&&(c(b),h(null))},disabled:y.type==="other",className:`block w-full px-2 py-1 text-left font-mono text-[10px] ${y.type==="other"?"text-on-surface-variant":`hover:bg-surface-low ${w?"bg-surface-high/80 text-on-surface":"text-on-surface"}`}`,children:y.type==="dir"?`▸ ${y.name}`:y.name})},b)})]})]}),i.jsx("main",{"data-testid":"skill-detail-viewer",className:"flex-1 min-w-0 overflow-y-auto bg-surface-lowest",children:d?i.jsx(fNe,{skillId:a.id,path:d}):i.jsx("div",{"data-testid":"skill-detail-viewer-no-selection",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Select a file from the tree."})})]})]}):i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"SKILL NOT FOUND",description:"The selected skill is not discoverable through the daemon skill library.",variant:"card",testId:"skill-detail-not-found"})})}function hNe({testId:e,skillName:t,path:n,onNavigate:s}){const r=n?n.split("/"):[];return i.jsxs("nav",{"data-testid":e,className:"flex flex-wrap items-baseline gap-1 border-b border-outline-variant px-2 py-1 font-mono text-[10px] text-on-surface",children:[i.jsx("button",{type:"button",onClick:()=>s(""),className:"font-bold hover:underline",children:t}),r.map((a,o)=>{const c=r.slice(0,o+1).join("/");return i.jsxs("span",{children:[i.jsx("span",{className:"mx-0.5 text-on-surface-variant",children:"/"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"hover:underline",children:a})]},c)})]})}function fNe({skillId:e,path:t}){var r;const n=lNe(e,t),s=C.useMemo(()=>uNe(t),[t]);return n.isLoading?i.jsx("div",{"data-testid":"skill-detail-viewer-loading",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):n.isError?i.jsx("div",{"data-testid":"skill-detail-viewer-error",className:"p-4 font-mono text-[10px] text-red-600",children:((r=n.error)==null?void 0:r.message)??"Error loading file."}):n.data?i.jsxs("div",{"data-testid":"skill-detail-viewer-content",className:"flex h-full flex-col",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2 font-mono text-[10px]",children:[i.jsx("div",{"data-testid":"skill-detail-viewer-path",className:"text-on-surface",children:t}),i.jsxs("div",{className:"flex items-baseline gap-3 text-on-surface-variant",children:[i.jsxs("span",{children:[n.data.size,"b"]}),i.jsx("span",{children:n.data.mtime})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[n.data.truncated&&i.jsxs("div",{"data-testid":"skill-detail-viewer-truncated",className:"mb-3 mx-4 mt-4 border border-amber-400 bg-amber-50 px-3 py-2 font-mono text-[10px] text-amber-900",children:["⚠ Truncated at ",Math.round((n.data.truncatedAtBytes??0)/1024)," KB — file is"," ",Math.round((n.data.totalBytes??n.data.size)/1024)," KB total."]}),s===".md"||s===".mdx"?i.jsx("div",{className:"p-4",children:i.jsx(Zn,{content:n.data.content})}):cNe.has(s)?i.jsx("div",{className:"p-4",children:i.jsx(Dv,{code:n.data.content,language:s.slice(1)})}):i.jsx("pre",{"data-testid":"skill-detail-viewer-text-fallback",className:"p-4 whitespace-pre-wrap break-words font-mono text-[10px] text-on-surface",children:n.data.content})]})]}):null}function pNe(e){return e==="workspace"?"Workspace":e==="openrig-managed"?"OpenRig managed":e}function mNe(){const{data:e=[],isLoading:t}=Tv(),n=[...e].sort((s,r)=>s.name.localeCompare(r.name));return i.jsxs("div",{"data-testid":"skills-index-page",className:"mx-auto w-full max-w-[960px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Library"}),i.jsxs("div",{className:"mt-1 flex items-baseline justify-between",children:[i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface",children:"Skills"}),i.jsx("span",{"data-testid":"skills-index-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${n.length} ${n.length===1?"skill":"skills"}`})]})]}),t&&n.length===0?i.jsx("div",{"data-testid":"skills-index-loading",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading skills…"}):n.length===0?i.jsxs("div",{"data-testid":"skills-index-empty",className:"border border-outline-variant bg-surface-lowest/25 px-4 py-6 font-mono text-xs leading-relaxed text-on-surface",children:[i.jsx("p",{className:"font-bold uppercase tracking-wide text-on-surface",children:"No skills visible"}),i.jsxs("p",{className:"mt-2",children:["Skills live under ",i.jsx("code",{className:"font-mono text-on-surface",children:".openrig/skills/"})," in your workspace, plus the built-in set shipped with OpenRig. If this list is empty, the daemon could not see either source through configured file roots."]})]}):i.jsx("ul",{"data-testid":"skills-index-rows",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow divide-y divide-outline-variant",children:n.map(s=>i.jsx("li",{children:i.jsxs(Ve,{to:"/specs/skills/$skillToken",params:{skillToken:Iv(s.id)},"data-testid":`skills-index-row-${s.id}`,className:"flex w-full items-center justify-between gap-3 px-3 py-2 font-mono text-left hover:bg-surface-low/60 focus:outline-none focus:bg-surface-low/80",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${s.name} skill`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:s.name})]}),i.jsxs("span",{className:"flex shrink-0 items-center gap-3 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:[i.jsx("span",{"data-testid":`skills-index-row-${s.id}-source`,children:pNe(s.source)}),i.jsxs("span",{"data-testid":`skills-index-row-${s.id}-filecount`,children:[s.files.length," ",s.files.length===1?"file":"files"]})]})]})},s.id))})]})}function gNe(){const{data:e=[],isLoading:t}=Av(),n=[...e].sort((s,r)=>s.name.localeCompare(r.name));return i.jsxs("div",{"data-testid":"plugins-index-page",className:"mx-auto w-full max-w-[960px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Library"}),i.jsxs("div",{className:"mt-1 flex items-baseline justify-between",children:[i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface",children:"Plugins"}),i.jsx("span",{"data-testid":"plugins-index-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${n.length} ${n.length===1?"plugin":"plugins"}`})]})]}),t&&n.length===0?i.jsx("div",{"data-testid":"plugins-index-loading",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading plugins…"}):n.length===0?i.jsxs("div",{"data-testid":"plugins-index-empty",className:"border border-outline-variant bg-surface-lowest/25 px-4 py-6 font-mono text-xs leading-relaxed text-on-surface",children:[i.jsx("p",{className:"font-bold uppercase tracking-wide text-on-surface",children:"No plugins visible"}),i.jsx("p",{className:"mt-2",children:"Plugins are discovered from Claude Code's global plugin cache, Codex's plugin cache, or OpenRig's vendored set (openrig-core ships with the daemon)."})]}):i.jsx("ul",{"data-testid":"plugins-index-rows",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow divide-y divide-outline-variant",children:n.map(s=>i.jsx("li",{children:i.jsxs(Ve,{to:"/plugins/$pluginId",params:{pluginId:s.id},"data-testid":`plugins-index-row-${s.id}`,className:"flex w-full items-center justify-between gap-3 px-3 py-2 font-mono text-left hover:bg-surface-low/60 focus:outline-none focus:bg-surface-low/80",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"plugin",title:`${s.name} plugin`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:s.name})]}),i.jsxs("span",{className:"flex shrink-0 items-center gap-3 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:[i.jsxs("span",{"data-testid":`plugins-index-row-${s.id}-version`,children:["v",s.version]}),i.jsx("span",{"data-testid":`plugins-index-row-${s.id}-runtimes`,className:"flex gap-1",children:s.runtimes.map(r=>i.jsx("span",{className:"border border-outline-variant px-1.5 py-0.5",children:r},r))}),i.jsxs("span",{"data-testid":`plugins-index-row-${s.id}-skillcount`,children:[s.skillCount," ",s.skillCount===1?"skill":"skills"]}),i.jsx("span",{"data-testid":`plugins-index-row-${s.id}-source`,children:s.sourceLabel})]})]})},s.id))})]})}async function xNe(e,t){const n=await fetch(`/api/plugins/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}async function vNe(e,t){const n=await fetch(`/api/plugins/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}function yNe(e,t){return Re({queryKey:["plugin-files","list",e,t],queryFn:()=>xNe(e,t??""),enabled:!!e,staleTime:15e3})}function bNe(e,t){return Re({queryKey:["plugin-files","read",e,t],queryFn:()=>vNe(e,t),enabled:!!e&&!!t,staleTime:15e3})}const _Ne=new Set([".md",".mdx",".txt",".log",".yaml",".yml",".json",".js",".jsx",".ts",".tsx",".py",".sh",".bash",".css",".html"]);function aW(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t).toLowerCase()}function wNe(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function SNe(e,t){return e?`${e}/${t}`:t}function jNe(e){const t=aW(e);return t===".md"||t===".mdx"}function NNe(e){const t=e.find(s=>s.type==="file"&&/^readme\.(md|mdx)$/i.test(s.name));if(t)return t.name;const n=e.find(s=>s.type==="file"&&jNe(s.name));return n?n.name:null}function kNe({pluginId:e}){var b;const{data:t,isLoading:n,error:s}=dne(e),{data:r=[]}=hne(e),[a,o]=C.useState(""),[c,d]=C.useState(null),[h,m]=C.useState(!1),f=yNe(e,a);if(C.useEffect(()=>{if(h||a!==""||!f.data)return;const _=NNe(f.data.entries);_&&d(_),m(!0)},[f.data,a,h]),n)return i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"LOADING PLUGIN",description:"Loading plugin manifest from discovery service.",variant:"card",testId:"plugin-detail-loading"})});if(s||!t)return i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"PLUGIN NOT FOUND",description:"The selected plugin is not visible through any configured discovery source.",variant:"card",testId:"plugin-detail-not-found"})});const g=t.entry,x=g.skillCount,y=r.length;return i.jsxs("div",{"data-testid":"plugin-detail-page",className:"h-full overflow-hidden bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"mb-4",children:[i.jsx(ct,{tone:"muted",children:"Plugin"}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-baseline gap-3",children:[i.jsx("h1",{className:"font-headline text-2xl font-bold tracking-tight text-on-surface",children:g.name}),i.jsxs("span",{className:"font-mono text-sm text-on-surface-variant",children:["v",g.version]}),g.runtimes.map(_=>i.jsx("span",{"data-testid":`plugin-detail-runtime-${_}`,className:"inline-block border border-outline-variant bg-surface-lowest/30 px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface",children:_},_)),i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",title:g.path,children:g.sourceLabel}),i.jsxs("span",{"data-testid":"plugin-detail-skill-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:[x," ",x===1?"skill":"skills"]}),i.jsxs("span",{"data-testid":"plugin-detail-used-by-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:["used by ",y," ",y===1?"agent":"agents"]})]}),g.description&&i.jsx("p",{className:"mt-2 max-w-3xl text-sm text-on-surface-variant",children:g.description})]}),i.jsxs("div",{"data-testid":"plugin-detail-docs-browser",className:"flex h-[calc(100%-7rem)] flex-col border border-outline-variant bg-surface-lowest/25 hard-shadow sm:flex-row",children:[i.jsxs("aside",{"data-testid":"plugin-detail-tree",className:"w-full max-h-64 shrink-0 overflow-y-auto border-b border-outline-variant bg-surface-lowest/30 sm:w-72 sm:max-h-none sm:border-b-0 sm:border-r",children:[i.jsx(CNe,{testId:"plugin-detail-breadcrumbs",pluginName:g.name,path:a,onNavigate:_=>{o(_),d(null)}}),f.isLoading?i.jsx("div",{"data-testid":"plugin-detail-tree-loading",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):f.isError?i.jsx("div",{"data-testid":"plugin-detail-tree-error",className:"p-3 font-mono text-[10px] text-red-600",children:((b=f.error)==null?void 0:b.message)??"Error loading directory."}):!f.data||f.data.entries.length===0?i.jsx("div",{"data-testid":"plugin-detail-tree-empty",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Empty directory."}):i.jsxs("ul",{className:"p-1",children:[a&&i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":"plugin-detail-tree-up",onClick:()=>{o(wNe(a)),d(null)},className:"block w-full px-2 py-1 text-left font-mono text-[10px] text-on-surface-variant hover:bg-surface-low",children:".."})}),f.data.entries.map(_=>{const w=SNe(a,_.name),E=_.type==="file",N=c===w;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`plugin-detail-tree-entry-${w}`,"data-type":_.type,"data-active":N,onClick:()=>{E?d(w):_.type==="dir"&&(o(w),d(null))},disabled:_.type==="other",className:`block w-full px-2 py-1 text-left font-mono text-[10px] ${_.type==="other"?"text-on-surface-variant":`hover:bg-surface-low ${N?"bg-surface-high/80 text-on-surface":"text-on-surface"}`}`,children:_.type==="dir"?`▸ ${_.name}`:_.name})},w)})]})]}),i.jsx("main",{"data-testid":"plugin-detail-viewer",className:"flex-1 min-w-0 overflow-y-auto bg-surface-lowest",children:c?i.jsx(ENe,{pluginId:e,path:c}):i.jsx("div",{"data-testid":"plugin-detail-viewer-no-selection",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Select a file from the tree."})})]})]})}function CNe({testId:e,pluginName:t,path:n,onNavigate:s}){const r=n?n.split("/"):[];return i.jsxs("nav",{"data-testid":e,className:"flex flex-wrap items-baseline gap-1 border-b border-outline-variant px-2 py-1 font-mono text-[10px] text-on-surface",children:[i.jsx("button",{type:"button",onClick:()=>s(""),className:"font-bold hover:underline",children:t}),r.map((a,o)=>{const c=r.slice(0,o+1).join("/");return i.jsxs("span",{children:[i.jsx("span",{className:"mx-0.5 text-on-surface-variant",children:"/"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"hover:underline",children:a})]},c)})]})}function ENe({pluginId:e,path:t}){var r;const n=bNe(e,t),s=C.useMemo(()=>aW(t),[t]);return n.isLoading?i.jsx("div",{"data-testid":"plugin-detail-viewer-loading",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):n.isError?i.jsx("div",{"data-testid":"plugin-detail-viewer-error",className:"p-4 font-mono text-[10px] text-red-600",children:((r=n.error)==null?void 0:r.message)??"Error loading file."}):n.data?i.jsxs("div",{"data-testid":"plugin-detail-viewer-content",className:"flex h-full flex-col",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2 font-mono text-[10px]",children:[i.jsx("div",{"data-testid":"plugin-detail-viewer-path",className:"text-on-surface",children:t}),i.jsxs("div",{className:"flex items-baseline gap-3 text-on-surface-variant",children:[i.jsxs("span",{children:[n.data.size,"b"]}),i.jsx("span",{children:n.data.mtime})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[n.data.truncated&&i.jsxs("div",{"data-testid":"plugin-detail-viewer-truncated",className:"mb-3 mx-4 mt-4 border border-amber-400 bg-amber-50 px-3 py-2 font-mono text-[10px] text-amber-900",children:["⚠ Truncated at ",Math.round((n.data.truncatedAtBytes??0)/1024)," KB — file is"," ",Math.round((n.data.totalBytes??n.data.size)/1024)," KB total."]}),s===".md"||s===".mdx"?i.jsx("div",{className:"p-4",children:i.jsx(Zn,{content:n.data.content})}):_Ne.has(s)?i.jsx("div",{className:"p-4",children:i.jsx(Dv,{code:n.data.content,language:s.slice(1)})}):i.jsx("pre",{"data-testid":"plugin-detail-viewer-text-fallback",className:"p-4 whitespace-pre-wrap break-words font-mono text-[10px] text-on-surface",children:n.data.content})]})]}):null}async function RNe(){const e=await fetch("/api/steering");if(e.status===503){const t=await e.json().catch(()=>({}));return{unavailable:!0,error:t.error??"steering_unavailable",hint:t.hint}}if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}function TNe(){return Re({queryKey:["steering"],queryFn:RNe,staleTime:3e4})}async function ANe(e,t){const n=await fetch(`/api/specs/review/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:t})});if(n.status===400)return await n.json();if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}function INe(e,t){return Re({queryKey:["spec-review",e,t?t.length:0,t?t.slice(0,64):""],queryFn:()=>ANe(e,t),enabled:!!e&&!!t,staleTime:6e4})}async function MNe(){const t=new URL(window.location.href).searchParams.get("session"),n=new URLSearchParams;if(t&&n.set("sessionName",t),n.toString()==="")return null;const s=await fetch(`/api/whoami?${n.toString()}`);if(!s.ok)return null;const r=await s.json().catch(()=>null);if(!r||typeof r!="object")return null;const a=r.workspace;return!a||typeof a!="object"?null:Array.isArray(a.repos)?a:{...a,repos:[]}}function LNe(){return Re({queryKey:["workspace","whoami"],queryFn:MNe,staleTime:6e4})}const ONe={user:{label:"USER",glyph:"U",bg:"bg-violet-50",fg:"text-violet-700",border:"border-violet-200"},project:{label:"PROJECT",glyph:"P",bg:"bg-blue-50",fg:"text-blue-700",border:"border-blue-200"},knowledge:{label:"KNOW",glyph:"K",bg:"bg-emerald-50",fg:"text-emerald-700",border:"border-emerald-200"},lab:{label:"LAB",glyph:"L",bg:"bg-amber-50",fg:"text-amber-700",border:"border-amber-200"},delivery:{label:"DELIVERY",glyph:"D",bg:"bg-rose-50",fg:"text-rose-700",border:"border-rose-200"}};function PNe({kind:e,compact:t,className:n}){const s=ONe[e];if(!s)return null;const r=`inline-block border ${s.border} ${s.bg} ${s.fg} font-mono text-[8px] uppercase tracking-[0.14em] leading-none rounded-sm`,a=t?"px-1 py-[2px]":"px-1.5 py-0.5";return i.jsx("span",{"data-testid":`workspace-kind-badge-${e}`,title:`workspace kind: ${e}`,className:`${r} ${a} ${n??""}`.trim(),children:t?s.glyph:s.label})}function DNe(e,t){if(!e||!t)return null;let n=null;for(const s of t.repos)y8(e,s.path)&&s.path.length>((n==null?void 0:n.len)??-1)&&(n={kind:s.kind,len:s.path.length});return n?n.kind:t.knowledgeRoot&&y8(e,t.knowledgeRoot)?"knowledge":null}function y8(e,t){return!e||!t?!1:e===t?!0:e.startsWith(t.endsWith("/")?t:t+"/")}const $Ne=new Set([".md",".txt",".log",".yaml",".yml",".json",".js",".jsx",".ts",".tsx",".py",".sh",".bash",".sql",".css",".html"]),BNe=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),qNe=new Set([".zip",".tar",".gz",".pdf",".mp4",".webm",".mov"]);function oW(e){return!!(e&&typeof e=="object"&&"unavailable"in e)}function FNe(){const e=Jf(),t=LNe(),[n,s]=C.useState(null),[r,a]=C.useState(""),[o,c]=C.useState(null),[d,h]=C.useState(!1);return C.useEffect(()=>{if(n||!e.data||oW(e.data))return;const m=e.data.roots[0];m&&s(m.name)},[e.data,n]),C.useEffect(()=>{a(""),c(null),h(!1)},[n]),i.jsxs("div",{"data-testid":"files-workspace",className:"flex h-full flex-col lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"border-b border-outline-variant bg-background px-4 py-3",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Workspace"}),i.jsx("h1",{className:"font-headline text-xl font-bold tracking-tight text-on-surface",children:"Files"})]}),i.jsxs("div",{className:"flex flex-1 min-h-0 flex-col sm:flex-row",children:[i.jsxs("aside",{"data-testid":"files-tree-pane",className:"w-full max-h-48 shrink-0 overflow-y-auto border-b border-outline-variant bg-background sm:w-72 sm:max-h-none sm:border-b-0 sm:border-r",children:[i.jsx(zNe,{roots:e.data,isLoading:e.isLoading,selectedRoot:n,onSelect:s,workspace:t.data??null}),n&&i.jsxs(i.Fragment,{children:[i.jsx(HNe,{root:n,path:r,onNavigate:a}),i.jsx(UNe,{root:n,path:r,onEnterDir:m=>{a(m),c(null)},onSelectFile:m=>{c(m),h(!1)},selectedFile:o})]})]}),i.jsxs("main",{"data-testid":"files-content-pane",className:"flex-1 min-w-0 overflow-y-auto bg-surface-lowest",children:[!n&&i.jsx("div",{className:"m-auto p-4 font-mono text-[10px] text-on-surface-variant",children:"Select an allowlist root to browse."}),n&&!o&&i.jsx("div",{className:"p-4 font-mono text-[10px] text-on-surface-variant","data-testid":"files-no-selection",children:"Select a file from the tree."}),n&&o&&i.jsx(VNe,{root:n,path:o,editMode:d,onToggleEditMode:()=>h(m=>!m)})]})]})]})}function zNe({roots:e,isLoading:t,selectedRoot:n,onSelect:s,workspace:r}){return t?i.jsx("div",{className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading roots…"}):e?oW(e)?i.jsxs("div",{"data-testid":"files-roots-unavailable",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:[i.jsx("div",{children:"Files routes unavailable."}),e.hint&&i.jsx("div",{className:"mt-1 text-on-surface-variant",children:e.hint})]}):e.roots.length===0?i.jsxs("div",{"data-testid":"files-roots-empty",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:[i.jsx("div",{children:"No allowlist roots configured."}),e.hint&&i.jsx("div",{className:"mt-1 text-on-surface-variant",children:e.hint})]}):i.jsxs("div",{"data-testid":"files-root-selector",className:"border-b border-outline-variant p-2",children:[i.jsx("div",{className:"mb-1 font-mono text-[8px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Roots"}),i.jsx("ul",{children:e.roots.map(a=>{const o=DNe(a.path,r);return i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`files-root-${a.name}`,"data-active":n===a.name,onClick:()=>s(a.name),className:`flex w-full items-center justify-between gap-2 px-2 py-1 text-left font-mono text-[10px] hover:bg-surface-low ${n===a.name?"bg-surface-high/80 text-on-surface":"text-on-surface"}`,title:a.path,children:[i.jsx("span",{className:"truncate",children:a.name}),o&&i.jsx(PNe,{kind:o,compact:!0})]})},a.name)})})]}):null}function HNe({root:e,path:t,onNavigate:n}){const s=t?t.split("/"):[];return i.jsxs("nav",{"data-testid":"files-breadcrumbs",className:"flex flex-wrap items-baseline gap-1 border-b border-outline-variant px-2 py-1 font-mono text-[10px] text-on-surface",children:[i.jsx("button",{type:"button",onClick:()=>n(""),className:"font-bold hover:underline",children:e}),s.map((r,a)=>{const o=s.slice(0,a+1).join("/");return i.jsxs("span",{children:[i.jsx("span",{className:"mx-0.5 text-on-surface-variant",children:"/"}),i.jsx("button",{type:"button",onClick:()=>n(o),className:"hover:underline",children:r})]},o)})]})}function UNe({root:e,path:t,onEnterDir:n,onSelectFile:s,selectedFile:r}){var o;const a=ep(e,t);return a.isLoading?i.jsx("div",{className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):a.isError?i.jsx("div",{"data-testid":"files-list-error",className:"p-3 font-mono text-[10px] text-red-600",children:((o=a.error)==null?void 0:o.message)??"Error loading directory."}):!a.data||a.data.entries.length===0?i.jsx("div",{className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Empty directory."}):i.jsxs("ul",{"data-testid":"files-directory-tree",className:"p-1",children:[t&&i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":"files-up",onClick:()=>n(XNe(t)),className:"block w-full px-2 py-1 text-left font-mono text-[10px] text-on-surface-variant hover:bg-surface-low",children:".."})}),a.data.entries.map(c=>{const d=t?`${t}/${c.name}`:c.name,h=c.type==="file",m=r===d;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`files-entry-${d}`,"data-type":c.type,onClick:()=>h?s(d):c.type==="dir"?n(d):void 0,disabled:c.type==="other",className:`block w-full px-2 py-1 text-left font-mono text-[10px] ${c.type==="other"?"text-on-surface-variant":`hover:bg-surface-low ${m?"bg-surface-high/80 text-on-surface":"text-on-surface"}`}`,children:c.type==="dir"?`▸ ${c.name}`:c.name})},d)})]})}function VNe({root:e,path:t,editMode:n,onToggleEditMode:s}){var a;const r=PE(e,t);return i.jsxs("div",{"data-testid":"files-content-panel",className:"flex h-full flex-col",children:[i.jsxs("header",{className:"flex items-center justify-between border-b border-outline-variant bg-background px-3 py-2 font-mono text-[10px]",children:[i.jsxs("div",{className:"text-on-surface","data-testid":"files-content-path",children:[e,"/",t]}),i.jsxs("div",{className:"flex items-center gap-3 text-on-surface-variant",children:[r.data&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-testid":"files-content-size",children:[r.data.size,"b"]}),i.jsx("span",{"data-testid":"files-content-mtime",children:r.data.mtime})]}),i.jsx("button",{type:"button","data-testid":"files-edit-toggle","data-active":n,onClick:s,className:`border px-2 py-0.5 font-mono text-[9px] uppercase tracking-[0.10em] ${n?"border-amber-400 bg-amber-50 text-amber-900":"border-outline-variant text-on-surface hover:bg-surface-low"}`,children:n?"editing":"edit"})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[r.isLoading&&i.jsx("div",{className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}),r.isError&&i.jsx("div",{"data-testid":"files-read-error",className:"p-4 font-mono text-[10px] text-red-600",children:((a=r.error)==null?void 0:a.message)??"Error loading file."}),r.data&&(n?i.jsx(YNe,{root:e,path:t,read:r.data}):i.jsx(WNe,{root:e,path:t,read:r.data}))]})]})}function WNe({root:e,path:t,read:n}){const s=QNe(t),r=GNe(t);return BNe.has(s)?i.jsxs("div",{"data-testid":"files-image-view",className:"p-4",children:[i.jsx(Xg,{read:n}),i.jsx("img",{src:sa(e,t),alt:t,className:"max-w-full border border-outline-variant"})]}):s===".md"?i.jsxs("div",{className:"p-4",children:[i.jsx(Xg,{read:n}),i.jsx(Zn,{content:n.content})]}):$Ne.has(s)?i.jsxs("div",{"data-testid":"files-code-view",className:"p-4",children:[i.jsx(Xg,{read:n}),r&&i.jsx(KNe,{kind:r,yaml:n.content}),i.jsx(Dv,{code:n.content,language:s.slice(1)})]}):qNe.has(s)?i.jsx("div",{"data-testid":"files-download-only",className:"p-4 font-mono text-[10px] text-on-surface",children:i.jsxs("a",{href:sa(e,t),download:!0,className:"text-blue-700 underline",children:["Download ",t]})}):i.jsxs("div",{"data-testid":"files-text-fallback",className:"p-4",children:[i.jsx(Xg,{read:n}),i.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[10px] text-on-surface",children:n.content})]})}function Xg({read:e}){if(!e.truncated)return null;const t=Math.round((e.totalBytes??e.size)/1024);return i.jsxs("div",{"data-testid":"files-truncation-marker","data-truncated-at-bytes":e.truncatedAtBytes??"","data-total-bytes":e.totalBytes??"",className:"mb-3 border border-amber-400 bg-amber-50 px-3 py-2 font-mono text-[10px] text-amber-900",children:["⚠ Truncated by file viewer at ",Math.round((e.truncatedAtBytes??0)/1024)," KB — file is ",t," KB total. Use an external editor for full content."]})}function GNe(e){const t=e.toLowerCase();return t.endsWith("/rig.yaml")||t==="rig.yaml"||t.endsWith("/rig.yml")||t==="rig.yml"?"rig":t.endsWith("/agent.yaml")||t==="agent.yaml"||t.endsWith("/agent.yml")||t==="agent.yml"?"agent":null}function KNe({kind:e,yaml:t}){var a;const n=INe(e,t);if(n.isLoading)return i.jsxs("div",{"data-testid":"files-spec-validation-loading",className:"mb-3 border border-outline-variant bg-background px-3 py-2 font-mono text-[10px] text-on-surface-variant",children:["Validating ",e,".yaml…"]});if(n.isError)return i.jsxs("div",{"data-testid":"files-spec-validation-error",className:"mb-3 border border-red-400 bg-red-50 px-3 py-2 font-mono text-[10px] text-red-900",children:["Validation failed to run: ",((a=n.error)==null?void 0:a.message)??"unknown error"]});if(!n.data)return null;const s=n.data.errors??[],r=s.length===0;return i.jsxs("div",{"data-testid":"files-spec-validation-panel","data-spec-kind":e,"data-valid":r,className:`mb-3 border px-3 py-2 font-mono text-[10px] ${r?"border-emerald-400 bg-emerald-50 text-emerald-900":"border-red-400 bg-red-50 text-red-900"}`,children:[i.jsx("div",{className:"mb-1 font-bold uppercase tracking-[0.10em]",children:r?`✓ Valid ${e==="rig"?"RigSpec":"AgentSpec"}`:`✗ ${e==="rig"?"RigSpec":"AgentSpec"} validation errors`}),s.length>0&&i.jsx("ul",{className:"space-y-1",children:s.map((o,c)=>i.jsxs("li",{"data-testid":`files-spec-validation-error-${c}`,className:"text-[10px]",children:[o.field&&i.jsxs("span",{className:"font-bold",children:[o.field,": "]}),o.message]},c))})]})}function YNe({root:e,path:t,read:n}){const[s,r]=C.useState(n.content),[a,o]=C.useState(null),[c,d]=C.useState(null),[h,m]=C.useState(!1),f=ete(),g=mt();C.useEffect(()=>{r(n.content),d(null)},[n.contentHash,n.mtime,n.content]);const x=C.useMemo(()=>s!==n.content,[s,n.content]);return i.jsxs("div",{"data-testid":"files-editor",className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-outline-variant bg-amber-50 px-3 py-1.5 font-mono text-[9px]",children:[i.jsx("span",{className:"font-bold text-amber-900","data-testid":"files-editor-status",children:x?"draft (unsaved)":"no changes"}),i.jsx("button",{type:"button","data-testid":"files-editor-save",disabled:!x||f.isPending,onClick:()=>{o(null),d(null),m(!1),f.mutate({root:e,path:t,content:s,expectedMtime:n.mtime,expectedContentHash:n.contentHash,actor:"ui-files-edit-mode"},{onSuccess:y=>{"conflict"in y?d({currentMtime:y.currentMtime,currentContentHash:y.currentContentHash}):(m(!0),setTimeout(()=>m(!1),2e3))},onError:y=>{o(y instanceof Error?y.message:String(y))}})},className:"border border-emerald-500 bg-emerald-50 px-2 py-0.5 uppercase tracking-[0.10em] text-emerald-900 disabled:cursor-not-allowed disabled:opacity-50",children:"save"}),i.jsx("button",{type:"button","data-testid":"files-editor-cancel",onClick:()=>{r(n.content),o(null),d(null)},className:"border border-outline bg-surface-lowest px-2 py-0.5 uppercase tracking-[0.10em] text-on-surface",children:"cancel"}),h&&i.jsx("span",{"data-testid":"files-editor-saved",className:"ml-auto text-emerald-700",children:"saved"})]}),c&&i.jsxs("div",{"data-testid":"files-editor-conflict",className:"flex items-center gap-2 border-b border-red-200 bg-red-50 px-3 py-2 font-mono text-[10px] text-red-900",children:[i.jsxs("span",{className:"flex-1",children:["File changed externally. Local mtime ",i.jsx("code",{children:n.mtime})," ≠ server ",i.jsx("code",{children:c.currentMtime}),". Click Refresh to re-read the file (your draft will be replaced with the new server content; copy it elsewhere first if you need to re-apply)."]}),i.jsx("button",{type:"button","data-testid":"files-editor-refresh",onClick:()=>{g.invalidateQueries({queryKey:["files","read",e,t]})},className:"border border-red-500 bg-surface-lowest px-2 py-0.5 uppercase tracking-[0.10em] text-red-900",children:"refresh"})]}),a&&i.jsxs("div",{"data-testid":"files-editor-error",className:"border-b border-red-200 bg-red-50 px-3 py-2 font-mono text-[10px] text-red-900",children:["Save failed: ",a]}),i.jsx("textarea",{"data-testid":"files-editor-textarea",value:s,onChange:y=>r(y.target.value),className:"flex-1 min-h-0 resize-none border-0 bg-background p-3 font-mono text-[11px] leading-relaxed text-on-surface outline-none",spellCheck:!1})]})}function QNe(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t).toLowerCase()}function XNe(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Fy({testId:e,title:t,children:n}){return i.jsxs("div",{"data-testid":e,className:"mx-auto w-full max-w-[960px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Configuration"}),i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface mt-1",children:t})]}),n]})}function ZNe(){return i.jsx(Fy,{testId:"settings-center",title:"Settings",children:i.jsx(sz,{})})}const b8="policies.claude_compaction.enabled",_8="policies.claude_compaction.threshold_percent",w8="policies.claude_compaction.pre_compact_instruction",S8="policies.claude_compaction.compact_instruction",j8="policies.claude_compaction.message_inline",N8="policies.claude_compaction.message_file_path",k8="policies.claude_compaction.post_restore_audit_instruction";function JNe(e,t){return typeof e=="boolean"?e:e==="true"?!0:e==="false"?!1:t}function eke(e,t){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){const n=Number(e);if(!Number.isNaN(n))return n}return t}function Oh(e){return typeof e=="string"?e:e==null?"":String(e)}function tke(){const{data:e,isLoading:t,error:n}=mr(),s=Nv();return e?i.jsx(nke,{data:e.settings,setSetting:s}):i.jsxs("section",{"data-testid":"claude-compaction-policy-form",className:"border border-outline-variant p-5 bg-surface-lowest/50",children:[i.jsx(ct,{tone:"muted",children:"Policy"}),i.jsx("h2",{className:"font-headline text-headline-sm font-bold tracking-tight uppercase text-on-surface mt-1",children:"Claude Auto-Compaction"}),t&&i.jsx("p",{className:"mt-4 text-sm text-on-surface-variant","data-testid":"claude-compaction-policy-loading",children:"Loading current settings…"}),n&&i.jsx("p",{className:"mt-4 text-sm text-error","data-testid":"claude-compaction-policy-error",children:n instanceof Error?n.message:String(n)})]})}function nke({data:e,setSetting:t}){const[n,s]=C.useState(()=>{var f,g,x,y,b,_,w;return{enabled:JNe((f=e[b8])==null?void 0:f.value,!1),thresholdPercent:String(eke((g=e[_8])==null?void 0:g.value,80)),preCompactInstruction:Oh((x=e[w8])==null?void 0:x.value),compactInstruction:Oh((y=e[S8])==null?void 0:y.value),messageInline:Oh((b=e[j8])==null?void 0:b.value),messageFilePath:Oh((_=e[N8])==null?void 0:_.value),postRestoreAuditInstruction:Oh((w=e[k8])==null?void 0:w.value)}}),[r,a]=C.useState(null),[o,c]=C.useState(null),[d,h]=C.useState(!1);async function m(f){f.preventDefault(),h(!1),c(null);const g=n.thresholdPercent.trim(),x=Number(g);if(!/^\d+$/.test(g)||x<1||x>100){a("Threshold must be an integer between 1 and 100.");return}a(null);const y=[{key:b8,value:n.enabled?"true":"false"},{key:_8,value:String(x)},{key:w8,value:n.preCompactInstruction},{key:S8,value:n.compactInstruction},{key:j8,value:n.messageInline},{key:N8,value:n.messageFilePath},{key:k8,value:n.postRestoreAuditInstruction}];try{for(const b of y)await t.mutateAsync(b);h(!0)}catch(b){c(b instanceof Error?b.message:String(b))}}return i.jsxs("section",{"data-testid":"claude-compaction-policy-form",className:"border border-outline-variant p-5 bg-surface-lowest/50",children:[i.jsx(ct,{tone:"muted",children:"Policy"}),i.jsx("h2",{className:"font-headline text-headline-sm font-bold tracking-tight uppercase text-on-surface mt-1",children:"Claude Auto-Compaction"}),i.jsxs("p",{className:"mt-2 text-sm text-on-surface-variant max-w-prose",children:["When a Claude seat's context usage crosses the configured threshold, OpenRig first sends a preparation message, then sends",i.jsx("code",{className:"font-mono text-[12px]",children:" /compact"})," on the next eligible observation. After compaction, OpenRig sends one restore prompt that points the seat at its restore packet, followed by a read-depth audit prompt."]}),i.jsxs("form",{className:"mt-4 flex flex-col gap-5",onSubmit:m,"data-testid":"claude-compaction-policy-form-element",children:[i.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-on-surface",children:[i.jsx("input",{type:"checkbox","data-testid":"claude-compaction-enabled",checked:n.enabled,onChange:f=>s(g=>({...g,enabled:f.target.checked}))}),i.jsx("span",{children:"Enable automatic pre-compaction trigger"})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-threshold",className:"text-sm font-medium text-on-surface",children:"Threshold percentage"}),i.jsx("input",{id:"claude-compaction-threshold","data-testid":"claude-compaction-threshold",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:n.thresholdPercent,onChange:f=>s(g=>({...g,thresholdPercent:f.target.value})),className:"border border-outline-variant px-2 py-1 w-32 font-mono text-sm","aria-describedby":"claude-compaction-threshold-hint"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Preparation starts when context usage is at-or-above this percentage (1–100)."}),r&&i.jsx("span",{className:"text-xs text-error","data-testid":"claude-compaction-threshold-error",children:r})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-pre-compact-instruction",className:"text-sm font-medium text-on-surface",children:"Pre-compaction prep message"}),i.jsx("textarea",{id:"claude-compaction-pre-compact-instruction","data-testid":"claude-compaction-pre-compact-instruction",rows:4,value:n.preCompactInstruction,onChange:f=>s(g=>({...g,preCompactInstruction:f.target.value})),placeholder:"Read the claude-compaction-restore skill and prepare for compaction.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"OpenRig wraps this with the current context usage, threshold, and operator-authorized user-channel framing."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-compact-instruction",className:"text-sm font-medium text-on-surface",children:"Compaction instruction"}),i.jsx("textarea",{id:"claude-compaction-compact-instruction","data-testid":"claude-compaction-compact-instruction",rows:3,value:n.compactInstruction,onChange:f=>s(g=>({...g,compactInstruction:f.target.value})),placeholder:"Optional. Sent as /compact <instruction> when OpenRig triggers compaction.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Optional advanced override. Leave blank to rely on Claude's native compaction summary; OpenRig still appends a trust-channel note."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-inline",className:"text-sm font-medium text-on-surface",children:"Post-compaction restore instruction (inline)"}),i.jsx("textarea",{id:"claude-compaction-inline","data-testid":"claude-compaction-message-inline",rows:4,value:n.messageInline,onChange:f=>s(g=>({...g,messageInline:f.target.value})),placeholder:"Optional override. Leave blank to use the instruction file path below.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Default asks Claude to read the claude-compaction-restore skill. OpenRig wraps this with marker, transcript, and current-task framing."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-file",className:"text-sm font-medium text-on-surface",children:"Post-compaction restore instruction (file path)"}),i.jsx("input",{id:"claude-compaction-file","data-testid":"claude-compaction-message-file-path",type:"text",value:n.messageFilePath,onChange:f=>s(g=>({...g,messageFilePath:f.target.value})),placeholder:"Path read at hook-fire time for extra restore instructions.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Default points at a user-owned placeholder file. Put mission-specific reading lists or extra restore notes there without changing the canonical skill."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-post-restore-audit",className:"text-sm font-medium text-on-surface",children:"Post-restore audit message"}),i.jsx("textarea",{id:"claude-compaction-post-restore-audit","data-testid":"claude-compaction-post-restore-audit-instruction",rows:4,value:n.postRestoreAuditInstruction,onChange:f=>s(g=>({...g,postRestoreAuditInstruction:f.target.value})),placeholder:"Read the claude-compaction-restore skill and audit restore read depth.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"OpenRig wraps this with the required FULL/PARTIAL/NOT_READ table and no-token-conservation language."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{type:"submit","data-testid":"claude-compaction-policy-submit",disabled:t.isPending,className:"border border-outline px-4 py-2 bg-inverse-surface text-background font-medium text-sm disabled:opacity-60",children:t.isPending?"Saving…":"Save policy"}),d&&i.jsx("span",{className:"text-sm text-success","data-testid":"claude-compaction-policy-saved",children:"Saved."}),o&&i.jsx("span",{className:"text-sm text-error","data-testid":"claude-compaction-policy-submit-error",children:o})]})]})]})}function ske(){return i.jsxs(Fy,{testId:"settings-page-policies",title:"Policies",children:[i.jsx("p",{className:"mb-6 text-sm text-on-surface-variant max-w-prose",children:"Opt-in policies that affect agent runtime behavior. Each policy ships disabled by default and can be turned on independently."}),i.jsx("div",{className:"flex flex-col gap-6",children:i.jsx(tke,{})})]})}const rke=["summary","body","detail","message","title","text","description"],ike=new Set(["ts","ts_created","ts_updated","ts_emitted","created_at","updated_at","received_at","stream_sort_key","audit_pointer"]);function G2(e,t=40){return e.length<=t?e:e.slice(0,t-1)+"…"}function ake(e){if(e==null)return null;if(typeof e=="string"){const t=e.trim();return t.length>0?G2(t):null}return typeof e=="number"||typeof e=="boolean"?String(e):null}function C8(e){if(!e||typeof e!="object")return"—";const t=e;for(const s of rke){const r=t[s];if(typeof r=="string"&&r.trim().length>0)return G2(r.trim(),200)}const n=[];for(const[s,r]of Object.entries(t)){if(ike.has(s))continue;const a=ake(r);if(a!==null&&(n.push(`${s}=${a}`),n.length>=4))break}if(n.length>0)return n.join(" · ");try{const s=JSON.stringify(t);return G2(s,200)}catch{return"—"}}function oke(){const{events:e}=KE();return i.jsx(Fy,{testId:"settings-page-log",title:"Log",children:e.length===0?i.jsx(Ae,{label:"LOG IS QUIET",description:"Activity events from rigs will stream here.",variant:"card",testId:"settings-log-empty"}):i.jsx("ul",{"data-testid":"settings-log-stream",className:"divide-y divide-outline-variant border border-outline-variant max-h-[60vh] overflow-y-auto",children:e.slice(0,100).map(t=>i.jsxs("li",{className:"px-3 py-2 flex items-baseline gap-3 font-mono text-xs",children:[i.jsx("span",{className:"text-on-surface-variant text-[10px] uppercase tracking-wide w-32 shrink-0 truncate",children:t.type}),i.jsx("span",{className:"text-on-surface truncate",title:C8(t.payload),children:C8(t.payload)})]},t.seq))})})}async function lke(){if(!(await fetch("/healthz")).ok)throw new Error("unhealthy");return!0}async function cke(){const e=await fetch("/api/adapters/cmux/status");if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}function uke(){var g;const e=Re({queryKey:["daemon","health"],queryFn:lke,refetchInterval:1e4,retry:!1}),t=Re({queryKey:["daemon","cmux"],queryFn:cke,refetchInterval:3e4,retry:!1}),{data:n,isLoading:s,error:r}=Dr(),{data:a}=Qf(),o=e.isSuccess,c=o?((g=t.data)==null?void 0:g.available)??null:null,d=(n==null?void 0:n.length)??0,h=(a==null?void 0:a.filter(x=>x.runningCount>0).length)??0,m=o?"active":e.isError?"error":e.isLoading?"info":"stopped",f=c===!0?"active":c===!1?"warning":"info";return i.jsxs("div",{"data-testid":"settings-status-panel",className:"space-y-4",children:[i.jsxs("section",{children:[i.jsx(ct,{tone:"muted",children:"Daemon"}),i.jsxs("div",{className:"mt-2 flex items-center justify-between font-mono text-xs",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Reachable"}),i.jsx(To,{status:m,label:o?"OK":e.isError?"ERROR":e.isLoading?"LOADING":"DISCONNECTED",variant:"pill",testId:"status-daemon"})]})]}),i.jsxs("section",{children:[i.jsx(ct,{tone:"muted",children:"Cmux control"}),i.jsxs("div",{className:"mt-2 flex items-center justify-between font-mono text-xs",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Adapter"}),i.jsx(To,{status:f,label:c===!0?"AVAILABLE":c===!1?"UNAVAILABLE":"UNKNOWN",variant:"pill",testId:"status-cmux"})]}),i.jsx("div",{className:"mt-1 font-mono text-[10px] text-on-surface-variant",children:"OpenRig can control cmux surfaces for node open-or-focus."})]}),i.jsxs("section",{children:[i.jsx(ct,{tone:"muted",children:"Rigs"}),i.jsxs("div",{className:"mt-2 space-y-1.5 font-mono text-xs",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Total"}),i.jsx("span",{className:"text-on-surface font-bold","data-testid":"status-rigs-total",children:d})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Running"}),i.jsx("span",{className:"text-on-surface font-bold","data-testid":"status-rigs-running",children:h})]})]})]})]})}function dke(){return i.jsx(Fy,{testId:"settings-page-status",title:"Status",children:i.jsx(uke,{})})}function AT({tabs:e,active:t,onSelect:n,testIdPrefix:s="topology-view-mode",trailing:r}){const a=i.jsx("div",{role:"tablist","aria-label":"Topology view modes","data-testid":`${s}-tabs`,className:"flex gap-6 items-center",children:e.map(o=>i.jsx("button",{type:"button",role:"tab","aria-selected":t===o.id,"data-testid":`${s}-tab-${o.id}`,"data-active":t===o.id,onClick:()=>n(o.id),className:ce("py-3 font-mono text-[10px] uppercase tracking-[0.18em] border-b-2",t===o.id?"border-on-surface text-on-surface":"border-transparent text-on-surface-variant hover:text-on-surface"),children:o.label},o.id))});return r?i.jsxs("div",{"data-testid":`${s}-tab-bar`,className:"flex items-center",children:[a,i.jsx("div",{"data-testid":`${s}-trailing`,className:"ml-auto",children:r})]}):a}const hke=[{id:"graph",label:"Graph"},{id:"table",label:"Table"},{id:"terminal",label:"Terminal"}],lW=[{id:"graph",label:"Graph"},{id:"table",label:"Table"},{id:"terminal",label:"Terminal"},{id:"overview",label:"Overview"}];/**
592
+ `);for(const a of n)if(r.includes(a.name))return a.name;return null}function Qje(e){const t=(e==null?void 0:e.tests.proofPackets.find(n=>n.screenshots.length>0))??(e==null?void 0:e.tests.proofPackets[0]);return!e||!t||t.screenshots.length===0?null:{sliceName:e.name,displayName:e.displayName||e.name,passFailBadge:t.passFailBadge,screenshots:t.screenshots}}function Xje(){var W;const{events:e}=KE(),[t,n]=C.useState("all"),s=WE(),[r,a]=C.useState(()=>new Map),o=C.useCallback((K,X)=>{a(ne=>{const se=new Map(ne);return se.set(K,X),se})},[]),c=s.anyRemoteEnabled,[d,h]=C.useState(null),m=jSe(50,c),f=C.useMemo(()=>{var K;return((K=m.data)==null?void 0:K.hosts)??[]},[m.data]),g=C.useMemo(()=>{var K;return(((K=m.data)==null?void 0:K.items)??[]).map(LSe)},[m.data]),x=qSe(),y=C.useMemo(()=>(x.data??[]).map(BSe),[x.data]),b=C.useMemo(()=>ASe(e).slice(0,Hje),[e]),_=C.useMemo(()=>[...g,...y],[g,y]),w=C.useMemo(()=>ISe(OSe(b,_)),[b,_]),E=C.useMemo(()=>$Se(w),[w]),N=C.useMemo(()=>w.map(K=>K.id),[w]),{dismissedSeqs:k,dismiss:R,undismiss:A}=WSe(E),{dismissedIds:T,dismiss:I,undismiss:M}=KSe(N),[P,L]=C.useState(null),D=C.useCallback(K=>{hv(K)?(I(K.id),L({kind:"id",id:K.id})):(R(K.source.seq),L({kind:"seq",seq:K.source.seq}))},[R,I]),q=C.useCallback(()=>{P!==null&&(P.kind==="seq"?A(P.seq):M(P.id),L(null))},[P,A,M]),B=C.useCallback(()=>{L(null)},[]),F=C.useMemo(()=>w.map(Yg).filter(K=>!!K),[w]),$=LE(F),U=WV({limit:200}),V=C.useMemo(()=>{var K;return Gje(((K=U.data)==null?void 0:K.rows)??[])},[(W=U.data)==null?void 0:W.rows]),Y=C.useMemo(()=>{const X=w.map(ie=>{const ge=Yg(ie),ye=ge?$.itemsById.get(ge):void 0,be=ge?V.get(ge):void 0,me=Yje(ie,ye,be);return me===ie.kind?ie:{...ie,kind:me}}).filter(ie=>Lne(ie.kind,s.state)),ne=t==="all"?X:X.filter(ie=>ie.kind===t);return(d===null?ne:ne.filter(ie=>(ie.hostId??"local")===d)).filter(ie=>hv(ie)?!T.has(ie.id):!k.has(ie.source.seq))},[w,t,d,$.itemsById,V,s.state,k,T]),Q=Zf("all"),z=C.useMemo(()=>!Q.data||"unavailable"in Q.data?[]:Q.data.slices,[Q.data]),G=C.useMemo(()=>{const K=new Set;for(const X of Y){if(X.kind!=="shipped")continue;const ne=Yg(X),se=ne?$.itemsById.get(ne):void 0,ie=g8(X,se,z);ie&&K.add(ie)}return Array.from(K)},[Y,$.itemsById,z]),ee=TF(G);return i.jsxs("div",{"data-testid":"for-you-feed",className:"mx-auto w-full max-w-[720px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Attention"}),i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface mt-1",children:"For You"})]}),i.jsx("div",{"data-testid":"feed-level-control",className:"mb-4",children:i.jsx(USe,{})}),i.jsx("div",{"data-testid":"feed-lens-chips",role:"toolbar","aria-label":"Feed filters",className:"flex flex-wrap gap-1 mb-4",children:zje.map(K=>i.jsx("button",{type:"button","data-testid":`feed-lens-${K.id}`,"data-active":t===K.id,onClick:()=>n(K.id),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",t===K.id?"border-on-surface bg-inverse-surface text-background":"border-outline-variant text-on-surface-variant hover:bg-surface-low"),children:K.label},K.id))}),f.length>0&&i.jsxs("div",{"data-testid":"feed-host-chips",role:"toolbar","aria-label":"Host filter",className:"flex flex-wrap gap-1 mb-2",children:[i.jsx("button",{type:"button","data-testid":"feed-host-all","data-active":d===null,onClick:()=>h(null),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",d===null?"border-on-surface bg-inverse-surface text-background":"border-outline-variant text-on-surface-variant hover:bg-surface-low"),children:"ALL HOSTS"}),f.map(K=>i.jsxs("button",{type:"button","data-testid":`feed-host-${K.hostId}`,"data-active":d===K.hostId,"data-host-status":K.status,onClick:()=>h(d===K.hostId?null:K.hostId),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",d===K.hostId?"border-on-surface bg-inverse-surface text-background":"border-outline-variant text-on-surface-variant hover:bg-surface-low",K.status!=="ok"&&"opacity-60"),children:[K.hostId,K.status!=="ok"?` · ${K.status}`:""]},K.hostId))]}),f.filter(K=>K.status!=="ok").map(K=>i.jsxs("div",{"data-testid":`feed-host-status-${K.hostId}`,className:"mb-2 border border-outline-variant px-2 py-1 font-mono text-[9px] text-on-surface-variant",children:[K.hostId,": ",K.status,K.error?` — ${K.error}`:""," (other hosts' items unaffected)"]},`status-${K.hostId}`)),Y.length===0?i.jsx(Ae,{label:p8[t].label,description:p8[t].description,variant:"card",testId:"for-you-empty"}):i.jsx("div",{"data-testid":"for-you-feed-cards",children:Y.map(K=>{const X=Yg(K),ne=X?$.itemsById.get(X):void 0,se=K.kind==="shipped"?g8(K,ne,z):null,ie=se?Qje(ee.itemsByName.get(se)):null,ge=X?r.get(X)??V.get(X)??null:null;return i.jsx(qje,{card:K,queueItem:ne,proofPreview:ie,actionOutcome:ge,onDismiss:D,onOptimisticOutcome:o},K.id)})}),P!==null?i.jsx(Fje,{label:"Card dismissed",onUndo:q,onExpire:B,durationMs:5e3},P.kind==="seq"?`seq-${P.seq}`:`id-${P.id}`):null]})}const Zje=[{label:"+ Add spec",to:"/specs/rig",testId:"specs-toolbar-add"},{label:"Import",to:"/import",testId:"specs-toolbar-import"},{label:"Discover",to:"/search",testId:"specs-toolbar-discover"},{label:"Create rig",to:"/specs/rig",testId:"specs-toolbar-create-rig"},{label:"Generate workflow",to:"/specs/agent",testId:"specs-toolbar-gen-workflow"}];function Qg(e){return e.status==="error"?{id:e.id,label:e.name,meta:e.errorMessage??"Invalid workflow YAML",status:"error"}:{id:e.id,label:e.name,entryId:e.id}}function Jje(e){return{id:e.id,label:e.name,entryId:e.id}}function eNe(e){const t=[`v${e.version}`];return e.derivedEstimatedTokens>0&&t.push(`~${e.derivedEstimatedTokens} tok`),e.stats.forkCount>0&&t.push(`forks: ${e.stats.forkCount}`),e.stats.lastUsedAt&&t.push(`used: ${tNe(e.stats.lastUsedAt)}`),{id:e.id,label:e.name,meta:t.join(" · "),entryId:e.id}}function tNe(e){const t=Date.now()-new Date(e).getTime();if(t<0)return"just now";const n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function cl({id:e,title:t,rows:n,isLoading:s,emptyLabel:r,badge:a}){return i.jsxs("section",{"data-testid":`library-section-${e}`,className:"border border-outline-variant bg-surface-lowest/25 hard-shadow",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2",children:[i.jsx(ct,{tone:"default",children:t}),i.jsx("span",{"data-testid":`library-section-${e}-badge`,className:"shrink-0 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:s?"loading":a??`${n.length} items`})]}),n.length>0?i.jsx("ul",{className:"divide-y divide-outline-variant",children:n.map(o=>i.jsx("li",{children:o.entryId?i.jsx(Ve,{to:"/specs/library/$entryId",params:{entryId:o.entryId},"data-testid":`library-row-${e}-${o.id}`,className:"block px-3 py-2 hover:bg-surface-low/50",children:i.jsx(x8,{row:o})}):i.jsx("div",{"data-testid":`library-row-${e}-${o.id}`,"data-status":o.status,className:`px-3 py-2 ${o.status==="error"?"bg-red-50/40 text-red-900":""}`,children:i.jsx(x8,{row:o})})},o.id))}):i.jsx("div",{className:"px-3 py-4 font-mono text-[10px] text-on-surface-variant",children:s?"Loading...":r??"No entries."})]})}function nNe(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB","TB"],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024))),s=e/Math.pow(1024,n);return`${n===0?s:s.toFixed(s>=100||n===0?0:1)} ${t[n]}`}function x8({row:e}){return i.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3 font-mono",children:[i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:e.label}),e.meta?i.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:e.meta}):null]})}function sNe({plugins:e,isLoading:t}){return i.jsxs("section",{id:"library-plugins","data-testid":"library-section-plugins",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2",children:[i.jsx(ct,{tone:"default",children:"Plugins"}),i.jsx("span",{className:"shrink-0 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${e.length} plugins`})]}),e.length===0?i.jsx("div",{className:"px-3 py-4",children:i.jsx(Ae,{label:t?"LOADING":"NO PLUGINS DISCOVERED",description:t?"Loading plugins...":"Install a Claude Code or Codex plugin (or wait for openrig-core to vendor) to see it appear here.",variant:"card",testId:"library-plugins-empty"})}):i.jsx("ul",{className:"divide-y divide-outline-variant",children:e.map(n=>i.jsx("li",{children:i.jsx(Ve,{to:"/plugins/$pluginId",params:{pluginId:n.id},"data-testid":`library-plugin-${n.id}`,className:"flex items-center gap-3 px-3 py-2 font-mono hover:bg-surface-low/50",children:i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${n.name} plugin`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:n.name})]})})},n.id))})]})}function rNe({skills:e,isLoading:t}){return i.jsxs("section",{id:"library-skills","data-testid":"library-section-skills",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2",children:[i.jsx(ct,{tone:"default",children:"Skills"}),i.jsx("span",{className:"shrink-0 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${e.length} folders`})]}),e.length===0?i.jsx("div",{className:"px-3 py-4",children:i.jsx(Ae,{label:t?"LOADING":"NO SKILLS FOUND",description:t?"Loading skill folders...":"No .openrig/skills or packaged OpenRig skill folders are visible through configured file roots.",variant:"card",testId:"library-skills-empty"})}):i.jsx("ul",{className:"divide-y divide-outline-variant",children:e.map(n=>i.jsx("li",{children:i.jsxs("a",{href:pne(n.id),"data-testid":`library-skill-${n.name}`,className:"flex items-center justify-between gap-3 px-3 py-2 font-mono hover:bg-surface-low/50",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${n.name} skill`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:n.name})]}),i.jsxs("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.08em] text-on-surface-variant",children:[n.files.length," files"]})]})},n.id))})]})}function rW(){const{data:e=[],isLoading:t}=np(),{data:n=[],isLoading:s}=UE(),{data:r=[],isLoading:a}=VE(),{data:o=[],isLoading:c}=Tv(),{data:d=[],isLoading:h}=Av(),m=C.useMemo(()=>{const x=e.filter(w=>w.kind==="rig"&&!w.hasServices).map(Qg),y=e.filter(w=>w.kind==="workflow").map(Qg),b=e.filter(w=>w.kind==="agent").map(Qg),_=e.filter(w=>w.kind==="rig"&&w.hasServices).map(Qg);return{rigSpecs:x,workflowSpecs:y,agentSpecs:b,applications:_}},[e]),f=C.useMemo(()=>{const x=r.length,y=r.reduce((b,_)=>{var w;return b+(((w=_.stats)==null?void 0:w.estimatedSizeBytes)??0)},0);return`${x} ${x===1?"image":"images"} · ${nNe(y)}`},[r]),g=m.rigSpecs.length+m.workflowSpecs.length+m.agentSpecs.length+m.applications.length+n.length+r.length+o.length;return i.jsxs("div",{"data-testid":"specs-library-page",className:"h-full overflow-y-auto bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"mb-5 flex items-start justify-between gap-4",children:[i.jsxs("div",{children:[i.jsx(ct,{tone:"muted",children:"Library"}),i.jsx("h1",{className:"mt-1 font-headline text-2xl font-bold tracking-tight text-on-surface",children:"Library"}),i.jsx("p",{className:"mt-1 max-w-3xl text-sm text-on-surface-variant",children:"Specs, context packs, agent images, applications, and skill folders."})]}),i.jsx("nav",{"aria-label":"Library actions",className:"flex flex-wrap justify-end gap-2",children:Zje.map(x=>i.jsx(Ve,{to:x.to,"data-testid":x.testId,className:"border border-outline-variant bg-surface-lowest/25 px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hard-shadow hover:bg-surface-lowest/40",children:x.label},x.testId))})]}),i.jsxs("div",{className:"mb-4 font-mono text-[10px] uppercase tracking-[0.14em] text-on-surface-variant",children:[g," library entries visible through current sources"]}),i.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[i.jsx(cl,{id:"rig-specs",title:"Rig Specs",rows:m.rigSpecs,isLoading:t,emptyLabel:"No rig specs found."}),i.jsx(cl,{id:"workspace-specs",title:"Workspace Specs",rows:[],emptyLabel:"No workspace specs source is wired yet."}),i.jsx(cl,{id:"workflow-specs",title:"Workflow Specs",rows:m.workflowSpecs,isLoading:t,emptyLabel:"No workflow specs found."}),i.jsx(cl,{id:"context-packs",title:"Context Packs",rows:n.map(Jje),isLoading:s,emptyLabel:"No context packs found."}),i.jsx(cl,{id:"agent-specs",title:"Agent Specs",rows:m.agentSpecs,isLoading:t,emptyLabel:"No agent specs found."}),i.jsx(cl,{id:"agent-images",title:"Agent Images",rows:r.map(eNe),isLoading:a,emptyLabel:"No agent images found.",badge:f}),i.jsx(cl,{id:"applications",title:"Applications",rows:m.applications,isLoading:t,emptyLabel:"No application specs found."})]}),i.jsxs("div",{className:"mt-4 space-y-4",children:[i.jsx(sNe,{plugins:d,isLoading:h}),i.jsx(rNe,{skills:o,isLoading:c})]})]})}async function iNe(e,t){const n=await fetch(`/api/skills/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}async function aNe(e,t){const n=await fetch(`/api/skills/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}function oNe(e,t){return Re({queryKey:["skill-files","list",e,t],queryFn:()=>iNe(e,t??""),enabled:!!e,staleTime:15e3})}function lNe(e,t){return Re({queryKey:["skill-files","read",e,t],queryFn:()=>aNe(e,t),enabled:!!e&&!!t,staleTime:15e3})}const cNe=new Set([".md",".mdx",".txt",".log",".yaml",".yml",".json",".js",".jsx",".ts",".tsx",".py",".sh",".bash",".css",".html"]);function uNe(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t).toLowerCase()}function v8(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function dNe(e,t){return e?`${e}/${t}`:t}function iW({skillToken:e,fileToken:t}){var x;const{data:n=[],isLoading:s}=Tv(),r=ZF(e),a=r?n.find(y=>y.id===r)??null:null,[o,c]=C.useState(""),[d,h]=C.useState(null),[m,f]=C.useState(!1);C.useEffect(()=>{if(!t||!a)return;const y=JF(t);y&&(c(v8(y)),h(y),f(!0))},[t,a]);const g=oNe((a==null?void 0:a.id)??null,o);return C.useEffect(()=>{if(m||o!==""||!g.data)return;const y=g.data.entries.find(b=>b.type==="file"&&/^skill\.md$/i.test(b.name));y&&h(y.name),f(!0)},[g.data,o,m]),s?i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"LOADING SKILL",description:"Loading skill files from the daemon skill library.",variant:"card",testId:"skill-detail-loading"})}):a?i.jsxs("div",{"data-testid":"skill-detail-page",className:"h-full overflow-hidden bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"mb-4",children:[i.jsx(ct,{tone:"muted",children:"Skill"}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-baseline gap-3",children:[i.jsx("h1",{className:"font-headline text-2xl font-bold tracking-tight text-on-surface",children:a.name}),i.jsx("span",{"data-testid":"skill-detail-source",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:a.source})]}),i.jsx("div",{"data-testid":"skill-detail-absolute-path",className:"mt-1 font-mono text-[10px] text-on-surface-variant truncate",title:a.absolutePath,children:a.absolutePath})]}),i.jsxs("div",{"data-testid":"skill-detail-docs-browser",className:"flex h-[calc(100%-5rem)] flex-col border border-outline-variant bg-surface-lowest/25 hard-shadow sm:flex-row",children:[i.jsxs("aside",{"data-testid":"skill-detail-tree",className:"w-full max-h-48 shrink-0 overflow-y-auto border-b border-outline-variant bg-surface-lowest/30 sm:w-64 sm:max-h-none sm:border-b-0 sm:border-r",children:[i.jsx(hNe,{testId:"skill-detail-breadcrumbs",skillName:a.name,path:o,onNavigate:y=>{c(y),h(null)}}),g.isLoading?i.jsx("div",{"data-testid":"skill-detail-tree-loading",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):g.isError?i.jsx("div",{"data-testid":"skill-detail-tree-error",className:"p-3 font-mono text-[10px] text-red-600",children:((x=g.error)==null?void 0:x.message)??"Error loading directory."}):!g.data||g.data.entries.length===0?i.jsx("div",{"data-testid":"skill-detail-tree-empty",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Empty directory."}):i.jsxs("ul",{className:"p-1",children:[o&&i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":"skill-detail-tree-up",onClick:()=>{c(v8(o)),h(null)},className:"block w-full px-2 py-1 text-left font-mono text-[10px] text-on-surface-variant hover:bg-surface-low",children:".."})}),g.data.entries.map(y=>{const b=dNe(o,y.name),_=y.type==="file",w=d===b;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`skill-detail-tree-entry-${b}`,"data-type":y.type,"data-active":w,onClick:()=>{_?h(b):y.type==="dir"&&(c(b),h(null))},disabled:y.type==="other",className:`block w-full px-2 py-1 text-left font-mono text-[10px] ${y.type==="other"?"text-on-surface-variant":`hover:bg-surface-low ${w?"bg-surface-high/80 text-on-surface":"text-on-surface"}`}`,children:y.type==="dir"?`▸ ${y.name}`:y.name})},b)})]})]}),i.jsx("main",{"data-testid":"skill-detail-viewer",className:"flex-1 min-w-0 overflow-y-auto bg-surface-lowest",children:d?i.jsx(fNe,{skillId:a.id,path:d}):i.jsx("div",{"data-testid":"skill-detail-viewer-no-selection",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Select a file from the tree."})})]})]}):i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"SKILL NOT FOUND",description:"The selected skill is not discoverable through the daemon skill library.",variant:"card",testId:"skill-detail-not-found"})})}function hNe({testId:e,skillName:t,path:n,onNavigate:s}){const r=n?n.split("/"):[];return i.jsxs("nav",{"data-testid":e,className:"flex flex-wrap items-baseline gap-1 border-b border-outline-variant px-2 py-1 font-mono text-[10px] text-on-surface",children:[i.jsx("button",{type:"button",onClick:()=>s(""),className:"font-bold hover:underline",children:t}),r.map((a,o)=>{const c=r.slice(0,o+1).join("/");return i.jsxs("span",{children:[i.jsx("span",{className:"mx-0.5 text-on-surface-variant",children:"/"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"hover:underline",children:a})]},c)})]})}function fNe({skillId:e,path:t}){var r;const n=lNe(e,t),s=C.useMemo(()=>uNe(t),[t]);return n.isLoading?i.jsx("div",{"data-testid":"skill-detail-viewer-loading",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):n.isError?i.jsx("div",{"data-testid":"skill-detail-viewer-error",className:"p-4 font-mono text-[10px] text-red-600",children:((r=n.error)==null?void 0:r.message)??"Error loading file."}):n.data?i.jsxs("div",{"data-testid":"skill-detail-viewer-content",className:"flex h-full flex-col",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2 font-mono text-[10px]",children:[i.jsx("div",{"data-testid":"skill-detail-viewer-path",className:"text-on-surface",children:t}),i.jsxs("div",{className:"flex items-baseline gap-3 text-on-surface-variant",children:[i.jsxs("span",{children:[n.data.size,"b"]}),i.jsx("span",{children:n.data.mtime})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[n.data.truncated&&i.jsxs("div",{"data-testid":"skill-detail-viewer-truncated",className:"mb-3 mx-4 mt-4 border border-amber-400 bg-amber-50 px-3 py-2 font-mono text-[10px] text-amber-900",children:["⚠ Truncated at ",Math.round((n.data.truncatedAtBytes??0)/1024)," KB — file is"," ",Math.round((n.data.totalBytes??n.data.size)/1024)," KB total."]}),s===".md"||s===".mdx"?i.jsx("div",{className:"p-4",children:i.jsx(Zn,{content:n.data.content})}):cNe.has(s)?i.jsx("div",{className:"p-4",children:i.jsx(Dv,{code:n.data.content,language:s.slice(1)})}):i.jsx("pre",{"data-testid":"skill-detail-viewer-text-fallback",className:"p-4 whitespace-pre-wrap break-words font-mono text-[10px] text-on-surface",children:n.data.content})]})]}):null}function pNe(e){return e==="workspace"?"Workspace":e==="openrig-managed"?"OpenRig managed":e}function mNe(){const{data:e=[],isLoading:t}=Tv(),n=[...e].sort((s,r)=>s.name.localeCompare(r.name));return i.jsxs("div",{"data-testid":"skills-index-page",className:"mx-auto w-full max-w-[960px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Library"}),i.jsxs("div",{className:"mt-1 flex items-baseline justify-between",children:[i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface",children:"Skills"}),i.jsx("span",{"data-testid":"skills-index-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${n.length} ${n.length===1?"skill":"skills"}`})]})]}),t&&n.length===0?i.jsx("div",{"data-testid":"skills-index-loading",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading skills…"}):n.length===0?i.jsxs("div",{"data-testid":"skills-index-empty",className:"border border-outline-variant bg-surface-lowest/25 px-4 py-6 font-mono text-xs leading-relaxed text-on-surface",children:[i.jsx("p",{className:"font-bold uppercase tracking-wide text-on-surface",children:"No skills visible"}),i.jsxs("p",{className:"mt-2",children:["Skills live under ",i.jsx("code",{className:"font-mono text-on-surface",children:".openrig/skills/"})," in your workspace, plus the built-in set shipped with OpenRig. If this list is empty, the daemon could not see either source through configured file roots."]})]}):i.jsx("ul",{"data-testid":"skills-index-rows",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow divide-y divide-outline-variant",children:n.map(s=>i.jsx("li",{children:i.jsxs(Ve,{to:"/specs/skills/$skillToken",params:{skillToken:Iv(s.id)},"data-testid":`skills-index-row-${s.id}`,className:"flex w-full items-center justify-between gap-3 px-3 py-2 font-mono text-left hover:bg-surface-low/60 focus:outline-none focus:bg-surface-low/80",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"skill",title:`${s.name} skill`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:s.name})]}),i.jsxs("span",{className:"flex shrink-0 items-center gap-3 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:[i.jsx("span",{"data-testid":`skills-index-row-${s.id}-source`,children:pNe(s.source)}),i.jsxs("span",{"data-testid":`skills-index-row-${s.id}-filecount`,children:[s.files.length," ",s.files.length===1?"file":"files"]})]})]})},s.id))})]})}function gNe(){const{data:e=[],isLoading:t}=Av(),n=[...e].sort((s,r)=>s.name.localeCompare(r.name));return i.jsxs("div",{"data-testid":"plugins-index-page",className:"mx-auto w-full max-w-[960px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Library"}),i.jsxs("div",{className:"mt-1 flex items-baseline justify-between",children:[i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface",children:"Plugins"}),i.jsx("span",{"data-testid":"plugins-index-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:t?"loading":`${n.length} ${n.length===1?"plugin":"plugins"}`})]})]}),t&&n.length===0?i.jsx("div",{"data-testid":"plugins-index-loading",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading plugins…"}):n.length===0?i.jsxs("div",{"data-testid":"plugins-index-empty",className:"border border-outline-variant bg-surface-lowest/25 px-4 py-6 font-mono text-xs leading-relaxed text-on-surface",children:[i.jsx("p",{className:"font-bold uppercase tracking-wide text-on-surface",children:"No plugins visible"}),i.jsx("p",{className:"mt-2",children:"Plugins are discovered from Claude Code's global plugin cache, Codex's plugin cache, or OpenRig's vendored set (openrig-core ships with the daemon)."})]}):i.jsx("ul",{"data-testid":"plugins-index-rows",className:"border border-outline-variant bg-surface-lowest/25 hard-shadow divide-y divide-outline-variant",children:n.map(s=>i.jsx("li",{children:i.jsxs(Ve,{to:"/plugins/$pluginId",params:{pluginId:s.id},"data-testid":`plugins-index-row-${s.id}`,className:"flex w-full items-center justify-between gap-3 px-3 py-2 font-mono text-left hover:bg-surface-low/60 focus:outline-none focus:bg-surface-low/80",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(ht,{tool:"plugin",title:`${s.name} plugin`,size:"xs",decorative:!0}),i.jsx("span",{className:"truncate text-xs font-bold text-on-surface",children:s.name})]}),i.jsxs("span",{className:"flex shrink-0 items-center gap-3 font-mono text-[9px] uppercase tracking-[0.12em] text-on-surface-variant",children:[i.jsxs("span",{"data-testid":`plugins-index-row-${s.id}-version`,children:["v",s.version]}),i.jsx("span",{"data-testid":`plugins-index-row-${s.id}-runtimes`,className:"flex gap-1",children:s.runtimes.map(r=>i.jsx("span",{className:"border border-outline-variant px-1.5 py-0.5",children:r},r))}),i.jsxs("span",{"data-testid":`plugins-index-row-${s.id}-skillcount`,children:[s.skillCount," ",s.skillCount===1?"skill":"skills"]}),i.jsx("span",{"data-testid":`plugins-index-row-${s.id}-source`,children:s.sourceLabel})]})]})},s.id))})]})}async function xNe(e,t){const n=await fetch(`/api/plugins/${encodeURIComponent(e)}/files/list?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}async function vNe(e,t){const n=await fetch(`/api/plugins/${encodeURIComponent(e)}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}function yNe(e,t){return Re({queryKey:["plugin-files","list",e,t],queryFn:()=>xNe(e,t??""),enabled:!!e,staleTime:15e3})}function bNe(e,t){return Re({queryKey:["plugin-files","read",e,t],queryFn:()=>vNe(e,t),enabled:!!e&&!!t,staleTime:15e3})}const _Ne=new Set([".md",".mdx",".txt",".log",".yaml",".yml",".json",".js",".jsx",".ts",".tsx",".py",".sh",".bash",".css",".html"]);function aW(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t).toLowerCase()}function wNe(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function SNe(e,t){return e?`${e}/${t}`:t}function jNe(e){const t=aW(e);return t===".md"||t===".mdx"}function NNe(e){const t=e.find(s=>s.type==="file"&&/^readme\.(md|mdx)$/i.test(s.name));if(t)return t.name;const n=e.find(s=>s.type==="file"&&jNe(s.name));return n?n.name:null}function kNe({pluginId:e}){var b;const{data:t,isLoading:n,error:s}=dne(e),{data:r=[]}=hne(e),[a,o]=C.useState(""),[c,d]=C.useState(null),[h,m]=C.useState(!1),f=yNe(e,a);if(C.useEffect(()=>{if(h||a!==""||!f.data)return;const _=NNe(f.data.entries);_&&d(_),m(!0)},[f.data,a,h]),n)return i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"LOADING PLUGIN",description:"Loading plugin manifest from discovery service.",variant:"card",testId:"plugin-detail-loading"})});if(s||!t)return i.jsx("div",{className:"h-full bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:i.jsx(Ae,{label:"PLUGIN NOT FOUND",description:"The selected plugin is not visible through any configured discovery source.",variant:"card",testId:"plugin-detail-not-found"})});const g=t.entry,x=g.skillCount,y=r.length;return i.jsxs("div",{"data-testid":"plugin-detail-page",className:"h-full overflow-hidden bg-paper-grid px-6 py-5 lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"mb-4",children:[i.jsx(ct,{tone:"muted",children:"Plugin"}),i.jsxs("div",{className:"mt-1 flex flex-wrap items-baseline gap-3",children:[i.jsx("h1",{className:"font-headline text-2xl font-bold tracking-tight text-on-surface",children:g.name}),i.jsxs("span",{className:"font-mono text-sm text-on-surface-variant",children:["v",g.version]}),g.runtimes.map(_=>i.jsx("span",{"data-testid":`plugin-detail-runtime-${_}`,className:"inline-block border border-outline-variant bg-surface-lowest/30 px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface",children:_},_)),i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",title:g.path,children:g.sourceLabel}),i.jsxs("span",{"data-testid":"plugin-detail-skill-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:[x," ",x===1?"skill":"skills"]}),i.jsxs("span",{"data-testid":"plugin-detail-used-by-count",className:"font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:["used by ",y," ",y===1?"agent":"agents"]})]}),g.description&&i.jsx("p",{className:"mt-2 max-w-3xl text-sm text-on-surface-variant",children:g.description})]}),i.jsxs("div",{"data-testid":"plugin-detail-docs-browser",className:"flex h-[calc(100%-7rem)] flex-col border border-outline-variant bg-surface-lowest/25 hard-shadow sm:flex-row",children:[i.jsxs("aside",{"data-testid":"plugin-detail-tree",className:"w-full max-h-64 shrink-0 overflow-y-auto border-b border-outline-variant bg-surface-lowest/30 sm:w-72 sm:max-h-none sm:border-b-0 sm:border-r",children:[i.jsx(CNe,{testId:"plugin-detail-breadcrumbs",pluginName:g.name,path:a,onNavigate:_=>{o(_),d(null)}}),f.isLoading?i.jsx("div",{"data-testid":"plugin-detail-tree-loading",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):f.isError?i.jsx("div",{"data-testid":"plugin-detail-tree-error",className:"p-3 font-mono text-[10px] text-red-600",children:((b=f.error)==null?void 0:b.message)??"Error loading directory."}):!f.data||f.data.entries.length===0?i.jsx("div",{"data-testid":"plugin-detail-tree-empty",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Empty directory."}):i.jsxs("ul",{className:"p-1",children:[a&&i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":"plugin-detail-tree-up",onClick:()=>{o(wNe(a)),d(null)},className:"block w-full px-2 py-1 text-left font-mono text-[10px] text-on-surface-variant hover:bg-surface-low",children:".."})}),f.data.entries.map(_=>{const w=SNe(a,_.name),E=_.type==="file",N=c===w;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`plugin-detail-tree-entry-${w}`,"data-type":_.type,"data-active":N,onClick:()=>{E?d(w):_.type==="dir"&&(o(w),d(null))},disabled:_.type==="other",className:`block w-full px-2 py-1 text-left font-mono text-[10px] ${_.type==="other"?"text-on-surface-variant":`hover:bg-surface-low ${N?"bg-surface-high/80 text-on-surface":"text-on-surface"}`}`,children:_.type==="dir"?`▸ ${_.name}`:_.name})},w)})]})]}),i.jsx("main",{"data-testid":"plugin-detail-viewer",className:"flex-1 min-w-0 overflow-y-auto bg-surface-lowest",children:c?i.jsx(ENe,{pluginId:e,path:c}):i.jsx("div",{"data-testid":"plugin-detail-viewer-no-selection",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Select a file from the tree."})})]})]})}function CNe({testId:e,pluginName:t,path:n,onNavigate:s}){const r=n?n.split("/"):[];return i.jsxs("nav",{"data-testid":e,className:"flex flex-wrap items-baseline gap-1 border-b border-outline-variant px-2 py-1 font-mono text-[10px] text-on-surface",children:[i.jsx("button",{type:"button",onClick:()=>s(""),className:"font-bold hover:underline",children:t}),r.map((a,o)=>{const c=r.slice(0,o+1).join("/");return i.jsxs("span",{children:[i.jsx("span",{className:"mx-0.5 text-on-surface-variant",children:"/"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"hover:underline",children:a})]},c)})]})}function ENe({pluginId:e,path:t}){var r;const n=bNe(e,t),s=C.useMemo(()=>aW(t),[t]);return n.isLoading?i.jsx("div",{"data-testid":"plugin-detail-viewer-loading",className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):n.isError?i.jsx("div",{"data-testid":"plugin-detail-viewer-error",className:"p-4 font-mono text-[10px] text-red-600",children:((r=n.error)==null?void 0:r.message)??"Error loading file."}):n.data?i.jsxs("div",{"data-testid":"plugin-detail-viewer-content",className:"flex h-full flex-col",children:[i.jsxs("header",{className:"flex items-baseline justify-between border-b border-outline-variant bg-surface-lowest/30 px-3 py-2 font-mono text-[10px]",children:[i.jsx("div",{"data-testid":"plugin-detail-viewer-path",className:"text-on-surface",children:t}),i.jsxs("div",{className:"flex items-baseline gap-3 text-on-surface-variant",children:[i.jsxs("span",{children:[n.data.size,"b"]}),i.jsx("span",{children:n.data.mtime})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[n.data.truncated&&i.jsxs("div",{"data-testid":"plugin-detail-viewer-truncated",className:"mb-3 mx-4 mt-4 border border-amber-400 bg-amber-50 px-3 py-2 font-mono text-[10px] text-amber-900",children:["⚠ Truncated at ",Math.round((n.data.truncatedAtBytes??0)/1024)," KB — file is"," ",Math.round((n.data.totalBytes??n.data.size)/1024)," KB total."]}),s===".md"||s===".mdx"?i.jsx("div",{className:"p-4",children:i.jsx(Zn,{content:n.data.content})}):_Ne.has(s)?i.jsx("div",{className:"p-4",children:i.jsx(Dv,{code:n.data.content,language:s.slice(1)})}):i.jsx("pre",{"data-testid":"plugin-detail-viewer-text-fallback",className:"p-4 whitespace-pre-wrap break-words font-mono text-[10px] text-on-surface",children:n.data.content})]})]}):null}async function RNe(){const e=await fetch("/api/steering");if(e.status===503){const t=await e.json().catch(()=>({}));return{unavailable:!0,error:t.error??"steering_unavailable",hint:t.hint}}if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}function TNe(){return Re({queryKey:["steering"],queryFn:RNe,staleTime:3e4})}async function ANe(e,t){const n=await fetch(`/api/specs/review/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:t})});if(n.status===400)return await n.json();if(!n.ok)throw new Error(`HTTP ${n.status}`);return await n.json()}function INe(e,t){return Re({queryKey:["spec-review",e,t?t.length:0,t?t.slice(0,64):""],queryFn:()=>ANe(e,t),enabled:!!e&&!!t,staleTime:6e4})}async function MNe(){const t=new URL(window.location.href).searchParams.get("session"),n=new URLSearchParams;if(t&&n.set("sessionName",t),n.toString()==="")return null;const s=await fetch(`/api/whoami?${n.toString()}`);if(!s.ok)return null;const r=await s.json().catch(()=>null);if(!r||typeof r!="object")return null;const a=r.workspace;return!a||typeof a!="object"?null:Array.isArray(a.repos)?a:{...a,repos:[]}}function LNe(){return Re({queryKey:["workspace","whoami"],queryFn:MNe,staleTime:6e4})}const ONe={user:{label:"USER",glyph:"U",bg:"bg-violet-50",fg:"text-violet-700",border:"border-violet-200"},project:{label:"PROJECT",glyph:"P",bg:"bg-blue-50",fg:"text-blue-700",border:"border-blue-200"},knowledge:{label:"KNOW",glyph:"K",bg:"bg-emerald-50",fg:"text-emerald-700",border:"border-emerald-200"},lab:{label:"LAB",glyph:"L",bg:"bg-amber-50",fg:"text-amber-700",border:"border-amber-200"},delivery:{label:"DELIVERY",glyph:"D",bg:"bg-rose-50",fg:"text-rose-700",border:"border-rose-200"}};function PNe({kind:e,compact:t,className:n}){const s=ONe[e];if(!s)return null;const r=`inline-block border ${s.border} ${s.bg} ${s.fg} font-mono text-[8px] uppercase tracking-[0.14em] leading-none rounded-sm`,a=t?"px-1 py-[2px]":"px-1.5 py-0.5";return i.jsx("span",{"data-testid":`workspace-kind-badge-${e}`,title:`workspace kind: ${e}`,className:`${r} ${a} ${n??""}`.trim(),children:t?s.glyph:s.label})}function DNe(e,t){if(!e||!t)return null;let n=null;for(const s of t.repos)y8(e,s.path)&&s.path.length>((n==null?void 0:n.len)??-1)&&(n={kind:s.kind,len:s.path.length});return n?n.kind:t.knowledgeRoot&&y8(e,t.knowledgeRoot)?"knowledge":null}function y8(e,t){return!e||!t?!1:e===t?!0:e.startsWith(t.endsWith("/")?t:t+"/")}const $Ne=new Set([".md",".txt",".log",".yaml",".yml",".json",".js",".jsx",".ts",".tsx",".py",".sh",".bash",".sql",".css",".html"]),BNe=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),qNe=new Set([".zip",".tar",".gz",".pdf",".mp4",".webm",".mov"]);function oW(e){return!!(e&&typeof e=="object"&&"unavailable"in e)}function FNe(){const e=Jf(),t=LNe(),[n,s]=C.useState(null),[r,a]=C.useState(""),[o,c]=C.useState(null),[d,h]=C.useState(!1);return C.useEffect(()=>{if(n||!e.data||oW(e.data))return;const m=e.data.roots[0];m&&s(m.name)},[e.data,n]),C.useEffect(()=>{a(""),c(null),h(!1)},[n]),i.jsxs("div",{"data-testid":"files-workspace",className:"flex h-full flex-col lg:pl-[var(--workspace-left-offset,0px)] lg:pr-[var(--workspace-right-offset,0px)]",children:[i.jsxs("header",{className:"border-b border-outline-variant bg-background px-4 py-3",children:[i.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Workspace"}),i.jsx("h1",{className:"font-headline text-xl font-bold tracking-tight text-on-surface",children:"Files"})]}),i.jsxs("div",{className:"flex flex-1 min-h-0 flex-col sm:flex-row",children:[i.jsxs("aside",{"data-testid":"files-tree-pane",className:"w-full max-h-48 shrink-0 overflow-y-auto border-b border-outline-variant bg-background sm:w-72 sm:max-h-none sm:border-b-0 sm:border-r",children:[i.jsx(zNe,{roots:e.data,isLoading:e.isLoading,selectedRoot:n,onSelect:s,workspace:t.data??null}),n&&i.jsxs(i.Fragment,{children:[i.jsx(HNe,{root:n,path:r,onNavigate:a}),i.jsx(UNe,{root:n,path:r,onEnterDir:m=>{a(m),c(null)},onSelectFile:m=>{c(m),h(!1)},selectedFile:o})]})]}),i.jsxs("main",{"data-testid":"files-content-pane",className:"flex-1 min-w-0 overflow-y-auto bg-surface-lowest",children:[!n&&i.jsx("div",{className:"m-auto p-4 font-mono text-[10px] text-on-surface-variant",children:"Select an allowlist root to browse."}),n&&!o&&i.jsx("div",{className:"p-4 font-mono text-[10px] text-on-surface-variant","data-testid":"files-no-selection",children:"Select a file from the tree."}),n&&o&&i.jsx(VNe,{root:n,path:o,editMode:d,onToggleEditMode:()=>h(m=>!m)})]})]})]})}function zNe({roots:e,isLoading:t,selectedRoot:n,onSelect:s,workspace:r}){return t?i.jsx("div",{className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading roots…"}):e?oW(e)?i.jsxs("div",{"data-testid":"files-roots-unavailable",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:[i.jsx("div",{children:"Files routes unavailable."}),e.hint&&i.jsx("div",{className:"mt-1 text-on-surface-variant",children:e.hint})]}):e.roots.length===0?i.jsxs("div",{"data-testid":"files-roots-empty",className:"p-3 font-mono text-[10px] text-on-surface-variant",children:[i.jsx("div",{children:"No allowlist roots configured."}),e.hint&&i.jsx("div",{className:"mt-1 text-on-surface-variant",children:e.hint})]}):i.jsxs("div",{"data-testid":"files-root-selector",className:"border-b border-outline-variant p-2",children:[i.jsx("div",{className:"mb-1 font-mono text-[8px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Roots"}),i.jsx("ul",{children:e.roots.map(a=>{const o=DNe(a.path,r);return i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`files-root-${a.name}`,"data-active":n===a.name,onClick:()=>s(a.name),className:`flex w-full items-center justify-between gap-2 px-2 py-1 text-left font-mono text-[10px] hover:bg-surface-low ${n===a.name?"bg-surface-high/80 text-on-surface":"text-on-surface"}`,title:a.path,children:[i.jsx("span",{className:"truncate",children:a.name}),o&&i.jsx(PNe,{kind:o,compact:!0})]})},a.name)})})]}):null}function HNe({root:e,path:t,onNavigate:n}){const s=t?t.split("/"):[];return i.jsxs("nav",{"data-testid":"files-breadcrumbs",className:"flex flex-wrap items-baseline gap-1 border-b border-outline-variant px-2 py-1 font-mono text-[10px] text-on-surface",children:[i.jsx("button",{type:"button",onClick:()=>n(""),className:"font-bold hover:underline",children:e}),s.map((r,a)=>{const o=s.slice(0,a+1).join("/");return i.jsxs("span",{children:[i.jsx("span",{className:"mx-0.5 text-on-surface-variant",children:"/"}),i.jsx("button",{type:"button",onClick:()=>n(o),className:"hover:underline",children:r})]},o)})]})}function UNe({root:e,path:t,onEnterDir:n,onSelectFile:s,selectedFile:r}){var o;const a=ep(e,t);return a.isLoading?i.jsx("div",{className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}):a.isError?i.jsx("div",{"data-testid":"files-list-error",className:"p-3 font-mono text-[10px] text-red-600",children:((o=a.error)==null?void 0:o.message)??"Error loading directory."}):!a.data||a.data.entries.length===0?i.jsx("div",{className:"p-3 font-mono text-[10px] text-on-surface-variant",children:"Empty directory."}):i.jsxs("ul",{"data-testid":"files-directory-tree",className:"p-1",children:[t&&i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":"files-up",onClick:()=>n(XNe(t)),className:"block w-full px-2 py-1 text-left font-mono text-[10px] text-on-surface-variant hover:bg-surface-low",children:".."})}),a.data.entries.map(c=>{const d=t?`${t}/${c.name}`:c.name,h=c.type==="file",m=r===d;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`files-entry-${d}`,"data-type":c.type,onClick:()=>h?s(d):c.type==="dir"?n(d):void 0,disabled:c.type==="other",className:`block w-full px-2 py-1 text-left font-mono text-[10px] ${c.type==="other"?"text-on-surface-variant":`hover:bg-surface-low ${m?"bg-surface-high/80 text-on-surface":"text-on-surface"}`}`,children:c.type==="dir"?`▸ ${c.name}`:c.name})},d)})]})}function VNe({root:e,path:t,editMode:n,onToggleEditMode:s}){var a;const r=PE(e,t);return i.jsxs("div",{"data-testid":"files-content-panel",className:"flex h-full flex-col",children:[i.jsxs("header",{className:"flex items-center justify-between border-b border-outline-variant bg-background px-3 py-2 font-mono text-[10px]",children:[i.jsxs("div",{className:"text-on-surface","data-testid":"files-content-path",children:[e,"/",t]}),i.jsxs("div",{className:"flex items-center gap-3 text-on-surface-variant",children:[r.data&&i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-testid":"files-content-size",children:[r.data.size,"b"]}),i.jsx("span",{"data-testid":"files-content-mtime",children:r.data.mtime})]}),i.jsx("button",{type:"button","data-testid":"files-edit-toggle","data-active":n,onClick:s,className:`border px-2 py-0.5 font-mono text-[9px] uppercase tracking-[0.10em] ${n?"border-amber-400 bg-amber-50 text-amber-900":"border-outline-variant text-on-surface hover:bg-surface-low"}`,children:n?"editing":"edit"})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[r.isLoading&&i.jsx("div",{className:"p-4 font-mono text-[10px] text-on-surface-variant",children:"Loading…"}),r.isError&&i.jsx("div",{"data-testid":"files-read-error",className:"p-4 font-mono text-[10px] text-red-600",children:((a=r.error)==null?void 0:a.message)??"Error loading file."}),r.data&&(n?i.jsx(YNe,{root:e,path:t,read:r.data}):i.jsx(WNe,{root:e,path:t,read:r.data}))]})]})}function WNe({root:e,path:t,read:n}){const s=QNe(t),r=GNe(t);return BNe.has(s)?i.jsxs("div",{"data-testid":"files-image-view",className:"p-4",children:[i.jsx(Xg,{read:n}),i.jsx("img",{src:sa(e,t),alt:t,className:"max-w-full border border-outline-variant"})]}):s===".md"?i.jsxs("div",{className:"p-4",children:[i.jsx(Xg,{read:n}),i.jsx(Zn,{content:n.content})]}):$Ne.has(s)?i.jsxs("div",{"data-testid":"files-code-view",className:"p-4",children:[i.jsx(Xg,{read:n}),r&&i.jsx(KNe,{kind:r,yaml:n.content}),i.jsx(Dv,{code:n.content,language:s.slice(1)})]}):qNe.has(s)?i.jsx("div",{"data-testid":"files-download-only",className:"p-4 font-mono text-[10px] text-on-surface",children:i.jsxs("a",{href:sa(e,t),download:!0,className:"text-blue-700 underline",children:["Download ",t]})}):i.jsxs("div",{"data-testid":"files-text-fallback",className:"p-4",children:[i.jsx(Xg,{read:n}),i.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[10px] text-on-surface",children:n.content})]})}function Xg({read:e}){if(!e.truncated)return null;const t=Math.round((e.totalBytes??e.size)/1024);return i.jsxs("div",{"data-testid":"files-truncation-marker","data-truncated-at-bytes":e.truncatedAtBytes??"","data-total-bytes":e.totalBytes??"",className:"mb-3 border border-amber-400 bg-amber-50 px-3 py-2 font-mono text-[10px] text-amber-900",children:["⚠ Truncated by file viewer at ",Math.round((e.truncatedAtBytes??0)/1024)," KB — file is ",t," KB total. Use an external editor for full content."]})}function GNe(e){const t=e.toLowerCase();return t.endsWith("/rig.yaml")||t==="rig.yaml"||t.endsWith("/rig.yml")||t==="rig.yml"?"rig":t.endsWith("/agent.yaml")||t==="agent.yaml"||t.endsWith("/agent.yml")||t==="agent.yml"?"agent":null}function KNe({kind:e,yaml:t}){var a;const n=INe(e,t);if(n.isLoading)return i.jsxs("div",{"data-testid":"files-spec-validation-loading",className:"mb-3 border border-outline-variant bg-background px-3 py-2 font-mono text-[10px] text-on-surface-variant",children:["Validating ",e,".yaml…"]});if(n.isError)return i.jsxs("div",{"data-testid":"files-spec-validation-error",className:"mb-3 border border-red-400 bg-red-50 px-3 py-2 font-mono text-[10px] text-red-900",children:["Validation failed to run: ",((a=n.error)==null?void 0:a.message)??"unknown error"]});if(!n.data)return null;const s=n.data.errors??[],r=s.length===0;return i.jsxs("div",{"data-testid":"files-spec-validation-panel","data-spec-kind":e,"data-valid":r,className:`mb-3 border px-3 py-2 font-mono text-[10px] ${r?"border-emerald-400 bg-emerald-50 text-emerald-900":"border-red-400 bg-red-50 text-red-900"}`,children:[i.jsx("div",{className:"mb-1 font-bold uppercase tracking-[0.10em]",children:r?`✓ Valid ${e==="rig"?"RigSpec":"AgentSpec"}`:`✗ ${e==="rig"?"RigSpec":"AgentSpec"} validation errors`}),s.length>0&&i.jsx("ul",{className:"space-y-1",children:s.map((o,c)=>i.jsxs("li",{"data-testid":`files-spec-validation-error-${c}`,className:"text-[10px]",children:[o.field&&i.jsxs("span",{className:"font-bold",children:[o.field,": "]}),o.message]},c))})]})}function YNe({root:e,path:t,read:n}){const[s,r]=C.useState(n.content),[a,o]=C.useState(null),[c,d]=C.useState(null),[h,m]=C.useState(!1),f=ete(),g=mt();C.useEffect(()=>{r(n.content),d(null)},[n.contentHash,n.mtime,n.content]);const x=C.useMemo(()=>s!==n.content,[s,n.content]);return i.jsxs("div",{"data-testid":"files-editor",className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-outline-variant bg-amber-50 px-3 py-1.5 font-mono text-[9px]",children:[i.jsx("span",{className:"font-bold text-amber-900","data-testid":"files-editor-status",children:x?"draft (unsaved)":"no changes"}),i.jsx("button",{type:"button","data-testid":"files-editor-save",disabled:!x||f.isPending,onClick:()=>{o(null),d(null),m(!1),f.mutate({root:e,path:t,content:s,expectedMtime:n.mtime,expectedContentHash:n.contentHash,actor:"ui-files-edit-mode"},{onSuccess:y=>{"conflict"in y?d({currentMtime:y.currentMtime,currentContentHash:y.currentContentHash}):(m(!0),setTimeout(()=>m(!1),2e3))},onError:y=>{o(y instanceof Error?y.message:String(y))}})},className:"border border-emerald-500 bg-emerald-50 px-2 py-0.5 uppercase tracking-[0.10em] text-emerald-900 disabled:cursor-not-allowed disabled:opacity-50",children:"save"}),i.jsx("button",{type:"button","data-testid":"files-editor-cancel",onClick:()=>{r(n.content),o(null),d(null)},className:"border border-outline bg-surface-lowest px-2 py-0.5 uppercase tracking-[0.10em] text-on-surface",children:"cancel"}),h&&i.jsx("span",{"data-testid":"files-editor-saved",className:"ml-auto text-emerald-700",children:"saved"})]}),c&&i.jsxs("div",{"data-testid":"files-editor-conflict",className:"flex items-center gap-2 border-b border-red-200 bg-red-50 px-3 py-2 font-mono text-[10px] text-red-900",children:[i.jsxs("span",{className:"flex-1",children:["File changed externally. Local mtime ",i.jsx("code",{children:n.mtime})," ≠ server ",i.jsx("code",{children:c.currentMtime}),". Click Refresh to re-read the file (your draft will be replaced with the new server content; copy it elsewhere first if you need to re-apply)."]}),i.jsx("button",{type:"button","data-testid":"files-editor-refresh",onClick:()=>{g.invalidateQueries({queryKey:["files","read",e,t]})},className:"border border-red-500 bg-surface-lowest px-2 py-0.5 uppercase tracking-[0.10em] text-red-900",children:"refresh"})]}),a&&i.jsxs("div",{"data-testid":"files-editor-error",className:"border-b border-red-200 bg-red-50 px-3 py-2 font-mono text-[10px] text-red-900",children:["Save failed: ",a]}),i.jsx("textarea",{"data-testid":"files-editor-textarea",value:s,onChange:y=>r(y.target.value),className:"flex-1 min-h-0 resize-none border-0 bg-background p-3 font-mono text-[11px] leading-relaxed text-on-surface outline-none",spellCheck:!1})]})}function QNe(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t).toLowerCase()}function XNe(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Fy({testId:e,title:t,children:n}){return i.jsxs("div",{"data-testid":e,className:"mx-auto w-full max-w-[960px] px-6 py-8",children:[i.jsxs("header",{className:"border-b border-outline-variant pb-4 mb-4",children:[i.jsx(ct,{tone:"muted",children:"Configuration"}),i.jsx("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface mt-1",children:t})]}),n]})}function ZNe(){return i.jsx(Fy,{testId:"settings-center",title:"Settings",children:i.jsx(sz,{})})}const b8="policies.claude_compaction.enabled",_8="policies.claude_compaction.threshold_percent",w8="policies.claude_compaction.pre_compact_instruction",S8="policies.claude_compaction.compact_instruction",j8="policies.claude_compaction.message_inline",N8="policies.claude_compaction.message_file_path",k8="policies.claude_compaction.post_restore_audit_instruction";function JNe(e,t){return typeof e=="boolean"?e:e==="true"?!0:e==="false"?!1:t}function eke(e,t){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){const n=Number(e);if(!Number.isNaN(n))return n}return t}function Oh(e){return typeof e=="string"?e:e==null?"":String(e)}function tke(){const{data:e,isLoading:t,error:n}=mr(),s=Nv();return e?i.jsx(nke,{data:e.settings,setSetting:s}):i.jsxs("section",{"data-testid":"claude-compaction-policy-form",className:"border border-outline-variant p-5 bg-surface-lowest/50",children:[i.jsx(ct,{tone:"muted",children:"Policy"}),i.jsx("h2",{className:"font-headline text-headline-sm font-bold tracking-tight uppercase text-on-surface mt-1",children:"Claude Auto-Compaction"}),t&&i.jsx("p",{className:"mt-4 text-sm text-on-surface-variant","data-testid":"claude-compaction-policy-loading",children:"Loading current settings…"}),n&&i.jsx("p",{className:"mt-4 text-sm text-error","data-testid":"claude-compaction-policy-error",children:n instanceof Error?n.message:String(n)})]})}function nke({data:e,setSetting:t}){const[n,s]=C.useState(()=>{var f,g,x,y,b,_,w;return{enabled:JNe((f=e[b8])==null?void 0:f.value,!1),thresholdPercent:String(eke((g=e[_8])==null?void 0:g.value,80)),preCompactInstruction:Oh((x=e[w8])==null?void 0:x.value),compactInstruction:Oh((y=e[S8])==null?void 0:y.value),messageInline:Oh((b=e[j8])==null?void 0:b.value),messageFilePath:Oh((_=e[N8])==null?void 0:_.value),postRestoreAuditInstruction:Oh((w=e[k8])==null?void 0:w.value)}}),[r,a]=C.useState(null),[o,c]=C.useState(null),[d,h]=C.useState(!1);async function m(f){f.preventDefault(),h(!1),c(null);const g=n.thresholdPercent.trim(),x=Number(g);if(!/^\d+$/.test(g)||x<1||x>100){a("Threshold must be an integer between 1 and 100.");return}a(null);const y=[{key:b8,value:n.enabled?"true":"false"},{key:_8,value:String(x)},{key:w8,value:n.preCompactInstruction},{key:S8,value:n.compactInstruction},{key:j8,value:n.messageInline},{key:N8,value:n.messageFilePath},{key:k8,value:n.postRestoreAuditInstruction}];try{for(const b of y)await t.mutateAsync(b);h(!0)}catch(b){c(b instanceof Error?b.message:String(b))}}return i.jsxs("section",{"data-testid":"claude-compaction-policy-form",className:"border border-outline-variant p-5 bg-surface-lowest/50",children:[i.jsx(ct,{tone:"muted",children:"Policy"}),i.jsx("h2",{className:"font-headline text-headline-sm font-bold tracking-tight uppercase text-on-surface mt-1",children:"Claude Auto-Compaction"}),i.jsxs("p",{className:"mt-2 text-sm text-on-surface-variant max-w-prose",children:["When a Claude seat's context usage crosses the configured threshold, OpenRig first sends a preparation message, then sends",i.jsx("code",{className:"font-mono text-[12px]",children:" /compact"})," on the next eligible observation. After compaction, OpenRig sends one restore prompt that points the seat at its restore packet, followed by a read-depth audit prompt."]}),i.jsxs("form",{className:"mt-4 flex flex-col gap-5",onSubmit:m,"data-testid":"claude-compaction-policy-form-element",children:[i.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-on-surface",children:[i.jsx("input",{type:"checkbox","data-testid":"claude-compaction-enabled",checked:n.enabled,onChange:f=>s(g=>({...g,enabled:f.target.checked}))}),i.jsx("span",{children:"Enable automatic pre-compaction trigger"})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-threshold",className:"text-sm font-medium text-on-surface",children:"Threshold percentage"}),i.jsx("input",{id:"claude-compaction-threshold","data-testid":"claude-compaction-threshold",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:n.thresholdPercent,onChange:f=>s(g=>({...g,thresholdPercent:f.target.value})),className:"border border-outline-variant px-2 py-1 w-32 font-mono text-sm","aria-describedby":"claude-compaction-threshold-hint"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Preparation starts when context usage is at-or-above this percentage (1–100)."}),r&&i.jsx("span",{className:"text-xs text-error","data-testid":"claude-compaction-threshold-error",children:r})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-pre-compact-instruction",className:"text-sm font-medium text-on-surface",children:"Pre-compaction prep message"}),i.jsx("textarea",{id:"claude-compaction-pre-compact-instruction","data-testid":"claude-compaction-pre-compact-instruction",rows:4,value:n.preCompactInstruction,onChange:f=>s(g=>({...g,preCompactInstruction:f.target.value})),placeholder:"Read the claude-compaction-restore skill and prepare for compaction.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"OpenRig wraps this with the current context usage, threshold, and operator-authorized user-channel framing."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-compact-instruction",className:"text-sm font-medium text-on-surface",children:"Compaction instruction"}),i.jsx("textarea",{id:"claude-compaction-compact-instruction","data-testid":"claude-compaction-compact-instruction",rows:3,value:n.compactInstruction,onChange:f=>s(g=>({...g,compactInstruction:f.target.value})),placeholder:"Optional. Sent as /compact <instruction> when OpenRig triggers compaction.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Optional advanced override. Leave blank to rely on Claude's native compaction summary; OpenRig still appends a trust-channel note."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-inline",className:"text-sm font-medium text-on-surface",children:"Post-compaction restore instruction (inline)"}),i.jsx("textarea",{id:"claude-compaction-inline","data-testid":"claude-compaction-message-inline",rows:4,value:n.messageInline,onChange:f=>s(g=>({...g,messageInline:f.target.value})),placeholder:"Optional override. Leave blank to use the instruction file path below.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Default asks Claude to read the claude-compaction-restore skill. OpenRig wraps this with marker, transcript, and current-task framing."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-file",className:"text-sm font-medium text-on-surface",children:"Post-compaction restore instruction (file path)"}),i.jsx("input",{id:"claude-compaction-file","data-testid":"claude-compaction-message-file-path",type:"text",value:n.messageFilePath,onChange:f=>s(g=>({...g,messageFilePath:f.target.value})),placeholder:"Path read at hook-fire time for extra restore instructions.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"Default points at a user-owned placeholder file. Put mission-specific reading lists or extra restore notes there without changing the canonical skill."})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("label",{htmlFor:"claude-compaction-post-restore-audit",className:"text-sm font-medium text-on-surface",children:"Post-restore audit message"}),i.jsx("textarea",{id:"claude-compaction-post-restore-audit","data-testid":"claude-compaction-post-restore-audit-instruction",rows:4,value:n.postRestoreAuditInstruction,onChange:f=>s(g=>({...g,postRestoreAuditInstruction:f.target.value})),placeholder:"Read the claude-compaction-restore skill and audit restore read depth.",className:"border border-outline-variant px-2 py-1 font-mono text-sm"}),i.jsx("span",{className:"text-xs text-on-surface-variant",children:"OpenRig wraps this with the required FULL/PARTIAL/NOT_READ table and no-token-conservation language."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{type:"submit","data-testid":"claude-compaction-policy-submit",disabled:t.isPending,className:"border border-outline px-4 py-2 bg-inverse-surface text-background font-medium text-sm disabled:opacity-60",children:t.isPending?"Saving…":"Save policy"}),d&&i.jsx("span",{className:"text-sm text-success","data-testid":"claude-compaction-policy-saved",children:"Saved."}),o&&i.jsx("span",{className:"text-sm text-error","data-testid":"claude-compaction-policy-submit-error",children:o})]})]})]})}function ske(){return i.jsxs(Fy,{testId:"settings-page-policies",title:"Policies",children:[i.jsx("p",{className:"mb-6 text-sm text-on-surface-variant max-w-prose",children:"Opt-in policies that affect agent runtime behavior. Each policy ships disabled by default and can be turned on independently."}),i.jsx("div",{className:"flex flex-col gap-6",children:i.jsx(tke,{})})]})}const rke=["summary","body","detail","message","title","text","description"],ike=new Set(["ts","ts_created","ts_updated","ts_emitted","created_at","updated_at","received_at","stream_sort_key","audit_pointer"]);function G2(e,t=40){if(e.length<=t)return e;const n=e.charCodeAt(t-2);return e.slice(0,n>=55296&&n<=56319?t-2:t-1)+"…"}function ake(e){if(e==null)return null;if(typeof e=="string"){const t=e.trim();return t.length>0?G2(t):null}return typeof e=="number"||typeof e=="boolean"?String(e):null}function C8(e){if(!e||typeof e!="object")return"—";const t=e;for(const s of rke){const r=t[s];if(typeof r=="string"&&r.trim().length>0)return G2(r.trim(),200)}const n=[];for(const[s,r]of Object.entries(t)){if(ike.has(s))continue;const a=ake(r);if(a!==null&&(n.push(`${s}=${a}`),n.length>=4))break}if(n.length>0)return n.join(" · ");try{const s=JSON.stringify(t);return G2(s,200)}catch{return"—"}}function oke(){const{events:e}=KE();return i.jsx(Fy,{testId:"settings-page-log",title:"Log",children:e.length===0?i.jsx(Ae,{label:"LOG IS QUIET",description:"Activity events from rigs will stream here.",variant:"card",testId:"settings-log-empty"}):i.jsx("ul",{"data-testid":"settings-log-stream",className:"divide-y divide-outline-variant border border-outline-variant max-h-[60vh] overflow-y-auto",children:e.slice(0,100).map(t=>i.jsxs("li",{className:"px-3 py-2 flex items-baseline gap-3 font-mono text-xs",children:[i.jsx("span",{className:"text-on-surface-variant text-[10px] uppercase tracking-wide w-32 shrink-0 truncate",children:t.type}),i.jsx("span",{className:"text-on-surface truncate",title:C8(t.payload),children:C8(t.payload)})]},t.seq))})})}async function lke(){if(!(await fetch("/healthz")).ok)throw new Error("unhealthy");return!0}async function cke(){const e=await fetch("/api/adapters/cmux/status");if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}function uke(){var g;const e=Re({queryKey:["daemon","health"],queryFn:lke,refetchInterval:1e4,retry:!1}),t=Re({queryKey:["daemon","cmux"],queryFn:cke,refetchInterval:3e4,retry:!1}),{data:n,isLoading:s,error:r}=Dr(),{data:a}=Qf(),o=e.isSuccess,c=o?((g=t.data)==null?void 0:g.available)??null:null,d=(n==null?void 0:n.length)??0,h=(a==null?void 0:a.filter(x=>x.runningCount>0).length)??0,m=o?"active":e.isError?"error":e.isLoading?"info":"stopped",f=c===!0?"active":c===!1?"warning":"info";return i.jsxs("div",{"data-testid":"settings-status-panel",className:"space-y-4",children:[i.jsxs("section",{children:[i.jsx(ct,{tone:"muted",children:"Daemon"}),i.jsxs("div",{className:"mt-2 flex items-center justify-between font-mono text-xs",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Reachable"}),i.jsx(To,{status:m,label:o?"OK":e.isError?"ERROR":e.isLoading?"LOADING":"DISCONNECTED",variant:"pill",testId:"status-daemon"})]})]}),i.jsxs("section",{children:[i.jsx(ct,{tone:"muted",children:"Cmux control"}),i.jsxs("div",{className:"mt-2 flex items-center justify-between font-mono text-xs",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Adapter"}),i.jsx(To,{status:f,label:c===!0?"AVAILABLE":c===!1?"UNAVAILABLE":"UNKNOWN",variant:"pill",testId:"status-cmux"})]}),i.jsx("div",{className:"mt-1 font-mono text-[10px] text-on-surface-variant",children:"OpenRig can control cmux surfaces for node open-or-focus."})]}),i.jsxs("section",{children:[i.jsx(ct,{tone:"muted",children:"Rigs"}),i.jsxs("div",{className:"mt-2 space-y-1.5 font-mono text-xs",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Total"}),i.jsx("span",{className:"text-on-surface font-bold","data-testid":"status-rigs-total",children:d})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-on-surface-variant",children:"Running"}),i.jsx("span",{className:"text-on-surface font-bold","data-testid":"status-rigs-running",children:h})]})]})]})]})}function dke(){return i.jsx(Fy,{testId:"settings-page-status",title:"Status",children:i.jsx(uke,{})})}function AT({tabs:e,active:t,onSelect:n,testIdPrefix:s="topology-view-mode",trailing:r}){const a=i.jsx("div",{role:"tablist","aria-label":"Topology view modes","data-testid":`${s}-tabs`,className:"flex gap-6 items-center",children:e.map(o=>i.jsx("button",{type:"button",role:"tab","aria-selected":t===o.id,"data-testid":`${s}-tab-${o.id}`,"data-active":t===o.id,onClick:()=>n(o.id),className:ce("py-3 font-mono text-[10px] uppercase tracking-[0.18em] border-b-2",t===o.id?"border-on-surface text-on-surface":"border-transparent text-on-surface-variant hover:text-on-surface"),children:o.label},o.id))});return r?i.jsxs("div",{"data-testid":`${s}-tab-bar`,className:"flex items-center",children:[a,i.jsx("div",{"data-testid":`${s}-trailing`,className:"ml-auto",children:r})]}):a}const hke=[{id:"graph",label:"Graph"},{id:"table",label:"Table"},{id:"terminal",label:"Terminal"}],lW=[{id:"graph",label:"Graph"},{id:"table",label:"Table"},{id:"terminal",label:"Terminal"},{id:"overview",label:"Overview"}];/**
593
593
  * table-core
594
594
  *
595
595
  * Copyright (c) TanStack