@openrig/cli 0.7.1 → 0.7.3

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 (1005) hide show
  1. package/README.md +5 -5
  2. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  3. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/SKILL.md +2 -2
  5. package/daemon/assets/plugins/openrig-core/skills/delegating-work/SKILL.md +1 -1
  6. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +37 -3
  7. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +90 -9
  8. package/daemon/assets/skills/rigs/SKILL.md +40 -9
  9. package/daemon/context-packs/help/help.md +6 -0
  10. package/daemon/context-packs/help/manifest.yaml +1 -1
  11. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  12. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +132 -24
  13. package/daemon/context-packs/reference/acp-agents.md +77 -0
  14. package/daemon/context-packs/reference/getting-started.md +84 -10
  15. package/daemon/context-packs/reference/manifest.yaml +6 -3
  16. package/daemon/context-packs/reference/rig-spec.md +179 -6
  17. package/daemon/context-packs/reference/whats-new.md +148 -169
  18. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  19. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  20. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  21. package/daemon/context-packs/skills/claude-compaction-restore/SKILL.md +2 -2
  22. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  23. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  24. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  25. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  26. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +37 -3
  28. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/openrig-herdr/SKILL.md +20 -5
  32. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  35. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/delegating-work/SKILL.md +1 -1
  43. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/openrig-user/SKILL.md +90 -9
  49. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  53. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  56. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/process/agent-browser/LICENSE.txt +201 -0
  63. package/daemon/context-packs/skills/process/agent-browser/OPENRIG.md +13 -29
  64. package/daemon/context-packs/skills/process/agent-browser/SKILL.md +8 -8
  65. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +3 -1
  66. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/process/dogfood/LICENSE.txt +201 -0
  68. package/daemon/context-packs/skills/process/dogfood/SKILL.md +6 -2
  69. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +3 -1
  70. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/process/systematic-debugging/LICENSE.txt +21 -0
  72. package/daemon/context-packs/skills/process/systematic-debugging/SKILL.md +6 -2
  73. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +3 -1
  74. package/daemon/context-packs/skills/process/systematic-debugging/root-cause-tracing.md +1 -1
  75. package/daemon/context-packs/skills/process/test-driven-development/LICENSE.txt +21 -0
  76. package/daemon/context-packs/skills/process/test-driven-development/SKILL.md +5 -1
  77. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +3 -1
  78. package/daemon/context-packs/skills/process/verification-before-completion/LICENSE.txt +21 -0
  79. package/daemon/context-packs/skills/process/verification-before-completion/SKILL.md +5 -1
  80. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +3 -1
  81. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  83. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  84. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  85. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  86. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  87. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  88. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  89. package/daemon/dist/adapters/claude-code-adapter.d.ts +4 -0
  90. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  91. package/daemon/dist/adapters/claude-code-adapter.js +46 -17
  92. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  93. package/daemon/dist/adapters/claude-resume.d.ts +8 -1
  94. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  95. package/daemon/dist/adapters/claude-resume.js +29 -10
  96. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  97. package/daemon/dist/adapters/codex-resume.d.ts +11 -4
  98. package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
  99. package/daemon/dist/adapters/codex-resume.js +69 -18
  100. package/daemon/dist/adapters/codex-resume.js.map +1 -1
  101. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +53 -13
  102. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  103. package/daemon/dist/adapters/codex-runtime-adapter.js +801 -119
  104. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  105. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +4 -0
  106. package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
  107. package/daemon/dist/adapters/community-harness-runtime-adapter.js +38 -7
  108. package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
  109. package/daemon/dist/adapters/compose-services-adapter.d.ts +16 -0
  110. package/daemon/dist/adapters/compose-services-adapter.d.ts.map +1 -1
  111. package/daemon/dist/adapters/compose-services-adapter.js +46 -2
  112. package/daemon/dist/adapters/compose-services-adapter.js.map +1 -1
  113. package/daemon/dist/adapters/kernel-authority.d.ts +1 -1
  114. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  115. package/daemon/dist/adapters/kernel-authority.js +13 -2
  116. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  117. package/daemon/dist/adapters/pi-resume.js +1 -1
  118. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  119. package/daemon/dist/adapters/pi-runner-protocol.d.ts +3 -3
  120. package/daemon/dist/adapters/pi-runner-protocol.js +2 -2
  121. package/daemon/dist/adapters/pi-runner.d.ts +1 -1
  122. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  123. package/daemon/dist/adapters/pi-runner.js +24 -17
  124. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  125. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  126. package/daemon/dist/adapters/tmux-server.js +6 -2
  127. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  128. package/daemon/dist/adapters/tmux.d.ts +51 -0
  129. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  130. package/daemon/dist/adapters/tmux.js +210 -17
  131. package/daemon/dist/adapters/tmux.js.map +1 -1
  132. package/daemon/dist/adapters/yolo-mode.d.ts +7 -0
  133. package/daemon/dist/adapters/yolo-mode.d.ts.map +1 -1
  134. package/daemon/dist/adapters/yolo-mode.js +8 -0
  135. package/daemon/dist/adapters/yolo-mode.js.map +1 -1
  136. package/daemon/dist/attention-surface.d.ts +16 -1
  137. package/daemon/dist/attention-surface.d.ts.map +1 -1
  138. package/daemon/dist/attention-surface.js.map +1 -1
  139. package/daemon/dist/build-info.js +3 -3
  140. package/daemon/dist/codex-auth-surface.d.ts +2 -0
  141. package/daemon/dist/codex-auth-surface.d.ts.map +1 -0
  142. package/daemon/dist/codex-auth-surface.js +2 -0
  143. package/daemon/dist/codex-auth-surface.js.map +1 -0
  144. package/daemon/dist/context-pack-taxonomy-surface.js +1 -1
  145. package/daemon/dist/context-pack-taxonomy-surface.js.map +1 -1
  146. package/daemon/dist/daemon-db-path.d.ts.map +1 -1
  147. package/daemon/dist/daemon-db-path.js +45 -12
  148. package/daemon/dist/daemon-db-path.js.map +1 -1
  149. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  150. package/daemon/dist/db/all-migrations.js +14 -0
  151. package/daemon/dist/db/all-migrations.js.map +1 -1
  152. package/daemon/dist/db/migrations/132_seat_runtime_switches.d.ts +10 -0
  153. package/daemon/dist/db/migrations/132_seat_runtime_switches.d.ts.map +1 -0
  154. package/daemon/dist/db/migrations/132_seat_runtime_switches.js +46 -0
  155. package/daemon/dist/db/migrations/132_seat_runtime_switches.js.map +1 -0
  156. package/daemon/dist/db/migrations/133_stream_reader_actions.d.ts +8 -0
  157. package/daemon/dist/db/migrations/133_stream_reader_actions.d.ts.map +1 -0
  158. package/daemon/dist/db/migrations/133_stream_reader_actions.js +25 -0
  159. package/daemon/dist/db/migrations/133_stream_reader_actions.js.map +1 -0
  160. package/daemon/dist/db/migrations/134_claude_token_readings.d.ts +3 -0
  161. package/daemon/dist/db/migrations/134_claude_token_readings.d.ts.map +1 -0
  162. package/daemon/dist/db/migrations/134_claude_token_readings.js +21 -0
  163. package/daemon/dist/db/migrations/134_claude_token_readings.js.map +1 -0
  164. package/daemon/dist/db/migrations/136_node_launch_recipe.d.ts +9 -0
  165. package/daemon/dist/db/migrations/136_node_launch_recipe.d.ts.map +1 -0
  166. package/daemon/dist/db/migrations/136_node_launch_recipe.js +11 -0
  167. package/daemon/dist/db/migrations/136_node_launch_recipe.js.map +1 -0
  168. package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts +3 -0
  169. package/daemon/dist/db/migrations/137_node_codex_permissions.d.ts.map +1 -0
  170. package/daemon/dist/db/migrations/137_node_codex_permissions.js +7 -0
  171. package/daemon/dist/db/migrations/137_node_codex_permissions.js.map +1 -0
  172. package/daemon/dist/db/migrations/138_node_claude_token_ref.d.ts +3 -0
  173. package/daemon/dist/db/migrations/138_node_claude_token_ref.d.ts.map +1 -0
  174. package/daemon/dist/db/migrations/138_node_claude_token_ref.js +8 -0
  175. package/daemon/dist/db/migrations/138_node_claude_token_ref.js.map +1 -0
  176. package/daemon/dist/db/migrations/139_node_claude_permissions.d.ts +3 -0
  177. package/daemon/dist/db/migrations/139_node_claude_permissions.d.ts.map +1 -0
  178. package/daemon/dist/db/migrations/139_node_claude_permissions.js +5 -0
  179. package/daemon/dist/db/migrations/139_node_claude_permissions.js.map +1 -0
  180. package/daemon/dist/domain/active-occupant.js +1 -1
  181. package/daemon/dist/domain/active-occupant.js.map +1 -1
  182. package/daemon/dist/domain/agent-activity-store.d.ts +1 -1
  183. package/daemon/dist/domain/agent-activity-store.js +2 -2
  184. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  185. package/daemon/dist/domain/agent-resolver.js +1 -1
  186. package/daemon/dist/domain/agent-resolver.js.map +1 -1
  187. package/daemon/dist/domain/bind-plan.js +1 -1
  188. package/daemon/dist/domain/bind-plan.js.map +1 -1
  189. package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
  190. package/daemon/dist/domain/bootstrap-orchestrator.js +16 -1
  191. package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
  192. package/daemon/dist/domain/bundle-skills-router.js +2 -2
  193. package/daemon/dist/domain/bundle-skills-router.js.map +1 -1
  194. package/daemon/dist/domain/claim-service.js +1 -1
  195. package/daemon/dist/domain/claim-service.js.map +1 -1
  196. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +24 -1
  197. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  198. package/daemon/dist/domain/claude-compaction-enforcer.js +70 -16
  199. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  200. package/daemon/dist/domain/claude-credential-precedence.d.ts +33 -0
  201. package/daemon/dist/domain/claude-credential-precedence.d.ts.map +1 -0
  202. package/daemon/dist/domain/claude-credential-precedence.js +62 -0
  203. package/daemon/dist/domain/claude-credential-precedence.js.map +1 -0
  204. package/daemon/dist/domain/claude-managed-launch.d.ts +43 -4
  205. package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
  206. package/daemon/dist/domain/claude-managed-launch.js +129 -27
  207. package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
  208. package/daemon/dist/domain/claude-permission-rules.d.ts +10 -0
  209. package/daemon/dist/domain/claude-permission-rules.d.ts.map +1 -0
  210. package/daemon/dist/domain/claude-permission-rules.js +41 -0
  211. package/daemon/dist/domain/claude-permission-rules.js.map +1 -0
  212. package/daemon/dist/domain/claude-seat-token.d.ts +30 -0
  213. package/daemon/dist/domain/claude-seat-token.d.ts.map +1 -0
  214. package/daemon/dist/domain/claude-seat-token.js +78 -0
  215. package/daemon/dist/domain/claude-seat-token.js.map +1 -0
  216. package/daemon/dist/domain/codex-auth.d.ts +148 -0
  217. package/daemon/dist/domain/codex-auth.d.ts.map +1 -0
  218. package/daemon/dist/domain/codex-auth.js +506 -0
  219. package/daemon/dist/domain/codex-auth.js.map +1 -0
  220. package/daemon/dist/domain/codex-daemon-support.d.ts +2 -1
  221. package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
  222. package/daemon/dist/domain/codex-daemon-support.js +3 -2
  223. package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
  224. package/daemon/dist/domain/codex-git-add-dirs.d.ts +1 -1
  225. package/daemon/dist/domain/codex-git-add-dirs.d.ts.map +1 -1
  226. package/daemon/dist/domain/codex-member-permissions.d.ts +56 -0
  227. package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -0
  228. package/daemon/dist/domain/codex-member-permissions.js +140 -0
  229. package/daemon/dist/domain/codex-member-permissions.js.map +1 -0
  230. package/daemon/dist/domain/codex-network-default.d.ts +2 -1
  231. package/daemon/dist/domain/codex-network-default.d.ts.map +1 -1
  232. package/daemon/dist/domain/codex-network-default.js +3 -2
  233. package/daemon/dist/domain/codex-network-default.js.map +1 -1
  234. package/daemon/dist/domain/codex-owned-plugin-trust.d.ts.map +1 -1
  235. package/daemon/dist/domain/codex-owned-plugin-trust.js +2 -1
  236. package/daemon/dist/domain/codex-owned-plugin-trust.js.map +1 -1
  237. package/daemon/dist/domain/codex-team-workspace.d.ts +5 -0
  238. package/daemon/dist/domain/codex-team-workspace.d.ts.map +1 -1
  239. package/daemon/dist/domain/codex-team-workspace.js +37 -0
  240. package/daemon/dist/domain/codex-team-workspace.js.map +1 -1
  241. package/daemon/dist/domain/community-harness-first-input.d.ts +7 -0
  242. package/daemon/dist/domain/community-harness-first-input.d.ts.map +1 -0
  243. package/daemon/dist/domain/community-harness-first-input.js +16 -0
  244. package/daemon/dist/domain/community-harness-first-input.js.map +1 -0
  245. package/daemon/dist/domain/community-harness-presets.d.ts +2 -0
  246. package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
  247. package/daemon/dist/domain/community-harness-presets.js +4 -2
  248. package/daemon/dist/domain/community-harness-presets.js.map +1 -1
  249. package/daemon/dist/domain/compaction-restore-notice.d.ts +6 -0
  250. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -0
  251. package/daemon/dist/domain/compaction-restore-notice.js +27 -0
  252. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -0
  253. package/daemon/dist/domain/context-packs/context-pack-library-service.js +2 -2
  254. package/daemon/dist/domain/context-packs/context-pack-library-service.js.map +1 -1
  255. package/daemon/dist/domain/context-packs/seat-recap-store.d.ts +14 -0
  256. package/daemon/dist/domain/context-packs/seat-recap-store.d.ts.map +1 -1
  257. package/daemon/dist/domain/context-packs/seat-recap-store.js +57 -1
  258. package/daemon/dist/domain/context-packs/seat-recap-store.js.map +1 -1
  259. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  260. package/daemon/dist/domain/context-usage-store.js +6 -1
  261. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  262. package/daemon/dist/domain/current-work.d.ts +15 -4
  263. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  264. package/daemon/dist/domain/current-work.js +26 -13
  265. package/daemon/dist/domain/current-work.js.map +1 -1
  266. package/daemon/dist/domain/execution-candidate-reader.d.ts +16 -0
  267. package/daemon/dist/domain/execution-candidate-reader.d.ts.map +1 -0
  268. package/daemon/dist/domain/execution-candidate-reader.js +77 -0
  269. package/daemon/dist/domain/execution-candidate-reader.js.map +1 -0
  270. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  271. package/daemon/dist/domain/execution-view.js +21 -8
  272. package/daemon/dist/domain/execution-view.js.map +1 -1
  273. package/daemon/dist/domain/feed-perspective.d.ts +14 -0
  274. package/daemon/dist/domain/feed-perspective.d.ts.map +1 -0
  275. package/daemon/dist/domain/feed-perspective.js +36 -0
  276. package/daemon/dist/domain/feed-perspective.js.map +1 -0
  277. package/daemon/dist/domain/gateway/channel-operations.d.ts +1 -1
  278. package/daemon/dist/domain/gateway/channel-operations.d.ts.map +1 -1
  279. package/daemon/dist/domain/gateway/human-registry.d.ts +11 -4
  280. package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
  281. package/daemon/dist/domain/gateway/human-registry.js +36 -5
  282. package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
  283. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  284. package/daemon/dist/domain/gateway/operator-delivery-engine.js +8 -3
  285. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  286. package/daemon/dist/domain/gateway/participants.d.ts +180 -0
  287. package/daemon/dist/domain/gateway/participants.d.ts.map +1 -0
  288. package/daemon/dist/domain/gateway/participants.js +434 -0
  289. package/daemon/dist/domain/gateway/participants.js.map +1 -0
  290. package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts +2 -2
  291. package/daemon/dist/domain/gateway/slack/inbound-admission.d.ts.map +1 -1
  292. package/daemon/dist/domain/gateway/slack/inbound-admission.js +73 -6
  293. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  294. package/daemon/dist/domain/gateway/slack/inbound.d.ts +19 -1
  295. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  296. package/daemon/dist/domain/gateway/slack/inbound.js +31 -14
  297. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  298. package/daemon/dist/domain/gateway/slack/message.d.ts +5 -1
  299. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  300. package/daemon/dist/domain/gateway/slack/message.js +25 -15
  301. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  302. package/daemon/dist/domain/gateway/slack/open-asks.d.ts +50 -0
  303. package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -0
  304. package/daemon/dist/domain/gateway/slack/open-asks.js +215 -0
  305. package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -0
  306. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +2 -0
  307. package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
  308. package/daemon/dist/domain/gateway/slack/outbound-driver.js +1 -0
  309. package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
  310. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +15 -1
  311. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  312. package/daemon/dist/domain/gateway/slack/queue-access.js +98 -29
  313. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  314. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  315. package/daemon/dist/domain/gateway/slack/slack-delivery.js +1 -0
  316. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  317. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  318. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +60 -2
  319. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  320. package/daemon/dist/domain/gateway/slack/state-store.d.ts +3 -0
  321. package/daemon/dist/domain/gateway/slack/state-store.d.ts.map +1 -1
  322. package/daemon/dist/domain/gateway/slack/state-store.js +18 -0
  323. package/daemon/dist/domain/gateway/slack/state-store.js.map +1 -1
  324. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  325. package/daemon/dist/domain/managed-restore-read-access.d.ts +20 -0
  326. package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -0
  327. package/daemon/dist/domain/managed-restore-read-access.js +77 -0
  328. package/daemon/dist/domain/managed-restore-read-access.js.map +1 -0
  329. package/daemon/dist/domain/markdown-address.d.ts.map +1 -1
  330. package/daemon/dist/domain/markdown-address.js +21 -2
  331. package/daemon/dist/domain/markdown-address.js.map +1 -1
  332. package/daemon/dist/domain/mission-control/mission-control-read-layer.d.ts.map +1 -1
  333. package/daemon/dist/domain/mission-control/mission-control-read-layer.js +3 -1
  334. package/daemon/dist/domain/mission-control/mission-control-read-layer.js.map +1 -1
  335. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +19 -3
  336. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  337. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +72 -21
  338. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  339. package/daemon/dist/domain/model-divergence/model-divergence-monitor.d.ts.map +1 -1
  340. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js +18 -1
  341. package/daemon/dist/domain/model-divergence/model-divergence-monitor.js.map +1 -1
  342. package/daemon/dist/domain/native-permission-store.d.ts +8 -2
  343. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  344. package/daemon/dist/domain/native-permission-store.js +26 -8
  345. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  346. package/daemon/dist/domain/native-resume-probe.d.ts +11 -0
  347. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  348. package/daemon/dist/domain/native-resume-probe.js +199 -37
  349. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  350. package/daemon/dist/domain/node-inventory.d.ts +5 -1
  351. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  352. package/daemon/dist/domain/node-inventory.js +18 -0
  353. package/daemon/dist/domain/node-inventory.js.map +1 -1
  354. package/daemon/dist/domain/node-launcher.d.ts +11 -0
  355. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  356. package/daemon/dist/domain/node-launcher.js +41 -6
  357. package/daemon/dist/domain/node-launcher.js.map +1 -1
  358. package/daemon/dist/domain/parent-session-env.d.ts +1 -1
  359. package/daemon/dist/domain/parent-session-env.d.ts.map +1 -1
  360. package/daemon/dist/domain/parent-session-env.js +3 -1
  361. package/daemon/dist/domain/parent-session-env.js.map +1 -1
  362. package/daemon/dist/domain/parked-query.d.ts +3 -0
  363. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  364. package/daemon/dist/domain/parked-query.js +1 -0
  365. package/daemon/dist/domain/parked-query.js.map +1 -1
  366. package/daemon/dist/domain/permission-account.d.ts +3 -0
  367. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  368. package/daemon/dist/domain/permission-account.js +60 -11
  369. package/daemon/dist/domain/permission-account.js.map +1 -1
  370. package/daemon/dist/domain/permission-drift-observer.js +1 -1
  371. package/daemon/dist/domain/permission-drift-observer.js.map +1 -1
  372. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts +6 -2
  373. package/daemon/dist/domain/policies/delivery-digest-flush.d.ts.map +1 -1
  374. package/daemon/dist/domain/policies/delivery-digest-flush.js +34 -9
  375. package/daemon/dist/domain/policies/delivery-digest-flush.js.map +1 -1
  376. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +8 -0
  377. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  378. package/daemon/dist/domain/policies/parked-owner-consumer.js +15 -1
  379. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  380. package/daemon/dist/domain/policies/quiet-release.d.ts +14 -0
  381. package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
  382. package/daemon/dist/domain/policies/quiet-release.js +13 -2
  383. package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
  384. package/daemon/dist/domain/profile-resolution-worker.d.ts +1 -1
  385. package/daemon/dist/domain/profile-resolution-worker.d.ts.map +1 -1
  386. package/daemon/dist/domain/profile-resolution-worker.js +5 -5
  387. package/daemon/dist/domain/profile-resolution-worker.js.map +1 -1
  388. package/daemon/dist/domain/proof/judgments.d.ts +7 -4
  389. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  390. package/daemon/dist/domain/proof/judgments.js +12 -8
  391. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  392. package/daemon/dist/domain/proof/source-watch.d.ts +6 -1
  393. package/daemon/dist/domain/proof/source-watch.d.ts.map +1 -1
  394. package/daemon/dist/domain/proof/source-watch.js +241 -35
  395. package/daemon/dist/domain/proof/source-watch.js.map +1 -1
  396. package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts +12 -0
  397. package/daemon/dist/domain/provider/claude-auth-status-reader.d.ts.map +1 -1
  398. package/daemon/dist/domain/provider/claude-auth-status-reader.js +4 -4
  399. package/daemon/dist/domain/provider/claude-auth-status-reader.js.map +1 -1
  400. package/daemon/dist/domain/provider/claude-seat-switch.d.ts +32 -0
  401. package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -0
  402. package/daemon/dist/domain/provider/claude-seat-switch.js +136 -0
  403. package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -0
  404. package/daemon/dist/domain/provider/claude-token-usage.d.ts +34 -0
  405. package/daemon/dist/domain/provider/claude-token-usage.d.ts.map +1 -0
  406. package/daemon/dist/domain/provider/claude-token-usage.js +168 -0
  407. package/daemon/dist/domain/provider/claude-token-usage.js.map +1 -0
  408. package/daemon/dist/domain/provider/provider-account-readings.d.ts +7 -6
  409. package/daemon/dist/domain/provider/provider-account-readings.d.ts.map +1 -1
  410. package/daemon/dist/domain/provider/provider-account-readings.js +31 -10
  411. package/daemon/dist/domain/provider/provider-account-readings.js.map +1 -1
  412. package/daemon/dist/domain/provider/provider-collect.d.ts +3 -0
  413. package/daemon/dist/domain/provider/provider-collect.d.ts.map +1 -1
  414. package/daemon/dist/domain/provider/provider-collect.js +3 -2
  415. package/daemon/dist/domain/provider/provider-collect.js.map +1 -1
  416. package/daemon/dist/domain/provider/provider-seat-accounts.d.ts +1 -1
  417. package/daemon/dist/domain/provider/provider-seat-accounts.d.ts.map +1 -1
  418. package/daemon/dist/domain/provider/provider-seat-accounts.js +29 -2
  419. package/daemon/dist/domain/provider/provider-seat-accounts.js.map +1 -1
  420. package/daemon/dist/domain/provider/provider-service-impl.d.ts +38 -4
  421. package/daemon/dist/domain/provider/provider-service-impl.d.ts.map +1 -1
  422. package/daemon/dist/domain/provider/provider-service-impl.js +147 -5
  423. package/daemon/dist/domain/provider/provider-service-impl.js.map +1 -1
  424. package/daemon/dist/domain/provider/provider-service.d.ts +109 -4
  425. package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
  426. package/daemon/dist/domain/provider/provider-signals.d.ts +3 -0
  427. package/daemon/dist/domain/provider/provider-signals.d.ts.map +1 -1
  428. package/daemon/dist/domain/provider/provider-signals.js +7 -2
  429. package/daemon/dist/domain/provider/provider-signals.js.map +1 -1
  430. package/daemon/dist/domain/provider/provider-types.d.ts +61 -5
  431. package/daemon/dist/domain/provider/provider-types.d.ts.map +1 -1
  432. package/daemon/dist/domain/provider/reactive-tap.d.ts +4 -0
  433. package/daemon/dist/domain/provider/reactive-tap.d.ts.map +1 -1
  434. package/daemon/dist/domain/provider/reactive-tap.js +3 -0
  435. package/daemon/dist/domain/provider/reactive-tap.js.map +1 -1
  436. package/daemon/dist/domain/provider/usage-across-hosts.d.ts.map +1 -1
  437. package/daemon/dist/domain/provider/usage-across-hosts.js +8 -2
  438. package/daemon/dist/domain/provider/usage-across-hosts.js.map +1 -1
  439. package/daemon/dist/domain/provider/usage-windows.d.ts +2 -0
  440. package/daemon/dist/domain/provider/usage-windows.d.ts.map +1 -1
  441. package/daemon/dist/domain/provider/usage-windows.js +4 -0
  442. package/daemon/dist/domain/provider/usage-windows.js.map +1 -1
  443. package/daemon/dist/domain/queue-destination-check.d.ts +5 -0
  444. package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
  445. package/daemon/dist/domain/queue-destination-check.js +5 -1
  446. package/daemon/dist/domain/queue-destination-check.js.map +1 -1
  447. package/daemon/dist/domain/queue-owner.d.ts +9 -0
  448. package/daemon/dist/domain/queue-owner.d.ts.map +1 -1
  449. package/daemon/dist/domain/queue-owner.js +28 -0
  450. package/daemon/dist/domain/queue-owner.js.map +1 -1
  451. package/daemon/dist/domain/queue-repository.d.ts +41 -8
  452. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  453. package/daemon/dist/domain/queue-repository.js +143 -33
  454. package/daemon/dist/domain/queue-repository.js.map +1 -1
  455. package/daemon/dist/domain/queue-retention.d.ts +1 -1
  456. package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
  457. package/daemon/dist/domain/queue-retention.js +6 -1
  458. package/daemon/dist/domain/queue-retention.js.map +1 -1
  459. package/daemon/dist/domain/queue-stuck-sweep.d.ts +14 -3
  460. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  461. package/daemon/dist/domain/queue-stuck-sweep.js +50 -8
  462. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  463. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  464. package/daemon/dist/domain/queue-wake-ladder.js +90 -28
  465. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  466. package/daemon/dist/domain/queue-wake-repository.d.ts +3 -0
  467. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  468. package/daemon/dist/domain/queue-wake-repository.js +5 -1
  469. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  470. package/daemon/dist/domain/restore-orchestrator.d.ts +30 -1
  471. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  472. package/daemon/dist/domain/restore-orchestrator.js +132 -14
  473. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  474. package/daemon/dist/domain/resume-metadata-refresher.d.ts +11 -2
  475. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  476. package/daemon/dist/domain/resume-metadata-refresher.js +32 -14
  477. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  478. package/daemon/dist/domain/resume-token-capture.d.ts +5 -1
  479. package/daemon/dist/domain/resume-token-capture.d.ts.map +1 -1
  480. package/daemon/dist/domain/resume-token-capture.js +3 -1
  481. package/daemon/dist/domain/resume-token-capture.js.map +1 -1
  482. package/daemon/dist/domain/review/compose.js +1 -1
  483. package/daemon/dist/domain/review/compose.js.map +1 -1
  484. package/daemon/dist/domain/review/gather.js +1 -1
  485. package/daemon/dist/domain/review/gather.js.map +1 -1
  486. package/daemon/dist/domain/rig-expansion-service.d.ts.map +1 -1
  487. package/daemon/dist/domain/rig-expansion-service.js +2 -0
  488. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  489. package/daemon/dist/domain/rig-repository.d.ts +20 -2
  490. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  491. package/daemon/dist/domain/rig-repository.js +262 -2
  492. package/daemon/dist/domain/rig-repository.js.map +1 -1
  493. package/daemon/dist/domain/rig-teardown.d.ts +4 -1
  494. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  495. package/daemon/dist/domain/rig-teardown.js +6 -1
  496. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  497. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  498. package/daemon/dist/domain/rigspec-codec.js +8 -0
  499. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  500. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  501. package/daemon/dist/domain/rigspec-exporter.js +19 -1
  502. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  503. package/daemon/dist/domain/rigspec-instantiator.d.ts +43 -1
  504. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  505. package/daemon/dist/domain/rigspec-instantiator.js +321 -138
  506. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  507. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  508. package/daemon/dist/domain/rigspec-schema.js +47 -1
  509. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  510. package/daemon/dist/domain/running-name-guard.d.ts.map +1 -1
  511. package/daemon/dist/domain/running-name-guard.js +2 -1
  512. package/daemon/dist/domain/running-name-guard.js.map +1 -1
  513. package/daemon/dist/domain/runtime-adapter.d.ts +19 -1
  514. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  515. package/daemon/dist/domain/runtime-adapter.js +2 -0
  516. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  517. package/daemon/dist/domain/runtime-switch-materials.d.ts +77 -0
  518. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -0
  519. package/daemon/dist/domain/runtime-switch-materials.js +253 -0
  520. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -0
  521. package/daemon/dist/domain/scope/dot-id.js +2 -2
  522. package/daemon/dist/domain/scope/dot-id.js.map +1 -1
  523. package/daemon/dist/domain/scope/scaffold-placeholder.d.ts +1 -1
  524. package/daemon/dist/domain/scope/scaffold-placeholder.js +1 -1
  525. package/daemon/dist/domain/scope/scope-approve.d.ts +1 -1
  526. package/daemon/dist/domain/scope/scope-audit.js +1 -1
  527. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  528. package/daemon/dist/domain/scope/types.d.ts.map +1 -1
  529. package/daemon/dist/domain/scope/types.js +2 -3
  530. package/daemon/dist/domain/scope/types.js.map +1 -1
  531. package/daemon/dist/domain/seat-activity-service.d.ts +4 -0
  532. package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
  533. package/daemon/dist/domain/seat-activity-service.js +17 -0
  534. package/daemon/dist/domain/seat-activity-service.js.map +1 -1
  535. package/daemon/dist/domain/seat-attention-reconciler.d.ts +8 -2
  536. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  537. package/daemon/dist/domain/seat-attention-reconciler.js +31 -2
  538. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  539. package/daemon/dist/domain/seat-handover-service.d.ts +1 -1
  540. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  541. package/daemon/dist/domain/seat-handover-service.js +7 -3
  542. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  543. package/daemon/dist/domain/seat-launch-environment.d.ts +5 -0
  544. package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
  545. package/daemon/dist/domain/seat-launch-environment.js +8 -4
  546. package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
  547. package/daemon/dist/domain/seat-lifecycle-service.d.ts +42 -11
  548. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  549. package/daemon/dist/domain/seat-lifecycle-service.js +210 -23
  550. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  551. package/daemon/dist/domain/seat-restart-in-place.d.ts +11 -4
  552. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  553. package/daemon/dist/domain/seat-restart-in-place.js +29 -9
  554. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  555. package/daemon/dist/domain/seat-runtime-dir.d.ts +17 -0
  556. package/daemon/dist/domain/seat-runtime-dir.d.ts.map +1 -0
  557. package/daemon/dist/domain/seat-runtime-dir.js +27 -0
  558. package/daemon/dist/domain/seat-runtime-dir.js.map +1 -0
  559. package/daemon/dist/domain/seat-runtime-home.d.ts +42 -0
  560. package/daemon/dist/domain/seat-runtime-home.d.ts.map +1 -0
  561. package/daemon/dist/domain/seat-runtime-home.js +89 -0
  562. package/daemon/dist/domain/seat-runtime-home.js.map +1 -0
  563. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +227 -0
  564. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -0
  565. package/daemon/dist/domain/seat-runtime-switch-service.js +641 -0
  566. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -0
  567. package/daemon/dist/domain/seat-skills-pointer.d.ts +5 -0
  568. package/daemon/dist/domain/seat-skills-pointer.d.ts.map +1 -0
  569. package/daemon/dist/domain/seat-skills-pointer.js +15 -0
  570. package/daemon/dist/domain/seat-skills-pointer.js.map +1 -0
  571. package/daemon/dist/domain/seat-status-service.d.ts +32 -0
  572. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  573. package/daemon/dist/domain/seat-status-service.js +55 -0
  574. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  575. package/daemon/dist/domain/seat-structural-activity-service.d.ts +3 -0
  576. package/daemon/dist/domain/seat-structural-activity-service.d.ts.map +1 -1
  577. package/daemon/dist/domain/seat-structural-activity-service.js +7 -1
  578. package/daemon/dist/domain/seat-structural-activity-service.js.map +1 -1
  579. package/daemon/dist/domain/service-orchestrator.d.ts +7 -0
  580. package/daemon/dist/domain/service-orchestrator.d.ts.map +1 -1
  581. package/daemon/dist/domain/service-orchestrator.js +4 -0
  582. package/daemon/dist/domain/service-orchestrator.js.map +1 -1
  583. package/daemon/dist/domain/session-registry.d.ts +2 -0
  584. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  585. package/daemon/dist/domain/session-registry.js +3 -1
  586. package/daemon/dist/domain/session-registry.js.map +1 -1
  587. package/daemon/dist/domain/session-transport.d.ts +62 -2
  588. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  589. package/daemon/dist/domain/session-transport.js +417 -67
  590. package/daemon/dist/domain/session-transport.js.map +1 -1
  591. package/daemon/dist/domain/skill-library-discovery.js +2 -2
  592. package/daemon/dist/domain/skill-library-discovery.js.map +1 -1
  593. package/daemon/dist/domain/slices/slice-indexer.d.ts +4 -4
  594. package/daemon/dist/domain/slices/slice-indexer.js +17 -17
  595. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  596. package/daemon/dist/domain/snapshot-capture.d.ts +4 -1
  597. package/daemon/dist/domain/snapshot-capture.d.ts.map +1 -1
  598. package/daemon/dist/domain/snapshot-capture.js +4 -1
  599. package/daemon/dist/domain/snapshot-capture.js.map +1 -1
  600. package/daemon/dist/domain/snapshot-repository.d.ts +4 -3
  601. package/daemon/dist/domain/snapshot-repository.d.ts.map +1 -1
  602. package/daemon/dist/domain/snapshot-repository.js +6 -5
  603. package/daemon/dist/domain/snapshot-repository.js.map +1 -1
  604. package/daemon/dist/domain/startup-orchestrator.d.ts +3 -16
  605. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  606. package/daemon/dist/domain/startup-orchestrator.js +65 -76
  607. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  608. package/daemon/dist/domain/startup-submission-evidence.d.ts +27 -0
  609. package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
  610. package/daemon/dist/domain/startup-submission-evidence.js +55 -0
  611. package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
  612. package/daemon/dist/domain/stream-reader-actions.d.ts +49 -0
  613. package/daemon/dist/domain/stream-reader-actions.d.ts.map +1 -0
  614. package/daemon/dist/domain/stream-reader-actions.js +104 -0
  615. package/daemon/dist/domain/stream-reader-actions.js.map +1 -0
  616. package/daemon/dist/domain/successor-session-launcher.d.ts +36 -1
  617. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  618. package/daemon/dist/domain/successor-session-launcher.js +59 -3
  619. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  620. package/daemon/dist/domain/terminal/herdr-adapter.d.ts +6 -28
  621. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  622. package/daemon/dist/domain/terminal/herdr-adapter.js +16 -66
  623. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  624. package/daemon/dist/domain/terminal/rex-adapter.d.ts +42 -0
  625. package/daemon/dist/domain/terminal/rex-adapter.d.ts.map +1 -0
  626. package/daemon/dist/domain/terminal/rex-adapter.js +228 -0
  627. package/daemon/dist/domain/terminal/rex-adapter.js.map +1 -0
  628. package/daemon/dist/domain/terminal/rex-layout.d.ts +26 -0
  629. package/daemon/dist/domain/terminal/rex-layout.d.ts.map +1 -0
  630. package/daemon/dist/domain/terminal/rex-layout.js +21 -0
  631. package/daemon/dist/domain/terminal/rex-layout.js.map +1 -0
  632. package/daemon/dist/domain/terminal/rex-transport.d.ts +43 -0
  633. package/daemon/dist/domain/terminal/rex-transport.d.ts.map +1 -0
  634. package/daemon/dist/domain/terminal/rex-transport.js +176 -0
  635. package/daemon/dist/domain/terminal/rex-transport.js.map +1 -0
  636. package/daemon/dist/domain/terminal/terminal-provider.d.ts +11 -0
  637. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  638. package/daemon/dist/domain/terminal/terminal-service.d.ts +2 -2
  639. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  640. package/daemon/dist/domain/terminal/terminal-service.js +10 -11
  641. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  642. package/daemon/dist/domain/terminal/tile-attach.d.ts +2 -0
  643. package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -0
  644. package/daemon/dist/domain/terminal/tile-attach.js +42 -0
  645. package/daemon/dist/domain/terminal/tile-attach.js.map +1 -0
  646. package/daemon/dist/domain/terminal/tile-layout.d.ts +32 -0
  647. package/daemon/dist/domain/terminal/tile-layout.d.ts.map +1 -0
  648. package/daemon/dist/domain/terminal/tile-layout.js +36 -0
  649. package/daemon/dist/domain/terminal/tile-layout.js.map +1 -0
  650. package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -1
  651. package/daemon/dist/domain/terminal/view-composer.js +11 -7
  652. package/daemon/dist/domain/terminal/view-composer.js.map +1 -1
  653. package/daemon/dist/domain/toml-tables.d.ts +20 -0
  654. package/daemon/dist/domain/toml-tables.d.ts.map +1 -0
  655. package/daemon/dist/domain/toml-tables.js +101 -0
  656. package/daemon/dist/domain/toml-tables.js.map +1 -0
  657. package/daemon/dist/domain/types.d.ts +86 -0
  658. package/daemon/dist/domain/types.d.ts.map +1 -1
  659. package/daemon/dist/domain/types.js.map +1 -1
  660. package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
  661. package/daemon/dist/domain/user-settings/settings-store.js +5 -6
  662. package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
  663. package/daemon/dist/domain/view-projector.d.ts +1 -0
  664. package/daemon/dist/domain/view-projector.d.ts.map +1 -1
  665. package/daemon/dist/domain/view-projector.js +15 -2
  666. package/daemon/dist/domain/view-projector.js.map +1 -1
  667. package/daemon/dist/domain/wake-recovery.d.ts +16 -0
  668. package/daemon/dist/domain/wake-recovery.d.ts.map +1 -0
  669. package/daemon/dist/domain/wake-recovery.js +31 -0
  670. package/daemon/dist/domain/wake-recovery.js.map +1 -0
  671. package/daemon/dist/domain/workflow-human-destination.d.ts.map +1 -1
  672. package/daemon/dist/domain/workflow-human-destination.js +5 -3
  673. package/daemon/dist/domain/workflow-human-destination.js.map +1 -1
  674. package/daemon/dist/domain/workflow-projector.d.ts +1 -0
  675. package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
  676. package/daemon/dist/domain/workflow-projector.js +19 -3
  677. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  678. package/daemon/dist/domain/workflow-runtime.d.ts +2 -2
  679. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  680. package/daemon/dist/domain/workflow-runtime.js +6 -4
  681. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  682. package/daemon/dist/gateway-human-registry-surface.d.ts +1 -0
  683. package/daemon/dist/gateway-human-registry-surface.d.ts.map +1 -1
  684. package/daemon/dist/gateway-human-registry-surface.js +1 -0
  685. package/daemon/dist/gateway-human-registry-surface.js.map +1 -1
  686. package/daemon/dist/index.d.ts.map +1 -1
  687. package/daemon/dist/index.js +7 -3
  688. package/daemon/dist/index.js.map +1 -1
  689. package/daemon/dist/lib/pane-envelope.d.ts +9 -0
  690. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  691. package/daemon/dist/lib/pane-envelope.js +9 -2
  692. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  693. package/daemon/dist/routes/activity.d.ts.map +1 -1
  694. package/daemon/dist/routes/activity.js +13 -1
  695. package/daemon/dist/routes/activity.js.map +1 -1
  696. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  697. package/daemon/dist/routes/agent-images.js +19 -0
  698. package/daemon/dist/routes/agent-images.js.map +1 -1
  699. package/daemon/dist/routes/attention.d.ts.map +1 -1
  700. package/daemon/dist/routes/attention.js +15 -3
  701. package/daemon/dist/routes/attention.js.map +1 -1
  702. package/daemon/dist/routes/bundles.js +1 -1
  703. package/daemon/dist/routes/bundles.js.map +1 -1
  704. package/daemon/dist/routes/context-packs.d.ts.map +1 -1
  705. package/daemon/dist/routes/context-packs.js +22 -0
  706. package/daemon/dist/routes/context-packs.js.map +1 -1
  707. package/daemon/dist/routes/gateway.d.ts.map +1 -1
  708. package/daemon/dist/routes/gateway.js +42 -0
  709. package/daemon/dist/routes/gateway.js.map +1 -1
  710. package/daemon/dist/routes/hosts.d.ts.map +1 -1
  711. package/daemon/dist/routes/hosts.js +5 -2
  712. package/daemon/dist/routes/hosts.js.map +1 -1
  713. package/daemon/dist/routes/mission-control.d.ts.map +1 -1
  714. package/daemon/dist/routes/mission-control.js +7 -3
  715. package/daemon/dist/routes/mission-control.js.map +1 -1
  716. package/daemon/dist/routes/plugins.js +1 -1
  717. package/daemon/dist/routes/plugins.js.map +1 -1
  718. package/daemon/dist/routes/provider.d.ts.map +1 -1
  719. package/daemon/dist/routes/provider.js +83 -3
  720. package/daemon/dist/routes/provider.js.map +1 -1
  721. package/daemon/dist/routes/queue.d.ts.map +1 -1
  722. package/daemon/dist/routes/queue.js +136 -18
  723. package/daemon/dist/routes/queue.js.map +1 -1
  724. package/daemon/dist/routes/require-sender-identity.d.ts +10 -8
  725. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  726. package/daemon/dist/routes/require-sender-identity.js +13 -11
  727. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  728. package/daemon/dist/routes/rigs.js +4 -0
  729. package/daemon/dist/routes/rigs.js.map +1 -1
  730. package/daemon/dist/routes/runtime-switch-custody.d.ts +21 -0
  731. package/daemon/dist/routes/runtime-switch-custody.d.ts.map +1 -0
  732. package/daemon/dist/routes/runtime-switch-custody.js +55 -0
  733. package/daemon/dist/routes/runtime-switch-custody.js.map +1 -0
  734. package/daemon/dist/routes/scope-approve.js +2 -2
  735. package/daemon/dist/routes/scope-approve.js.map +1 -1
  736. package/daemon/dist/routes/scope-audit.js +1 -1
  737. package/daemon/dist/routes/scope-audit.js.map +1 -1
  738. package/daemon/dist/routes/seat.d.ts.map +1 -1
  739. package/daemon/dist/routes/seat.js +135 -18
  740. package/daemon/dist/routes/seat.js.map +1 -1
  741. package/daemon/dist/routes/sessions.d.ts.map +1 -1
  742. package/daemon/dist/routes/sessions.js +24 -3
  743. package/daemon/dist/routes/sessions.js.map +1 -1
  744. package/daemon/dist/routes/skills.js +1 -1
  745. package/daemon/dist/routes/skills.js.map +1 -1
  746. package/daemon/dist/routes/slices.js +1 -1
  747. package/daemon/dist/routes/slices.js.map +1 -1
  748. package/daemon/dist/routes/startup.js +15 -5
  749. package/daemon/dist/routes/startup.js.map +1 -1
  750. package/daemon/dist/routes/stream.d.ts.map +1 -1
  751. package/daemon/dist/routes/stream.js +25 -2
  752. package/daemon/dist/routes/stream.js.map +1 -1
  753. package/daemon/dist/routes/transcripts.js +2 -2
  754. package/daemon/dist/routes/transcripts.js.map +1 -1
  755. package/daemon/dist/routes/transport.d.ts.map +1 -1
  756. package/daemon/dist/routes/transport.js +41 -4
  757. package/daemon/dist/routes/transport.js.map +1 -1
  758. package/daemon/dist/routes/workflow.js +1 -1
  759. package/daemon/dist/routes/workflow.js.map +1 -1
  760. package/daemon/dist/seat-recap-store-surface.d.ts +1 -1
  761. package/daemon/dist/seat-recap-store-surface.d.ts.map +1 -1
  762. package/daemon/dist/seat-recap-store-surface.js +1 -1
  763. package/daemon/dist/seat-recap-store-surface.js.map +1 -1
  764. package/daemon/dist/server.d.ts +2 -0
  765. package/daemon/dist/server.d.ts.map +1 -1
  766. package/daemon/dist/server.js +1 -0
  767. package/daemon/dist/server.js.map +1 -1
  768. package/daemon/dist/startup.d.ts +5 -0
  769. package/daemon/dist/startup.d.ts.map +1 -1
  770. package/daemon/dist/startup.js +107 -29
  771. package/daemon/dist/startup.js.map +1 -1
  772. package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -2
  773. package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
  774. package/daemon/dist/terminal/TerminalSessionBroker.js +60 -9
  775. package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
  776. package/daemon/dist/terminal/window-pin.d.ts +41 -0
  777. package/daemon/dist/terminal/window-pin.d.ts.map +1 -0
  778. package/daemon/dist/terminal/window-pin.js +103 -0
  779. package/daemon/dist/terminal/window-pin.js.map +1 -0
  780. package/daemon/docs/reference/a2a-agents.md +16 -4
  781. package/daemon/docs/reference/agent-startup-guide.md +34 -2
  782. package/daemon/docs/reference/community-harness-examples/cursor/cursor.yaml +2 -2
  783. package/daemon/docs/reference/community-harness-examples/cursor/openrig-cursor-launch +7 -0
  784. package/daemon/docs/reference/community-harness-examples/hermes/config.yaml.example +2 -1
  785. package/daemon/docs/reference/community-harness-examples/openclaw/openclaw-gateway.yaml +15 -0
  786. package/daemon/docs/reference/community-harness-examples/openclaw/openclaw.yaml +5 -2
  787. package/daemon/docs/reference/community-harness-examples/openclaw/openrig-openclaw-launch +56 -24
  788. package/daemon/docs/reference/community-harness-presets.md +104 -19
  789. package/daemon/docs/reference/gateway-participants.md +165 -0
  790. package/daemon/docs/reference/getting-started.md +84 -10
  791. package/daemon/docs/reference/health-diagnosis.md +13 -0
  792. package/daemon/docs/reference/help.md +6 -0
  793. package/daemon/docs/reference/keeping-a-watch.md +21 -0
  794. package/daemon/docs/reference/project-workspace.md +18 -0
  795. package/daemon/docs/reference/publishing-a-rig-bundle.md +11 -0
  796. package/daemon/docs/reference/quickstart.md +13 -1
  797. package/daemon/docs/reference/rig-spec.md +179 -6
  798. package/daemon/docs/reference/sdlc-conventions.md +3 -1
  799. package/daemon/docs/reference/seat-delivery.md +25 -5
  800. package/daemon/docs/reference/seat-node-targeting.md +17 -0
  801. package/daemon/docs/reference/slack-app-setup.md +21 -3
  802. package/daemon/docs/reference/terminal-sessions.md +51 -0
  803. package/daemon/docs/reference/whats-new.md +148 -169
  804. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +37 -3
  805. package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +20 -5
  806. package/daemon/specs/agents/shared/skills/process/agent-browser/LICENSE.txt +201 -0
  807. package/daemon/specs/agents/shared/skills/process/agent-browser/OPENRIG.md +13 -29
  808. package/daemon/specs/agents/shared/skills/process/agent-browser/SKILL.md +8 -8
  809. package/daemon/specs/agents/shared/skills/process/dogfood/LICENSE.txt +201 -0
  810. package/daemon/specs/agents/shared/skills/process/dogfood/SKILL.md +6 -2
  811. package/daemon/specs/agents/shared/skills/process/systematic-debugging/LICENSE.txt +21 -0
  812. package/daemon/specs/agents/shared/skills/process/systematic-debugging/SKILL.md +6 -2
  813. package/daemon/specs/agents/shared/skills/process/systematic-debugging/root-cause-tracing.md +1 -1
  814. package/daemon/specs/agents/shared/skills/process/test-driven-development/LICENSE.txt +21 -0
  815. package/daemon/specs/agents/shared/skills/process/test-driven-development/SKILL.md +5 -1
  816. package/daemon/specs/agents/shared/skills/process/verification-before-completion/LICENSE.txt +21 -0
  817. package/daemon/specs/agents/shared/skills/process/verification-before-completion/SKILL.md +5 -1
  818. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +18 -1
  819. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +3 -0
  820. package/daemon/specs/rigs/launch/kernel/agents/queue/worker/guidance/role.md +3 -2
  821. package/dist/build-info.js +3 -3
  822. package/dist/client.d.ts +12 -0
  823. package/dist/client.d.ts.map +1 -1
  824. package/dist/client.js +20 -2
  825. package/dist/client.js.map +1 -1
  826. package/dist/commands/acp.js +1 -1
  827. package/dist/commands/auth.d.ts.map +1 -1
  828. package/dist/commands/auth.js +2 -1
  829. package/dist/commands/auth.js.map +1 -1
  830. package/dist/commands/capture.d.ts +27 -0
  831. package/dist/commands/capture.d.ts.map +1 -1
  832. package/dist/commands/capture.js +68 -2
  833. package/dist/commands/capture.js.map +1 -1
  834. package/dist/commands/chatroom.d.ts.map +1 -1
  835. package/dist/commands/chatroom.js +6 -0
  836. package/dist/commands/chatroom.js.map +1 -1
  837. package/dist/commands/context.d.ts.map +1 -1
  838. package/dist/commands/context.js +29 -23
  839. package/dist/commands/context.js.map +1 -1
  840. package/dist/commands/doctor.d.ts +9 -1
  841. package/dist/commands/doctor.d.ts.map +1 -1
  842. package/dist/commands/doctor.js +18 -2
  843. package/dist/commands/doctor.js.map +1 -1
  844. package/dist/commands/down.d.ts.map +1 -1
  845. package/dist/commands/down.js +9 -2
  846. package/dist/commands/down.js.map +1 -1
  847. package/dist/commands/env.d.ts.map +1 -1
  848. package/dist/commands/env.js +3 -0
  849. package/dist/commands/env.js.map +1 -1
  850. package/dist/commands/export.d.ts.map +1 -1
  851. package/dist/commands/export.js +57 -5
  852. package/dist/commands/export.js.map +1 -1
  853. package/dist/commands/gateway.d.ts.map +1 -1
  854. package/dist/commands/gateway.js +309 -23
  855. package/dist/commands/gateway.js.map +1 -1
  856. package/dist/commands/health.js +1 -1
  857. package/dist/commands/health.js.map +1 -1
  858. package/dist/commands/launch.js +1 -1
  859. package/dist/commands/launch.js.map +1 -1
  860. package/dist/commands/project.d.ts.map +1 -1
  861. package/dist/commands/project.js +6 -1
  862. package/dist/commands/project.js.map +1 -1
  863. package/dist/commands/proof.d.ts.map +1 -1
  864. package/dist/commands/proof.js +33 -2
  865. package/dist/commands/proof.js.map +1 -1
  866. package/dist/commands/provider.d.ts.map +1 -1
  867. package/dist/commands/provider.js +172 -24
  868. package/dist/commands/provider.js.map +1 -1
  869. package/dist/commands/queue.d.ts.map +1 -1
  870. package/dist/commands/queue.js +180 -38
  871. package/dist/commands/queue.js.map +1 -1
  872. package/dist/commands/rig-mode.d.ts +1 -2
  873. package/dist/commands/rig-mode.d.ts.map +1 -1
  874. package/dist/commands/rig-mode.js +2 -2
  875. package/dist/commands/rig-mode.js.map +1 -1
  876. package/dist/commands/scope.d.ts.map +1 -1
  877. package/dist/commands/scope.js +17 -6
  878. package/dist/commands/scope.js.map +1 -1
  879. package/dist/commands/seat.d.ts.map +1 -1
  880. package/dist/commands/seat.js +243 -6
  881. package/dist/commands/seat.js.map +1 -1
  882. package/dist/commands/send.d.ts +3 -0
  883. package/dist/commands/send.d.ts.map +1 -1
  884. package/dist/commands/send.js +16 -18
  885. package/dist/commands/send.js.map +1 -1
  886. package/dist/commands/setup.d.ts.map +1 -1
  887. package/dist/commands/setup.js +10 -2
  888. package/dist/commands/setup.js.map +1 -1
  889. package/dist/commands/skill.d.ts.map +1 -1
  890. package/dist/commands/skill.js +22 -1
  891. package/dist/commands/skill.js.map +1 -1
  892. package/dist/commands/slack.d.ts +10 -0
  893. package/dist/commands/slack.d.ts.map +1 -1
  894. package/dist/commands/slack.js +70 -2
  895. package/dist/commands/slack.js.map +1 -1
  896. package/dist/commands/stream-outcome.d.ts +586 -1
  897. package/dist/commands/stream-outcome.d.ts.map +1 -1
  898. package/dist/commands/stream-outcome.js +38 -1
  899. package/dist/commands/stream-outcome.js.map +1 -1
  900. package/dist/commands/stream.d.ts.map +1 -1
  901. package/dist/commands/stream.js +22 -0
  902. package/dist/commands/stream.js.map +1 -1
  903. package/dist/commands/terminal.d.ts +4 -0
  904. package/dist/commands/terminal.d.ts.map +1 -1
  905. package/dist/commands/terminal.js +7 -5
  906. package/dist/commands/terminal.js.map +1 -1
  907. package/dist/commands/up.d.ts.map +1 -1
  908. package/dist/commands/up.js +7 -1
  909. package/dist/commands/up.js.map +1 -1
  910. package/dist/config-store.d.ts.map +1 -1
  911. package/dist/config-store.js +3 -2
  912. package/dist/config-store.js.map +1 -1
  913. package/dist/daemon-lifecycle.d.ts +1 -1
  914. package/dist/daemon-lifecycle.js +2 -2
  915. package/dist/daemon-lifecycle.js.map +1 -1
  916. package/dist/fetch-with-timeout.d.ts.map +1 -1
  917. package/dist/fetch-with-timeout.js +3 -1
  918. package/dist/fetch-with-timeout.js.map +1 -1
  919. package/dist/lib/codex-auth.d.ts +1 -147
  920. package/dist/lib/codex-auth.d.ts.map +1 -1
  921. package/dist/lib/codex-auth.js +2 -505
  922. package/dist/lib/codex-auth.js.map +1 -1
  923. package/dist/lib/scope/dot-id.js +2 -2
  924. package/dist/lib/scope/dot-id.js.map +1 -1
  925. package/dist/lib/scope/scaffold-placeholder.d.ts +1 -1
  926. package/dist/lib/scope/scaffold-placeholder.js +1 -1
  927. package/dist/lib/scope/scope-audit.js +1 -1
  928. package/dist/lib/scope/scope-audit.js.map +1 -1
  929. package/dist/lib/scope/types.d.ts.map +1 -1
  930. package/dist/lib/scope/types.js +2 -3
  931. package/dist/lib/scope/types.js.map +1 -1
  932. package/dist/long-request-fetch.d.ts +9 -0
  933. package/dist/long-request-fetch.d.ts.map +1 -0
  934. package/dist/long-request-fetch.js +48 -0
  935. package/dist/long-request-fetch.js.map +1 -0
  936. package/dist/mcp-server.d.ts.map +1 -1
  937. package/dist/mcp-server.js +53 -2
  938. package/dist/mcp-server.js.map +1 -1
  939. package/dist/release-surface/affected-skills.d.ts.map +1 -1
  940. package/dist/release-surface/affected-skills.js +1 -2
  941. package/dist/release-surface/affected-skills.js.map +1 -1
  942. package/dist/remote-host-ops.d.ts +1 -0
  943. package/dist/remote-host-ops.d.ts.map +1 -1
  944. package/dist/remote-host-ops.js +2 -2
  945. package/dist/remote-host-ops.js.map +1 -1
  946. package/dist/terminal-window-rex.d.ts +6 -0
  947. package/dist/terminal-window-rex.d.ts.map +1 -0
  948. package/dist/terminal-window-rex.js +129 -0
  949. package/dist/terminal-window-rex.js.map +1 -0
  950. package/dist/terminal-window.d.ts +2 -0
  951. package/dist/terminal-window.d.ts.map +1 -1
  952. package/dist/terminal-window.js +19 -7
  953. package/dist/terminal-window.js.map +1 -1
  954. package/dist/tmux-health.d.ts +26 -0
  955. package/dist/tmux-health.d.ts.map +1 -1
  956. package/dist/tmux-health.js +42 -0
  957. package/dist/tmux-health.js.map +1 -1
  958. package/package.json +1 -1
  959. package/tui/dist/attention/attention-model.d.ts +19 -0
  960. package/tui/dist/attention/attention-model.d.ts.map +1 -1
  961. package/tui/dist/attention/attention-model.js +38 -6
  962. package/tui/dist/attention/attention-model.js.map +1 -1
  963. package/tui/dist/commands/registry.d.ts.map +1 -1
  964. package/tui/dist/commands/registry.js +5 -2
  965. package/tui/dist/commands/registry.js.map +1 -1
  966. package/tui/dist/daemon-client.d.ts +13 -7
  967. package/tui/dist/daemon-client.d.ts.map +1 -1
  968. package/tui/dist/daemon-client.js +20 -11
  969. package/tui/dist/daemon-client.js.map +1 -1
  970. package/tui/dist/demo-data.js +17 -17
  971. package/tui/dist/demo-data.js.map +1 -1
  972. package/tui/dist/hydrate.d.ts +1 -1
  973. package/tui/dist/hydrate.d.ts.map +1 -1
  974. package/tui/dist/hydrate.js +35 -11
  975. package/tui/dist/hydrate.js.map +1 -1
  976. package/tui/dist/live-events.js +1 -1
  977. package/tui/dist/live-events.js.map +1 -1
  978. package/tui/dist/live.d.ts.map +1 -1
  979. package/tui/dist/live.js +6 -4
  980. package/tui/dist/live.js.map +1 -1
  981. package/tui/dist/main.js +27 -7
  982. package/tui/dist/main.js.map +1 -1
  983. package/tui/dist/page-read.js +1 -1
  984. package/tui/dist/page-read.js.map +1 -1
  985. package/tui/dist/render.d.ts.map +1 -1
  986. package/tui/dist/render.js +51 -7
  987. package/tui/dist/render.js.map +1 -1
  988. package/tui/dist/state.d.ts.map +1 -1
  989. package/tui/dist/state.js +5 -1
  990. package/tui/dist/state.js.map +1 -1
  991. package/tui/dist/terminals/open-window.d.ts +15 -6
  992. package/tui/dist/terminals/open-window.d.ts.map +1 -1
  993. package/tui/dist/terminals/open-window.js +47 -15
  994. package/tui/dist/terminals/open-window.js.map +1 -1
  995. package/tui/dist/terminals/terminal-model.d.ts +2 -1
  996. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  997. package/tui/dist/terminals/terminal-model.js +5 -4
  998. package/tui/dist/terminals/terminal-model.js.map +1 -1
  999. package/tui/dist/types.d.ts +10 -1
  1000. package/tui/dist/types.d.ts.map +1 -1
  1001. package/tui/dist/usage/usage-model.d.ts.map +1 -1
  1002. package/tui/dist/usage/usage-model.js +5 -3
  1003. package/tui/dist/usage/usage-model.js.map +1 -1
  1004. package/ui/dist/assets/{index-Blg-p32B.js → index-DV0UNxFw.js} +2 -2
  1005. package/ui/dist/index.html +1 -1
@@ -586,7 +586,7 @@ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHid
586
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),[h,d]=C.useState(null),[m,f]=C.useState(!1),g=_=>{d(_),f(!0)},x=()=>{h&&c.mutate(h,{onSuccess:()=>{f(!1),d(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(h=>typeof h=="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,h]=C.useState(null),[d,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()});h(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:[...d]});h(q),r("done")}catch(q){y(q.message),r("error")}},N=()=>{r("enter"),o(""),h(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)&&d.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||d.has(q.key),disabled:f||q.classification==="manual_only",onChange:B=>{const F=new Set(d);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,h]=C.useState("idle"),[d,m]=C.useState([]);C.useEffect(()=>{n(a)},[n,a]),C.useEffect(()=>{t&&(o(t.yaml),r())},[r,t]);const f=async()=>{s(a),h("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){h("valid");return}m(x.errors??["Validation failed"]),h("invalid")}catch{m(["Validation request failed"]),h("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:d.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(d=>[d.id,d])),c=n.nodes.map(d=>{const m=o.get(d.id)??{x:0,y:0};return{id:d.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:[d.pod?`${d.pod} / `:"",d.label]}),i.jsx(Cs,{runtime:d.runtime,size:"xs",compact:!0,variant:"inline"})]})},style:{backgroundColor:Swe(d.runtime),border:"1px solid #8a8577",fontSize:11,fontFamily:"monospace",width:bwe,height:_we}}}),h=n.edges.map((d,m)=>({id:`e-${m}`,source:d.source,target:d.target,label:d.kind,labelStyle:{fontSize:9,fontFamily:"monospace"},style:{strokeDasharray:"4 4",stroke:"#8a8577"}}));return{nodes:c,edges:h}},[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"],[h,d]=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:()=>d(w),className:`px-3 py-1.5 font-mono text-[10px] uppercase tracking-wider transition-colors ${h===w?"border-b-2 border-on-surface text-on-surface font-bold":"text-on-surface-variant hover:text-on-surface"}`,children:w},w))}),h==="topology"&&e&&i.jsx(Nwe,{graph:e.graph,testId:`${x}topology-preview`}),h==="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))})]})]})]}),h==="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))]})]}),h==="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)??[],h=(r==null?void 0:r.nodes)??[],d=(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:h.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):h.length,testId:"rig-spec-summary-members"}),i.jsx(st,{label:"Edges",value:d.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,h)=>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]},h))]}),a.guidance.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Guidance:"})," ",a.guidance.map((c,h)=>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}-${h}`))]}),a.plugins.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-on-surface-variant",children:"Plugins:"})," ",a.plugins.map((c,h)=>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}-${h}`))]})]})]}),(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,h)=>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"})]},h))]}),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,h)=>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]},h))]})]}),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 h=r.integrityResult.mismatches.includes(c),d=r.integrityResult.missing.includes(c),m=h?"MISMATCH":d?"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(""),[h,d]=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});d(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()});d(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"&&h&&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:h.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"&&h&&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:h.status.toUpperCase()}),h.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"})]}),h.rigId&&i.jsxs("div",{className:"text-label-sm font-mono","data-testid":"result-rig-id",children:["Rig: ",h.rigId]}),h.rigId&&i.jsx(Se,{variant:"tactical",className:"mt-spacing-3",onClick:()=>e({to:"/rigs/$rigId",params:{rigId:h.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 h=$we(e),d=new Map;for(const b of e.nodes){const _=h.get(b.stepId)??0;d.has(_)||d.set(_,[]),d.get(_).push(b.stepId)}const m=new Map;for(const[b,_]of d)_.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,h);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"}:e.status==="aborted"?{glyph:"⊘",label:"ABORTED",cls:"text-on-surface-variant"}:{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(d=>d.status==="active"||d.status==="waiting").length,h=o.filter(d=>Zi(d)<=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",h>0?` · ${h} need attention`:""]})]}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:o.map(d=>i.jsx(UV,{instance:d},d.instanceId))})]})}function Qwe({entry:e}){const[t,n]=C.useState(!1),[s,r]=C.useState(null),[a,o]=C.useState(null),[c,h]=C.useState(null),[d,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||!d.trim())throw new Error("Missing required fields");const T={id:d.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)??d.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),h(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),h(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=>h(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:d,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||!d.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??d} 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(d=>[d.name,d]));const a=e.pods??[],o=e.nodes??[],c=e.edges??[],h=d=>{if(!d.startsWith("local:"))return null;const m=d.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 d=a.find(m=>m.members.some(f=>f.id==="specialist"));return d?i.jsx(st,{label:"Specialist Agent",value:`${d.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((d,m)=>d+m.members.length,0):o.length,testId:"lib-rig-members"}),i.jsx(st,{label:"Edges",value:c.length+(e.format==="pod_aware"?a.reduce((d,m)=>{var f;return d+(((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:(d,m)=>{const f=h(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),h=(s==null?void 0:s.specName)===e.name&&(s==null?void 0:s.specVersion)===e.version,d=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:[h?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 d(),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(h=>h.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(h=>h.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,h]=C.useState(null),d=async()=>{if(!(t!=null&&t.starterSnippet))return;await ia(t.starterSnippet)&&(o(!0),window.setTimeout(()=>o(!1),2e3))},m=async()=>{h(null);try{await r.mutateAsync({id:e.id,pin:!e.pinned})}catch(f){h(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 d(),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",h=!!(n!=null&&n.recent),d=h?null:ME(e.agentActivity),m=!h&&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":h?"ring":r,className:c?"topology-table-active-shimmer text-emerald-600":"text-on-surface",children:[o,d?` ${d.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(h=>h.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,[h,d]=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:h,onSelect:d}),i.jsxs("div",{"data-testid":"live-node-tab-body",className:"space-y-4",children:[h==="overview"&&i.jsx(M1e,{data:n,activityVisual:c}),h==="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 h=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:()=>{h()},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(h=>h.startsWith("# WARNING:")).map(h=>h.replace(/^# WARNING:\s*/,"")),c=a.filter(h=>!h.startsWith("# WARNING:")).join(`
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((h,d)=>i.jsx("div",{className:"text-warning font-mono",children:h},d))}),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 h;return(h=navigator.clipboard)==null?void 0:h.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,h]=C.useState(!1),[d,m]=C.useState(""),[f,g]=C.useState(""),x=k=>{o(k),h(!0),m(""),g(""),s.reset()},y=()=>{h(!1),o(null)},b=()=>{!a||!d||!f.trim()||s.mutate({discoveredId:a,rigId:d,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:h,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:d,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:()=>h(!1),children:"CANCEL"}),i.jsx(Se,{variant:"tactical",onClick:b,disabled:!d||!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")),[h,d]=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:h||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:h,onChange:A=>d(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:h,onPrimary:d,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:d,"data-testid":`rig-primary-action-${e}`,className:"w-full font-mono text-[10px] tracking-widest",children:s==="up"?"RUNNING":h})}),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","leave-attached":"info"},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"),h=((b=r.data)==null?void 0:b.nodes)??[],d=h.map(_=>_.logicalId);C.useEffect(()=>{n&&(c("restore-original"),a.reset(),r.mutate(void 0))},[n,e]);function m(_){_!==o&&(c(_),r.mutate(_==="fresh"?h.map(w=>w.logicalId):void 0))}const f=h.filter(_=>_.intendedAction==="awaiting-decision"),g=o==="restore-original"&&f.length>0,x=!g&&h.length>0&&!r.isPending&&!a.isPending;function y(){a.mutate(o==="fresh"?d: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:h.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:[],h=c.filter(f=>f.startup_status==="ready").length,d=[`kernel-status.kernel_state=${e.kernel_state??"unknown"}`,...e.variant?[`variant=${e.variant}`]:[],`agents ${h}/${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:h,seatsTotal:c.length,recoverable:o==="down"||o==="partial",src:d,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,h]=C.useState(""),[d,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=d.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=>h(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:()=>{h(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:d,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,h=(typeof window>"u"?"localhost":window.location.hostname||"localhost").toUpperCase(),d=!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 ",h," IS ",i.jsxs("b",{children:["[ ",d?"ONLINE":"CONNECTING"," ]"]})]}),i.jsx(ySe,{station:h,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(`
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((h,d)=>i.jsx("div",{className:"text-warning font-mono",children:h},d))}),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 h;return(h=navigator.clipboard)==null?void 0:h.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,h]=C.useState(!1),[d,m]=C.useState(""),[f,g]=C.useState(""),x=k=>{o(k),h(!0),m(""),g(""),s.reset()},y=()=>{h(!1),o(null)},b=()=>{!a||!d||!f.trim()||s.mutate({discoveredId:a,rigId:d,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:h,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:d,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:()=>h(!1),children:"CANCEL"}),i.jsx(Se,{variant:"tactical",onClick:b,disabled:!d||!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")),[h,d]=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:h||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:h,onChange:A=>d(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",untracked:"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",untracked:"border-stone-300 text-stone-500"},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.",untracked:"Kernel boot was skipped; readiness is not tracked."};function Fk({rigId:e,rigName:t,isKernel:n=!1,status:s,seatsRunning:r,seatsTotal:a,recoverable:o,src:c,primaryLabel:h,onPrimary:d,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==="untracked"?"boot not tracked":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:d,"data-testid":`rig-primary-action-${e}`,className:"w-full font-mono text-[10px] tracking-widest",children:s==="up"?"RUNNING":h})}),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","leave-attached":"info"},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"),h=((b=r.data)==null?void 0:b.nodes)??[],d=h.map(_=>_.logicalId);C.useEffect(()=>{n&&(c("restore-original"),a.reset(),r.mutate(void 0))},[n,e]);function m(_){_!==o&&(c(_),r.mutate(_==="fresh"?h.map(w=>w.logicalId):void 0))}const f=h.filter(_=>_.intendedAction==="awaiting-decision"),g=o==="restore-original"&&f.length>0,x=!g&&h.length>0&&!r.isPending&&!a.isPending;function y(){a.mutate(o==="fresh"?d: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:h.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"skipped":return"untracked";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=Array.isArray(e.agents)?rSe(e.kernel_state):"unknown",c=Array.isArray(e.agents)?e.agents:[],h=c.filter(f=>f.startup_status==="ready").length,d=[`kernel-status.kernel_state=${e.kernel_state??"unknown"}`,...e.variant?[`variant=${e.variant}`]:[],`agents ${h}/${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:h,seatsTotal:c.length,recoverable:o==="down"||o==="partial",src:d,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,h]=C.useState(""),[d,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=d.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=>h(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:()=>{h(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:d,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,h=(typeof window>"u"?"localhost":window.location.hostname||"localhost").toUpperCase(),d=!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 ",h," IS ",i.jsxs("b",{children:["[ ",d?"ONLINE":"CONNECTING"," ]"]})]}),i.jsx(ySe,{station:h,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"),h=Cn(t,"state","toState"),d=Cn(t,"tier"),m=ESe(e.type,h,d),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(h=>h.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:h,source:d}=Xf(c.agentActivity,c.terminalActive);h==="needs_input"&&n.push({logicalId:c.logicalId,sessionName:c.canonicalSessionName,source:d,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 h of t)h>=s?c.add(h):o=!0;o&&(n(c),zk(c))},[s,t]);const r=C.useCallback(o=>{n(c=>{if(c.has(o))return c;const h=new Set(c);return h.add(o),zk(h),h})},[]),a=C.useCallback(o=>{n(c=>{if(!c.has(o))return c;const h=new Set(c);return h.delete(o),zk(h),h})},[]);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 h of t)s.has(h)?c.add(h):o=!0;o&&(n(c),Hk(c))},[s,t]);const r=C.useCallback(o=>{n(c=>{if(c.has(o))return c;const h=new Set(c);return h.add(o),Hk(h),h})},[]),a=C.useCallback(o=>{n(c=>{if(!c.has(o))return c;const h=new Set(c);return h.delete(o),Hk(h),h})},[]);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:h,accent:d,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 ${h} 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:d,textClass:_}),f==="stat"&&i.jsx(tje,{label:r,num:n,icon:a,body:o,graphic:c,to:t,accent:d,textClass:_}),f==="coordinate"&&i.jsx(nje,{label:r,num:n,icon:a,body:o,graphic:c,to:t,accent:d,textClass:_}),f==="schematic"&&i.jsx(sje,{label:r,num:n,icon:a,body:o,graphic:c,to:t,accent:d,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:d,textClass:_}),d&&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:h}){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 ${h}`,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 ${h} ${c?"text-tertiary":"text-on-surface"}`,children:r}),i.jsxs("span",{className:`ml-auto font-mono text-[9px] tracking-tight text-on-surface-variant ${h}`,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 h=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:h.map((d,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:h.map((d,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((d,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((d,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:h,washed:d}){const m=h??["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 ${d?"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:h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.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 h=W1e(),[d,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=d==="route"||d==="handoff",A=d==="annotate",T=d==="hold"||d==="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;h.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(){d&&P(d,{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."})]}),d?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[d].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:h.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",d===Y?h8[Y].active:h8[Y].idle),children:[i.jsx(z,{className:"h-3 w-3",strokeWidth:1.7}),Q.label]},Y)})}),d&&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[d].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:`${d} 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:h.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:h.isPending?"...":`Confirm ${vu[d].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),[h,d]=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:()=>d(P=>!P),className:"border border-outline px-3 py-1 font-mono text-[11px] uppercase hover:bg-surface-variant disabled:opacity-50",children:"⌨ Chat"})]}),h&&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
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,[h,d]=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(h===null?ne:ne.filter(ie=>(ie.hostId??"local")===h)).filter(ie=>hv(ie)?!T.has(ie.id):!k.has(ie.source.seq))},[w,t,h,$.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":h===null,onClick:()=>d(null),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",h===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":h===K.hostId,"data-host-status":K.status,onClick:()=>d(h===K.hostId?null:K.hostId),className:ce("px-2 py-1 border font-mono text-[9px] uppercase tracking-wide",h===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:h=[],isLoading:d}=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:h,isLoading:d}),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(""),[h,d]=C.useState(null),[m,f]=C.useState(!1);C.useEffect(()=>{if(!t||!a)return;const y=JF(t);y&&(c(v8(y)),d(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&&d(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),d(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)),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:".."})}),g.data.entries.map(y=>{const b=dNe(o,y.name),_=y.type==="file",w=h===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:()=>{_?d(b):y.type==="dir"&&(c(b),d(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:h?i.jsx(fNe,{skillId:a.id,path:h}):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,h]=C.useState(null),[d,m]=C.useState(!1),f=yNe(e,a);if(C.useEffect(()=>{if(d||a!==""||!f.data)return;const _=NNe(f.data.entries);_&&h(_),m(!0)},[f.data,a,d]),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(_),h(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)),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:".."})}),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?h(w):_.type==="dir"&&(o(w),h(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),[h,d]=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),d(!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),d(!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:h,onToggleEditMode:()=>d(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 h=t?`${t}/${c.name}`:c.name,d=c.type==="file",m=r===h;return i.jsx("li",{children:i.jsx("button",{type:"button","data-testid":`files-entry-${h}`,"data-type":c.type,onClick:()=>d?s(h):c.type==="dir"?n(h):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})},h)})]})}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[{draft:s,base:r},a]=C.useState({draft:n.content,base:n}),[o,c]=C.useState(null),[h,d]=C.useState(null),[m,f]=C.useState(!1),g=ete(),x=C.useRef(g.isPending);x.current=g.isPending;const y=mt();C.useEffect(()=>{const _=x.current;a(w=>_||w.draft!==w.base.content?w:{draft:n.content,base:n})},[n.contentHash,n.mtime,n.content]);const b=C.useMemo(()=>s!==r.content,[s,r.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:b?"draft (unsaved)":"no changes"}),i.jsx("button",{type:"button","data-testid":"files-editor-save",disabled:!b||g.isPending,onClick:()=>{c(null),d(null),f(!1),g.mutate({root:e,path:t,content:s,expectedMtime:r.mtime,expectedContentHash:r.contentHash,actor:"ui-files-edit-mode"},{onSuccess:_=>{"conflict"in _?d({currentMtime:_.currentMtime,currentContentHash:_.currentContentHash}):(a(w=>({...w,base:{...r,content:s,mtime:_.newMtime,contentHash:_.newContentHash}})),f(!0),setTimeout(()=>f(!1),2e3))},onError:_=>{c(_ instanceof Error?_.message:String(_))}})},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:()=>{a({draft:n.content,base:n}),c(null),d(null)},className:"border border-outline bg-surface-lowest px-2 py-0.5 uppercase tracking-[0.10em] text-on-surface",children:"cancel"}),m&&i.jsx("span",{"data-testid":"files-editor-saved",className:"ml-auto text-emerald-700",children:"saved"})]}),h&&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:r.mtime})," ≠ server ",i.jsx("code",{children:h.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:async()=>{const _=["files","read",e,t];try{await y.refetchQueries({queryKey:_,exact:!0},{throwOnError:!0});const w=y.getQueryData(_);w&&(a({draft:w.content,base:w}),d(null),c(null))}catch(w){c(w instanceof Error?w.message:String(w))}},className:"border border-red-500 bg-surface-lowest px-2 py-0.5 uppercase tracking-[0.10em] text-red-900",children:"refresh"})]}),o&&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: ",o]}),i.jsx("textarea",{"data-testid":"files-editor-textarea",value:s,onChange:_=>{const w=_.target.value;a(E=>({...E,draft:w}))},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),[h,d]=C.useState(!1);async function m(f){f.preventDefault(),d(!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);d(!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"}),h&&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,h=(n==null?void 0:n.length)??0,d=(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:h})]}),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:d})]})]})]})]})}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"}];/**
@@ -620,4 +620,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
620
620
  `).trim();return a.length>0?a:null}function yEe({missionId:e}){const t=FT(e),{known:n,isLocal:s}=sd(),a=rd()&&t.data&&"missionPath"in t.data?t.data.missionPath:null,o=Yl(a,"MISSION_BRIEF.md");if(n&&!s)return i.jsx("div",{"data-testid":`portfolio-glance-remote-gated-${e}`,className:"font-mono text-[11px] text-on-surface-variant",children:"Local files not shown — the steering glance reads MISSION_BRIEF.md from the selected host's filesystem, which the remote read view does not browse."});if(!n||t.isLoading||o.isLoading)return i.jsx("div",{"data-testid":`portfolio-glance-loading-${e}`,className:"font-mono text-[11px] text-on-surface-variant",children:"Loading steering…"});if(o.unavailable||!o.content)return i.jsx("div",{"data-testid":`portfolio-glance-empty-${e}`,className:"font-mono text-[11px] text-on-surface-variant",children:"No MISSION_BRIEF.md at this mission root yet — the steering glance projects here once it is briefed."});const c=U8(o.content,"Building"),h=U8(o.content,"Needs you");return!c&&!h?i.jsx("div",{"data-testid":`portfolio-glance-thin-${e}`,className:"font-mono text-[11px] text-on-surface-variant",children:"MISSION_BRIEF.md has no Building / Needs-you sections yet."}):i.jsxs("div",{"data-testid":`portfolio-glance-${e}`,className:"space-y-2",children:[c?i.jsxs("div",{children:[i.jsx("div",{className:"mb-0.5 font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Building"}),i.jsx(Zn,{content:c,hideFrontmatter:!0,hideRawToggle:!0})]}):null,h?i.jsxs("div",{children:[i.jsx("div",{className:"mb-0.5 font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Needs you"}),i.jsx(Zn,{content:h,hideFrontmatter:!0,hideRawToggle:!0})]}):null]})}function bEe({mission:e,expanded:t,onToggle:n}){const s=LC(e),r=e.slices.length,a=e.slices.filter(c=>c.hasProofPacket).length,o=e.slices.filter(c=>c.status==="active").length;return i.jsxs("article",{"data-testid":`portfolio-mission-${e.id}`,className:"border border-outline-variant bg-surface-lowest/35 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-stretch",children:[i.jsxs("button",{type:"button",onClick:n,"aria-expanded":t,"data-testid":`portfolio-toggle-${e.id}`,className:"flex flex-1 items-start gap-3 px-4 py-3 text-left hover:bg-surface-lowest/50",children:[i.jsx("span",{"aria-hidden":!0,className:ce("mt-0.5 font-mono text-[12px] text-on-surface-variant transition-transform",t&&"rotate-90 text-on-surface-variant"),children:"▸"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("span",{className:"font-mono text-[13px] uppercase tracking-[0.06em] text-on-surface",children:e.label}),i.jsx(MF,{status:e.status,label:e.statusLabel})]}),i.jsxs("div",{className:"mt-1 font-mono text-[10px] uppercase tracking-[0.06em] text-on-surface-variant",children:[a," proven · ",o," active · ",r," slice",r===1?"":"s"," · ",vEe(s)]})]})]}),i.jsx(Ve,{to:"/project/mission/$missionId",params:{missionId:e.id},"data-testid":`portfolio-open-${e.id}`,className:"flex shrink-0 items-center border-l border-outline-variant px-3 font-mono text-[10px] uppercase tracking-[0.08em] text-on-surface-variant hover:bg-surface-lowest/50 hover:text-on-surface",children:"Open →"})]}),t?i.jsxs("div",{className:"border-t border-outline-variant bg-surface-lowest/20 px-4 py-3",children:[i.jsx("div",{className:"mb-1 font-mono text-[9px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Steering glance · MISSION_BRIEF.md"}),i.jsx(yEe,{missionId:e.id})]}):null]})}function _Ee(){const{data:e,isLoading:t}=Zf("all"),n=C.useMemo(()=>{if(!e||"unavailable"in e)return[];const a=new Map;for(const c of e.slices){const h=YF(c),d=h.missionId??h.railItem??"unsorted";a.has(d)||a.set(d,[]),a.get(d).push(h)}const o=e.missions??{};return Array.from(a.entries()).map(([c,h])=>{var m,f;const d=ox(((m=o[c])==null?void 0:m.authoredStatus)??null,h,void 0,(f=o[c])==null?void 0:f.readiness);return{id:c,label:c==="unsorted"?"Unsorted":c,status:d.state,statusLabel:d.label,statusSource:d.source,slices:h}}).sort(OC)},[e]),[s,r]=C.useState(()=>new Set);return t?i.jsx(Ae,{label:"LOADING WORKSPACE",description:"Reading the mission index.",variant:"card",testId:"portfolio-loading"}):e&&"unavailable"in e?i.jsx(Ae,{label:"WORKSPACE INDEX UNAVAILABLE",description:e.hint??"The slice index is not available from the configured workspace.",variant:"card",testId:"portfolio-unavailable"}):n.length===0?i.jsx(Ae,{label:"NO MISSIONS YET",description:"No missions are indexed in this workspace. Missions appear here as you create them; each row opens to its steering glance.",variant:"card",testId:"portfolio-empty"}):i.jsxs("div",{"data-testid":"workspace-portfolio",className:"space-y-3",children:[i.jsxs("div",{className:"flex items-baseline justify-between",children:[i.jsx(ct,{children:"Portfolio · all missions"}),i.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-on-surface-variant",children:[n.length," mission",n.length===1?"":"s"," · most recently modified"]})]}),i.jsx("div",{className:"space-y-2",children:n.map(a=>i.jsx(bEe,{mission:a,expanded:s.has(a.id),onToggle:()=>r(o=>{const c=new Set(o);return c.has(a.id)?c.delete(a.id):c.add(a.id),c})},a.id))})]})}const wEe=[{id:"overview",label:"Overview"},{id:"story",label:"Story"},{id:"progress",label:"Progress"},{id:"artifacts",label:"Artifacts"},{id:"proof",label:"Proof"},{id:"queue",label:"Queue"},{id:"topology",label:"Workflow"}],SEe=[{id:"overview",label:"Overview"},{id:"steering",label:"Steering"},{id:"review",label:"Review"},{id:"story",label:"Story"},{id:"progress",label:"Progress"},{id:"artifacts",label:"Artifacts"},{id:"proof",label:"Proof"},{id:"queue",label:"Queue"},{id:"topology",label:"Workflow"}],sC=[{id:"review",label:"Review"},{id:"story",label:"Story"},{id:"overview",label:"Overview"},{id:"progress",label:"Progress"},{id:"artifacts",label:"Artifacts"},{id:"proof",label:"Proof"},{id:"queue",label:"Queue"},{id:"topology",label:"Workflow"}];function jEe({tabs:e,active:t,onSelect:n}){return i.jsx("div",{role:"tablist","data-testid":"project-tab-nav",className:"flex gap-1 border-b border-outline-variant mb-6 overflow-x-auto",children:e.map(s=>i.jsx("button",{type:"button",role:"tab","aria-selected":t===s.id,"data-testid":`project-tab-${s.id}`,"data-active":t===s.id,onClick:()=>n(s.id),className:ce("px-3 py-2 font-mono text-[10px] uppercase tracking-[0.18em] border-b-2 -mb-px shrink-0",t===s.id?"border-on-surface text-on-surface":"border-transparent text-on-surface-variant hover:text-on-surface"),children:s.label},s.id))})}function VW({testId:e}){return i.jsx("div",{"data-testid":e,className:"font-mono text-[11px] text-on-surface-variant",children:"Resolving host selection…"})}function WW({testId:e}){return i.jsx(Ae,{label:"REVIEW NOT AVAILABLE FOR REMOTE HOSTS",description:"Review composition reads this host's local records. Select the local host to review local work; remote review lands with the MH-3/MH-4 acting lanes.",variant:"card",testId:e})}function uf({eyebrow:e,title:t,hostChip:n,tabs:s,active:r,onSelect:a,children:o}){const c=GR();return i.jsx(KR,{cap:c,children:i.jsxs("div",{className:"mx-auto w-full max-w-[1200px] 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:e}),i.jsxs("h1",{className:"font-headline text-headline-md font-bold tracking-tight uppercase text-on-surface mt-1",children:[t,n?i.jsxs("span",{"data-testid":"scope-host-chip",className:"ml-3 inline-flex translate-y-[-0.15em] items-center bg-inverse-surface px-2 py-0.5 align-middle font-mono text-[11px] font-bold uppercase tracking-[0.14em] text-background",children:["on ",n]}):null]})]}),i.jsx(jEe,{tabs:s,active:r,onSelect:a}),i.jsx("div",{role:"tabpanel","data-testid":"project-tab-panel",children:o})]})})}function GW({label:e,description:t}){return i.jsx(Ae,{label:e,description:t??"Phase 5 polish.",variant:"card",testId:`project-tab-placeholder-${e.toLowerCase()}`})}function NEe(e){return e.missionId??e.railItem??"unsorted"}function kEe(e,t){return t?e.filter(n=>NEe(n)===t):e}function KW(e,t){const n=Zf("all"),s=C.useMemo(()=>!n.data||"unavailable"in n.data?[]:kEe(n.data.slices,e),[n.data,e]),r=TF(t?s.map(c=>c.name):[]),a=C.useMemo(()=>{const c=new Set;for(const h of r.itemsByName.values())Array.isArray(h.qitemIds)&&h.qitemIds.forEach(d=>c.add(d));return Array.from(c).sort()},[r.itemsByName]),o=LE(t?a:[]);return{list:n,rows:s,details:r,qitemIds:a,queueItems:o}}function CEe({rows:e,detailsByName:t,isLoading:n}){return n&&e.length===0?i.jsx(GW,{label:"LOADING PROGRESS",description:"Reading scoped slice progress."}):e.length===0?i.jsx(Ae,{label:"NO SCOPED SLICES",description:"No slices are indexed for this scope.",variant:"card",testId:"scope-progress-empty"}):i.jsx("div",{"data-testid":"scope-progress-rollup",className:"space-y-3",children:e.map(s=>{const r=t.get(s.name);return i.jsxs("article",{className:"border border-outline-variant bg-surface-lowest/35 p-3 backdrop-blur-sm",children:[i.jsx("div",{className:"flex items-start justify-between gap-3 border-b border-outline-variant pb-2",children:i.jsxs("div",{className:"min-w-0",children:[i.jsx(Ve,{to:"/project/slice/$sliceId",params:{sliceId:s.name},className:"font-mono text-[12px] uppercase tracking-[0.12em] text-on-surface hover:underline",children:s.displayName}),i.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[i.jsx(ra,{token:UF(),compact:!0}),i.jsx(ra,{token:{label:s.status,tone:Cv(s.status)},compact:!0}),i.jsx(_f,{value:s.lastActivityAt})]})]})}),i.jsxs("div",{className:"mt-3 grid gap-2 font-mono text-[10px] text-on-surface sm:grid-cols-4",children:[i.jsx(cr,{label:"Qitems",value:(r==null?void 0:r.qitemIds.length)??s.qitemCount}),i.jsx(cr,{label:"Proof",value:r?r.tests.proofPackets.length:s.hasProofPacket?1:0}),i.jsx(cr,{label:"Progress",value:r?`${r.acceptance.percentage}%`:"unknown"}),i.jsx(cr,{label:"Last activity",value:ZW(s.lastActivityAt)})]})]},s.name)})})}function YW({qitemIds:e,queueItemsById:t,isFetching:n}){const s=[...e].sort((r,a)=>{const o=t.get(r),c=t.get(a),h=(o==null?void 0:o.tsCreated)??r,d=(c==null?void 0:c.tsCreated)??a;return h===d?0:h<d?1:-1});return s.length===0?i.jsx(Ae,{label:"NO QITEMS",description:"No queue items are indexed for this scope.",variant:"card",testId:"scope-queue-empty"}):i.jsxs("div",{"data-testid":"scope-queue-rollup",children:[n?i.jsx("div",{className:"mb-2 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading queue bodies..."}):null,i.jsx("ul",{className:"divide-y divide-outline-variant border border-outline-variant",children:s.map(r=>{const a=t.get(r);return i.jsx("li",{className:"bg-surface-lowest/35 backdrop-blur-sm",children:i.jsxs(Ap,{data:QW(r,a),testId:`scope-queue-trigger-${r}`,className:"block w-full px-3 py-2 text-left font-mono text-xs transition-colors hover:bg-surface-lowest/55",children:[i.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[a!=null&&a.state?i.jsx(zE,{state:a.state,compact:!0}):i.jsx(WF,{kind:"queue.item",compact:!0}),i.jsx(_f,{value:a==null?void 0:a.tsCreated})]}),i.jsx("span",{className:"mt-2 block whitespace-pre-wrap break-words text-on-surface",children:XW(r,a)}),a?i.jsxs("span",{className:"mt-2 block space-y-2",children:[i.jsx(HE,{source:a.sourceSession,destination:a.destinationSession,muted:!0}),i.jsx("span",{className:"flex flex-wrap gap-1.5",children:(a.tags??[]).slice(0,5).map(o=>i.jsx(Uu,{tag:o},o))})]}):null]})},r)})})]})}function EEe({rows:e,detailsByName:t}){return e.length===0?i.jsx(Ae,{label:"NO ARTIFACTS",description:"No slices are indexed for this scope.",variant:"card",testId:"scope-artifacts-empty"}):i.jsx("div",{"data-testid":"scope-artifacts-rollup",className:"space-y-3",children:e.map(n=>{const s=t.get(n.name),r=(s==null?void 0:s.tests.proofPackets.length)??(n.hasProofPacket?1:0),a=(s==null?void 0:s.tests.proofPackets.reduce((o,c)=>o+c.screenshots.length,0))??0;return i.jsxs("article",{className:"border border-outline-variant bg-surface-lowest/35 p-3 backdrop-blur-sm",children:[i.jsx(Ve,{to:"/project/slice/$sliceId",params:{sliceId:n.name},className:"font-mono text-[12px] uppercase tracking-[0.12em] text-on-surface hover:underline",children:n.displayName}),i.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[i.jsx(ra,{token:UF(),compact:!0}),i.jsx(ra,{token:{label:n.status,tone:Cv(n.status)},compact:!0})]}),i.jsxs("div",{className:"mt-3 grid gap-2 font-mono text-[10px] text-on-surface sm:grid-cols-4",children:[i.jsx(cr,{label:"Files",value:(s==null?void 0:s.docs.tree.length)??"unknown"}),i.jsx(cr,{label:"Commits",value:(s==null?void 0:s.commitRefs.length)??"unknown"}),i.jsx(cr,{label:"Proof packets",value:r}),i.jsx(cr,{label:"Screenshots",value:a})]})]},n.name)})})}function REe(e){return{qitemId:e.qitemId,tsCreated:e.tsCreated,tsUpdated:e.tsUpdated,sourceSession:e.sourceSession,destinationSession:e.destinationSession,state:e.state,closureReason:e.closureReason??null,closureTarget:e.closureTarget??null,priority:e.priority??null,tier:e.tier??null,blockedOn:e.blockedOn??null,tags:e.tags??[],body:e.body,summary:e.summary??null,chainOfRecord:e.chainOfRecord??null,handedOffFrom:e.handedOffFrom??null,handedOffTo:e.handedOffTo??null,claimedAt:e.claimedAt??null,expiresAt:e.expiresAt??null,closureRequiredAt:e.closureRequiredAt??null,lastNudgeAttempt:e.lastNudgeAttempt??null,lastNudgeResult:e.lastNudgeResult??null,lastHeartbeat:e.lastHeartbeat??null,resolution:e.resolution??null,targetRepo:e.targetRepo??null}}function KT({queueItemsById:e,isFetching:t}){const n=C.useMemo(()=>s2e(Array.from(e.values()).map(REe)),[e]);return t&&n.nodes.length===0?i.jsx(GW,{label:"LOADING STORY",description:"Reading queue lineage."}):i.jsx("div",{"data-testid":"scope-story-rollup",children:i.jsx(c2e,{forest:n})})}function TEe(e){const t=new Map;for(const s of e.values())if(!(!s.topology||!Array.isArray(s.topology.affectedRigs)))for(const r of s.topology.affectedRigs){const a=r.rigName||r.rigId;t.has(a)||t.set(a,{rigId:r.rigId,rigName:r.rigName,sessionNames:new Set});const o=t.get(a);r.sessionNames.forEach(c=>o.sessionNames.add(c))}const n=Array.from(t.values()).map(s=>({rigId:s.rigId,rigName:s.rigName,sessionNames:Array.from(s.sessionNames).sort()}));return{affectedRigs:n,totalSeats:n.reduce((s,r)=>s+r.sessionNames.length,0),specGraph:null}}function AEe({detailsByName:e}){return i.jsx("div",{"data-testid":"scope-topology-rollup",children:i.jsx(HT,{topology:TEe(e)})})}function IEe(){const[e,t]=C.useState("overview"),n=OE(),s=KW(null,e!=="overview"),{data:r}=Pr(),a=(r==null?void 0:r.selected)??at,o=a!==at,c=typeof window<"u"&&new URLSearchParams(window.location.search).get("from")==="fleet",h=rd();return!o&&!n.isLoading&&n.name===null?i.jsx("div",{className:"mx-auto w-full max-w-[960px] px-6 py-12",children:i.jsx(Ae,{label:"NO WORKSPACE CONNECTED",description:"Configure a workspace root to browse missions and slices in this destination.",variant:"card",testId:"workspace-scope-no-workspace",action:{label:"Open settings",href:"/settings"}})}):i.jsxs(uf,{eyebrow:c?`Fleet ▸ ${a} · Workspace`:"Workspace",title:o?"workspace":n.name??"loading…",hostChip:o?a:null,tabs:wEe,active:e,onSelect:d=>t(d),children:[e==="overview"?i.jsx(_Ee,{}):null,e==="story"?i.jsx(KT,{rows:s.rows,detailsByName:s.details.itemsByName,queueItemsById:s.queueItems.itemsById,isFetching:s.details.isFetching||s.queueItems.isFetching}):null,e==="progress"?i.jsx(CEe,{rows:s.rows,detailsByName:s.details.itemsByName,isLoading:s.list.isLoading||s.details.isFetching}):null,e==="artifacts"?i.jsx(EEe,{rows:s.rows,detailsByName:s.details.itemsByName}):null,e==="proof"?i.jsx(OW,{rows:s.rows.map(d=>({name:d.name,displayName:d.displayName,slicePath:h?d.slicePath??null:null}))}):null,e==="queue"?i.jsx(YW,{qitemIds:s.qitemIds,queueItemsById:s.queueItems.itemsById,isFetching:s.details.isFetching||s.queueItems.isFetching}):null,e==="topology"?i.jsx("div",{"data-testid":"workspace-topology-hostmultirig",className:"flex-1 min-h-0 relative h-[60vh]",children:i.jsx(RW,{})}):null]})}function MEe(){const{missionId:e}=An({from:"/project/mission/$missionId"}),[t,n]=C.useState("steering"),s=KW(e,t!=="overview"&&t!=="steering"),r=FT(e),{data:a}=Pr(),o=(a==null?void 0:a.selected)??at,c=o!==at,h=rd(),{known:d,isLocal:m}=sd(),f=h&&r.data&&"missionPath"in r.data?r.data.missionPath:null,g=Yl(f,"README.md"),x=Yl(f,"PROGRESS.md"),y=DW(e);return i.jsxs(uf,{eyebrow:"Mission",title:e,hostChip:c?o:null,tabs:SEe,active:t,onSelect:b=>n(b),children:[t==="steering"?i.jsx(q2e,{missionId:e}):null,t==="review"?d?m?i.jsx(xEe,{missionId:e}):i.jsx(WW,{testId:"mission-review-remote-gated"}):i.jsx(VW,{testId:"mission-review-selection-pending"}):null,t==="overview"?i.jsxs("div",{"data-testid":"mission-overview-panel",className:"space-y-6",children:[g.content&&i.jsx("section",{"data-testid":"mission-overview-readme",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:i.jsx(Zn,{content:g.content,hideFrontmatter:!0,hideRawToggle:!0})}),i.jsx("div",{className:"space-y-3",children:s.rows.length>0?s.rows.map(b=>{const _=QF(b);return i.jsx("article",{className:"border border-outline-variant bg-surface-lowest/35 p-3 backdrop-blur-sm",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Ve,{to:"/project/slice/$sliceId",params:{sliceId:b.name},"data-testid":`mission-overview-slice-${b.name}`,title:`${b.displayName} — ${_}`,"aria-label":`${b.displayName} (${_})`,className:"min-w-0 flex-1 whitespace-normal break-words font-mono text-[12px] uppercase leading-snug tracking-[0.12em] text-on-surface hover:underline",children:b.displayName}),i.jsxs("span",{"data-testid":`mission-overview-slice-${b.name}-meta`,className:"flex shrink-0 items-center gap-1.5",children:[i.jsx(GF,{count:b.qitemCount,testId:`mission-overview-slice-${b.name}-qitems`}),i.jsx(KF,{tone:Ev(b.status),label:b.status,testId:`mission-overview-slice-${b.name}-status`})]})]})},b.name)}):i.jsx(Ae,{label:"NO SLICES",description:"No indexed slices are attached to this mission.",variant:"card",testId:"mission-overview-empty"})})]}):null,t==="story"?i.jsx(KT,{rows:s.rows,detailsByName:s.details.itemsByName,queueItemsById:s.queueItems.itemsById,isFetching:s.details.isFetching||s.queueItems.isFetching}):null,t==="progress"?i.jsxs("div",{"data-testid":"mission-progress-panel",className:"space-y-6",children:[i.jsx(I2e,{rows:s.rows,detailsByName:s.details.itemsByName,isLoading:s.list.isLoading||s.details.isFetching}),y.data&&(y.data.mission.railStatus==="missing"||y.data.mission.railStatus==="malformed")?i.jsx(Ae,{label:y.data.mission.railStatus==="malformed"?"PROGRESS RAIL MALFORMED":"PROGRESS RAIL MISSING",description:y.data.mission.railStatus==="malformed"?`Mission progress rail has errors (${y.data.mission.frontmatterError??"malformed frontmatter"}). Run the audit command to diagnose.`:"This mission has no PROGRESS.md. Scaffold one or run the audit to check scope health.",variant:"card",testId:"mission-progress-rail-status",action:{label:`rig scope audit --mission ${e}`}}):d&&!m?i.jsx(Ae,{label:"LOCAL FILES NOT SHOWN",description:"Local files not shown — mission progress markdown reads this host's local filesystem, which the remote read view does not browse.",variant:"card",testId:"mission-progress-remote-gated"}):x.content?i.jsx("section",{"data-testid":"mission-progress-readme",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:i.jsx(Zn,{content:x.content,hideFrontmatter:!0,hideRawToggle:!0})}):x.state==="read_error"?i.jsx(Ae,{label:"PROGRESS READ FAILED",description:"The daemon could not read PROGRESS.md — this is a read failure, not an empty progress file. Check daemon logs and file permissions.",variant:"card",testId:"mission-progress-read-error"}):x.state==="unresolved"?i.jsx(Ae,{label:"PROGRESS OUTSIDE FILE ROOTS",description:"The mission path is not under any allowlisted file root, so PROGRESS.md cannot be read. Check OPENRIG_FILES_ALLOWLIST / the daemon's file-roots settings.",variant:"card",testId:"mission-progress-unresolved"}):y.isLoading?null:i.jsx(Ae,{label:"NO PROGRESS YET",description:"No progress data has been written for this mission.",variant:"card",testId:"mission-progress-empty"}),y.data&&y.data.totalFindings>0&&i.jsxs("section",{"data-testid":"mission-scope-findings",className:"border border-outline-variant bg-amber-50/40 p-4",children:[i.jsxs(ct,{children:["Scope Audit Findings (",y.data.totalFindings,")"]}),i.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[11px]",children:[...y.data.mission.findings,...y.data.slices.flatMap(b=>b.findings)].map((b,_)=>i.jsxs("li",{className:ce("px-2 py-1",b.severity==="high"?"text-red-700":"text-on-surface-variant"),children:["[",b.severity,"] ",b.kind,": ",b.message]},_))})]})]}):null,t==="artifacts"?i.jsx(UT,{scopePath:f,scopeLabel:e,remoteGated:c}):null,t==="proof"?i.jsx(OW,{rows:s.rows.map(b=>({name:b.name,displayName:b.displayName,slicePath:h?b.slicePath??null:null}))}):null,t==="queue"?i.jsx(YW,{qitemIds:s.qitemIds,queueItemsById:s.queueItems.itemsById,isFetching:s.details.isFetching||s.queueItems.isFetching}):null,t==="topology"?(()=>{const b=r.data&&"topology"in r.data?r.data.topology:null;return b!=null&&b.specGraph?i.jsx(HT,{topology:{affectedRigs:[],totalSeats:0,specGraph:b.specGraph}}):i.jsx(AEe,{detailsByName:s.details.itemsByName})})():null]})}function QW(e,t){return{qitemId:e,source:t==null?void 0:t.sourceSession,destination:t==null?void 0:t.destinationSession,state:t==null?void 0:t.state,tags:(t==null?void 0:t.tags)??void 0,createdAt:t==null?void 0:t.tsCreated,body:t==null?void 0:t.body}}function XW(e,t){if(!(t!=null&&t.body))return e;const n=t.body.split(`
621
621
  `);return n.length<=8?t.body:`${n.slice(0,8).join(`
622
622
  `)}
623
- ... ${n.length-8} more lines`}function LEe({qitemIds:e,queueItemsById:t,queueItemsFetching:n}){return e.length===0?i.jsx(Ae,{label:"NO QITEMS",description:"No queue items associated with this slice.",variant:"card",testId:"slice-queue-empty"}):i.jsxs("div",{children:[n?i.jsx("div",{"data-testid":"slice-queue-fetching",className:"mb-2 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading queue bodies..."}):null,i.jsx("ul",{"data-testid":"slice-queue-list",className:"divide-y divide-outline-variant border border-outline-variant",children:e.map(s=>{const r=t.get(s);return i.jsx("li",{className:"bg-surface-lowest/35 backdrop-blur-sm",children:i.jsxs(Ap,{data:QW(s,r),testId:`slice-queue-trigger-${s}`,className:"block w-full px-3 py-2 text-left hover:bg-surface-lowest/55 transition-colors font-mono text-xs",children:[i.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[r!=null&&r.state?i.jsx(zE,{state:r.state,compact:!0}):i.jsx(WF,{kind:"queue.item",compact:!0}),i.jsx(_f,{value:r==null?void 0:r.tsCreated})]}),i.jsx("span",{className:"mt-2 block whitespace-pre-wrap break-words text-on-surface",children:XW(s,r)}),r?i.jsxs("span",{"data-testid":`slice-queue-meta-${s}`,className:"mt-2 block space-y-2 text-[10px] text-on-surface-variant",children:[i.jsx(HE,{source:r.sourceSession,destination:r.destinationSession,muted:!0}),i.jsxs("span",{className:"flex flex-wrap gap-1.5",children:[i.jsx(Uu,{tag:s}),(r.tags??[]).slice(0,5).map(a=>i.jsx(Uu,{tag:a},a))]})]}):null]})},s)})})]})}function ZW(e){return FE(e)}function cr({label:e,value:t}){return i.jsxs("div",{className:"border border-outline-variant bg-surface-lowest/35 p-3 backdrop-blur-sm",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:e}),i.jsx("div",{className:"mt-1 font-mono text-sm font-bold text-on-surface",children:t})]})}function OEe({detail:e,remoteGated:t}){const n=e.acceptance.currentStep,s=Yl(t?null:e.slicePath??null,"README.md");return i.jsxs("div",{"data-testid":"slice-overview-tab",className:"space-y-6",children:[i.jsxs("section",{"data-testid":"slice-overview-summary",className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[i.jsx(cr,{label:"Status",value:e.status}),i.jsx(cr,{label:"Progress",value:`${e.acceptance.percentage}%`}),i.jsx(cr,{label:"Qitems",value:e.qitemIds.length}),i.jsx(cr,{label:"Last Activity",value:ZW(e.lastActivityAt)})]}),s.content&&i.jsx("section",{"data-testid":"slice-overview-readme",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:i.jsx(Zn,{content:s.content,hideFrontmatter:!0,hideRawToggle:!0})}),i.jsxs("section",{"data-testid":"slice-overview-current-step",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:[i.jsx(ct,{tone:"muted",children:"Current Step"}),n?i.jsxs("div",{className:"mt-3 grid gap-2 font-mono text-[10px] text-on-surface sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Step"}),i.jsx("div",{className:"font-bold text-on-surface",children:n.stepId})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Role"}),i.jsx("div",{className:"font-bold text-on-surface",children:n.role})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Objective"}),i.jsx("div",{children:n.objective??"No objective declared."})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Allowed exits"}),i.jsx("div",{children:n.allowedExits.join(", ")||"-"})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Hop count"}),i.jsx("div",{children:n.hopCount})]})]}):i.jsx("div",{className:"mt-3 font-mono text-[10px] text-on-surface-variant",children:"No workflow step is currently bound."})]}),i.jsxs("section",{"data-testid":"slice-overview-readiness",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:[i.jsx(ct,{tone:"muted",children:"Readiness"}),i.jsxs("div",{className:"mt-3 space-y-2 font-mono text-[10px] text-on-surface",children:[i.jsxs("div",{children:[e.acceptance.doneItems," of ",e.acceptance.totalItems," acceptance items complete."]}),i.jsxs("div",{children:[e.tests.aggregate.passCount," proof packets passing / ",e.tests.aggregate.failCount," failing."]}),e.acceptance.closureCallout&&i.jsx("div",{className:"border border-amber-300 bg-amber-50 px-2 py-1 text-amber-800",children:e.acceptance.closureCallout}),e.workflowBinding&&i.jsxs("div",{className:"text-on-surface-variant",children:["Workflow: ",e.workflowBinding.workflowName," v",e.workflowBinding.workflowVersion]})]})]})]})}function PEe(){var y,b,_;const{sliceId:e}=An({from:"/project/slice/$sliceId"}),[t,n]=C.useState("review"),{data:s}=Pr(),r=((s==null?void 0:s.selected)??at)!==at,a=rd(),{known:o,isLocal:c}=sd(),h=Uee(e),d=LE(((y=h.data)==null?void 0:y.qitemIds)??[]),m=C.useMemo(()=>d.itemsById,[d.itemsById]),f=DW(((b=h.data)==null?void 0:b.missionId)??null);if(h.isLoading)return i.jsx(uf,{eyebrow:"Slice",title:e,tabs:sC,active:t,onSelect:w=>n(w),children:i.jsx(Ae,{label:"LOADING",description:`Fetching /api/slices/${e}…`,variant:"card",testId:"slice-scope-loading"})});if(h.isError||!h.data)return i.jsx(uf,{eyebrow:"Slice",title:e,tabs:sC,active:t,onSelect:w=>n(w),children:i.jsx(Ae,{label:"SLICE NOT AVAILABLE",description:h.error instanceof Error?h.error.message:`Could not load slice "${e}". The slices indexer may not be configured (rig config get workspace.slices_root).`,variant:"card",testId:"slice-scope-error"})});const g=h.data,x=((_=f.data)==null?void 0:_.slices.find(w=>w.name===g.name))??null;return i.jsxs(uf,{eyebrow:"Slice",title:g.displayName||g.name,tabs:sC,active:t,onSelect:w=>n(w),children:[t==="review"?o?c?i.jsx(uEe,{sliceName:g.name,slicePath:a?g.slicePath:null,anchorIdentity:typeof window<"u"&&window.location.hash.startsWith("#needs-you-")?window.location.hash.slice(11):null}):i.jsx(WW,{testId:"slice-review-remote-gated"}):i.jsx(VW,{testId:"slice-review-selection-pending"}):null,t==="story"?i.jsx(KT,{rows:[],detailsByName:new Map,queueItemsById:m,isFetching:!1}):null,t==="overview"?i.jsx(OEe,{detail:g,remoteGated:!a}):null,t==="progress"?i.jsxs("div",{className:"space-y-6",children:[x&&(x.railStatus==="missing"||x.railStatus==="malformed")&&i.jsx(Ae,{label:x.railStatus==="malformed"?"PROGRESS RAIL MALFORMED":"PROGRESS RAIL MISSING",description:x.railStatus==="malformed"?`Slice progress rail has errors (${x.frontmatterError??"malformed frontmatter"}). Run the audit command to diagnose.`:"This slice has no PROGRESS.md and no readme-only marker.",variant:"card",testId:"slice-progress-rail-status",action:{label:`rig scope audit --mission ${g.missionId}`}}),x&&x.findings.length>0&&i.jsxs("section",{"data-testid":"slice-scope-findings",className:"border border-outline-variant bg-amber-50/40 p-4",children:[i.jsxs(ct,{children:["Scope Findings (",x.findings.length,")"]}),i.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[11px]",children:x.findings.map((w,E)=>i.jsxs("li",{className:ce("px-2 py-1",w.severity==="high"?"text-red-700":"text-on-surface-variant"),children:["[",w.severity,"] ",w.kind,": ",w.message]},E))})]}),i.jsx(g2e,{acceptance:g.acceptance})]}):null,t==="artifacts"?i.jsx(UT,{scopePath:a?g.slicePath:null,scopeLabel:g.displayName||g.name,remoteGated:r}):null,t==="proof"?i.jsx(N2e,{sliceId:g.displayName,title:g.name,slicePath:a?g.slicePath:null}):null,t==="queue"?i.jsx(LEe,{qitemIds:g.qitemIds,queueItemsById:m,queueItemsFetching:d.isFetching}):null,t==="topology"?i.jsx(HT,{topology:g.topology}):null]})}const DEe=15e3,$Ee=3e4,BEe=["review","fleet"];async function qEe(){const e=await fetch("/api/review/fleet");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}function JW(e={}){return Re({queryKey:BEe,queryFn:qEe,enabled:e.enabled??!0,staleTime:DEe,refetchInterval:$Ee,refetchOnWindowFocus:"always"})}function FEe({hostId:e}){return i.jsx("span",{className:ce("shrink-0 border px-1 font-mono text-[9px] uppercase tracking-wide",e==="local"?"border-outline-variant text-on-surface-variant":"border-on-surface text-on-surface"),children:e})}function zEe(){var a;const{data:e,isError:t}=Pr(),n=(((a=e==null?void 0:e.hosts)==null?void 0:a.length)??0)>0,{data:s}=JW({enabled:n||t});if(!s||s.hosts.length<=1&&!s.registryError)return null;const r=s.needsYou.items.find(o=>o.source==="derived")??s.needsYou.items[0];return i.jsxs("div",{"data-testid":"fleet-band",className:ce("flex flex-wrap items-center gap-2 px-2 py-1.5",fr),children:[i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface",children:"FLEET"}),i.jsxs("span",{"data-testid":"fleet-band-rollup",className:"flex items-center gap-2 font-mono text-[10px]",children:[i.jsxs("span",{className:"text-emerald-700",children:["● ",s.rollup.needsYouCount]}),i.jsxs("span",{className:"text-amber-700",children:["▲ ",s.rollup.exceptionCount]}),i.jsxs("span",{className:"text-on-surface-variant",children:[s.rollup.hostCount," hosts",s.rollup.unreachableCount>0?` · ${s.rollup.unreachableCount} unreachable`:""]})]}),s.registryError?i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-error",children:"host registry unreadable — local-only glance"}):r?i.jsxs("span",{"data-testid":"fleet-band-worst",className:"flex min-w-0 flex-1 items-center gap-1.5 truncate font-mono text-[10px] text-on-surface-variant",children:["worst: ",i.jsx(FEe,{hostId:r.hostId}),i.jsx("span",{className:"min-w-0 truncate",children:r.summary})]}):i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:"quiet"}),i.jsx("a",{href:"/fleet","data-testid":"fleet-band-open",className:"font-mono text-[10px] uppercase text-on-surface hover:underline",children:"open fleet →"})]})}const HEe="human@host",UEe={root:null,relPath:null,slicePath:null};function V8(e){return typeof window>"u"?null:new URLSearchParams(window.location.search).get(e)}function VEe(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 WEe(){const{data:e,isLoading:t,error:n}=K2e(),s=V8("slice"),r=V8("group")==="slice"?"slice":"agent",[a,o]=C.useState(r),c=d=>{if(o(d),typeof window>"u")return;const m=new URL(window.location.href);m.searchParams.set("group",d),window.history.replaceState({},"",`${m.pathname}${m.search}${m.hash}`)},h=C.useMemo(()=>{if(!e)return null;if(!s)return e.agents;const d=e.agents.rows.filter(m=>m.slices.includes(s));return{...e.agents,rows:d,provenance:d.length===0?`no agents holding or recently holding work on ${s} — ${e.agents.provenance}`:`anchored to ${s} — ${e.agents.provenance}`}},[e,s]);return t?i.jsx("p",{className:"p-4 font-mono text-[11px] text-on-surface-variant",children:"composing the rig coordination story…"}):n||!e||!h?i.jsxs("p",{"data-testid":"rig-agents-error",className:"p-4 font-mono text-[11px] text-red-700",children:["rig agents panel unavailable: ",n instanceof Error?n.message:"composer unreachable"]}):i.jsxs("div",{"data-testid":"rig-agents-page",className:"mx-auto max-w-4xl space-y-5 p-4",children:[i.jsx(zEe,{}),i.jsxs("nav",{className:"flex items-center gap-2 font-mono text-[10px] uppercase text-on-surface-variant",children:[i.jsx(Ve,{to:"/project",className:"hover:underline",children:"project"}),i.jsx("span",{children:"/"}),i.jsx("span",{"data-testid":"rig-agents-crumb",children:"agents (rig)"}),s?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsxs("span",{"data-testid":"rig-agents-anchor",children:["anchored: ",s]}),i.jsx("a",{href:"/agents",className:"hover:underline","data-testid":"rig-agents-unanchor",children:"[full rig]"})]}):null]}),i.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-2",children:[i.jsx("h2",{className:"text-[14px] font-semibold",children:"AGENTS — the coordination story"}),i.jsxs("div",{className:"flex items-center gap-1 font-mono text-[10px] uppercase",children:[i.jsx("span",{className:"text-on-surface-variant",children:"group by"}),["agent","slice"].map(d=>i.jsx("button",{type:"button","data-testid":`rig-agents-group-${d}`,onClick:()=>c(d),className:`border px-2 py-0.5 ${a===d?"border-outline bg-surface-variant":"border-outline-variant hover:bg-surface-variant/50"}`,children:d},d))]})]}),i.jsx(HW,{band:e.needsYou,slice:"rig",missionId:null,actorSession:HEe,ctx:UEe,showApprove:!1}),i.jsx(GT,{band:h,itemRef:"rig",grouping:a}),i.jsxs("section",{"data-testid":"settled-band",className:"space-y-1",children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"SETTLED"}),e.settled.length===0?i.jsx("p",{"data-testid":"settled-empty",className:"font-mono text-[11px] text-on-surface-variant",children:e.settledProvenance}):i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:e.settled.map(d=>i.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:bf(d.fromSession)}),i.jsx("span",{className:"text-on-surface-variant",children:"→"}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:bf(d.toSession)}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px]","data-testid":`settled-summary-${d.qitemId}`,children:d.summary??d.qitemId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:VEe(d.closedAtIso)})]},`${d.qitemId}-${d.closedAtIso}`))}),i.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant",children:e.settledProvenance})]})]}),i.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant",children:["composed ",e.composedAt]})]})}function GEe(e){return typeof window>"u"?null:new URLSearchParams(window.location.search).get(e)}function eG(e){if(!e)return"—";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 tG({hostId:e}){return i.jsx("span",{"data-testid":`fleet-item-host-${e}`,className:ce("shrink-0 border px-1 font-mono text-[9px] uppercase tracking-wide",e==="local"?"border-outline-variant text-on-surface-variant":"border-on-surface text-on-surface"),children:e})}function KEe(){const e=jv();return t=>{e.mutate({hostId:t},{onSuccess:()=>window.location.assign("/project?from=fleet")})}}function YEe(e){if(typeof window>"u")return;const t=new URL(window.location.href);e===null?t.searchParams.delete("open"):t.searchParams.set("open",e),window.history.replaceState({},"",`${t.pathname}${t.search}${t.hash}`)}function QEe({item:e,expanded:t,onToggle:n,onOpenHost:s}){return i.jsxs("li",{"data-testid":`fleet-needs-you-${e.fleetKey}`,"data-source":e.source,className:"px-2 py-1.5",children:[i.jsx("button",{type:"button",onClick:n,className:"block w-full text-left",children:i.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("span",{className:ce("font-mono text-[11px]",e.source==="derived"?"text-amber-700":"text-emerald-700"),title:e.source==="derived"?"machine-derived exception":"agent-initiated",children:e.source==="derived"?"▲":"●"}),i.jsx(tG,{hostId:e.hostId}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-on-surface",children:e.summary}),e.derived?i.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wide text-amber-700",children:e.derived.kind}):null,i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:e.where}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:eG(e.ageIso)})]})}),e.derived?i.jsxs("p",{className:"mt-0.5 pl-6 font-mono text-[10px] text-on-surface-variant",children:["▲ ",e.derived.evidence," · threshold: ",e.derived.threshold]}):null,i.jsxs("p",{className:"mt-0.5 pl-6 font-mono text-[9px] text-on-surface-variant/80",children:["counted once · seen from ",e.seenFrom.join(" · ")," on ",e.hostId]}),t?i.jsxs("div",{"data-testid":`fleet-item-expanded-${e.fleetKey}`,className:"mt-1.5 ml-6 border border-outline-variant bg-surface-low/50 px-2 py-1.5",children:[i.jsxs("p",{className:"font-mono text-[10px] text-on-surface",children:["identity: ",i.jsx("span",{className:"text-on-surface-variant",children:e.fleetKey})]}),e.derived?i.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-on-surface",children:["evidence: ",i.jsx("span",{className:"text-on-surface-variant",children:e.derived.evidence})]}):null,i.jsxs("p",{className:"mt-1 font-mono text-[9px] uppercase tracking-wide text-on-surface-variant",children:["read-only here — acting on a remote host's item rides cross-host routing (MH-3/MH-4) ·"," ",i.jsxs("button",{type:"button",onClick:()=>s(e.hostId),className:"underline",children:["open ",e.hostId," →"]})]})]}):null]})}function XEe(e){return e.status.status==="ok"?{char:"●",cls:"text-emerald-700"}:{char:"✕",cls:"text-error"}}function ZEe(){const{data:e,isLoading:t,error:n,refetch:s}=JW(),r=KEe(),a=GEe("open");if(t)return i.jsx("p",{className:"p-4 font-mono text-[11px] text-on-surface-variant",children:"composing the fleet glance…"});if(n||!e)return i.jsxs("p",{"data-testid":"fleet-error",className:"p-4 font-mono text-[11px] text-error",children:["fleet glance unavailable: ",n instanceof Error?n.message:"composer unreachable"]});const o=e.hosts.filter(c=>c.status.status==="ok").length;return i.jsxs("div",{"data-testid":"fleet-page",className:"mx-auto max-w-4xl space-y-5 p-4",children:[i.jsxs("nav",{className:"flex items-center gap-2 font-mono text-[10px] uppercase text-on-surface-variant",children:[i.jsx("span",{"data-testid":"fleet-crumb",className:"text-on-surface",children:"fleet"}),i.jsx("span",{children:"·"}),i.jsx("span",{children:"every factory, one glance"})]}),i.jsxs("header",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[i.jsx("h2",{className:"text-[14px] font-semibold uppercase",children:"Fleet — needs me / stuck / failing"}),i.jsxs("div",{"data-testid":"fleet-rollup",className:"flex items-center gap-2 font-mono text-[10px] uppercase",children:[i.jsxs("span",{className:"text-emerald-700",children:["● ",e.rollup.needsYouCount," need you"]}),i.jsxs("span",{className:"text-amber-700",children:["▲ ",e.rollup.exceptionCount," exceptions",e.rollup.exceptionsByKind.length>0?` (${e.rollup.exceptionsByKind.map(c=>`${c.count} ${c.kind}`).join(" · ")})`:""]}),i.jsxs("span",{className:"text-on-surface-variant",children:[e.rollup.hostCount," hosts"]}),e.rollup.unreachableCount>0?i.jsxs("span",{className:"text-error",children:[e.rollup.unreachableCount," unreachable"]}):null]})]}),e.registryError?i.jsxs("p",{"data-testid":"fleet-registry-error",className:"font-mono text-[10px] text-error",children:["host registry unreadable — this glance is LOCAL-ONLY, not the fleet: ",e.registryError]}):null,i.jsxs("section",{"data-testid":"fleet-needs-you",className:ce("space-y-1 p-2",fr),children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"NEEDS YOU"}),e.needsYou.items.length>0?i.jsx("ul",{className:"divide-y divide-outline-variant/50",children:e.needsYou.items.map(c=>i.jsx(QEe,{item:c,expanded:a===c.fleetKey,onToggle:()=>YEe(a===c.fleetKey?null:c.fleetKey),onOpenHost:r},c.fleetKey))}):null,i.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant",children:e.needsYou.provenance})]}),i.jsxs("section",{"data-testid":"fleet-hosts",className:ce("space-y-1 p-2",fr),children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"HOSTS"}),i.jsx("ul",{className:"divide-y divide-outline-variant/50",children:e.hosts.map(c=>{const h=XEe(c),d=c.status.status==="ok";return i.jsxs("li",{"data-testid":`fleet-host-${c.hostId}`,className:"flex flex-wrap items-center gap-2 px-2 py-1.5",children:[i.jsx("span",{className:ce("font-mono text-[11px]",h.cls),children:h.char}),i.jsx(SE,{className:"h-3 w-3 text-on-surface-variant"}),i.jsx("span",{className:"font-mono text-[11px] uppercase text-on-surface",children:c.hostId}),c.kind==="local"?i.jsx("span",{className:"font-mono text-[8px] uppercase text-on-surface-variant",children:"local"}):null,d?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:c.topLine}),(c.needsYouCount??0)>0?i.jsxs("span",{className:"font-mono text-[10px] text-emerald-700",children:["● ",c.needsYouCount]}):null,(c.exceptionsByKind??[]).map(m=>i.jsxs("span",{className:"font-mono text-[10px] text-amber-700",children:["▲ ",m.count," ",m.kind]},m.kind)),i.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant",children:[c.rigCount," rigs · ",c.seatCount," seats"]}),i.jsx("button",{type:"button","data-testid":`fleet-host-${c.hostId}-open`,onClick:()=>r(c.hostId),className:"font-mono text-[10px] uppercase text-on-surface hover:underline",children:"open →"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-error",children:[c.status.status,c.status.error?` — ${c.status.error}`:""," · items absent from this glance, not zero"]}),i.jsx("button",{type:"button","data-testid":`fleet-host-${c.hostId}-retry`,onClick:()=>void s(),className:"border border-error px-1.5 py-0.5 font-mono text-[9px] uppercase text-error hover:bg-surface-low",children:"retry"})]})]},c.hostId)})})]}),i.jsxs("section",{"data-testid":"fleet-settled",className:"space-y-1",children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"SETTLED"}),e.settled.length>0?i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:e.settled.map(c=>i.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.jsx(tG,{hostId:c.hostId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:c.fromSession.split("@")[0]}),i.jsx("span",{className:"text-on-surface-variant",children:"→"}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:c.toSession.split("@")[0]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px]",children:c.summary??c.qitemId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:eG(c.closedAtIso)})]},`${c.hostId}|${c.qitemId}`))}):null,i.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant",children:e.settledProvenance})]}),i.jsxs("p",{"data-testid":"fleet-fanout-footer",className:"font-mono text-[10px] text-on-surface-variant",children:["composed ",e.composedAt," · fleet fan-out ",o,"/",e.hosts.length," hosts ok ·"," ",i.jsx(Ve,{to:"/agents",className:"hover:underline",children:"this host's agents →"})]})]})}function JEe(e){const t=new Map;for(const s of e){const r=`${s.workflowName}:${s.workflowVersion}`;t.has(r)||t.set(r,[]),t.get(r).push(s)}const n=[...t.entries()].map(([s,r])=>({key:s,name:r[0].workflowName,version:r[0].workflowVersion,rows:r.sort((a,o)=>Zi(a)-Zi(o))}));return n.sort((s,r)=>Zi(s.rows[0])-Zi(r.rows[0])),n}function eRe(){const e=Pt(),{data:t,isLoading:n}=HV(),{data:s}=zwe(),r=t??[],a=JEe(r),o=r.filter(f=>Zi(f)<=1).length,c=r.filter(f=>f.status==="active"||f.status==="waiting").length,h=r.filter(f=>f.status==="completed").length,d=new Set(r.map(f=>`${f.workflowName}:${f.workflowVersion}`)),m=((s==null?void 0:s.specs)??[]).filter(f=>!d.has(`${f.name}:${f.version}`));return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"workflows-page",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Workflows",title:"Deterministic Runs",description:n?"Loading instances…":`${r.length} instance${r.length===1?"":"s"} · ${o} need attention · ${c} live · ${h} completed — computed from /api/workflow/list`,actions:i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/specs"}),children:"Workflow Library"})}),r.length===0&&!n?i.jsx("p",{"data-testid":"workflows-empty",className:"font-mono text-[11px] text-on-surface-variant",children:"0 instances — instantiate one from a library spec (rig workflow instantiate) and it appears here with its live position."}):null,a.map(f=>{const g=f.rows.filter(y=>Zi(y)<=1).length,x=f.rows.filter(y=>y.status==="active"||y.status==="waiting").length;return i.jsxs("section",{"data-testid":`workflows-group-${f.name}`,className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button","data-testid":`workflows-group-spec-${f.name}`,onClick:()=>e({to:"/specs/library/$entryId",params:{entryId:`workflow:${f.name}:${f.version}`}}),className:"font-mono text-[11px] font-bold text-on-surface underline-offset-2 hover:underline",children:[f.name," v",f.version]}),i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:[f.rows.length," instance",f.rows.length===1?"":"s"," · ",x," live",g>0?` · ▲ ${g}`:""]})]}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:f.rows.map(y=>i.jsx(UV,{instance:y},y.instanceId))})]},f.key)}),m.length>0?i.jsxs("section",{"data-testid":"workflows-idle-specs",className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Cached Specs — No Instances"}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:m.map(f=>i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`workflows-idle-spec-${f.name}`,onClick:()=>e({to:"/specs/library/$entryId",params:{entryId:`workflow:${f.name}:${f.version}`}}),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:"font-mono text-[11px] text-on-surface-variant","aria-hidden":!0,children:"◌"}),i.jsxs("span",{className:"font-mono text-[11px] text-on-surface",children:[f.name," v",f.version]}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:f.purpose??""}),i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:[f.isBuiltIn?"built-in":"user file"," · 0 instances"]})]})},`${f.name}:${f.version}`))})]}):null]})})}const tRe={handoff:{glyph:"→",cls:"text-emerald-800"},waiting:{glyph:"◐",cls:"text-on-surface-variant"},done:{glyph:"○",cls:"text-on-surface-variant"},failed:{glyph:"▲",cls:"text-red-700"}};function nRe(e){return e.replace("T"," ").replace(/\.\d+Z$/,"Z")}function sRe({entry:e,index:t,expanded:n,onToggle:s}){const r=tRe[e.closureReason]??{glyph:"?",cls:"text-on-surface-variant"},a=e.closureEvidence&&typeof e.closureEvidence.resultNote=="string"?e.closureEvidence.resultNote:null;return i.jsxs("li",{id:`step-${e.stepId}`,children:[i.jsxs("button",{type:"button","data-testid":`workflow-trail-row-${e.trailId}`,onClick:s,className:"flex w-full items-center gap-2 px-2 py-1.5 text-left hover:bg-surface-variant/50",children:[i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant w-6 shrink-0",children:[t+1,"."]}),i.jsx("span",{className:"font-mono text-[11px] font-bold text-on-surface w-28 shrink-0",children:e.stepId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant w-20 shrink-0",children:e.stepRole}),i.jsxs("span",{className:ce("font-mono text-[11px] w-20 shrink-0",r.cls),children:[r.glyph," ",e.closureReason]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-on-surface-variant",children:a??"—"}),i.jsx("span",{className:"hidden font-mono text-[10px] text-on-surface-variant lg:inline",children:e.actorSession}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:nRe(e.closedAt)})]}),n?i.jsxs("div",{"data-testid":`workflow-trail-expanded-${e.trailId}`,className:"space-y-1 border-t border-outline-variant/50 bg-surface-lowest/10 px-8 py-2 font-mono text-[10px]",children:[i.jsxs("p",{children:[i.jsx("span",{className:"uppercase text-on-surface-variant",children:"actor: "}),e.actorSession]}),i.jsxs("p",{children:[i.jsx("span",{className:"uppercase text-on-surface-variant",children:"closed packet: "}),e.priorQitemId]}),i.jsxs("p",{children:[i.jsx("span",{className:"uppercase text-on-surface-variant",children:"routed next: "}),e.nextQitemId??"(terminal — no next packet)"]}),e.closureEvidence?i.jsx("pre",{className:"overflow-x-auto border border-outline-variant/40 bg-surface-lowest/20 p-2 text-[9px] leading-snug",children:JSON.stringify(e.closureEvidence,null,2)}):i.jsx("p",{className:"text-on-surface-variant",children:"(no closure evidence recorded)"})]}):null]})}function rRe({trail:e,instance:t,anchorStepId:n}){const[s,r]=C.useState(()=>{if(!n)return null;const o=e.find(c=>c.stepId===n);return o?o.trailId:null}),a=n!=null&&n===t.currentStepId;return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:["Routing History",i.jsxs("span",{className:"ml-2 normal-case tracking-normal",children:[e.length," closed step",e.length===1?"":"s"," · append-only trail · deterministic path",t.currentStepId?` → now at ${t.currentStepId}`:""]})]}),e.length===0?i.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant",children:"No steps closed yet — the entry packet is on the frontier."}):i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:e.map((o,c)=>i.jsx(sRe,{entry:o,index:c,expanded:s===o.trailId,onToggle:()=>r(h=>h===o.trailId?null:o.trailId)},o.trailId))}),t.currentStepId?i.jsxs("div",{id:`step-${t.currentStepId}`,"data-testid":"workflow-frontier-row",className:ce("flex items-center gap-2 border border-dashed px-2 py-1.5",a?"border-amber-700 bg-amber-700/5":"border-outline-variant"),children:[i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant w-6 shrink-0",children:[e.length+1,"."]}),i.jsx("span",{className:"font-mono text-[11px] font-bold text-on-surface w-28 shrink-0",children:t.currentStepId}),i.jsx("span",{className:"font-mono text-[11px] text-emerald-800 w-20 shrink-0",children:"● open"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:["frontier packet ",t.currentFrontier[0]??"(none)",t.deadline.evidence?` · held by ${t.deadline.evidence.ownerSession}`:""]})]}):null]})}function W8(e){return e.replace("T"," ").replace(/\.\d+Z$/,"Z")}const iRe="human@host";async function aRe(e){const t=await fetch(`/api/workflow/${encodeURIComponent(e)}/resume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actorSession:iRe})});if(!t.ok)throw new Error(`resume failed — HTTP ${t.status}`)}function oRe(e,t){const n=e.map(r=>r.stepId);t&&n.push(t);const s=[];for(let r=0;r+1<n.length;r++)n[r]!==n[r+1]&&s.push(`${n[r]}→${n[r+1]}`);return{visited:e.map(r=>r.stepId),edgeKeys:s}}function lRe({instance:e,onResume:t,resuming:n,resumeError:s}){const r=e.status==="waiting"&&e.currentStepId!=null,a=e.deadline.state!=="healthy"&&e.deadline.evidence,o=e.status==="failed";if(!r&&!a&&!o)return null;const c=o||a?"border-red-700/60 bg-red-700/5":"border-amber-700/60 bg-amber-700/5";return i.jsxs("div",{"data-testid":"workflow-exception-banner",className:ce("space-y-2 border px-3 py-2",c),children:[o?i.jsxs("p",{className:"font-mono text-[11px] text-red-700",children:["▲ FAILED — no remediation branch mapped for the failing exit",e.resumeCount>0?` · resumed ${e.resumeCount}× already`:""]}):null,a?i.jsxs("p",{className:"font-mono text-[11px] text-red-700",children:["▲ ",e.deadline.state.toUpperCase()," — step ",e.deadline.evidence.stepId??"(unbound)"," packet"," ",e.deadline.evidence.packetId," held by ",e.deadline.evidence.ownerSession,","," ",Math.floor(e.deadline.evidence.overdueBySeconds/60),"m past its"," ",e.deadline.evidence.anchor," anchor"]}):null,r&&!a&&!o?i.jsxs("p",{className:"font-mono text-[11px] text-amber-800",children:["◐ WAITING at ",e.currentStepId," — the gate packet is parked pending sign-off; resolving the NEEDS-YOU item resumes the deterministic flow"]}):null,i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?i.jsx("button",{type:"button","data-testid":"workflow-resume",disabled:n,onClick:t,className:"border border-outline px-3 py-1 font-mono text-[11px] uppercase hover:bg-surface-variant disabled:cursor-not-allowed disabled:opacity-50",title:`POST /api/workflow/${e.instanceId}/resume — redrive from the failed step (WF-5 FR-4)`,children:n?"Resuming…":"Resume"}):null,s?i.jsx("span",{"data-testid":"workflow-resume-error",className:"font-mono text-[10px] text-red-700",children:s}):null,i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:["CLI: rig workflow trace ",e.instanceId]})]})]})}function cRe({instanceId:e,anchorStepId:t}){const n=Pt(),s=mt(),{data:r,isLoading:a,error:o}=Hwe(e),c=r?`workflow:${r.instance.workflowName}:${r.instance.workflowVersion}`:null,{data:h}=Rv(c),[d,m]=C.useState(!1),[f,g]=C.useState(null),x=()=>{m(!0),g(null),aRe(e).then(()=>s.invalidateQueries({queryKey:["workflow"]})).catch(k=>g(k.message)).finally(()=>m(!1))};if(a)return i.jsx(ot,{children:i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading workflow instance…"})});if(o||!r)return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"workflow-instance-error",className:"space-y-4",children:[i.jsx(wn,{eyebrow:"Workflow — Instance",title:"Instance Not Found",description:(o==null?void 0:o.message)??`No workflow instance ${e}.`}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>n({to:"/workflows"}),children:"Back to Workflows"})]})});const{instance:y,trail:b}=r,{visited:_,edgeKeys:w}=oRe(b,y.currentStepId),E=h&&h.kind==="workflow"?h:null,N=y.deadline.state!=="healthy"?y.deadline.state:y.status;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"workflow-instance-page",className:"space-y-6",children:[i.jsx(wn,{eyebrow:`Workflow — Instance · ${y.workflowName} v${y.workflowVersion}`,title:y.instanceId,description:y.currentStepId?`${y.status} at ${y.currentStepId} · hop ${y.hopCount}`:`${y.status} · hop ${y.hopCount}`,actions:i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"workflow-view-spec",onClick:()=>c&&n({to:"/specs/library/$entryId",params:{entryId:c}}),children:"View Spec"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>n({to:"/workflows"}),children:"Back"})]})}),i.jsxs(Do,{children:[i.jsx(st,{label:"Status",value:N,testId:"wf-inst-status"}),i.jsx(st,{label:"Position",value:y.currentStepId??(y.status==="completed"?"closed":"felled"),testId:"wf-inst-position"}),i.jsx(st,{label:"Hops",value:y.hopCount,testId:"wf-inst-hops"}),i.jsx(st,{label:"Resumes",value:y.resumeCount,testId:"wf-inst-resumes"})]}),i.jsxs("p",{"data-testid":"wf-inst-provenance",className:"font-mono text-[10px] text-on-surface-variant",children:["created by ",y.createdBySession," · ",W8(y.createdAt),y.completedAt?` · completed ${W8(y.completedAt)}`:""]}),i.jsx(lRe,{instance:y,onResume:x,resuming:d,resumeError:f}),E?i.jsx(zV,{topology:E.topology,testId:"workflow-instance-graph",currentStepId:y.currentStepId,visitedStepIds:_,takenEdgeKeys:w}):i.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant",children:"(workflow shape unavailable — the spec is not in the library cache)"}),i.jsx(rRe,{trail:b,instance:y,anchorStepId:t})]})})}const uRe={neutral:"border-outline-variant bg-surface-lowest/65 text-on-surface",info:"border-sky-300 bg-sky-50/70 text-sky-800",success:"border-emerald-300 bg-emerald-50/70 text-emerald-800",warning:"border-amber-300 bg-amber-50/80 text-amber-800",danger:"border-rose-300 bg-rose-50/75 text-rose-800"},ko=[{label:"Queue created",tone:"info",icon:eF},{label:"Handoff",tone:"neutral",icon:wv},{label:"Claimed",tone:"warning",icon:yf},{label:"Completed",tone:"success",icon:vf},{label:"Human action",tone:"danger",icon:Co},{label:"Shipped",tone:"success",icon:NE}],nG=[{label:"idea-ledger",tone:"neutral"},{label:"cycle-4",tone:"info"},{label:"proof",tone:"success"},{label:"urgent",tone:"danger"},{label:"human-review",tone:"warning"}];function si({token:e,compact:t=!1}){const n=e.icon;return i.jsxs("span",{className:ce("inline-flex items-center gap-1 border font-mono uppercase tracking-[0.10em]",t?"px-1.5 py-0.5 text-[8px]":"px-2 py-1 text-[9px]",uRe[e.tone]),children:[n?i.jsx(n,{className:t?"h-2.5 w-2.5":"h-3 w-3",strokeWidth:1.6}):null,e.label]})}function Dl({kind:e,label:t,muted:n}){const s=e==="human"?LJ:SZ;return i.jsxs("span",{className:ce("inline-flex min-w-0 items-center gap-1 border px-1.5 py-0.5 font-mono text-[9px]",n?"border-outline-variant bg-surface-lowest/45 text-on-surface-variant":"border-outline-variant bg-surface-lowest/45 text-on-surface"),children:[i.jsx(s,{className:"h-3 w-3 shrink-0",strokeWidth:1.5}),i.jsx("span",{className:"truncate",children:t})]})}function sG({label:e}){return i.jsxs("span",{className:"inline-flex items-center gap-1 border border-outline-variant bg-surface-lowest/55 px-1.5 py-0.5 font-mono text-[9px] text-on-surface-variant",children:[i.jsx(_E,{className:"h-3 w-3",strokeWidth:1.5}),e]})}function dRe(){return i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[i.jsx(Dl,{kind:"agent",label:"orch-lead@my-rig"}),i.jsx(Dx,{className:"h-3.5 w-3.5 text-on-surface-variant",strokeWidth:1.4}),i.jsx(Dl,{kind:"agent",label:"driver@my-rig"}),i.jsx(Dx,{className:"h-3.5 w-3.5 text-on-surface-variant",strokeWidth:1.4}),i.jsx(Dl,{kind:"human",label:"human@host"})]})}function hRe(){return i.jsx("div",{className:"grid grid-cols-3 gap-2",children:["for-you-human-and-shipped.png","project-overview-missions.png","project-triage-slice.png"].map(e=>i.jsxs("div",{className:"border border-outline-variant bg-surface-low/80",children:[i.jsx("div",{className:"flex aspect-[4/3] items-center justify-center bg-surface-lowest/65 text-on-surface-variant",children:i.jsx(UZ,{className:"h-7 w-7",strokeWidth:1.2})}),i.jsx("div",{className:"truncate border-t border-outline-variant px-1 py-0.5 font-mono text-[8px] text-on-surface-variant",children:e})]},e))})}function rC({label:e,description:t,children:n}){return i.jsx(zx,{as:"section",className:"bg-surface-lowest/65 backdrop-blur-sm",header:i.jsx("span",{className:"uppercase tracking-[0.16em]",children:e}),children:i.jsxs("div",{className:"space-y-4 p-4",children:[i.jsx("p",{className:"font-mono text-[10px] leading-relaxed text-on-surface",children:t}),n]})})}function G8({dense:e=!1}){return i.jsxs("article",{className:ce("border border-outline-variant bg-surface-lowest/60 backdrop-blur-sm hard-shadow",e?"p-3":"p-4"),children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(si,{token:{label:"Action required",tone:"danger",icon:Co},compact:e}),i.jsx("h3",{className:"font-mono text-sm text-on-surface",children:"Review demo-seed triage proof packet"})]}),i.jsx(sG,{label:"Today 4:18 PM"})]}),i.jsx("p",{className:"mt-3 whitespace-pre-line font-mono text-[11px] leading-relaxed text-on-surface",children:"Review the proof packet screenshots, confirm the shipped slice is ready, then approve or route back with notes."}),i.jsx("div",{className:"mt-3",children:i.jsx(dRe,{})}),i.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:nG.slice(0,4).map(t=>i.jsx(si,{token:t,compact:!0},t.label))})]})}function fRe(){return i.jsxs("article",{className:"relative border border-outline-variant bg-surface-lowest/60 p-4 hard-shadow backdrop-blur-sm",children:[i.jsx("div",{className:"absolute left-5 top-12 bottom-5 w-px bg-surface-highest"}),i.jsx("div",{className:"relative space-y-5 pl-8",children:[{token:ko[5],title:"Slice shipped with proof packet",body:"The triage slice closed with screenshots, queue context, and verification notes attached."},{token:ko[3],title:"Implementation completed",body:"Driver finished the UI pass and handed verification to guard and QA."},{token:ko[1],title:"Work routed for review",body:"The queue item moved from driver to guard with targeted checks."}].map(e=>{const t=e.token.icon??bu;return i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute -left-[38px] top-0 flex h-5 w-5 items-center justify-center border border-outline-variant bg-surface-lowest text-on-surface",children:i.jsx(t,{className:"h-3 w-3",strokeWidth:1.5})}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(si,{token:e.token,compact:!0}),i.jsx(sG,{label:"12 min ago"})]}),i.jsx("h4",{className:"mt-2 font-mono text-[12px] text-on-surface",children:e.title}),i.jsx("p",{className:"mt-1 font-mono text-[10px] leading-relaxed text-on-surface",children:e.body})]},e.title)})})]})}function pRe(){return i.jsx("div",{className:"divide-y divide-outline-variant border border-outline-variant bg-surface-lowest/55 backdrop-blur-sm",children:[{token:ko[4],title:"Approval needed",body:"Review proof screenshots and approve release-readiness.",actor:"human@host"},{token:ko[2],title:"Claimed by QA",body:"VM verification is in progress with current worktree source.",actor:"qa@my-rig"},{token:ko[1],title:"Route to guard",body:"Run narrow advisory on UI-only diff and source scans.",actor:"guard@my-rig"}].map(e=>i.jsxs("div",{className:"grid gap-3 p-3 sm:grid-cols-[auto_1fr_auto]",children:[i.jsx(si,{token:e.token,compact:!0}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"font-mono text-[12px] text-on-surface",children:e.title}),i.jsx("div",{className:"mt-1 font-mono text-[10px] leading-relaxed text-on-surface",children:e.body})]}),i.jsx(Dl,{kind:e.actor.includes("human")?"human":"agent",label:e.actor,muted:!0})]},e.title))})}function mRe(){return i.jsx("div",{className:"paper-grid min-h-full p-8",children:i.jsxs("div",{className:"mx-auto max-w-7xl space-y-8",children:[i.jsxs("header",{className:"border border-outline-variant bg-surface-lowest/60 p-4 font-mono backdrop-blur-sm hard-shadow",children:[i.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Project graphics package preview"}),i.jsx("h1",{className:"mt-2 text-xl uppercase tracking-[0.14em] text-on-surface",children:"Queue, story, and proof card language"}),i.jsx("p",{className:"mt-2 max-w-3xl text-[11px] leading-relaxed text-on-surface",children:"Hidden preview route for choosing metadata badges, action chips, flow arrows, and proof-card density before applying the system to For You, Story, Queue, and scope rollups."})]}),i.jsxs("section",{className:"grid gap-4 lg:grid-cols-3",children:[i.jsxs(rC,{label:"A / Compact Ledger",description:"Small pills and restrained icons. Best when density matters and queue cards need to scan like a work ledger.",children:[i.jsx(G8,{dense:!0}),i.jsx(pRe,{})]}),i.jsxs(rC,{label:"B / Narrative Rail",description:"Story-first layout with event icons on a vertical rail. Best for showing how work moved from idea to proof.",children:[i.jsx(fRe,{}),i.jsx(hRe,{})]}),i.jsxs(rC,{label:"C / Action Board",description:"Bolder cards with explicit status, actors, and proof thumbnails. Best for For You and approval surfaces.",children:[i.jsx(G8,{}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:ko.map(e=>i.jsx(si,{token:e},e.label))})]})]}),i.jsxs("section",{className:"grid gap-4 lg:grid-cols-[1.2fr_0.8fr]",children:[i.jsx(zx,{as:"section",className:"bg-surface-lowest/65 backdrop-blur-sm",header:"EVENT BADGE VOCABULARY",children:i.jsx("div",{className:"grid gap-3 p-4 sm:grid-cols-2 lg:grid-cols-3",children:ko.map(e=>i.jsxs("div",{className:"border border-outline-variant bg-surface-lowest/55 p-3",children:[i.jsx(si,{token:e}),i.jsxs("div",{className:"mt-2 font-mono text-[10px] leading-relaxed text-on-surface",children:[e.label==="Queue created"?"A work item entered the system.":null,e.label==="Handoff"?"Ownership moved from one actor to another.":null,e.label==="Claimed"?"An actor is actively working the item.":null,e.label==="Completed"?"The assigned work item closed.":null,e.label==="Human action"?"A person needs to approve, deny, or route.":null,e.label==="Shipped"?"The slice closed with evidence attached.":null]})]},e.label))})}),i.jsx(zx,{as:"section",className:"bg-surface-lowest/65 backdrop-blur-sm",header:"SUPPORTING CHIPS",children:i.jsxs("div",{className:"space-y-4 p-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"mb-2 font-mono text-[9px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Tags"}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:nG.map(e=>i.jsx(si,{token:e},e.label))})]}),i.jsxs("div",{children:[i.jsx("div",{className:"mb-2 font-mono text-[9px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Actors"}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.jsx(Dl,{kind:"human",label:"human@host"}),i.jsx(Dl,{kind:"agent",label:"driver@my-rig"}),i.jsx(Dl,{kind:"agent",label:"guard@my-rig",muted:!0})]})]}),i.jsxs("div",{children:[i.jsx("div",{className:"mb-2 font-mono text-[9px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Scope"}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.jsx(si,{token:{label:"Workspace",tone:"neutral",icon:iF}}),i.jsx(si,{token:{label:"Mission",tone:"info",icon:IC}}),i.jsx(si,{token:{label:"Slice",tone:"success",icon:_v}})]})]})]})})]})]})})}const Ip={shipped:{stripe:"border-l-emerald-600",pill:"bg-emerald-50 border-emerald-300",ink:"text-emerald-800",label:"SHIPPED"},incident:{stripe:"border-l-red-600",pill:"bg-red-50 border-red-300",ink:"text-red-800",label:"INCIDENT"},progress:{stripe:"border-l-sky-600",pill:"bg-sky-50 border-sky-300",ink:"text-sky-800",label:"PROGRESS"},approval:{stripe:"border-l-amber-600",pill:"bg-amber-50 border-amber-300",ink:"text-amber-800",label:"APPROVAL NEEDED"},concept:{stripe:"border-l-violet-600",pill:"bg-violet-50 border-violet-300",ink:"text-violet-800",label:"CONCEPT"}},gRe={shipped:"bg-success",incident:"bg-tertiary",progress:"bg-secondary",approval:"bg-warning",concept:"bg-outline"},xRe={shipped:"Shipped",incident:"Incident",progress:"Progress",approval:"Approval",concept:"Concept"},vRe={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 Mp({testId:e,kind:t,title:n,oneLiner:s,expanded:r,drillInHref:a,drillInLabel:o,inlineActions:c,leadingAccessory:h}){const[d,m]=C.useState(!1);return i.jsxs("article",{"data-testid":e,"data-card-kind":t,"data-expanded":d,style:vRe,className:"relative bg-surface-low/45 backdrop-blur-[10px] overflow-hidden",children:[i.jsx(lr,{position:"tl"}),i.jsx(lr,{position:"tr"}),i.jsx(lr,{position:"bl"}),i.jsx(lr,{position:"br"}),i.jsxs("div",{role:"button",tabIndex:0,"data-testid":`${e}-toggle`,onClick:()=>m(f=>!f),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),m(g=>!g))},className:"flex w-full min-h-[80px] cursor-pointer items-start gap-4 px-5 py-4 text-left","aria-expanded":d,children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{"data-testid":`${e}-pill`,className:"flex items-center gap-2 font-mono text-[10px] uppercase tracking-[0.18em] text-on-surface",children:[i.jsx("span",{"aria-hidden":"true",className:`inline-block w-1.5 h-1.5 rounded-full ${gRe[t]}`}),i.jsx("span",{children:xRe[t]})]}),i.jsxs("h3",{"data-testid":`${e}-title`,className:"mt-2 flex items-center gap-2 font-headline text-[16px] font-bold leading-tight text-on-surface",children:[h,i.jsx("span",{className:"truncate",children:n})]}),i.jsx("p",{"data-testid":`${e}-one-liner`,className:"mt-1.5 font-body text-[12px] leading-relaxed text-on-surface line-clamp-2",children:s})]}),c&&i.jsx("div",{"data-testid":`${e}-inline-actions`,className:"flex shrink-0 items-center gap-2",onClick:f=>f.stopPropagation(),children:c})]}),d&&i.jsxs("div",{"data-testid":`${e}-expanded`,className:"border-t border-outline-variant/40 px-5 py-4",children:[r,a&&i.jsx("div",{className:"mt-3 flex justify-end",children:i.jsxs("a",{"data-testid":`${e}-drill-in`,href:a,className:"inline-flex items-center gap-1 min-h-[44px] border border-on-surface px-3 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hover:bg-inverse-surface hover:text-background transition-colors",onClick:f=>f.stopPropagation(),children:[o??"Open"," →"]})})]})]})}function yRe({source:e}){return i.jsx(Mp,{testId:`feed-card-shipped-${e.sliceId}`,kind:"shipped",title:e.title,oneLiner:e.oneLiner,accent:Ip.shipped,drillInHref:`/project/slice/${e.sliceId}`,expanded:e.sections&&e.sections.length>0?i.jsx("ol",{className:"space-y-2 text-[11px]",children:e.sections.slice(0,3).map(t=>i.jsxs("li",{"data-testid":`feed-card-shipped-${e.sliceId}-section-${t.number}`,className:"flex gap-2",children:[i.jsxs("span",{className:"font-mono text-[10px] font-bold text-on-surface-variant",children:[t.number,"."]}),i.jsxs("div",{children:[i.jsx("div",{className:"font-semibold text-on-surface",children:t.heading}),i.jsx("div",{className:"text-on-surface",children:t.summary})]})]},t.number))}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:e.oneLiner})})}const K8={success:"bg-emerald-500",warning:"bg-amber-500",danger:"bg-red-500",info:"bg-sky-500",muted:"bg-outline-variant"};function bRe({source:e}){return i.jsx(Mp,{testId:`feed-card-incident-${e.sliceId}`,kind:"incident",title:e.title,oneLiner:e.oneLiner,accent:Ip.incident,drillInHref:`/project/slice/${e.sliceId}`,drillInLabel:"Open timeline",leadingAccessory:i.jsx("span",{"data-testid":`feed-card-incident-${e.sliceId}-dot`,className:`inline-block h-3 w-3 rounded-full shrink-0 ${K8[e.status]}`,"aria-hidden":"true"}),expanded:e.recentEntries&&e.recentEntries.length>0?i.jsx("ul",{className:"space-y-2 text-[11px]",children:e.recentEntries.slice(0,3).map((t,n)=>i.jsxs("li",{"data-testid":`feed-card-incident-${e.sliceId}-entry-${n}`,className:"flex items-baseline gap-2",children:[i.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${K8[t.status]} shrink-0`,"aria-hidden":"true"}),i.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.10em] text-on-surface-variant shrink-0",children:t.time}),i.jsx("span",{className:"text-on-surface",children:t.title})]},n))}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:"No recent entries."})})}function _Re({source:e,onMarkComplete:t}){const n=Math.max(0,Math.min(100,Math.round(e.percent))),s=t?i.jsx("button",{type:"button","data-testid":"progress-card-mark-complete",onClick:r=>{r.stopPropagation(),t(e.missionId)},className:"min-h-[36px] border border-on-surface px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hover:bg-inverse-surface hover:text-background transition-colors focus:outline-none focus:ring-1 focus:ring-on-surface",children:"Mark complete"}):void 0;return i.jsx(Mp,{testId:`feed-card-progress-${e.missionId}`,kind:"progress",title:e.title,oneLiner:e.nextStep??e.oneLiner,accent:Ip.progress,drillInHref:`/project/mission/${e.missionId}`,drillInLabel:"Open mission",inlineActions:s,leadingAccessory:i.jsx("div",{"data-testid":`feed-card-progress-${e.missionId}-bar`,"data-percent":n,className:"h-1.5 w-16 shrink-0 border border-outline-variant bg-surface-low overflow-hidden","aria-label":`Progress ${n}%`,children:i.jsx("div",{"data-testid":`feed-card-progress-${e.missionId}-bar-fill`,className:"h-full bg-sky-500",style:{width:`${n}%`}})}),expanded:e.activeSlice?i.jsxs("div",{"data-testid":`feed-card-progress-${e.missionId}-active-slice`,className:"border border-outline-variant bg-background px-2 py-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Active slice"}),i.jsx("div",{className:"mt-1 text-[12px] font-semibold text-on-surface",children:e.activeSlice.label}),i.jsxs("div",{className:"mt-0.5 font-mono text-[9px] text-on-surface-variant",children:["status: ",e.activeSlice.status]})]}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:"No active slice."})})}function wRe({source:e}){return i.jsx(Mp,{testId:`feed-card-approval-${e.qitemId}`,kind:"approval",title:e.title,oneLiner:e.oneLiner,accent:Ip.approval,drillInHref:e.drillInHref,drillInLabel:"Open detail",inlineActions:i.jsxs(i.Fragment,{children:[e.onApprove&&i.jsx("button",{type:"button","data-testid":`feed-card-approval-${e.qitemId}-approve`,onClick:e.onApprove,className:"min-h-[44px] border border-success px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-success hover:bg-success hover:text-white transition-colors",children:"Approve"}),e.onDeny&&i.jsx("button",{type:"button","data-testid":`feed-card-approval-${e.qitemId}-deny`,onClick:e.onDeny,className:"min-h-[44px] border border-on-surface px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hover:bg-inverse-surface hover:text-background transition-colors",children:"Deny"})]}),expanded:e.bodyPreview?i.jsx("pre",{"data-testid":`feed-card-approval-${e.qitemId}-body`,className:"overflow-x-auto whitespace-pre-wrap break-words bg-background p-2 font-body text-[11px] leading-relaxed text-on-surface",children:e.bodyPreview}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:"No body preview."})})}function SRe({source:e}){return i.jsx(Mp,{testId:`feed-card-concept-${e.sliceId}`,kind:"concept",title:e.title,oneLiner:e.oneLiner,accent:Ip.concept,drillInHref:`/project/slice/${e.sliceId}`,drillInLabel:"Open concept",expanded:e.comparePreview&&e.comparePreview.length>0?i.jsxs("table",{className:"w-full border-collapse text-[11px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-background",children:[i.jsx("th",{className:"border border-outline-variant px-2 py-1 text-left font-mono text-[8px] uppercase tracking-[0.12em] text-on-surface-variant"}),i.jsx("th",{className:"border border-outline-variant px-2 py-1 text-left font-mono text-[8px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Old"}),i.jsx("th",{className:"border border-outline-variant px-2 py-1 text-left font-mono text-[8px] uppercase tracking-[0.12em] text-on-surface-variant",children:"New"})]})}),i.jsx("tbody",{children:e.comparePreview.slice(0,3).map((t,n)=>i.jsxs("tr",{children:[i.jsx("td",{className:"border border-outline-variant px-2 py-1 font-mono text-[10px] font-semibold text-on-surface",children:t.label}),i.jsx("td",{className:"border border-outline-variant px-2 py-1 text-on-surface",children:t.valueOld}),i.jsx("td",{className:"border border-outline-variant px-2 py-1 text-on-surface",children:t.valueNew})]},n))})]}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:e.oneLiner})})}function jRe(){return i.jsxs("div",{className:"mx-auto max-w-5xl space-y-10 px-6 py-10","data-testid":"card-previews-lab",children:[i.jsxs("header",{className:"space-y-2",children:[i.jsx("h1",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-on-surface-variant",children:"/lab/card-previews"}),i.jsx("p",{className:"font-mono text-[11px] text-on-surface",children:"Visual gallery of for-you card kind variants. Each section renders the same card component the live feed uses, with sample data."})]}),i.jsx(ou,{title:"Shipped",description:"A slice merged + summary view. Used when a slice closes successfully and the feed surfaces it to operators downstream."}),i.jsx(yRe,{source:{sliceId:"first-conveyor-run",title:"First Conveyor Run — shipped",oneLiner:"Slice merged at b71cddf. 4 commits + 1 proof packet.",sections:[{number:1,heading:"Lint parses + validates entries",summary:"12 tests pass; UTF-8 edge cases handled."},{number:2,heading:"Reviewer accepted with one concern",summary:"Combining-character edge addressed mid-flight."},{number:3,heading:"Proof packet captured",summary:"CLI output screenshot + diff render."}]}}),i.jsx(ou,{title:"Incident / Action Required",description:"A timeline-shaped surface for an in-flight or recent incident. Use status='warning' or 'danger' to surface attention; 'info' for informational; 'muted' for resolved."}),i.jsx(bRe,{source:{sliceId:"auth-bearer-tailscale-trust",title:"Auth bearer tailscale trust — concerning",oneLiner:"Reviewer flagged loopback-only default at fix-1; remediated at fix-2.",status:"warning",recentEntries:[{time:"13:42",title:"Reviewer BLOCKING-CONCERN raised",status:"danger"},{time:"14:01",title:"Driver forward-fix scoped",status:"info"},{time:"14:38",title:"Forward-fix landed; gates green",status:"success"}]}}),i.jsx(ou,{title:"Progress",description:"A mission-level progress card with percent + active-slice context. Used during a mission lifecycle to keep operators informed without requiring them to open the mission page."}),i.jsx(_Re,{source:{missionId:"release-0.3.1",title:"Release 0.3.1 — in flight",oneLiner:"Wave 3a + 3b dispatches; multiple slices in review.",percent:62,nextStep:"design-reviewer audit on slice 21 narrative voice",activeSlice:{id:"slice-21-onboarding-conveyor",label:"slice-21-onboarding-conveyor",status:"in-progress"}}}),i.jsx(ou,{title:"Approval / Action Required",description:"An operator-decision-needed surface. Renders the qitem context + the two action paths (Approve / Deny) the operator picks between."}),i.jsx(wRe,{source:{qitemId:"qitem-20260511201234-abcdef01",title:"Auth bearer tailscale trust — approve merge?",oneLiner:"All gates green; merge requires operator sign-off.",bodyPreview:"Triple-guard CLEAR. velocity-qa VM walk PASS. Ready for merge to main.",drillInHref:"/project/slice/auth-bearer-tailscale-trust",onApprove:()=>{},onDeny:()=>{}}}),i.jsx(ou,{title:"Concept / Observation",description:"A discovery / lab / scratch-pad surface. Used for not-yet-actionable observations, draft ideas, or comparison previews."}),i.jsx(SRe,{source:{sliceId:"concept-storytelling-primitives",title:"Storytelling primitives — concept",oneLiner:"Could replace one-off card components with kind-frame primitives.",comparePreview:[{label:"Card kinds",valueOld:"5 components",valueNew:"1 kind-frame + 5 sources"},{label:"Visual variance",valueOld:"drift over time",valueNew:"centralized accent tokens"},{label:"Maintenance",valueOld:"edit each component",valueNew:"edit kind-frame once"}]}}),i.jsx(ou,{title:"Empty state",description:"What the for-you feed shows when no events qualify. Reusable across surfaces; the EmptyState primitive is the canonical pattern."}),i.jsx(Ae,{label:"ALL CAUGHT UP",description:"No new events. Spin up a rig or declare a slice to populate this feed.",variant:"card",testId:"card-previews-empty-state"})]})}function ou({title:e,description:t}){return i.jsxs("div",{className:"space-y-1 pt-4",children:[i.jsx("h2",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-on-surface",children:e}),i.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant max-w-3xl",children:t})]})}function Uy({backLayerOverride:e,vellumSheetOverride:t}={}){return i.jsxs("div",{"data-testid":"vellum-lab",className:"relative min-h-screen overflow-hidden",children:[e,t,i.jsx(XSe,{}),i.jsx(ZSe,{}),i.jsx(uje,{})]})}function NRe(){return i.jsx(Uy,{backLayerOverride:i.jsx(IRe,{}),vellumSheetOverride:i.jsx(TRe,{})})}function kRe(){return i.jsx(Uy,{backLayerOverride:i.jsx(MRe,{}),vellumSheetOverride:i.jsx(ARe,{})})}function CRe(){return i.jsx(Uy,{backLayerOverride:i.jsx(RRe,{}),vellumSheetOverride:i.jsx(ERe,{})})}function ERe(){return i.jsx("div",{"data-testid":"vellum-sheet-heavy-diffuse","aria-hidden":"true",className:"absolute inset-0 z-[5] bg-surface-lowest/25 backdrop-blur-[8px] pointer-events-none"})}function RRe(){const r=Math.ceil(27.5)+2,a=(c,h,d=0)=>c/1280*Math.PI*2*h+d,o=[];for(let c=0;c<r;c++){const h=c*40-40;let d=`M 0 ${h.toFixed(2)}`;for(let m=0;m<=2560;m+=32){const f=Math.sin(a(m,2,c*.3))*36,g=Math.sin(a(m,5,c*.5))*9,x=Math.sin(a(m,3,c*.18))*14,y=f+g+x;d+=` L ${m} ${(h+y).toFixed(2)}`}o.push(d)}return i.jsx("div",{"data-testid":"back-layer-scrolling-topo","aria-hidden":"true",className:"absolute inset-0 z-0 overflow-hidden pointer-events-none select-none",children:i.jsx("svg",{className:"absolute top-0 left-0 h-full vellum-scroll-x",style:{width:"200%"},viewBox:"0 0 2560 1100",preserveAspectRatio:"xMidYMid slice",children:o.map((c,h)=>i.jsx("path",{d:c,stroke:"#1c1917",strokeWidth:"1.0",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},h))})})}function TRe(){return i.jsx("div",{"data-testid":"vellum-sheet-diffuse","aria-hidden":"true",className:"absolute top-[14px] bottom-[12px] left-[16px] right-[14px] z-[5] bg-surface-lowest/35 backdrop-blur-[14px] pointer-events-none"})}function ARe(){return i.jsx("div",{"data-testid":"vellum-sheet-more-diffuse","aria-hidden":"true",className:"absolute top-[14px] bottom-[12px] left-[16px] right-[14px] z-[5] bg-surface-lowest/45 backdrop-blur-[22px] pointer-events-none"})}function IRe(){const s=Math.ceil(27.5)+2,r=[];for(let a=0;a<s;a++){const o=a*40-40;let c=`M -50 ${o.toFixed(2)}`;for(let h=0;h<=1380;h+=40){const d=h/1280,m=Math.sin(d*Math.PI*2.2+a*.28)*36,f=Math.sin(d*Math.PI*5.8+a*.47)*9,g=Math.sin(d*Math.PI*3.6+a*.13+Math.sin(a*.5)*2)*16,x=m+f+g;c+=` L ${h.toFixed(0)} ${(o+x).toFixed(2)}`}r.push(c)}return i.jsx("div",{"data-testid":"back-layer-topo","aria-hidden":"true",className:"absolute inset-0 z-0 overflow-hidden pointer-events-none select-none",children:i.jsx("svg",{className:"w-full h-full",viewBox:"0 0 1280 1100",preserveAspectRatio:"xMidYMid slice",children:r.map((a,o)=>i.jsx("path",{d:a,stroke:"#1c1917",strokeWidth:"1.2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},o))})})}function MRe(){const e=[{type:"cube",size:220,pos:"top-[2%] -left-6"},{type:"spool",size:200,pos:"top-[4%] left-[24%]"},{type:"x-prism",size:220,pos:"top-[2%] left-[50%]"},{type:"cube-frame",size:240,pos:"top-[1%] -right-8"},{type:"arc-stripes",size:200,pos:"top-[28%] left-[4%]"},{type:"donut-dots",size:220,pos:"top-[26%] left-[28%]"},{type:"hex-prism",size:220,pos:"top-[26%] left-[54%]"},{type:"cylinder-stripes",size:200,pos:"top-[28%] right-[4%]"},{type:"wedge",size:230,pos:"top-[52%] -left-4"},{type:"stairs-iso",size:240,pos:"top-[50%] left-[24%]"},{type:"barrel",size:220,pos:"top-[52%] left-[50%]"},{type:"pacman",size:240,pos:"top-[50%] -right-6"},{type:"cube-stack",size:260,pos:"bottom-[-4%] left-[5%]"},{type:"L-prism",size:260,pos:"bottom-[-2%] left-[36%]"},{type:"cube-ports",size:260,pos:"bottom-[-4%] right-[4%]"}];return i.jsx("div",{"data-testid":"back-layer-isometric","aria-hidden":"true",className:"absolute inset-0 z-0 overflow-hidden pointer-events-none select-none",children:e.map((t,n)=>i.jsx(LRe,{...t},n))})}function LRe({type:e,size:t,pos:n}){return i.jsx("div",{className:`absolute ${n}`,style:{width:t,height:t},children:i.jsx(ORe,{type:e})})}function ORe({type:e}){const t={fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round",strokeLinecap:"round"};switch(e){case"cube":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,8 52,20 52,44 30,56 8,44 8,20"}),i.jsx("line",{x1:"30",y1:"8",x2:"30",y2:"32"}),i.jsx("line",{x1:"30",y1:"32",x2:"8",y2:"20"}),i.jsx("line",{x1:"30",y1:"32",x2:"52",y2:"20"})]});case"cylinder-v":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"30",cy:"14",rx:"14",ry:"5"}),i.jsx("line",{x1:"16",y1:"14",x2:"16",y2:"46"}),i.jsx("line",{x1:"44",y1:"14",x2:"44",y2:"46"}),i.jsx("path",{d:"M 16 46 A 14 5 0 0 0 44 46"})]});case"triangle-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"14,46 30,12 46,46"}),i.jsx("polygon",{points:"46,46 30,12 38,8 54,42"}),i.jsx("line",{x1:"14",y1:"46",x2:"54",y2:"42"})]});case"rod":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("line",{x1:"12",y1:"48",x2:"48",y2:"12",strokeWidth:"1.5"}),i.jsx("circle",{cx:"12",cy:"48",r:"4"}),i.jsx("circle",{cx:"48",cy:"12",r:"4"})]});case"cube-frame":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,8 52,20 52,44 30,56 8,44 8,20"}),i.jsx("line",{x1:"30",y1:"8",x2:"30",y2:"32"}),i.jsx("line",{x1:"30",y1:"32",x2:"8",y2:"20"}),i.jsx("line",{x1:"30",y1:"32",x2:"52",y2:"20"}),i.jsx("rect",{x:"22",y:"28",width:"16",height:"16"})]});case"stairs":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("polyline",{points:"8,52 18,52 18,42 28,42 28,32 38,32 38,22 48,22 48,12 56,12"})});case"spool":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"36",cy:"30",rx:"14",ry:"6"}),i.jsx("path",{d:"M 22 30 L 8 30",strokeWidth:"1.5"}),i.jsx("line",{x1:"36",y1:"14",x2:"36",y2:"22"})]});case"arc-c":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("path",{d:"M 44 12 A 20 20 0 1 0 44 48",strokeWidth:"1.5"})});case"diamond-row":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"8,30 14,24 20,30 14,36"}),i.jsx("polygon",{points:"20,30 26,24 32,30 26,36"}),i.jsx("polygon",{points:"32,30 38,24 44,30 38,36"}),i.jsx("polygon",{points:"44,30 50,24 56,30 50,36"})]});case"plus":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("polygon",{points:"24,8 36,8 36,24 52,24 52,36 36,36 36,52 24,52 24,36 8,36 8,24 24,24"})});case"cylinder-h":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"14",cy:"30",rx:"5",ry:"14"}),i.jsx("line",{x1:"14",y1:"16",x2:"46",y2:"16"}),i.jsx("line",{x1:"14",y1:"44",x2:"46",y2:"44"}),i.jsx("path",{d:"M 46 16 A 5 14 0 0 1 46 44"})]});case"wave":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 8 16 Q 18 8 28 16 T 48 16",strokeWidth:"1.2"}),i.jsx("path",{d:"M 8 30 Q 18 22 28 30 T 48 30",strokeWidth:"1.2"}),i.jsx("path",{d:"M 8 44 Q 18 36 28 44 T 48 44",strokeWidth:"1.2"})]});case"x-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"14,8 24,8 30,18 36,8 46,8 36,22 46,36 36,36 30,26 24,36 14,36 24,22"}),i.jsx("line",{x1:"14",y1:"36",x2:"20",y2:"40"}),i.jsx("line",{x1:"46",y1:"36",x2:"52",y2:"40"})]});case"tri-stack":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"12,40 18,28 24,40"}),i.jsx("polygon",{points:"24,40 30,28 36,40"}),i.jsx("polygon",{points:"36,40 42,28 48,40"})]});case"L-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"8,28 28,18 48,28 28,38"}),i.jsx("polygon",{points:"28,38 48,28 48,44 28,54"}),i.jsx("polygon",{points:"8,28 8,44 28,54 28,38"})]});case"arc-stripes":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 12 50 A 22 22 0 0 1 48 14",strokeWidth:"1"}),i.jsx("path",{d:"M 16 50 A 18 18 0 0 1 48 18",strokeWidth:"1"}),i.jsx("path",{d:"M 20 50 A 14 14 0 0 1 48 22",strokeWidth:"1"}),i.jsx("path",{d:"M 24 50 A 10 10 0 0 1 48 26",strokeWidth:"1"})]});case"hex-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,8 48,18 48,38 30,48 12,38 12,18"}),i.jsx("line",{x1:"30",y1:"8",x2:"30",y2:"48"}),i.jsx("line",{x1:"12",y1:"18",x2:"30",y2:"28"}),i.jsx("line",{x1:"48",y1:"18",x2:"30",y2:"28"})]});case"dot-circle":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:Array.from({length:16}).map((n,s)=>{const r=s/16*Math.PI*2,a=30+Math.cos(r)*22,o=30+Math.sin(r)*22;return i.jsx("circle",{cx:a,cy:o,r:"1.8"},s)})});case"wedge":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 30 30 L 30 8 A 22 22 0 0 1 52 30 Z",fill:"currentColor"}),i.jsx("path",{d:"M 30 30 L 8 30 A 22 22 0 0 1 30 8"}),i.jsx("line",{x1:"30",y1:"30",x2:"14",y2:"44"}),i.jsx("line",{x1:"30",y1:"30",x2:"22",y2:"50"}),i.jsx("line",{x1:"30",y1:"30",x2:"34",y2:"52"})]});case"down-arrows":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"20,8 40,8 30,22"}),i.jsx("polygon",{points:"20,22 40,22 30,36"}),i.jsx("polygon",{points:"20,36 40,36 30,50"})]});case"donut-dots":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("circle",{cx:"30",cy:"30",r:"22"}),i.jsx("circle",{cx:"30",cy:"30",r:"10"}),i.jsx("g",{fill:"currentColor",children:Array.from({length:24}).map((n,s)=>{const r=s/24*Math.PI*2+.08,a=16;return i.jsx("circle",{cx:30+Math.cos(r)*a,cy:30+Math.sin(r)*a,r:"0.9"},s)})})]});case"bowtie":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"8,18 22,30 8,42"}),i.jsx("polygon",{points:"52,18 38,30 52,42"}),i.jsx("circle",{cx:"30",cy:"30",r:"3"})]});case"dot-grid":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:Array.from({length:6}).map((n,s)=>Array.from({length:6}).map((r,a)=>i.jsx("circle",{cx:10+a*8,cy:10+s*8,r:"1.4"},`${s}-${a}`)))});case"arc-half":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("path",{d:"M 8 38 A 22 22 0 0 1 52 38",strokeWidth:"1.5"})});case"cylinder-stripes":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"30",cy:"14",rx:"14",ry:"5"}),i.jsx("line",{x1:"16",y1:"14",x2:"16",y2:"46"}),i.jsx("line",{x1:"44",y1:"14",x2:"44",y2:"46"}),i.jsx("path",{d:"M 16 46 A 14 5 0 0 0 44 46"}),i.jsx("line",{x1:"22",y1:"18",x2:"22",y2:"44",strokeDasharray:"2 2"}),i.jsx("line",{x1:"30",y1:"19",x2:"30",y2:"45",strokeDasharray:"2 2"}),i.jsx("line",{x1:"38",y1:"18",x2:"38",y2:"44",strokeDasharray:"2 2"})]});case"dot-cloud":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:[[22,18],[30,14],[38,18],[16,24],[24,24],[32,22],[40,24],[46,28],[18,32],[26,32],[34,32],[42,32],[22,38],[30,38],[38,38],[28,44],[36,44]].map(([n,s],r)=>i.jsx("circle",{cx:n,cy:s,r:"1.5"},r))});case"pacman":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 30 30 L 52 18 A 22 22 0 1 1 52 42 Z",fill:"currentColor"}),i.jsx("line",{x1:"20",y1:"20",x2:"14",y2:"14"}),i.jsx("line",{x1:"20",y1:"40",x2:"14",y2:"46"}),i.jsx("line",{x1:"12",y1:"30",x2:"6",y2:"30"})]});case"down-triangles":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"22,12 38,12 30,24"}),i.jsx("polygon",{points:"22,28 38,28 30,40"})]});case"cube-inset":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,4 50,16 50,36 30,48 10,36 10,16"}),i.jsx("line",{x1:"30",y1:"4",x2:"30",y2:"48"}),i.jsx("line",{x1:"10",y1:"16",x2:"30",y2:"28"}),i.jsx("line",{x1:"50",y1:"16",x2:"30",y2:"28"}),i.jsx("rect",{x:"22",y:"46",width:"16",height:"10"})]});case"hex-small":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("polygon",{points:"30,18 42,24 42,38 30,44 18,38 18,24"})});case"cylinder-disc":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"34",cy:"30",rx:"14",ry:"5"}),i.jsx("path",{d:"M 20 30 A 14 5 0 0 1 48 30"}),i.jsx("line",{x1:"20",y1:"30",x2:"20",y2:"36",strokeWidth:"1.5"}),i.jsx("ellipse",{cx:"20",cy:"36",rx:"3",ry:"1.4"}),i.jsx("path",{d:"M 20 30 L 14 32"})]});case"triangle-solid":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:i.jsx("polygon",{points:"30,16 46,44 14,44"})});case"stairs-iso":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"8,40 16,36 24,40 16,44"}),i.jsx("polygon",{points:"16,36 24,32 32,36 24,40"}),i.jsx("polygon",{points:"24,32 32,28 40,32 32,36"}),i.jsx("polygon",{points:"32,28 40,24 48,28 40,32"}),i.jsx("polygon",{points:"40,24 48,20 56,24 48,28"})]});case"coin":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"30",cy:"26",rx:"14",ry:"6"}),i.jsx("path",{d:"M 16 26 L 16 34 A 14 6 0 0 0 44 34 L 44 26"}),i.jsx("line",{x1:"22",y1:"26",x2:"22",y2:"34"}),i.jsx("line",{x1:"30",y1:"32",x2:"30",y2:"38"}),i.jsx("line",{x1:"38",y1:"26",x2:"38",y2:"34"})]});case"cube-ports":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,6 52,18 52,42 30,54 8,42 8,18"}),i.jsx("line",{x1:"30",y1:"6",x2:"30",y2:"30"}),i.jsx("line",{x1:"30",y1:"30",x2:"8",y2:"18"}),i.jsx("line",{x1:"30",y1:"30",x2:"52",y2:"18"}),i.jsx("circle",{cx:"20",cy:"20",r:"2.5",fill:"currentColor"}),i.jsx("circle",{cx:"40",cy:"20",r:"2.5",fill:"currentColor"}),i.jsx("circle",{cx:"30",cy:"42",r:"2.5",fill:"currentColor"})]});case"arc-bridge":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 8 44 Q 30 8 52 44",strokeWidth:"1.5"}),i.jsx("circle",{cx:"30",cy:"44",r:"3",fill:"currentColor"})]});case"zigzag-v":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polyline",{points:"24,8 36,16 24,24 36,32 24,40 36,48",strokeWidth:"1.5"}),i.jsx("polyline",{points:"20,12 32,20 20,28 32,36 20,44 32,52",strokeWidth:"1.5"})]});case"x-flat":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:i.jsx("polygon",{points:"14,14 22,14 30,22 38,14 46,14 36,28 46,46 38,46 30,34 22,46 14,46 24,28"})});case"cube-stack":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"14,30 22,26 30,30 22,34"}),i.jsx("polygon",{points:"22,34 30,30 30,38 22,42"}),i.jsx("polygon",{points:"14,30 14,38 22,42 22,34"}),i.jsx("polygon",{points:"30,22 38,18 46,22 38,26"}),i.jsx("polygon",{points:"38,26 46,22 46,30 38,34"}),i.jsx("polygon",{points:"30,22 30,30 38,34 38,26"})]});case"back-arrows":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"42,16 42,44 24,30"}),i.jsx("polygon",{points:"28,16 28,44 10,30"})]});case"barrel":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"44",cy:"30",rx:"6",ry:"14"}),i.jsx("line",{x1:"44",y1:"16",x2:"14",y2:"20"}),i.jsx("line",{x1:"44",y1:"44",x2:"14",y2:"40"}),i.jsx("ellipse",{cx:"14",cy:"30",rx:"4",ry:"10"}),i.jsx("line",{x1:"20",y1:"20",x2:"20",y2:"40",strokeDasharray:"2 2"}),i.jsx("line",{x1:"28",y1:"19",x2:"28",y2:"41",strokeDasharray:"2 2"}),i.jsx("line",{x1:"36",y1:"18",x2:"36",y2:"42",strokeDasharray:"2 2"})]});case"wave-s":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 22 8 Q 32 18 22 28 T 22 48",strokeWidth:"1.5"}),i.jsx("path",{d:"M 38 8 Q 28 18 38 28 T 38 48",strokeWidth:"1.5"})]})}}const Pe=uX({component:()=>i.jsx(QX,{client:oZ,children:i.jsx(aZ,{children:i.jsx(Gie,{children:i.jsx(Mq,{})})})})}),PRe=Oe({getParentRoute:()=>Pe,path:"/",component:vSe}),DRe=Oe({getParentRoute:()=>Pe,path:"/topology",component:KCe}),$Re=Oe({getParentRoute:()=>Pe,path:"/topology/rig/$rigId",component:YCe}),BRe=Oe({getParentRoute:()=>Pe,path:"/topology/pod/$rigId/$podName",component:XCe}),qRe=Oe({getParentRoute:()=>Pe,path:"/topology/seat/$rigId/$logicalId",component:ZCe}),FRe=Oe({getParentRoute:()=>Pe,path:"/for-you",component:Xje}),zRe=Oe({getParentRoute:()=>Pe,path:"/project",component:IEe}),HRe=Oe({getParentRoute:()=>Pe,path:"/project/mission/$missionId",component:MEe}),URe=Oe({getParentRoute:()=>Pe,path:"/project/slice/$sliceId",component:PEe}),VRe=Oe({getParentRoute:()=>Pe,path:"/agents",component:WEe}),WRe=Oe({getParentRoute:()=>Pe,path:"/fleet",component:ZEe}),GRe=Oe({getParentRoute:()=>Pe,path:"/workflows",component:eRe}),KRe=Oe({getParentRoute:()=>Pe,path:"/workflow/instance/$instanceId",validateSearch:e=>({step:typeof e.step=="string"?e.step:void 0}),component:()=>{const{instanceId:e}=An({from:"/workflow/instance/$instanceId"}),{step:t}=vv({from:"/workflow/instance/$instanceId"});return i.jsx(cRe,{instanceId:e,anchorStepId:t??null})}}),YRe=Oe({getParentRoute:()=>Pe,path:"/specs",component:rW}),QRe=Oe({getParentRoute:()=>Pe,path:"/specs/applications",component:rW}),XRe=Oe({getParentRoute:()=>Pe,path:"/specs/skills",component:mNe}),ZRe=Oe({getParentRoute:()=>Pe,path:"/specs/skills/$skillToken",component:()=>{const{skillToken:e}=An({from:"/specs/skills/$skillToken"});return i.jsx(iW,{skillToken:e})}}),JRe=Oe({getParentRoute:()=>Pe,path:"/specs/skills/$skillToken/file/$fileToken",component:()=>{const{skillToken:e,fileToken:t}=An({from:"/specs/skills/$skillToken/file/$fileToken"});return i.jsx(iW,{skillToken:e,fileToken:t})}}),eTe=Oe({getParentRoute:()=>Pe,path:"/specs/plugins",component:gNe}),tTe=Oe({getParentRoute:()=>Pe,path:"/files",component:FNe}),nTe=Oe({getParentRoute:()=>Pe,path:"/plugins/$pluginId",component:()=>{const{pluginId:e}=An({from:"/plugins/$pluginId"});return i.jsx(kNe,{pluginId:e})}}),sTe=Oe({getParentRoute:()=>Pe,path:"/specs/$specKind/$specName",component:()=>{const{specName:e}=An({from:"/specs/$specKind/$specName"});return i.jsx(Ql,{to:"/specs/library/$entryId",params:{entryId:e}})}}),rTe=Oe({getParentRoute:()=>Pe,path:"/settings",component:ZNe}),iTe=Oe({getParentRoute:()=>Pe,path:"/settings/policies",component:ske}),aTe=Oe({getParentRoute:()=>Pe,path:"/settings/log",component:oke}),oTe=Oe({getParentRoute:()=>Pe,path:"/settings/status",component:dke}),lTe=Oe({getParentRoute:()=>Pe,path:"/search",component:G1e}),cTe=Oe({getParentRoute:()=>Pe,path:"/lab/project-graphics-preview",component:mRe}),uTe=Oe({getParentRoute:()=>Pe,path:"/lab/card-previews",component:jRe}),dTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-lab",component:Uy}),hTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-bg/a-large",component:NRe}),fTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-bg/b-small",component:kRe}),pTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-bg/c-allover",component:CRe});function mTe(){var s;const{rigId:e}=An({from:"/rigs/$rigId"}),{data:t}=Dr(),n=(s=t==null?void 0:t.find(r=>r.id===e))==null?void 0:s.name;return i.jsx("div",{className:"flex flex-col flex-1 h-full",children:i.jsx("div",{className:"flex-1 min-h-[400px] relative",children:i.jsx(bT,{rigId:e,rigName:n??null,showDiscovered:!1})})})}const gTe=Oe({getParentRoute:()=>Pe,path:"/rigs/$rigId",component:mTe}),xTe=Oe({getParentRoute:()=>Pe,path:"/rigs/$rigId/nodes/$logicalId",component:()=>{const{rigId:e,logicalId:t}=An({from:"/rigs/$rigId/nodes/$logicalId"});return i.jsx(VV,{rigId:e,logicalId:decodeURIComponent(t)})}}),vTe=Oe({getParentRoute:()=>Pe,path:"/import",component:Kbe}),yTe=Oe({getParentRoute:()=>Pe,path:"/packages",component:e0e}),bTe=Oe({getParentRoute:()=>Pe,path:"/packages/install",component:a0e}),_Te=Oe({getParentRoute:()=>Pe,path:"/packages/$packageId",component:iwe}),wTe=Oe({getParentRoute:()=>Pe,path:"/bootstrap",component:pwe}),STe=Oe({getParentRoute:()=>Pe,path:"/agents/validate",component:mwe}),jTe=Oe({getParentRoute:()=>Pe,path:"/specs/rig",component:Ewe}),NTe=Oe({getParentRoute:()=>Pe,path:"/specs/agent",component:Twe}),kTe=Oe({getParentRoute:()=>Pe,path:"/specs/library/$entryId",component:()=>{const{entryId:e}=An({from:"/specs/library/$entryId"});return i.jsx(e1e,{entryId:e})}}),CTe=Oe({getParentRoute:()=>Pe,path:"/discovery",component:()=>i.jsx("div",{className:"flex h-full w-full items-center justify-center p-8",children:i.jsx(Ae,{label:"DISCOVERY",description:"Discovery surface preserved; redesign deferred per code-map.",variant:"card",testId:"discovery-placeholder"})})}),ETe=Oe({getParentRoute:()=>Pe,path:"/discovery/inventory",component:H1e}),RTe=Oe({getParentRoute:()=>Pe,path:"/bundles/inspect",component:Mwe}),TTe=Oe({getParentRoute:()=>Pe,path:"/bundles/install",component:Lwe}),ATe=Oe({getParentRoute:()=>Pe,path:"/context",component:()=>i.jsx(Ql,{to:"/topology"})}),ITe=Oe({getParentRoute:()=>Pe,path:"/mission-control",component:()=>i.jsx(Ql,{to:"/for-you"})}),MTe=Oe({getParentRoute:()=>Pe,path:"/slices",component:()=>i.jsx(Ql,{to:"/project"})}),LTe=Oe({getParentRoute:()=>Pe,path:"/slices/$name",component:()=>{const{name:e}=An({from:"/slices/$name"});return i.jsx(Ql,{to:"/project/slice/$sliceId",params:{sliceId:e}})}}),OTe=Oe({getParentRoute:()=>Pe,path:"/progress",component:()=>i.jsx(Ql,{to:"/project"})}),PTe=Oe({getParentRoute:()=>Pe,path:"/steering",component:()=>i.jsx(Ql,{to:"/project"})}),DTe=Pe.addChildren([PRe,DRe,$Re,BRe,qRe,FRe,zRe,HRe,URe,VRe,WRe,GRe,KRe,YRe,QRe,XRe,eTe,ZRe,JRe,nTe,tTe,sTe,rTe,iTe,aTe,oTe,lTe,cTe,uTe,dTe,hTe,fTe,pTe,gTe,xTe,vTe,yTe,bTe,_Te,wTe,STe,jTe,NTe,kTe,CTe,ETe,RTe,TTe,ATe,ITe,MTe,LTe,OTe,PTe]),$Te=bX({routeTree:DTe}),rG="openrig.uiMaintenanceNoticeDismissed",BTe="The OpenRig UI is experimental and in maintenance mode. It is not under active development; support is best-effort. The CLI is the primary supported interface. Contributions welcome.";function qTe(){try{return localStorage.getItem(rG)==="1"}catch{return!1}}function FTe(){const[e,t]=C.useState(qTe);if(e)return null;const n=()=>{try{localStorage.setItem(rG,"1")}catch{}t(!0)};return i.jsxs("div",{className:"fixed inset-x-0 top-0 z-[100] flex items-start justify-between gap-3 border-b border-amber-500/40 bg-amber-50 px-4 py-2 text-sm text-amber-950 shadow-sm dark:bg-amber-950 dark:text-amber-50","data-testid":"ui-maintenance-notice",role:"status",children:[i.jsx("span",{children:BTe}),i.jsx("button",{"aria-label":"Dismiss maintenance notice",className:"shrink-0 rounded px-1.5 font-semibold hover:bg-amber-200/60 dark:hover:bg-amber-900",onClick:n,type:"button",children:"×"})]})}function zTe(){return i.jsxs(i.Fragment,{children:[i.jsx(FTe,{}),i.jsx(SX,{router:$Te})]})}const Y8=document.getElementById("root");Y8&&_Y.createRoot(Y8).render(i.jsx(C.StrictMode,{children:i.jsx(qie,{children:i.jsx(zTe,{})})}));
623
+ ... ${n.length-8} more lines`}function LEe({qitemIds:e,queueItemsById:t,queueItemsFetching:n}){return e.length===0?i.jsx(Ae,{label:"NO QITEMS",description:"No queue items associated with this slice.",variant:"card",testId:"slice-queue-empty"}):i.jsxs("div",{children:[n?i.jsx("div",{"data-testid":"slice-queue-fetching",className:"mb-2 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Loading queue bodies..."}):null,i.jsx("ul",{"data-testid":"slice-queue-list",className:"divide-y divide-outline-variant border border-outline-variant",children:e.map(s=>{const r=t.get(s);return i.jsx("li",{className:"bg-surface-lowest/35 backdrop-blur-sm",children:i.jsxs(Ap,{data:QW(s,r),testId:`slice-queue-trigger-${s}`,className:"block w-full px-3 py-2 text-left hover:bg-surface-lowest/55 transition-colors font-mono text-xs",children:[i.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[r!=null&&r.state?i.jsx(zE,{state:r.state,compact:!0}):i.jsx(WF,{kind:"queue.item",compact:!0}),i.jsx(_f,{value:r==null?void 0:r.tsCreated})]}),i.jsx("span",{className:"mt-2 block whitespace-pre-wrap break-words text-on-surface",children:XW(s,r)}),r?i.jsxs("span",{"data-testid":`slice-queue-meta-${s}`,className:"mt-2 block space-y-2 text-[10px] text-on-surface-variant",children:[i.jsx(HE,{source:r.sourceSession,destination:r.destinationSession,muted:!0}),i.jsxs("span",{className:"flex flex-wrap gap-1.5",children:[i.jsx(Uu,{tag:s}),(r.tags??[]).slice(0,5).map(a=>i.jsx(Uu,{tag:a},a))]})]}):null]})},s)})})]})}function ZW(e){return FE(e)}function cr({label:e,value:t}){return i.jsxs("div",{className:"border border-outline-variant bg-surface-lowest/35 p-3 backdrop-blur-sm",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:e}),i.jsx("div",{className:"mt-1 font-mono text-sm font-bold text-on-surface",children:t})]})}function OEe({detail:e,remoteGated:t}){const n=e.acceptance.currentStep,s=Yl(t?null:e.slicePath??null,"README.md");return i.jsxs("div",{"data-testid":"slice-overview-tab",className:"space-y-6",children:[i.jsxs("section",{"data-testid":"slice-overview-summary",className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[i.jsx(cr,{label:"Status",value:e.status}),i.jsx(cr,{label:"Progress",value:`${e.acceptance.percentage}%`}),i.jsx(cr,{label:"Qitems",value:e.qitemIds.length}),i.jsx(cr,{label:"Last Activity",value:ZW(e.lastActivityAt)})]}),s.content&&i.jsx("section",{"data-testid":"slice-overview-readme",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:i.jsx(Zn,{content:s.content,hideFrontmatter:!0,hideRawToggle:!0})}),i.jsxs("section",{"data-testid":"slice-overview-current-step",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:[i.jsx(ct,{tone:"muted",children:"Current Step"}),n?i.jsxs("div",{className:"mt-3 grid gap-2 font-mono text-[10px] text-on-surface sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Step"}),i.jsx("div",{className:"font-bold text-on-surface",children:n.stepId})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Role"}),i.jsx("div",{className:"font-bold text-on-surface",children:n.role})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Objective"}),i.jsx("div",{children:n.objective??"No objective declared."})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Allowed exits"}),i.jsx("div",{children:n.allowedExits.join(", ")||"-"})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-[8px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Hop count"}),i.jsx("div",{children:n.hopCount})]})]}):i.jsx("div",{className:"mt-3 font-mono text-[10px] text-on-surface-variant",children:"No workflow step is currently bound."})]}),i.jsxs("section",{"data-testid":"slice-overview-readiness",className:"border border-outline-variant bg-surface-lowest/20 p-4",children:[i.jsx(ct,{tone:"muted",children:"Readiness"}),i.jsxs("div",{className:"mt-3 space-y-2 font-mono text-[10px] text-on-surface",children:[i.jsxs("div",{children:[e.acceptance.doneItems," of ",e.acceptance.totalItems," acceptance items complete."]}),i.jsxs("div",{children:[e.tests.aggregate.passCount," proof packets passing / ",e.tests.aggregate.failCount," failing."]}),e.acceptance.closureCallout&&i.jsx("div",{className:"border border-amber-300 bg-amber-50 px-2 py-1 text-amber-800",children:e.acceptance.closureCallout}),e.workflowBinding&&i.jsxs("div",{className:"text-on-surface-variant",children:["Workflow: ",e.workflowBinding.workflowName," v",e.workflowBinding.workflowVersion]})]})]})]})}function PEe(){var y,b,_;const{sliceId:e}=An({from:"/project/slice/$sliceId"}),[t,n]=C.useState("review"),{data:s}=Pr(),r=((s==null?void 0:s.selected)??at)!==at,a=rd(),{known:o,isLocal:c}=sd(),h=Uee(e),d=LE(((y=h.data)==null?void 0:y.qitemIds)??[]),m=C.useMemo(()=>d.itemsById,[d.itemsById]),f=DW(((b=h.data)==null?void 0:b.missionId)??null);if(h.isLoading)return i.jsx(uf,{eyebrow:"Slice",title:e,tabs:sC,active:t,onSelect:w=>n(w),children:i.jsx(Ae,{label:"LOADING",description:`Fetching /api/slices/${e}…`,variant:"card",testId:"slice-scope-loading"})});if(h.isError||!h.data)return i.jsx(uf,{eyebrow:"Slice",title:e,tabs:sC,active:t,onSelect:w=>n(w),children:i.jsx(Ae,{label:"SLICE NOT AVAILABLE",description:h.error instanceof Error?h.error.message:`Could not load slice "${e}". The slices indexer may not be configured (rig config get workspace.slices_root).`,variant:"card",testId:"slice-scope-error"})});const g=h.data,x=((_=f.data)==null?void 0:_.slices.find(w=>w.name===g.name))??null;return i.jsxs(uf,{eyebrow:"Slice",title:g.displayName||g.name,tabs:sC,active:t,onSelect:w=>n(w),children:[t==="review"?o?c?i.jsx(uEe,{sliceName:g.name,slicePath:a?g.slicePath:null,anchorIdentity:typeof window<"u"&&window.location.hash.startsWith("#needs-you-")?window.location.hash.slice(11):null}):i.jsx(WW,{testId:"slice-review-remote-gated"}):i.jsx(VW,{testId:"slice-review-selection-pending"}):null,t==="story"?i.jsx(KT,{rows:[],detailsByName:new Map,queueItemsById:m,isFetching:!1}):null,t==="overview"?i.jsx(OEe,{detail:g,remoteGated:!a}):null,t==="progress"?i.jsxs("div",{className:"space-y-6",children:[x&&(x.railStatus==="missing"||x.railStatus==="malformed")&&i.jsx(Ae,{label:x.railStatus==="malformed"?"PROGRESS RAIL MALFORMED":"PROGRESS RAIL MISSING",description:x.railStatus==="malformed"?`Slice progress rail has errors (${x.frontmatterError??"malformed frontmatter"}). Run the audit command to diagnose.`:"This slice has no PROGRESS.md and no readme-only marker.",variant:"card",testId:"slice-progress-rail-status",action:{label:`rig scope audit --mission ${g.missionId}`}}),x&&x.findings.length>0&&i.jsxs("section",{"data-testid":"slice-scope-findings",className:"border border-outline-variant bg-amber-50/40 p-4",children:[i.jsxs(ct,{children:["Scope Findings (",x.findings.length,")"]}),i.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[11px]",children:x.findings.map((w,E)=>i.jsxs("li",{className:ce("px-2 py-1",w.severity==="high"?"text-red-700":"text-on-surface-variant"),children:["[",w.severity,"] ",w.kind,": ",w.message]},E))})]}),i.jsx(g2e,{acceptance:g.acceptance})]}):null,t==="artifacts"?i.jsx(UT,{scopePath:a?g.slicePath:null,scopeLabel:g.displayName||g.name,remoteGated:r}):null,t==="proof"?i.jsx(N2e,{sliceId:g.displayName,title:g.name,slicePath:a?g.slicePath:null}):null,t==="queue"?i.jsx(LEe,{qitemIds:g.qitemIds,queueItemsById:m,queueItemsFetching:d.isFetching}):null,t==="topology"?i.jsx(HT,{topology:g.topology}):null]})}const DEe=15e3,$Ee=3e4,BEe=["review","fleet"];async function qEe(){const e=await fetch("/api/review/fleet");if(!e.ok)throw new Error(`HTTP ${e.status}`);return await e.json()}function JW(e={}){return Re({queryKey:BEe,queryFn:qEe,enabled:e.enabled??!0,staleTime:DEe,refetchInterval:$Ee,refetchOnWindowFocus:"always"})}function FEe({hostId:e}){return i.jsx("span",{className:ce("shrink-0 border px-1 font-mono text-[9px] uppercase tracking-wide",e==="local"?"border-outline-variant text-on-surface-variant":"border-on-surface text-on-surface"),children:e})}function zEe(){var a;const{data:e,isError:t}=Pr(),n=(((a=e==null?void 0:e.hosts)==null?void 0:a.length)??0)>0,{data:s}=JW({enabled:n||t});if(!s||s.hosts.length<=1&&!s.registryError)return null;const r=s.needsYou.items.find(o=>o.source==="derived")??s.needsYou.items[0];return i.jsxs("div",{"data-testid":"fleet-band",className:ce("flex flex-wrap items-center gap-2 px-2 py-1.5",fr),children:[i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface",children:"FLEET"}),i.jsxs("span",{"data-testid":"fleet-band-rollup",className:"flex items-center gap-2 font-mono text-[10px]",children:[i.jsxs("span",{className:"text-emerald-700",children:["● ",s.rollup.needsYouCount]}),i.jsxs("span",{className:"text-amber-700",children:["▲ ",s.rollup.exceptionCount]}),i.jsxs("span",{className:"text-on-surface-variant",children:[s.rollup.hostCount," hosts",s.rollup.unreachableCount>0?` · ${s.rollup.unreachableCount} unreachable`:""]})]}),s.registryError?i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-error",children:"host registry unreadable — local-only glance"}):r?i.jsxs("span",{"data-testid":"fleet-band-worst",className:"flex min-w-0 flex-1 items-center gap-1.5 truncate font-mono text-[10px] text-on-surface-variant",children:["worst: ",i.jsx(FEe,{hostId:r.hostId}),i.jsx("span",{className:"min-w-0 truncate",children:r.summary})]}):i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:"quiet"}),i.jsx("a",{href:"/fleet","data-testid":"fleet-band-open",className:"font-mono text-[10px] uppercase text-on-surface hover:underline",children:"open fleet →"})]})}const HEe="human@host",UEe={root:null,relPath:null,slicePath:null};function V8(e){return typeof window>"u"?null:new URLSearchParams(window.location.search).get(e)}function VEe(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 WEe(){const{data:e,isLoading:t,error:n}=K2e(),s=V8("slice"),r=V8("group")==="slice"?"slice":"agent",[a,o]=C.useState(r),c=d=>{if(o(d),typeof window>"u")return;const m=new URL(window.location.href);m.searchParams.set("group",d),window.history.replaceState({},"",`${m.pathname}${m.search}${m.hash}`)},h=C.useMemo(()=>{if(!e)return null;if(!s)return e.agents;const d=e.agents.rows.filter(m=>m.slices.includes(s));return{...e.agents,rows:d,provenance:d.length===0?`no agents holding or recently holding work on ${s} — ${e.agents.provenance}`:`anchored to ${s} — ${e.agents.provenance}`}},[e,s]);return t?i.jsx("p",{className:"p-4 font-mono text-[11px] text-on-surface-variant",children:"composing the rig coordination story…"}):n||!e||!h?i.jsxs("p",{"data-testid":"rig-agents-error",className:"p-4 font-mono text-[11px] text-red-700",children:["rig agents panel unavailable: ",n instanceof Error?n.message:"composer unreachable"]}):i.jsxs("div",{"data-testid":"rig-agents-page",className:"mx-auto max-w-4xl space-y-5 p-4",children:[i.jsx(zEe,{}),i.jsxs("nav",{className:"flex items-center gap-2 font-mono text-[10px] uppercase text-on-surface-variant",children:[i.jsx(Ve,{to:"/project",className:"hover:underline",children:"project"}),i.jsx("span",{children:"/"}),i.jsx("span",{"data-testid":"rig-agents-crumb",children:"agents (rig)"}),s?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsxs("span",{"data-testid":"rig-agents-anchor",children:["anchored: ",s]}),i.jsx("a",{href:"/agents",className:"hover:underline","data-testid":"rig-agents-unanchor",children:"[full rig]"})]}):null]}),i.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-2",children:[i.jsx("h2",{className:"text-[14px] font-semibold",children:"AGENTS — the coordination story"}),i.jsxs("div",{className:"flex items-center gap-1 font-mono text-[10px] uppercase",children:[i.jsx("span",{className:"text-on-surface-variant",children:"group by"}),["agent","slice"].map(d=>i.jsx("button",{type:"button","data-testid":`rig-agents-group-${d}`,onClick:()=>c(d),className:`border px-2 py-0.5 ${a===d?"border-outline bg-surface-variant":"border-outline-variant hover:bg-surface-variant/50"}`,children:d},d))]})]}),i.jsx(HW,{band:e.needsYou,slice:"rig",missionId:null,actorSession:HEe,ctx:UEe,showApprove:!1}),i.jsx(GT,{band:h,itemRef:"rig",grouping:a}),i.jsxs("section",{"data-testid":"settled-band",className:"space-y-1",children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"SETTLED"}),e.settled.length===0?i.jsx("p",{"data-testid":"settled-empty",className:"font-mono text-[11px] text-on-surface-variant",children:e.settledProvenance}):i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:e.settled.map(d=>i.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:bf(d.fromSession)}),i.jsx("span",{className:"text-on-surface-variant",children:"→"}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:bf(d.toSession)}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px]","data-testid":`settled-summary-${d.qitemId}`,children:d.summary??d.qitemId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:VEe(d.closedAtIso)})]},`${d.qitemId}-${d.closedAtIso}`))}),i.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant",children:e.settledProvenance})]})]}),i.jsxs("p",{className:"font-mono text-[10px] text-on-surface-variant",children:["composed ",e.composedAt]})]})}function GEe(e){return typeof window>"u"?null:new URLSearchParams(window.location.search).get(e)}function eG(e){if(!e)return"—";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 tG({hostId:e}){return i.jsx("span",{"data-testid":`fleet-item-host-${e}`,className:ce("shrink-0 border px-1 font-mono text-[9px] uppercase tracking-wide",e==="local"?"border-outline-variant text-on-surface-variant":"border-on-surface text-on-surface"),children:e})}function KEe(){const e=jv();return t=>{e.mutate({hostId:t},{onSuccess:()=>window.location.assign("/project?from=fleet")})}}function YEe(e){if(typeof window>"u")return;const t=new URL(window.location.href);e===null?t.searchParams.delete("open"):t.searchParams.set("open",e),window.history.replaceState({},"",`${t.pathname}${t.search}${t.hash}`)}function QEe({item:e,expanded:t,onToggle:n,onOpenHost:s}){return i.jsxs("li",{"data-testid":`fleet-needs-you-${e.fleetKey}`,"data-source":e.source,className:"px-2 py-1.5",children:[i.jsx("button",{type:"button",onClick:n,className:"block w-full text-left",children:i.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("span",{className:ce("font-mono text-[11px]",e.source==="derived"?"text-amber-700":"text-emerald-700"),title:e.source==="derived"?"machine-derived exception":"agent-initiated",children:e.source==="derived"?"▲":"●"}),i.jsx(tG,{hostId:e.hostId}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-on-surface",children:e.summary}),e.derived?i.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wide text-amber-700",children:e.derived.kind}):null,i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:e.where}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:eG(e.ageIso)})]})}),e.derived?i.jsxs("p",{className:"mt-0.5 pl-6 font-mono text-[10px] text-on-surface-variant",children:["▲ ",e.derived.evidence," · threshold: ",e.derived.threshold]}):null,i.jsxs("p",{className:"mt-0.5 pl-6 font-mono text-[9px] text-on-surface-variant/80",children:["counted once · seen from ",e.seenFrom.join(" · ")," on ",e.hostId]}),t?i.jsxs("div",{"data-testid":`fleet-item-expanded-${e.fleetKey}`,className:"mt-1.5 ml-6 border border-outline-variant bg-surface-low/50 px-2 py-1.5",children:[i.jsxs("p",{className:"font-mono text-[10px] text-on-surface",children:["identity: ",i.jsx("span",{className:"text-on-surface-variant",children:e.fleetKey})]}),e.derived?i.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-on-surface",children:["evidence: ",i.jsx("span",{className:"text-on-surface-variant",children:e.derived.evidence})]}):null,i.jsxs("p",{className:"mt-1 font-mono text-[9px] uppercase tracking-wide text-on-surface-variant",children:["read-only here — acting on a remote host's item rides cross-host routing (MH-3/MH-4) ·"," ",i.jsxs("button",{type:"button",onClick:()=>s(e.hostId),className:"underline",children:["open ",e.hostId," →"]})]})]}):null]})}function XEe(e){return e.status.status==="ok"?{char:"●",cls:"text-emerald-700"}:{char:"✕",cls:"text-error"}}function ZEe(){const{data:e,isLoading:t,error:n,refetch:s}=JW(),r=KEe(),a=GEe("open");if(t)return i.jsx("p",{className:"p-4 font-mono text-[11px] text-on-surface-variant",children:"composing the fleet glance…"});if(n||!e)return i.jsxs("p",{"data-testid":"fleet-error",className:"p-4 font-mono text-[11px] text-error",children:["fleet glance unavailable: ",n instanceof Error?n.message:"composer unreachable"]});const o=e.hosts.filter(c=>c.status.status==="ok").length;return i.jsxs("div",{"data-testid":"fleet-page",className:"mx-auto max-w-4xl space-y-5 p-4",children:[i.jsxs("nav",{className:"flex items-center gap-2 font-mono text-[10px] uppercase text-on-surface-variant",children:[i.jsx("span",{"data-testid":"fleet-crumb",className:"text-on-surface",children:"fleet"}),i.jsx("span",{children:"·"}),i.jsx("span",{children:"every factory, one glance"})]}),i.jsxs("header",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[i.jsx("h2",{className:"text-[14px] font-semibold uppercase",children:"Fleet — needs me / stuck / failing"}),i.jsxs("div",{"data-testid":"fleet-rollup",className:"flex items-center gap-2 font-mono text-[10px] uppercase",children:[i.jsxs("span",{className:"text-emerald-700",children:["● ",e.rollup.needsYouCount," need you"]}),i.jsxs("span",{className:"text-amber-700",children:["▲ ",e.rollup.exceptionCount," exceptions",e.rollup.exceptionsByKind.length>0?` (${e.rollup.exceptionsByKind.map(c=>`${c.count} ${c.kind}`).join(" · ")})`:""]}),i.jsxs("span",{className:"text-on-surface-variant",children:[e.rollup.hostCount," hosts"]}),e.rollup.unreachableCount>0?i.jsxs("span",{className:"text-error",children:[e.rollup.unreachableCount," unreachable"]}):null]})]}),e.registryError?i.jsxs("p",{"data-testid":"fleet-registry-error",className:"font-mono text-[10px] text-error",children:["host registry unreadable — this glance is LOCAL-ONLY, not the fleet: ",e.registryError]}):null,i.jsxs("section",{"data-testid":"fleet-needs-you",className:ce("space-y-1 p-2",fr),children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"NEEDS YOU"}),e.needsYou.items.length>0?i.jsx("ul",{className:"divide-y divide-outline-variant/50",children:e.needsYou.items.map(c=>i.jsx(QEe,{item:c,expanded:a===c.fleetKey,onToggle:()=>YEe(a===c.fleetKey?null:c.fleetKey),onOpenHost:r},c.fleetKey))}):null,i.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant",children:e.needsYou.provenance})]}),i.jsxs("section",{"data-testid":"fleet-hosts",className:ce("space-y-1 p-2",fr),children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"HOSTS"}),i.jsx("ul",{className:"divide-y divide-outline-variant/50",children:e.hosts.map(c=>{const h=XEe(c),d=c.status.status==="ok";return i.jsxs("li",{"data-testid":`fleet-host-${c.hostId}`,className:"flex flex-wrap items-center gap-2 px-2 py-1.5",children:[i.jsx("span",{className:ce("font-mono text-[11px]",h.cls),children:h.char}),i.jsx(SE,{className:"h-3 w-3 text-on-surface-variant"}),i.jsx("span",{className:"font-mono text-[11px] uppercase text-on-surface",children:c.hostId}),c.kind==="local"?i.jsx("span",{className:"font-mono text-[8px] uppercase text-on-surface-variant",children:"local"}):null,d?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:c.topLine}),(c.needsYouCount??0)>0?i.jsxs("span",{className:"font-mono text-[10px] text-emerald-700",children:["● ",c.needsYouCount]}):null,(c.exceptionsByKind??[]).map(m=>i.jsxs("span",{className:"font-mono text-[10px] text-amber-700",children:["▲ ",m.count," ",m.kind]},m.kind)),i.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant",children:[c.rigCount," rigs · ",c.seatCount," seats"]}),i.jsx("button",{type:"button","data-testid":`fleet-host-${c.hostId}-open`,onClick:()=>r(c.hostId),className:"font-mono text-[10px] uppercase text-on-surface hover:underline",children:"open →"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-error",children:[c.status.status,c.status.error?` — ${c.status.error}`:""," · items absent from this glance, not zero"]}),i.jsx("button",{type:"button","data-testid":`fleet-host-${c.hostId}-retry`,onClick:()=>void s(),className:"border border-error px-1.5 py-0.5 font-mono text-[9px] uppercase text-error hover:bg-surface-low",children:"retry"})]})]},c.hostId)})})]}),i.jsxs("section",{"data-testid":"fleet-settled",className:"space-y-1",children:[i.jsx("h3",{className:"font-mono text-[10px] uppercase tracking-wide text-on-surface-variant",children:"SETTLED"}),e.settled.length>0?i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:e.settled.map(c=>i.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5",children:[i.jsx(tG,{hostId:c.hostId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:c.fromSession.split("@")[0]}),i.jsx("span",{className:"text-on-surface-variant",children:"→"}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:c.toSession.split("@")[0]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px]",children:c.summary??c.qitemId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:eG(c.closedAtIso)})]},`${c.hostId}|${c.qitemId}`))}):null,i.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant",children:e.settledProvenance})]}),i.jsxs("p",{"data-testid":"fleet-fanout-footer",className:"font-mono text-[10px] text-on-surface-variant",children:["composed ",e.composedAt," · fleet fan-out ",o,"/",e.hosts.length," hosts ok ·"," ",i.jsx(Ve,{to:"/agents",className:"hover:underline",children:"this host's agents →"})]})]})}function JEe(e){const t=new Map;for(const s of e){const r=`${s.workflowName}:${s.workflowVersion}`;t.has(r)||t.set(r,[]),t.get(r).push(s)}const n=[...t.entries()].map(([s,r])=>({key:s,name:r[0].workflowName,version:r[0].workflowVersion,rows:r.sort((a,o)=>Zi(a)-Zi(o))}));return n.sort((s,r)=>Zi(s.rows[0])-Zi(r.rows[0])),n}function eRe(){const e=Pt(),{data:t,isLoading:n}=HV(),{data:s}=zwe(),r=t??[],a=JEe(r),o=r.filter(f=>Zi(f)<=1).length,c=r.filter(f=>f.status==="active"||f.status==="waiting").length,h=r.filter(f=>f.status==="completed").length,d=new Set(r.map(f=>`${f.workflowName}:${f.workflowVersion}`)),m=((s==null?void 0:s.specs)??[]).filter(f=>!d.has(`${f.name}:${f.version}`));return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"workflows-page",className:"space-y-6",children:[i.jsx(wn,{eyebrow:"Workflows",title:"Deterministic Runs",description:n?"Loading instances…":`${r.length} instance${r.length===1?"":"s"} · ${o} need attention · ${c} live · ${h} completed — computed from /api/workflow/list`,actions:i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>e({to:"/specs"}),children:"Workflow Library"})}),r.length===0&&!n?i.jsx("p",{"data-testid":"workflows-empty",className:"font-mono text-[11px] text-on-surface-variant",children:"0 instances — instantiate one from a library spec (rig workflow instantiate) and it appears here with its live position."}):null,a.map(f=>{const g=f.rows.filter(y=>Zi(y)<=1).length,x=f.rows.filter(y=>y.status==="active"||y.status==="waiting").length;return i.jsxs("section",{"data-testid":`workflows-group-${f.name}`,className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button","data-testid":`workflows-group-spec-${f.name}`,onClick:()=>e({to:"/specs/library/$entryId",params:{entryId:`workflow:${f.name}:${f.version}`}}),className:"font-mono text-[11px] font-bold text-on-surface underline-offset-2 hover:underline",children:[f.name," v",f.version]}),i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:[f.rows.length," instance",f.rows.length===1?"":"s"," · ",x," live",g>0?` · ▲ ${g}`:""]})]}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:f.rows.map(y=>i.jsx(UV,{instance:y},y.instanceId))})]},f.key)}),m.length>0?i.jsxs("section",{"data-testid":"workflows-idle-specs",className:"space-y-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:"Cached Specs — No Instances"}),i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:m.map(f=>i.jsx("li",{children:i.jsxs("button",{type:"button","data-testid":`workflows-idle-spec-${f.name}`,onClick:()=>e({to:"/specs/library/$entryId",params:{entryId:`workflow:${f.name}:${f.version}`}}),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:"font-mono text-[11px] text-on-surface-variant","aria-hidden":!0,children:"◌"}),i.jsxs("span",{className:"font-mono text-[11px] text-on-surface",children:[f.name," v",f.version]}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:f.purpose??""}),i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:[f.isBuiltIn?"built-in":"user file"," · 0 instances"]})]})},`${f.name}:${f.version}`))})]}):null]})})}const tRe={handoff:{glyph:"→",cls:"text-emerald-800"},waiting:{glyph:"◐",cls:"text-on-surface-variant"},done:{glyph:"○",cls:"text-on-surface-variant"},failed:{glyph:"▲",cls:"text-red-700"}};function nRe(e){return e.replace("T"," ").replace(/\.\d+Z$/,"Z")}function sRe({entry:e,index:t,expanded:n,onToggle:s}){const r=tRe[e.closureReason]??{glyph:"?",cls:"text-on-surface-variant"},a=e.closureEvidence&&typeof e.closureEvidence.resultNote=="string"?e.closureEvidence.resultNote:null;return i.jsxs("li",{id:`step-${e.stepId}`,children:[i.jsxs("button",{type:"button","data-testid":`workflow-trail-row-${e.trailId}`,onClick:s,className:"flex w-full items-center gap-2 px-2 py-1.5 text-left hover:bg-surface-variant/50",children:[i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant w-6 shrink-0",children:[t+1,"."]}),i.jsx("span",{className:"font-mono text-[11px] font-bold text-on-surface w-28 shrink-0",children:e.stepId}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant w-20 shrink-0",children:e.stepRole}),i.jsxs("span",{className:ce("font-mono text-[11px] w-20 shrink-0",r.cls),children:[r.glyph," ",e.closureReason]}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-on-surface-variant",children:a??"—"}),i.jsx("span",{className:"hidden font-mono text-[10px] text-on-surface-variant lg:inline",children:e.actorSession}),i.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:nRe(e.closedAt)})]}),n?i.jsxs("div",{"data-testid":`workflow-trail-expanded-${e.trailId}`,className:"space-y-1 border-t border-outline-variant/50 bg-surface-lowest/10 px-8 py-2 font-mono text-[10px]",children:[i.jsxs("p",{children:[i.jsx("span",{className:"uppercase text-on-surface-variant",children:"actor: "}),e.actorSession]}),i.jsxs("p",{children:[i.jsx("span",{className:"uppercase text-on-surface-variant",children:"closed packet: "}),e.priorQitemId]}),i.jsxs("p",{children:[i.jsx("span",{className:"uppercase text-on-surface-variant",children:"routed next: "}),e.nextQitemId??"(terminal — no next packet)"]}),e.closureEvidence?i.jsx("pre",{className:"overflow-x-auto border border-outline-variant/40 bg-surface-lowest/20 p-2 text-[9px] leading-snug",children:JSON.stringify(e.closureEvidence,null,2)}):i.jsx("p",{className:"text-on-surface-variant",children:"(no closure evidence recorded)"})]}):null]})}function rRe({trail:e,instance:t,anchorStepId:n}){const[s,r]=C.useState(()=>{if(!n)return null;const o=e.find(c=>c.stepId===n);return o?o.trailId:null}),a=n!=null&&n===t.currentStepId;return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"font-mono text-[8px] uppercase tracking-[0.16em] text-on-surface-variant",children:["Routing History",i.jsxs("span",{className:"ml-2 normal-case tracking-normal",children:[e.length," closed step",e.length===1?"":"s"," · append-only trail · deterministic path",t.currentStepId?` → now at ${t.currentStepId}`:""]})]}),e.length===0?i.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant",children:"No steps closed yet — the entry packet is on the frontier."}):i.jsx("ul",{className:"divide-y divide-outline-variant/50 border border-outline-variant",children:e.map((o,c)=>i.jsx(sRe,{entry:o,index:c,expanded:s===o.trailId,onToggle:()=>r(h=>h===o.trailId?null:o.trailId)},o.trailId))}),t.currentStepId?i.jsxs("div",{id:`step-${t.currentStepId}`,"data-testid":"workflow-frontier-row",className:ce("flex items-center gap-2 border border-dashed px-2 py-1.5",a?"border-amber-700 bg-amber-700/5":"border-outline-variant"),children:[i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant w-6 shrink-0",children:[e.length+1,"."]}),i.jsx("span",{className:"font-mono text-[11px] font-bold text-on-surface w-28 shrink-0",children:t.currentStepId}),i.jsx("span",{className:"font-mono text-[11px] text-emerald-800 w-20 shrink-0",children:"● open"}),i.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-on-surface-variant",children:["frontier packet ",t.currentFrontier[0]??"(none)",t.deadline.evidence?` · held by ${t.deadline.evidence.ownerSession}`:""]})]}):null]})}function W8(e){return e.replace("T"," ").replace(/\.\d+Z$/,"Z")}const iRe="human@host";async function aRe(e){const t=await fetch(`/api/workflow/${encodeURIComponent(e)}/resume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actorSession:iRe})});if(!t.ok)throw new Error(`resume failed — HTTP ${t.status}`)}function oRe(e,t){const n=e.map(r=>r.stepId);t&&n.push(t);const s=[];for(let r=0;r+1<n.length;r++)n[r]!==n[r+1]&&s.push(`${n[r]}→${n[r+1]}`);return{visited:e.map(r=>r.stepId),edgeKeys:s}}function lRe({instance:e,onResume:t,resuming:n,resumeError:s}){const r=e.status==="waiting"&&e.currentStepId!=null,a=e.deadline.state!=="healthy"&&e.deadline.evidence,o=e.status==="failed";if(!r&&!a&&!o)return null;const c=o||a?"border-red-700/60 bg-red-700/5":"border-amber-700/60 bg-amber-700/5";return i.jsxs("div",{"data-testid":"workflow-exception-banner",className:ce("space-y-2 border px-3 py-2",c),children:[o?i.jsxs("p",{className:"font-mono text-[11px] text-red-700",children:["▲ FAILED — no remediation branch mapped for the failing exit",e.resumeCount>0?` · resumed ${e.resumeCount}× already`:""]}):null,a?i.jsxs("p",{className:"font-mono text-[11px] text-red-700",children:["▲ ",e.deadline.state.toUpperCase()," — step ",e.deadline.evidence.stepId??"(unbound)"," packet"," ",e.deadline.evidence.packetId," held by ",e.deadline.evidence.ownerSession,","," ",Math.floor(e.deadline.evidence.overdueBySeconds/60),"m past its"," ",e.deadline.evidence.anchor," anchor"]}):null,r&&!a&&!o?i.jsxs("p",{className:"font-mono text-[11px] text-amber-800",children:["◐ WAITING at ",e.currentStepId," — the gate packet is parked pending sign-off; resolving the NEEDS-YOU item resumes the deterministic flow"]}):null,i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?i.jsx("button",{type:"button","data-testid":"workflow-resume",disabled:n,onClick:t,className:"border border-outline px-3 py-1 font-mono text-[11px] uppercase hover:bg-surface-variant disabled:cursor-not-allowed disabled:opacity-50",title:`POST /api/workflow/${e.instanceId}/resume — redrive from the failed step (WF-5 FR-4)`,children:n?"Resuming…":"Resume"}):null,s?i.jsx("span",{"data-testid":"workflow-resume-error",className:"font-mono text-[10px] text-red-700",children:s}):null,i.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant",children:["CLI: rig workflow trace ",e.instanceId]})]})]})}function cRe({instanceId:e,anchorStepId:t}){const n=Pt(),s=mt(),{data:r,isLoading:a,error:o}=Hwe(e),c=r?`workflow:${r.instance.workflowName}:${r.instance.workflowVersion}`:null,{data:h}=Rv(c),[d,m]=C.useState(!1),[f,g]=C.useState(null),x=()=>{m(!0),g(null),aRe(e).then(()=>s.invalidateQueries({queryKey:["workflow"]})).catch(k=>g(k.message)).finally(()=>m(!1))};if(a)return i.jsx(ot,{children:i.jsx("div",{className:"font-mono text-[10px] text-on-surface-variant",children:"Loading workflow instance…"})});if(o||!r)return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"workflow-instance-error",className:"space-y-4",children:[i.jsx(wn,{eyebrow:"Workflow — Instance",title:"Instance Not Found",description:(o==null?void 0:o.message)??`No workflow instance ${e}.`}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>n({to:"/workflows"}),children:"Back to Workflows"})]})});const{instance:y,trail:b}=r,{visited:_,edgeKeys:w}=oRe(b,y.currentStepId),E=h&&h.kind==="workflow"?h:null,N=y.deadline.state!=="healthy"?y.deadline.state:y.status;return i.jsx(ot,{children:i.jsxs("div",{"data-testid":"workflow-instance-page",className:"space-y-6",children:[i.jsx(wn,{eyebrow:`Workflow — Instance · ${y.workflowName} v${y.workflowVersion}`,title:y.instanceId,description:y.currentStepId?`${y.status} at ${y.currentStepId} · hop ${y.hopCount}`:`${y.status} · hop ${y.hopCount}`,actions:i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(Se,{variant:"outline",size:"sm","data-testid":"workflow-view-spec",onClick:()=>c&&n({to:"/specs/library/$entryId",params:{entryId:c}}),children:"View Spec"}),i.jsx(Se,{variant:"outline",size:"sm",onClick:()=>n({to:"/workflows"}),children:"Back"})]})}),i.jsxs(Do,{children:[i.jsx(st,{label:"Status",value:N,testId:"wf-inst-status"}),i.jsx(st,{label:"Position",value:y.currentStepId??(y.status==="completed"?"closed":"felled"),testId:"wf-inst-position"}),i.jsx(st,{label:"Hops",value:y.hopCount,testId:"wf-inst-hops"}),i.jsx(st,{label:"Resumes",value:y.resumeCount,testId:"wf-inst-resumes"})]}),i.jsxs("p",{"data-testid":"wf-inst-provenance",className:"font-mono text-[10px] text-on-surface-variant",children:["created by ",y.createdBySession," · ",W8(y.createdAt),y.completedAt?` · completed ${W8(y.completedAt)}`:""]}),i.jsx(lRe,{instance:y,onResume:x,resuming:d,resumeError:f}),E?i.jsx(zV,{topology:E.topology,testId:"workflow-instance-graph",currentStepId:y.currentStepId,visitedStepIds:_,takenEdgeKeys:w}):i.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant",children:"(workflow shape unavailable — the spec is not in the library cache)"}),i.jsx(rRe,{trail:b,instance:y,anchorStepId:t})]})})}const uRe={neutral:"border-outline-variant bg-surface-lowest/65 text-on-surface",info:"border-sky-300 bg-sky-50/70 text-sky-800",success:"border-emerald-300 bg-emerald-50/70 text-emerald-800",warning:"border-amber-300 bg-amber-50/80 text-amber-800",danger:"border-rose-300 bg-rose-50/75 text-rose-800"},ko=[{label:"Queue created",tone:"info",icon:eF},{label:"Handoff",tone:"neutral",icon:wv},{label:"Claimed",tone:"warning",icon:yf},{label:"Completed",tone:"success",icon:vf},{label:"Human action",tone:"danger",icon:Co},{label:"Shipped",tone:"success",icon:NE}],nG=[{label:"idea-ledger",tone:"neutral"},{label:"cycle-4",tone:"info"},{label:"proof",tone:"success"},{label:"urgent",tone:"danger"},{label:"human-review",tone:"warning"}];function si({token:e,compact:t=!1}){const n=e.icon;return i.jsxs("span",{className:ce("inline-flex items-center gap-1 border font-mono uppercase tracking-[0.10em]",t?"px-1.5 py-0.5 text-[8px]":"px-2 py-1 text-[9px]",uRe[e.tone]),children:[n?i.jsx(n,{className:t?"h-2.5 w-2.5":"h-3 w-3",strokeWidth:1.6}):null,e.label]})}function Dl({kind:e,label:t,muted:n}){const s=e==="human"?LJ:SZ;return i.jsxs("span",{className:ce("inline-flex min-w-0 items-center gap-1 border px-1.5 py-0.5 font-mono text-[9px]",n?"border-outline-variant bg-surface-lowest/45 text-on-surface-variant":"border-outline-variant bg-surface-lowest/45 text-on-surface"),children:[i.jsx(s,{className:"h-3 w-3 shrink-0",strokeWidth:1.5}),i.jsx("span",{className:"truncate",children:t})]})}function sG({label:e}){return i.jsxs("span",{className:"inline-flex items-center gap-1 border border-outline-variant bg-surface-lowest/55 px-1.5 py-0.5 font-mono text-[9px] text-on-surface-variant",children:[i.jsx(_E,{className:"h-3 w-3",strokeWidth:1.5}),e]})}function dRe(){return i.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[i.jsx(Dl,{kind:"agent",label:"orch-lead@my-rig"}),i.jsx(Dx,{className:"h-3.5 w-3.5 text-on-surface-variant",strokeWidth:1.4}),i.jsx(Dl,{kind:"agent",label:"driver@my-rig"}),i.jsx(Dx,{className:"h-3.5 w-3.5 text-on-surface-variant",strokeWidth:1.4}),i.jsx(Dl,{kind:"human",label:"human@host"})]})}function hRe(){return i.jsx("div",{className:"grid grid-cols-3 gap-2",children:["for-you-human-and-shipped.png","project-overview-missions.png","project-triage-slice.png"].map(e=>i.jsxs("div",{className:"border border-outline-variant bg-surface-low/80",children:[i.jsx("div",{className:"flex aspect-[4/3] items-center justify-center bg-surface-lowest/65 text-on-surface-variant",children:i.jsx(UZ,{className:"h-7 w-7",strokeWidth:1.2})}),i.jsx("div",{className:"truncate border-t border-outline-variant px-1 py-0.5 font-mono text-[8px] text-on-surface-variant",children:e})]},e))})}function rC({label:e,description:t,children:n}){return i.jsx(zx,{as:"section",className:"bg-surface-lowest/65 backdrop-blur-sm",header:i.jsx("span",{className:"uppercase tracking-[0.16em]",children:e}),children:i.jsxs("div",{className:"space-y-4 p-4",children:[i.jsx("p",{className:"font-mono text-[10px] leading-relaxed text-on-surface",children:t}),n]})})}function G8({dense:e=!1}){return i.jsxs("article",{className:ce("border border-outline-variant bg-surface-lowest/60 backdrop-blur-sm hard-shadow",e?"p-3":"p-4"),children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(si,{token:{label:"Action required",tone:"danger",icon:Co},compact:e}),i.jsx("h3",{className:"font-mono text-sm text-on-surface",children:"Review demo-seed triage proof packet"})]}),i.jsx(sG,{label:"Today 4:18 PM"})]}),i.jsx("p",{className:"mt-3 whitespace-pre-line font-mono text-[11px] leading-relaxed text-on-surface",children:"Review the proof packet screenshots, confirm the shipped slice is ready, then approve or route back with notes."}),i.jsx("div",{className:"mt-3",children:i.jsx(dRe,{})}),i.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:nG.slice(0,4).map(t=>i.jsx(si,{token:t,compact:!0},t.label))})]})}function fRe(){return i.jsxs("article",{className:"relative border border-outline-variant bg-surface-lowest/60 p-4 hard-shadow backdrop-blur-sm",children:[i.jsx("div",{className:"absolute left-5 top-12 bottom-5 w-px bg-surface-highest"}),i.jsx("div",{className:"relative space-y-5 pl-8",children:[{token:ko[5],title:"Slice shipped with proof packet",body:"The triage slice closed with screenshots, queue context, and verification notes attached."},{token:ko[3],title:"Implementation completed",body:"Driver finished the UI pass and handed verification to guard and QA."},{token:ko[1],title:"Work routed for review",body:"The queue item moved from driver to guard with targeted checks."}].map(e=>{const t=e.token.icon??bu;return i.jsxs("div",{className:"relative",children:[i.jsx("span",{className:"absolute -left-[38px] top-0 flex h-5 w-5 items-center justify-center border border-outline-variant bg-surface-lowest text-on-surface",children:i.jsx(t,{className:"h-3 w-3",strokeWidth:1.5})}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx(si,{token:e.token,compact:!0}),i.jsx(sG,{label:"12 min ago"})]}),i.jsx("h4",{className:"mt-2 font-mono text-[12px] text-on-surface",children:e.title}),i.jsx("p",{className:"mt-1 font-mono text-[10px] leading-relaxed text-on-surface",children:e.body})]},e.title)})})]})}function pRe(){return i.jsx("div",{className:"divide-y divide-outline-variant border border-outline-variant bg-surface-lowest/55 backdrop-blur-sm",children:[{token:ko[4],title:"Approval needed",body:"Review proof screenshots and approve release-readiness.",actor:"human@host"},{token:ko[2],title:"Claimed by QA",body:"VM verification is in progress with current worktree source.",actor:"qa@my-rig"},{token:ko[1],title:"Route to guard",body:"Run narrow advisory on UI-only diff and source scans.",actor:"guard@my-rig"}].map(e=>i.jsxs("div",{className:"grid gap-3 p-3 sm:grid-cols-[auto_1fr_auto]",children:[i.jsx(si,{token:e.token,compact:!0}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"font-mono text-[12px] text-on-surface",children:e.title}),i.jsx("div",{className:"mt-1 font-mono text-[10px] leading-relaxed text-on-surface",children:e.body})]}),i.jsx(Dl,{kind:e.actor.includes("human")?"human":"agent",label:e.actor,muted:!0})]},e.title))})}function mRe(){return i.jsx("div",{className:"paper-grid min-h-full p-8",children:i.jsxs("div",{className:"mx-auto max-w-7xl space-y-8",children:[i.jsxs("header",{className:"border border-outline-variant bg-surface-lowest/60 p-4 font-mono backdrop-blur-sm hard-shadow",children:[i.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Project graphics package preview"}),i.jsx("h1",{className:"mt-2 text-xl uppercase tracking-[0.14em] text-on-surface",children:"Queue, story, and proof card language"}),i.jsx("p",{className:"mt-2 max-w-3xl text-[11px] leading-relaxed text-on-surface",children:"Hidden preview route for choosing metadata badges, action chips, flow arrows, and proof-card density before applying the system to For You, Story, Queue, and scope rollups."})]}),i.jsxs("section",{className:"grid gap-4 lg:grid-cols-3",children:[i.jsxs(rC,{label:"A / Compact Ledger",description:"Small pills and restrained icons. Best when density matters and queue cards need to scan like a work ledger.",children:[i.jsx(G8,{dense:!0}),i.jsx(pRe,{})]}),i.jsxs(rC,{label:"B / Narrative Rail",description:"Story-first layout with event icons on a vertical rail. Best for showing how work moved from idea to proof.",children:[i.jsx(fRe,{}),i.jsx(hRe,{})]}),i.jsxs(rC,{label:"C / Action Board",description:"Bolder cards with explicit status, actors, and proof thumbnails. Best for For You and approval surfaces.",children:[i.jsx(G8,{}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:ko.map(e=>i.jsx(si,{token:e},e.label))})]})]}),i.jsxs("section",{className:"grid gap-4 lg:grid-cols-[1.2fr_0.8fr]",children:[i.jsx(zx,{as:"section",className:"bg-surface-lowest/65 backdrop-blur-sm",header:"EVENT BADGE VOCABULARY",children:i.jsx("div",{className:"grid gap-3 p-4 sm:grid-cols-2 lg:grid-cols-3",children:ko.map(e=>i.jsxs("div",{className:"border border-outline-variant bg-surface-lowest/55 p-3",children:[i.jsx(si,{token:e}),i.jsxs("div",{className:"mt-2 font-mono text-[10px] leading-relaxed text-on-surface",children:[e.label==="Queue created"?"A work item entered the system.":null,e.label==="Handoff"?"Ownership moved from one actor to another.":null,e.label==="Claimed"?"An actor is actively working the item.":null,e.label==="Completed"?"The assigned work item closed.":null,e.label==="Human action"?"A person needs to approve, deny, or route.":null,e.label==="Shipped"?"The slice closed with evidence attached.":null]})]},e.label))})}),i.jsx(zx,{as:"section",className:"bg-surface-lowest/65 backdrop-blur-sm",header:"SUPPORTING CHIPS",children:i.jsxs("div",{className:"space-y-4 p-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"mb-2 font-mono text-[9px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Tags"}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:nG.map(e=>i.jsx(si,{token:e},e.label))})]}),i.jsxs("div",{children:[i.jsx("div",{className:"mb-2 font-mono text-[9px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Actors"}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.jsx(Dl,{kind:"human",label:"human@host"}),i.jsx(Dl,{kind:"agent",label:"driver@my-rig"}),i.jsx(Dl,{kind:"agent",label:"guard@my-rig",muted:!0})]})]}),i.jsxs("div",{children:[i.jsx("div",{className:"mb-2 font-mono text-[9px] uppercase tracking-[0.14em] text-on-surface-variant",children:"Scope"}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.jsx(si,{token:{label:"Workspace",tone:"neutral",icon:iF}}),i.jsx(si,{token:{label:"Mission",tone:"info",icon:IC}}),i.jsx(si,{token:{label:"Slice",tone:"success",icon:_v}})]})]})]})})]})]})})}const Ip={shipped:{stripe:"border-l-emerald-600",pill:"bg-emerald-50 border-emerald-300",ink:"text-emerald-800",label:"SHIPPED"},incident:{stripe:"border-l-red-600",pill:"bg-red-50 border-red-300",ink:"text-red-800",label:"INCIDENT"},progress:{stripe:"border-l-sky-600",pill:"bg-sky-50 border-sky-300",ink:"text-sky-800",label:"PROGRESS"},approval:{stripe:"border-l-amber-600",pill:"bg-amber-50 border-amber-300",ink:"text-amber-800",label:"APPROVAL NEEDED"},concept:{stripe:"border-l-violet-600",pill:"bg-violet-50 border-violet-300",ink:"text-violet-800",label:"CONCEPT"}},gRe={shipped:"bg-success",incident:"bg-tertiary",progress:"bg-secondary",approval:"bg-warning",concept:"bg-outline"},xRe={shipped:"Shipped",incident:"Incident",progress:"Progress",approval:"Approval",concept:"Concept"},vRe={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 Mp({testId:e,kind:t,title:n,oneLiner:s,expanded:r,drillInHref:a,drillInLabel:o,inlineActions:c,leadingAccessory:h}){const[d,m]=C.useState(!1);return i.jsxs("article",{"data-testid":e,"data-card-kind":t,"data-expanded":d,style:vRe,className:"relative bg-surface-low/45 backdrop-blur-[10px] overflow-hidden",children:[i.jsx(lr,{position:"tl"}),i.jsx(lr,{position:"tr"}),i.jsx(lr,{position:"bl"}),i.jsx(lr,{position:"br"}),i.jsxs("div",{role:"button",tabIndex:0,"data-testid":`${e}-toggle`,onClick:()=>m(f=>!f),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),m(g=>!g))},className:"flex w-full min-h-[80px] cursor-pointer items-start gap-4 px-5 py-4 text-left","aria-expanded":d,children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{"data-testid":`${e}-pill`,className:"flex items-center gap-2 font-mono text-[10px] uppercase tracking-[0.18em] text-on-surface",children:[i.jsx("span",{"aria-hidden":"true",className:`inline-block w-1.5 h-1.5 rounded-full ${gRe[t]}`}),i.jsx("span",{children:xRe[t]})]}),i.jsxs("h3",{"data-testid":`${e}-title`,className:"mt-2 flex items-center gap-2 font-headline text-[16px] font-bold leading-tight text-on-surface",children:[h,i.jsx("span",{className:"truncate",children:n})]}),i.jsx("p",{"data-testid":`${e}-one-liner`,className:"mt-1.5 font-body text-[12px] leading-relaxed text-on-surface line-clamp-2",children:s})]}),c&&i.jsx("div",{"data-testid":`${e}-inline-actions`,className:"flex shrink-0 items-center gap-2",onClick:f=>f.stopPropagation(),children:c})]}),d&&i.jsxs("div",{"data-testid":`${e}-expanded`,className:"border-t border-outline-variant/40 px-5 py-4",children:[r,a&&i.jsx("div",{className:"mt-3 flex justify-end",children:i.jsxs("a",{"data-testid":`${e}-drill-in`,href:a,className:"inline-flex items-center gap-1 min-h-[44px] border border-on-surface px-3 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hover:bg-inverse-surface hover:text-background transition-colors",onClick:f=>f.stopPropagation(),children:[o??"Open"," →"]})})]})]})}function yRe({source:e}){return i.jsx(Mp,{testId:`feed-card-shipped-${e.sliceId}`,kind:"shipped",title:e.title,oneLiner:e.oneLiner,accent:Ip.shipped,drillInHref:`/project/slice/${e.sliceId}`,expanded:e.sections&&e.sections.length>0?i.jsx("ol",{className:"space-y-2 text-[11px]",children:e.sections.slice(0,3).map(t=>i.jsxs("li",{"data-testid":`feed-card-shipped-${e.sliceId}-section-${t.number}`,className:"flex gap-2",children:[i.jsxs("span",{className:"font-mono text-[10px] font-bold text-on-surface-variant",children:[t.number,"."]}),i.jsxs("div",{children:[i.jsx("div",{className:"font-semibold text-on-surface",children:t.heading}),i.jsx("div",{className:"text-on-surface",children:t.summary})]})]},t.number))}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:e.oneLiner})})}const K8={success:"bg-emerald-500",warning:"bg-amber-500",danger:"bg-red-500",info:"bg-sky-500",muted:"bg-outline-variant"};function bRe({source:e}){return i.jsx(Mp,{testId:`feed-card-incident-${e.sliceId}`,kind:"incident",title:e.title,oneLiner:e.oneLiner,accent:Ip.incident,drillInHref:`/project/slice/${e.sliceId}`,drillInLabel:"Open timeline",leadingAccessory:i.jsx("span",{"data-testid":`feed-card-incident-${e.sliceId}-dot`,className:`inline-block h-3 w-3 rounded-full shrink-0 ${K8[e.status]}`,"aria-hidden":"true"}),expanded:e.recentEntries&&e.recentEntries.length>0?i.jsx("ul",{className:"space-y-2 text-[11px]",children:e.recentEntries.slice(0,3).map((t,n)=>i.jsxs("li",{"data-testid":`feed-card-incident-${e.sliceId}-entry-${n}`,className:"flex items-baseline gap-2",children:[i.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${K8[t.status]} shrink-0`,"aria-hidden":"true"}),i.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.10em] text-on-surface-variant shrink-0",children:t.time}),i.jsx("span",{className:"text-on-surface",children:t.title})]},n))}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:"No recent entries."})})}function _Re({source:e,onMarkComplete:t}){const n=Math.max(0,Math.min(100,Math.round(e.percent))),s=t?i.jsx("button",{type:"button","data-testid":"progress-card-mark-complete",onClick:r=>{r.stopPropagation(),t(e.missionId)},className:"min-h-[36px] border border-on-surface px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hover:bg-inverse-surface hover:text-background transition-colors focus:outline-none focus:ring-1 focus:ring-on-surface",children:"Mark complete"}):void 0;return i.jsx(Mp,{testId:`feed-card-progress-${e.missionId}`,kind:"progress",title:e.title,oneLiner:e.nextStep??e.oneLiner,accent:Ip.progress,drillInHref:`/project/mission/${e.missionId}`,drillInLabel:"Open mission",inlineActions:s,leadingAccessory:i.jsx("div",{"data-testid":`feed-card-progress-${e.missionId}-bar`,"data-percent":n,className:"h-1.5 w-16 shrink-0 border border-outline-variant bg-surface-low overflow-hidden","aria-label":`Progress ${n}%`,children:i.jsx("div",{"data-testid":`feed-card-progress-${e.missionId}-bar-fill`,className:"h-full bg-sky-500",style:{width:`${n}%`}})}),expanded:e.activeSlice?i.jsxs("div",{"data-testid":`feed-card-progress-${e.missionId}-active-slice`,className:"border border-outline-variant bg-background px-2 py-2",children:[i.jsx("div",{className:"font-mono text-[8px] uppercase tracking-[0.18em] text-on-surface-variant",children:"Active slice"}),i.jsx("div",{className:"mt-1 text-[12px] font-semibold text-on-surface",children:e.activeSlice.label}),i.jsxs("div",{className:"mt-0.5 font-mono text-[9px] text-on-surface-variant",children:["status: ",e.activeSlice.status]})]}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:"No active slice."})})}function wRe({source:e}){return i.jsx(Mp,{testId:`feed-card-approval-${e.qitemId}`,kind:"approval",title:e.title,oneLiner:e.oneLiner,accent:Ip.approval,drillInHref:e.drillInHref,drillInLabel:"Open detail",inlineActions:i.jsxs(i.Fragment,{children:[e.onApprove&&i.jsx("button",{type:"button","data-testid":`feed-card-approval-${e.qitemId}-approve`,onClick:e.onApprove,className:"min-h-[44px] border border-success px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-success hover:bg-success hover:text-white transition-colors",children:"Approve"}),e.onDeny&&i.jsx("button",{type:"button","data-testid":`feed-card-approval-${e.qitemId}-deny`,onClick:e.onDeny,className:"min-h-[44px] border border-on-surface px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-on-surface hover:bg-inverse-surface hover:text-background transition-colors",children:"Deny"})]}),expanded:e.bodyPreview?i.jsx("pre",{"data-testid":`feed-card-approval-${e.qitemId}-body`,className:"overflow-x-auto whitespace-pre-wrap break-words bg-background p-2 font-body text-[11px] leading-relaxed text-on-surface",children:e.bodyPreview}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:"No body preview."})})}function SRe({source:e}){return i.jsx(Mp,{testId:`feed-card-concept-${e.sliceId}`,kind:"concept",title:e.title,oneLiner:e.oneLiner,accent:Ip.concept,drillInHref:`/project/slice/${e.sliceId}`,drillInLabel:"Open concept",expanded:e.comparePreview&&e.comparePreview.length>0?i.jsxs("table",{className:"w-full border-collapse text-[11px]",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-background",children:[i.jsx("th",{className:"border border-outline-variant px-2 py-1 text-left font-mono text-[8px] uppercase tracking-[0.12em] text-on-surface-variant"}),i.jsx("th",{className:"border border-outline-variant px-2 py-1 text-left font-mono text-[8px] uppercase tracking-[0.12em] text-on-surface-variant",children:"Old"}),i.jsx("th",{className:"border border-outline-variant px-2 py-1 text-left font-mono text-[8px] uppercase tracking-[0.12em] text-on-surface-variant",children:"New"})]})}),i.jsx("tbody",{children:e.comparePreview.slice(0,3).map((t,n)=>i.jsxs("tr",{children:[i.jsx("td",{className:"border border-outline-variant px-2 py-1 font-mono text-[10px] font-semibold text-on-surface",children:t.label}),i.jsx("td",{className:"border border-outline-variant px-2 py-1 text-on-surface",children:t.valueOld}),i.jsx("td",{className:"border border-outline-variant px-2 py-1 text-on-surface",children:t.valueNew})]},n))})]}):i.jsx("div",{className:"text-[11px] text-on-surface-variant",children:e.oneLiner})})}function jRe(){return i.jsxs("div",{className:"mx-auto max-w-5xl space-y-10 px-6 py-10","data-testid":"card-previews-lab",children:[i.jsxs("header",{className:"space-y-2",children:[i.jsx("h1",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-on-surface-variant",children:"/lab/card-previews"}),i.jsx("p",{className:"font-mono text-[11px] text-on-surface",children:"Visual gallery of for-you card kind variants. Each section renders the same card component the live feed uses, with sample data."})]}),i.jsx(ou,{title:"Shipped",description:"A slice merged + summary view. Used when a slice closes successfully and the feed surfaces it to operators downstream."}),i.jsx(yRe,{source:{sliceId:"first-conveyor-run",title:"First Conveyor Run — shipped",oneLiner:"Slice merged at b71cddf. 4 commits + 1 proof packet.",sections:[{number:1,heading:"Lint parses + validates entries",summary:"12 tests pass; UTF-8 edge cases handled."},{number:2,heading:"Reviewer accepted with one concern",summary:"Combining-character edge addressed mid-flight."},{number:3,heading:"Proof packet captured",summary:"CLI output screenshot + diff render."}]}}),i.jsx(ou,{title:"Incident / Action Required",description:"A timeline-shaped surface for an in-flight or recent incident. Use status='warning' or 'danger' to surface attention; 'info' for informational; 'muted' for resolved."}),i.jsx(bRe,{source:{sliceId:"auth-bearer-tailscale-trust",title:"Auth bearer tailscale trust — concerning",oneLiner:"Reviewer flagged loopback-only default at fix-1; remediated at fix-2.",status:"warning",recentEntries:[{time:"13:42",title:"Reviewer BLOCKING-CONCERN raised",status:"danger"},{time:"14:01",title:"Driver forward-fix scoped",status:"info"},{time:"14:38",title:"Forward-fix landed; gates green",status:"success"}]}}),i.jsx(ou,{title:"Progress",description:"A mission-level progress card with percent + active-slice context. Used during a mission lifecycle to keep operators informed without requiring them to open the mission page."}),i.jsx(_Re,{source:{missionId:"release-0.3.1",title:"Release 0.3.1 — in flight",oneLiner:"Wave 3a + 3b dispatches; multiple slices in review.",percent:62,nextStep:"design-reviewer audit on slice 21 narrative voice",activeSlice:{id:"slice-21-onboarding-conveyor",label:"slice-21-onboarding-conveyor",status:"in-progress"}}}),i.jsx(ou,{title:"Approval / Action Required",description:"An operator-decision-needed surface. Renders the qitem context + the two action paths (Approve / Deny) the operator picks between."}),i.jsx(wRe,{source:{qitemId:"qitem-preview-approval-01",title:"Auth bearer tailscale trust — approve merge?",oneLiner:"All gates green; merge requires operator sign-off.",bodyPreview:"Triple-guard CLEAR. velocity-qa VM walk PASS. Ready for merge to main.",drillInHref:"/project/slice/auth-bearer-tailscale-trust",onApprove:()=>{},onDeny:()=>{}}}),i.jsx(ou,{title:"Concept / Observation",description:"A discovery / lab / scratch-pad surface. Used for not-yet-actionable observations, draft ideas, or comparison previews."}),i.jsx(SRe,{source:{sliceId:"concept-storytelling-primitives",title:"Storytelling primitives — concept",oneLiner:"Could replace one-off card components with kind-frame primitives.",comparePreview:[{label:"Card kinds",valueOld:"5 components",valueNew:"1 kind-frame + 5 sources"},{label:"Visual variance",valueOld:"drift over time",valueNew:"centralized accent tokens"},{label:"Maintenance",valueOld:"edit each component",valueNew:"edit kind-frame once"}]}}),i.jsx(ou,{title:"Empty state",description:"What the for-you feed shows when no events qualify. Reusable across surfaces; the EmptyState primitive is the canonical pattern."}),i.jsx(Ae,{label:"ALL CAUGHT UP",description:"No new events. Spin up a rig or declare a slice to populate this feed.",variant:"card",testId:"card-previews-empty-state"})]})}function ou({title:e,description:t}){return i.jsxs("div",{className:"space-y-1 pt-4",children:[i.jsx("h2",{className:"font-mono text-[10px] uppercase tracking-[0.16em] text-on-surface",children:e}),i.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant max-w-3xl",children:t})]})}function Uy({backLayerOverride:e,vellumSheetOverride:t}={}){return i.jsxs("div",{"data-testid":"vellum-lab",className:"relative min-h-screen overflow-hidden",children:[e,t,i.jsx(XSe,{}),i.jsx(ZSe,{}),i.jsx(uje,{})]})}function NRe(){return i.jsx(Uy,{backLayerOverride:i.jsx(IRe,{}),vellumSheetOverride:i.jsx(TRe,{})})}function kRe(){return i.jsx(Uy,{backLayerOverride:i.jsx(MRe,{}),vellumSheetOverride:i.jsx(ARe,{})})}function CRe(){return i.jsx(Uy,{backLayerOverride:i.jsx(RRe,{}),vellumSheetOverride:i.jsx(ERe,{})})}function ERe(){return i.jsx("div",{"data-testid":"vellum-sheet-heavy-diffuse","aria-hidden":"true",className:"absolute inset-0 z-[5] bg-surface-lowest/25 backdrop-blur-[8px] pointer-events-none"})}function RRe(){const r=Math.ceil(27.5)+2,a=(c,h,d=0)=>c/1280*Math.PI*2*h+d,o=[];for(let c=0;c<r;c++){const h=c*40-40;let d=`M 0 ${h.toFixed(2)}`;for(let m=0;m<=2560;m+=32){const f=Math.sin(a(m,2,c*.3))*36,g=Math.sin(a(m,5,c*.5))*9,x=Math.sin(a(m,3,c*.18))*14,y=f+g+x;d+=` L ${m} ${(h+y).toFixed(2)}`}o.push(d)}return i.jsx("div",{"data-testid":"back-layer-scrolling-topo","aria-hidden":"true",className:"absolute inset-0 z-0 overflow-hidden pointer-events-none select-none",children:i.jsx("svg",{className:"absolute top-0 left-0 h-full vellum-scroll-x",style:{width:"200%"},viewBox:"0 0 2560 1100",preserveAspectRatio:"xMidYMid slice",children:o.map((c,h)=>i.jsx("path",{d:c,stroke:"#1c1917",strokeWidth:"1.0",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},h))})})}function TRe(){return i.jsx("div",{"data-testid":"vellum-sheet-diffuse","aria-hidden":"true",className:"absolute top-[14px] bottom-[12px] left-[16px] right-[14px] z-[5] bg-surface-lowest/35 backdrop-blur-[14px] pointer-events-none"})}function ARe(){return i.jsx("div",{"data-testid":"vellum-sheet-more-diffuse","aria-hidden":"true",className:"absolute top-[14px] bottom-[12px] left-[16px] right-[14px] z-[5] bg-surface-lowest/45 backdrop-blur-[22px] pointer-events-none"})}function IRe(){const s=Math.ceil(27.5)+2,r=[];for(let a=0;a<s;a++){const o=a*40-40;let c=`M -50 ${o.toFixed(2)}`;for(let h=0;h<=1380;h+=40){const d=h/1280,m=Math.sin(d*Math.PI*2.2+a*.28)*36,f=Math.sin(d*Math.PI*5.8+a*.47)*9,g=Math.sin(d*Math.PI*3.6+a*.13+Math.sin(a*.5)*2)*16,x=m+f+g;c+=` L ${h.toFixed(0)} ${(o+x).toFixed(2)}`}r.push(c)}return i.jsx("div",{"data-testid":"back-layer-topo","aria-hidden":"true",className:"absolute inset-0 z-0 overflow-hidden pointer-events-none select-none",children:i.jsx("svg",{className:"w-full h-full",viewBox:"0 0 1280 1100",preserveAspectRatio:"xMidYMid slice",children:r.map((a,o)=>i.jsx("path",{d:a,stroke:"#1c1917",strokeWidth:"1.2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},o))})})}function MRe(){const e=[{type:"cube",size:220,pos:"top-[2%] -left-6"},{type:"spool",size:200,pos:"top-[4%] left-[24%]"},{type:"x-prism",size:220,pos:"top-[2%] left-[50%]"},{type:"cube-frame",size:240,pos:"top-[1%] -right-8"},{type:"arc-stripes",size:200,pos:"top-[28%] left-[4%]"},{type:"donut-dots",size:220,pos:"top-[26%] left-[28%]"},{type:"hex-prism",size:220,pos:"top-[26%] left-[54%]"},{type:"cylinder-stripes",size:200,pos:"top-[28%] right-[4%]"},{type:"wedge",size:230,pos:"top-[52%] -left-4"},{type:"stairs-iso",size:240,pos:"top-[50%] left-[24%]"},{type:"barrel",size:220,pos:"top-[52%] left-[50%]"},{type:"pacman",size:240,pos:"top-[50%] -right-6"},{type:"cube-stack",size:260,pos:"bottom-[-4%] left-[5%]"},{type:"L-prism",size:260,pos:"bottom-[-2%] left-[36%]"},{type:"cube-ports",size:260,pos:"bottom-[-4%] right-[4%]"}];return i.jsx("div",{"data-testid":"back-layer-isometric","aria-hidden":"true",className:"absolute inset-0 z-0 overflow-hidden pointer-events-none select-none",children:e.map((t,n)=>i.jsx(LRe,{...t},n))})}function LRe({type:e,size:t,pos:n}){return i.jsx("div",{className:`absolute ${n}`,style:{width:t,height:t},children:i.jsx(ORe,{type:e})})}function ORe({type:e}){const t={fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round",strokeLinecap:"round"};switch(e){case"cube":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,8 52,20 52,44 30,56 8,44 8,20"}),i.jsx("line",{x1:"30",y1:"8",x2:"30",y2:"32"}),i.jsx("line",{x1:"30",y1:"32",x2:"8",y2:"20"}),i.jsx("line",{x1:"30",y1:"32",x2:"52",y2:"20"})]});case"cylinder-v":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"30",cy:"14",rx:"14",ry:"5"}),i.jsx("line",{x1:"16",y1:"14",x2:"16",y2:"46"}),i.jsx("line",{x1:"44",y1:"14",x2:"44",y2:"46"}),i.jsx("path",{d:"M 16 46 A 14 5 0 0 0 44 46"})]});case"triangle-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"14,46 30,12 46,46"}),i.jsx("polygon",{points:"46,46 30,12 38,8 54,42"}),i.jsx("line",{x1:"14",y1:"46",x2:"54",y2:"42"})]});case"rod":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("line",{x1:"12",y1:"48",x2:"48",y2:"12",strokeWidth:"1.5"}),i.jsx("circle",{cx:"12",cy:"48",r:"4"}),i.jsx("circle",{cx:"48",cy:"12",r:"4"})]});case"cube-frame":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,8 52,20 52,44 30,56 8,44 8,20"}),i.jsx("line",{x1:"30",y1:"8",x2:"30",y2:"32"}),i.jsx("line",{x1:"30",y1:"32",x2:"8",y2:"20"}),i.jsx("line",{x1:"30",y1:"32",x2:"52",y2:"20"}),i.jsx("rect",{x:"22",y:"28",width:"16",height:"16"})]});case"stairs":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("polyline",{points:"8,52 18,52 18,42 28,42 28,32 38,32 38,22 48,22 48,12 56,12"})});case"spool":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"36",cy:"30",rx:"14",ry:"6"}),i.jsx("path",{d:"M 22 30 L 8 30",strokeWidth:"1.5"}),i.jsx("line",{x1:"36",y1:"14",x2:"36",y2:"22"})]});case"arc-c":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("path",{d:"M 44 12 A 20 20 0 1 0 44 48",strokeWidth:"1.5"})});case"diamond-row":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"8,30 14,24 20,30 14,36"}),i.jsx("polygon",{points:"20,30 26,24 32,30 26,36"}),i.jsx("polygon",{points:"32,30 38,24 44,30 38,36"}),i.jsx("polygon",{points:"44,30 50,24 56,30 50,36"})]});case"plus":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("polygon",{points:"24,8 36,8 36,24 52,24 52,36 36,36 36,52 24,52 24,36 8,36 8,24 24,24"})});case"cylinder-h":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"14",cy:"30",rx:"5",ry:"14"}),i.jsx("line",{x1:"14",y1:"16",x2:"46",y2:"16"}),i.jsx("line",{x1:"14",y1:"44",x2:"46",y2:"44"}),i.jsx("path",{d:"M 46 16 A 5 14 0 0 1 46 44"})]});case"wave":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 8 16 Q 18 8 28 16 T 48 16",strokeWidth:"1.2"}),i.jsx("path",{d:"M 8 30 Q 18 22 28 30 T 48 30",strokeWidth:"1.2"}),i.jsx("path",{d:"M 8 44 Q 18 36 28 44 T 48 44",strokeWidth:"1.2"})]});case"x-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"14,8 24,8 30,18 36,8 46,8 36,22 46,36 36,36 30,26 24,36 14,36 24,22"}),i.jsx("line",{x1:"14",y1:"36",x2:"20",y2:"40"}),i.jsx("line",{x1:"46",y1:"36",x2:"52",y2:"40"})]});case"tri-stack":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"12,40 18,28 24,40"}),i.jsx("polygon",{points:"24,40 30,28 36,40"}),i.jsx("polygon",{points:"36,40 42,28 48,40"})]});case"L-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"8,28 28,18 48,28 28,38"}),i.jsx("polygon",{points:"28,38 48,28 48,44 28,54"}),i.jsx("polygon",{points:"8,28 8,44 28,54 28,38"})]});case"arc-stripes":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 12 50 A 22 22 0 0 1 48 14",strokeWidth:"1"}),i.jsx("path",{d:"M 16 50 A 18 18 0 0 1 48 18",strokeWidth:"1"}),i.jsx("path",{d:"M 20 50 A 14 14 0 0 1 48 22",strokeWidth:"1"}),i.jsx("path",{d:"M 24 50 A 10 10 0 0 1 48 26",strokeWidth:"1"})]});case"hex-prism":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,8 48,18 48,38 30,48 12,38 12,18"}),i.jsx("line",{x1:"30",y1:"8",x2:"30",y2:"48"}),i.jsx("line",{x1:"12",y1:"18",x2:"30",y2:"28"}),i.jsx("line",{x1:"48",y1:"18",x2:"30",y2:"28"})]});case"dot-circle":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:Array.from({length:16}).map((n,s)=>{const r=s/16*Math.PI*2,a=30+Math.cos(r)*22,o=30+Math.sin(r)*22;return i.jsx("circle",{cx:a,cy:o,r:"1.8"},s)})});case"wedge":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 30 30 L 30 8 A 22 22 0 0 1 52 30 Z",fill:"currentColor"}),i.jsx("path",{d:"M 30 30 L 8 30 A 22 22 0 0 1 30 8"}),i.jsx("line",{x1:"30",y1:"30",x2:"14",y2:"44"}),i.jsx("line",{x1:"30",y1:"30",x2:"22",y2:"50"}),i.jsx("line",{x1:"30",y1:"30",x2:"34",y2:"52"})]});case"down-arrows":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"20,8 40,8 30,22"}),i.jsx("polygon",{points:"20,22 40,22 30,36"}),i.jsx("polygon",{points:"20,36 40,36 30,50"})]});case"donut-dots":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("circle",{cx:"30",cy:"30",r:"22"}),i.jsx("circle",{cx:"30",cy:"30",r:"10"}),i.jsx("g",{fill:"currentColor",children:Array.from({length:24}).map((n,s)=>{const r=s/24*Math.PI*2+.08,a=16;return i.jsx("circle",{cx:30+Math.cos(r)*a,cy:30+Math.sin(r)*a,r:"0.9"},s)})})]});case"bowtie":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"8,18 22,30 8,42"}),i.jsx("polygon",{points:"52,18 38,30 52,42"}),i.jsx("circle",{cx:"30",cy:"30",r:"3"})]});case"dot-grid":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:Array.from({length:6}).map((n,s)=>Array.from({length:6}).map((r,a)=>i.jsx("circle",{cx:10+a*8,cy:10+s*8,r:"1.4"},`${s}-${a}`)))});case"arc-half":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("path",{d:"M 8 38 A 22 22 0 0 1 52 38",strokeWidth:"1.5"})});case"cylinder-stripes":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"30",cy:"14",rx:"14",ry:"5"}),i.jsx("line",{x1:"16",y1:"14",x2:"16",y2:"46"}),i.jsx("line",{x1:"44",y1:"14",x2:"44",y2:"46"}),i.jsx("path",{d:"M 16 46 A 14 5 0 0 0 44 46"}),i.jsx("line",{x1:"22",y1:"18",x2:"22",y2:"44",strokeDasharray:"2 2"}),i.jsx("line",{x1:"30",y1:"19",x2:"30",y2:"45",strokeDasharray:"2 2"}),i.jsx("line",{x1:"38",y1:"18",x2:"38",y2:"44",strokeDasharray:"2 2"})]});case"dot-cloud":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:[[22,18],[30,14],[38,18],[16,24],[24,24],[32,22],[40,24],[46,28],[18,32],[26,32],[34,32],[42,32],[22,38],[30,38],[38,38],[28,44],[36,44]].map(([n,s],r)=>i.jsx("circle",{cx:n,cy:s,r:"1.5"},r))});case"pacman":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 30 30 L 52 18 A 22 22 0 1 1 52 42 Z",fill:"currentColor"}),i.jsx("line",{x1:"20",y1:"20",x2:"14",y2:"14"}),i.jsx("line",{x1:"20",y1:"40",x2:"14",y2:"46"}),i.jsx("line",{x1:"12",y1:"30",x2:"6",y2:"30"})]});case"down-triangles":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"22,12 38,12 30,24"}),i.jsx("polygon",{points:"22,28 38,28 30,40"})]});case"cube-inset":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,4 50,16 50,36 30,48 10,36 10,16"}),i.jsx("line",{x1:"30",y1:"4",x2:"30",y2:"48"}),i.jsx("line",{x1:"10",y1:"16",x2:"30",y2:"28"}),i.jsx("line",{x1:"50",y1:"16",x2:"30",y2:"28"}),i.jsx("rect",{x:"22",y:"46",width:"16",height:"10"})]});case"hex-small":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:i.jsx("polygon",{points:"30,18 42,24 42,38 30,44 18,38 18,24"})});case"cylinder-disc":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"34",cy:"30",rx:"14",ry:"5"}),i.jsx("path",{d:"M 20 30 A 14 5 0 0 1 48 30"}),i.jsx("line",{x1:"20",y1:"30",x2:"20",y2:"36",strokeWidth:"1.5"}),i.jsx("ellipse",{cx:"20",cy:"36",rx:"3",ry:"1.4"}),i.jsx("path",{d:"M 20 30 L 14 32"})]});case"triangle-solid":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",fill:"currentColor",children:i.jsx("polygon",{points:"30,16 46,44 14,44"})});case"stairs-iso":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"8,40 16,36 24,40 16,44"}),i.jsx("polygon",{points:"16,36 24,32 32,36 24,40"}),i.jsx("polygon",{points:"24,32 32,28 40,32 32,36"}),i.jsx("polygon",{points:"32,28 40,24 48,28 40,32"}),i.jsx("polygon",{points:"40,24 48,20 56,24 48,28"})]});case"coin":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"30",cy:"26",rx:"14",ry:"6"}),i.jsx("path",{d:"M 16 26 L 16 34 A 14 6 0 0 0 44 34 L 44 26"}),i.jsx("line",{x1:"22",y1:"26",x2:"22",y2:"34"}),i.jsx("line",{x1:"30",y1:"32",x2:"30",y2:"38"}),i.jsx("line",{x1:"38",y1:"26",x2:"38",y2:"34"})]});case"cube-ports":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"30,6 52,18 52,42 30,54 8,42 8,18"}),i.jsx("line",{x1:"30",y1:"6",x2:"30",y2:"30"}),i.jsx("line",{x1:"30",y1:"30",x2:"8",y2:"18"}),i.jsx("line",{x1:"30",y1:"30",x2:"52",y2:"18"}),i.jsx("circle",{cx:"20",cy:"20",r:"2.5",fill:"currentColor"}),i.jsx("circle",{cx:"40",cy:"20",r:"2.5",fill:"currentColor"}),i.jsx("circle",{cx:"30",cy:"42",r:"2.5",fill:"currentColor"})]});case"arc-bridge":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 8 44 Q 30 8 52 44",strokeWidth:"1.5"}),i.jsx("circle",{cx:"30",cy:"44",r:"3",fill:"currentColor"})]});case"zigzag-v":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polyline",{points:"24,8 36,16 24,24 36,32 24,40 36,48",strokeWidth:"1.5"}),i.jsx("polyline",{points:"20,12 32,20 20,28 32,36 20,44 32,52",strokeWidth:"1.5"})]});case"x-flat":return i.jsx("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:i.jsx("polygon",{points:"14,14 22,14 30,22 38,14 46,14 36,28 46,46 38,46 30,34 22,46 14,46 24,28"})});case"cube-stack":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("polygon",{points:"14,30 22,26 30,30 22,34"}),i.jsx("polygon",{points:"22,34 30,30 30,38 22,42"}),i.jsx("polygon",{points:"14,30 14,38 22,42 22,34"}),i.jsx("polygon",{points:"30,22 38,18 46,22 38,26"}),i.jsx("polygon",{points:"38,26 46,22 46,30 38,34"}),i.jsx("polygon",{points:"30,22 30,30 38,34 38,26"})]});case"back-arrows":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,fill:"currentColor",children:[i.jsx("polygon",{points:"42,16 42,44 24,30"}),i.jsx("polygon",{points:"28,16 28,44 10,30"})]});case"barrel":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("ellipse",{cx:"44",cy:"30",rx:"6",ry:"14"}),i.jsx("line",{x1:"44",y1:"16",x2:"14",y2:"20"}),i.jsx("line",{x1:"44",y1:"44",x2:"14",y2:"40"}),i.jsx("ellipse",{cx:"14",cy:"30",rx:"4",ry:"10"}),i.jsx("line",{x1:"20",y1:"20",x2:"20",y2:"40",strokeDasharray:"2 2"}),i.jsx("line",{x1:"28",y1:"19",x2:"28",y2:"41",strokeDasharray:"2 2"}),i.jsx("line",{x1:"36",y1:"18",x2:"36",y2:"42",strokeDasharray:"2 2"})]});case"wave-s":return i.jsxs("svg",{className:"w-full h-full text-on-surface",viewBox:"0 0 60 60",...t,children:[i.jsx("path",{d:"M 22 8 Q 32 18 22 28 T 22 48",strokeWidth:"1.5"}),i.jsx("path",{d:"M 38 8 Q 28 18 38 28 T 38 48",strokeWidth:"1.5"})]})}}const Pe=uX({component:()=>i.jsx(QX,{client:oZ,children:i.jsx(aZ,{children:i.jsx(Gie,{children:i.jsx(Mq,{})})})})}),PRe=Oe({getParentRoute:()=>Pe,path:"/",component:vSe}),DRe=Oe({getParentRoute:()=>Pe,path:"/topology",component:KCe}),$Re=Oe({getParentRoute:()=>Pe,path:"/topology/rig/$rigId",component:YCe}),BRe=Oe({getParentRoute:()=>Pe,path:"/topology/pod/$rigId/$podName",component:XCe}),qRe=Oe({getParentRoute:()=>Pe,path:"/topology/seat/$rigId/$logicalId",component:ZCe}),FRe=Oe({getParentRoute:()=>Pe,path:"/for-you",component:Xje}),zRe=Oe({getParentRoute:()=>Pe,path:"/project",component:IEe}),HRe=Oe({getParentRoute:()=>Pe,path:"/project/mission/$missionId",component:MEe}),URe=Oe({getParentRoute:()=>Pe,path:"/project/slice/$sliceId",component:PEe}),VRe=Oe({getParentRoute:()=>Pe,path:"/agents",component:WEe}),WRe=Oe({getParentRoute:()=>Pe,path:"/fleet",component:ZEe}),GRe=Oe({getParentRoute:()=>Pe,path:"/workflows",component:eRe}),KRe=Oe({getParentRoute:()=>Pe,path:"/workflow/instance/$instanceId",validateSearch:e=>({step:typeof e.step=="string"?e.step:void 0}),component:()=>{const{instanceId:e}=An({from:"/workflow/instance/$instanceId"}),{step:t}=vv({from:"/workflow/instance/$instanceId"});return i.jsx(cRe,{instanceId:e,anchorStepId:t??null})}}),YRe=Oe({getParentRoute:()=>Pe,path:"/specs",component:rW}),QRe=Oe({getParentRoute:()=>Pe,path:"/specs/applications",component:rW}),XRe=Oe({getParentRoute:()=>Pe,path:"/specs/skills",component:mNe}),ZRe=Oe({getParentRoute:()=>Pe,path:"/specs/skills/$skillToken",component:()=>{const{skillToken:e}=An({from:"/specs/skills/$skillToken"});return i.jsx(iW,{skillToken:e})}}),JRe=Oe({getParentRoute:()=>Pe,path:"/specs/skills/$skillToken/file/$fileToken",component:()=>{const{skillToken:e,fileToken:t}=An({from:"/specs/skills/$skillToken/file/$fileToken"});return i.jsx(iW,{skillToken:e,fileToken:t})}}),eTe=Oe({getParentRoute:()=>Pe,path:"/specs/plugins",component:gNe}),tTe=Oe({getParentRoute:()=>Pe,path:"/files",component:FNe}),nTe=Oe({getParentRoute:()=>Pe,path:"/plugins/$pluginId",component:()=>{const{pluginId:e}=An({from:"/plugins/$pluginId"});return i.jsx(kNe,{pluginId:e})}}),sTe=Oe({getParentRoute:()=>Pe,path:"/specs/$specKind/$specName",component:()=>{const{specName:e}=An({from:"/specs/$specKind/$specName"});return i.jsx(Ql,{to:"/specs/library/$entryId",params:{entryId:e}})}}),rTe=Oe({getParentRoute:()=>Pe,path:"/settings",component:ZNe}),iTe=Oe({getParentRoute:()=>Pe,path:"/settings/policies",component:ske}),aTe=Oe({getParentRoute:()=>Pe,path:"/settings/log",component:oke}),oTe=Oe({getParentRoute:()=>Pe,path:"/settings/status",component:dke}),lTe=Oe({getParentRoute:()=>Pe,path:"/search",component:G1e}),cTe=Oe({getParentRoute:()=>Pe,path:"/lab/project-graphics-preview",component:mRe}),uTe=Oe({getParentRoute:()=>Pe,path:"/lab/card-previews",component:jRe}),dTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-lab",component:Uy}),hTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-bg/a-large",component:NRe}),fTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-bg/b-small",component:kRe}),pTe=Oe({getParentRoute:()=>Pe,path:"/lab/vellum-bg/c-allover",component:CRe});function mTe(){var s;const{rigId:e}=An({from:"/rigs/$rigId"}),{data:t}=Dr(),n=(s=t==null?void 0:t.find(r=>r.id===e))==null?void 0:s.name;return i.jsx("div",{className:"flex flex-col flex-1 h-full",children:i.jsx("div",{className:"flex-1 min-h-[400px] relative",children:i.jsx(bT,{rigId:e,rigName:n??null,showDiscovered:!1})})})}const gTe=Oe({getParentRoute:()=>Pe,path:"/rigs/$rigId",component:mTe}),xTe=Oe({getParentRoute:()=>Pe,path:"/rigs/$rigId/nodes/$logicalId",component:()=>{const{rigId:e,logicalId:t}=An({from:"/rigs/$rigId/nodes/$logicalId"});return i.jsx(VV,{rigId:e,logicalId:decodeURIComponent(t)})}}),vTe=Oe({getParentRoute:()=>Pe,path:"/import",component:Kbe}),yTe=Oe({getParentRoute:()=>Pe,path:"/packages",component:e0e}),bTe=Oe({getParentRoute:()=>Pe,path:"/packages/install",component:a0e}),_Te=Oe({getParentRoute:()=>Pe,path:"/packages/$packageId",component:iwe}),wTe=Oe({getParentRoute:()=>Pe,path:"/bootstrap",component:pwe}),STe=Oe({getParentRoute:()=>Pe,path:"/agents/validate",component:mwe}),jTe=Oe({getParentRoute:()=>Pe,path:"/specs/rig",component:Ewe}),NTe=Oe({getParentRoute:()=>Pe,path:"/specs/agent",component:Twe}),kTe=Oe({getParentRoute:()=>Pe,path:"/specs/library/$entryId",component:()=>{const{entryId:e}=An({from:"/specs/library/$entryId"});return i.jsx(e1e,{entryId:e})}}),CTe=Oe({getParentRoute:()=>Pe,path:"/discovery",component:()=>i.jsx("div",{className:"flex h-full w-full items-center justify-center p-8",children:i.jsx(Ae,{label:"DISCOVERY",description:"Discovery surface preserved; redesign deferred per code-map.",variant:"card",testId:"discovery-placeholder"})})}),ETe=Oe({getParentRoute:()=>Pe,path:"/discovery/inventory",component:H1e}),RTe=Oe({getParentRoute:()=>Pe,path:"/bundles/inspect",component:Mwe}),TTe=Oe({getParentRoute:()=>Pe,path:"/bundles/install",component:Lwe}),ATe=Oe({getParentRoute:()=>Pe,path:"/context",component:()=>i.jsx(Ql,{to:"/topology"})}),ITe=Oe({getParentRoute:()=>Pe,path:"/mission-control",component:()=>i.jsx(Ql,{to:"/for-you"})}),MTe=Oe({getParentRoute:()=>Pe,path:"/slices",component:()=>i.jsx(Ql,{to:"/project"})}),LTe=Oe({getParentRoute:()=>Pe,path:"/slices/$name",component:()=>{const{name:e}=An({from:"/slices/$name"});return i.jsx(Ql,{to:"/project/slice/$sliceId",params:{sliceId:e}})}}),OTe=Oe({getParentRoute:()=>Pe,path:"/progress",component:()=>i.jsx(Ql,{to:"/project"})}),PTe=Oe({getParentRoute:()=>Pe,path:"/steering",component:()=>i.jsx(Ql,{to:"/project"})}),DTe=Pe.addChildren([PRe,DRe,$Re,BRe,qRe,FRe,zRe,HRe,URe,VRe,WRe,GRe,KRe,YRe,QRe,XRe,eTe,ZRe,JRe,nTe,tTe,sTe,rTe,iTe,aTe,oTe,lTe,cTe,uTe,dTe,hTe,fTe,pTe,gTe,xTe,vTe,yTe,bTe,_Te,wTe,STe,jTe,NTe,kTe,CTe,ETe,RTe,TTe,ATe,ITe,MTe,LTe,OTe,PTe]),$Te=bX({routeTree:DTe}),rG="openrig.uiMaintenanceNoticeDismissed",BTe="The OpenRig UI is experimental and in maintenance mode. It is not under active development; support is best-effort. The CLI is the primary supported interface. Contributions welcome.";function qTe(){try{return localStorage.getItem(rG)==="1"}catch{return!1}}function FTe(){const[e,t]=C.useState(qTe);if(e)return null;const n=()=>{try{localStorage.setItem(rG,"1")}catch{}t(!0)};return i.jsxs("div",{className:"fixed inset-x-0 top-0 z-[100] flex items-start justify-between gap-3 border-b border-amber-500/40 bg-amber-50 px-4 py-2 text-sm text-amber-950 shadow-sm dark:bg-amber-950 dark:text-amber-50","data-testid":"ui-maintenance-notice",role:"status",children:[i.jsx("span",{children:BTe}),i.jsx("button",{"aria-label":"Dismiss maintenance notice",className:"shrink-0 rounded px-1.5 font-semibold hover:bg-amber-200/60 dark:hover:bg-amber-900",onClick:n,type:"button",children:"×"})]})}function zTe(){return i.jsxs(i.Fragment,{children:[i.jsx(FTe,{}),i.jsx(SX,{router:$Te})]})}const Y8=document.getElementById("root");Y8&&_Y.createRoot(Y8).render(i.jsx(C.StrictMode,{children:i.jsx(qie,{children:i.jsx(zTe,{})})}));