@ouro.bot/cli 0.1.0-alpha.116 → 0.1.0-alpha.1161

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 (994) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +196 -30
  3. package/RepairGuide.ouro/agent.json +5 -0
  4. package/RepairGuide.ouro/psyche/IDENTITY.md +19 -0
  5. package/RepairGuide.ouro/psyche/SOUL.md +55 -0
  6. package/RepairGuide.ouro/skills/diagnose-broken-remote.md +63 -0
  7. package/RepairGuide.ouro/skills/diagnose-stacked-typed-issues.md +35 -0
  8. package/RepairGuide.ouro/skills/diagnose-sync-blocked.md +54 -0
  9. package/RepairGuide.ouro/skills/diagnose-vault-expired.md +60 -0
  10. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +4 -2
  11. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +2 -2
  12. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
  13. package/assets/bluebubbles-host +264 -0
  14. package/assets/sanctuary-host-launcher.sh +16 -0
  15. package/changelog.json +6967 -16
  16. package/deploy/unraid/Dockerfile +85 -0
  17. package/deploy/unraid/INSTALL.md +64 -0
  18. package/deploy/unraid/README.txt +3032 -0
  19. package/deploy/unraid/audit-container-spec.sh +4 -0
  20. package/deploy/unraid/container-runtime.json +1 -0
  21. package/deploy/unraid/credit-gateway.md +95 -0
  22. package/deploy/unraid/docker-man-template-transaction.mjs +727 -0
  23. package/deploy/unraid/docker-man-template-xml.cjs +105 -0
  24. package/deploy/unraid/github_known_hosts +3 -0
  25. package/deploy/unraid/install.sh +274 -0
  26. package/deploy/unraid/migrate-sanctuary-bundle.mjs +63 -0
  27. package/deploy/unraid/ouro-events/bootstrap-spool.sh +92 -0
  28. package/deploy/unraid/ouro-events/emit-event.mjs +310 -0
  29. package/deploy/unraid/ouro-events/emit-usenet-event.sh +54 -0
  30. package/deploy/unraid/ouro-events/install-usenet-guard.sh +435 -0
  31. package/deploy/unraid/ouro-events/usenet-health.sh +176 -0
  32. package/deploy/unraid/ouro-sync-ssh +98 -0
  33. package/deploy/unraid/ouro-sync.sudoers +3 -0
  34. package/deploy/unraid/sanctuary-acceptance-adapter.sh +43 -0
  35. package/deploy/unraid/sanctuary-acceptance-contract.json +198 -0
  36. package/deploy/unraid/sanctuary-acceptance-harness.sh +23 -0
  37. package/deploy/unraid/sanctuary-authority-installation.json +36 -0
  38. package/deploy/unraid/sanctuary-authority-service.sh +30 -0
  39. package/deploy/unraid/sanctuary-butler-upgrade.mjs +1523 -0
  40. package/deploy/unraid/sanctuary-deployment-target.mjs +710 -0
  41. package/deploy/unraid/sanctuary-replay-gate.mjs +2562 -0
  42. package/deploy/unraid/sanctuary-safe-rename.py +24 -0
  43. package/deploy/unraid/sanctuary-sync-cutover.sh +1039 -0
  44. package/deploy/unraid/sanctuary-unit16-host-broker.mjs +2088 -0
  45. package/deploy/unraid/sanctuary-unit16-run.sh +570 -0
  46. package/deploy/unraid/sanctuary-unit18-target-audit.sh +27 -0
  47. package/deploy/unraid/sanctuary.ouro/agent.json +73 -0
  48. package/deploy/unraid/sanctuary.ouro/arc/README.md +3 -0
  49. package/deploy/unraid/sanctuary.ouro/awaiting/house-care-sweep.md +17 -0
  50. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +5 -0
  51. package/deploy/unraid/sanctuary.ouro/habits/sanctuary-health.md +8 -0
  52. package/deploy/unraid/sanctuary.ouro/mcp/media-mcp.mjs +2452 -0
  53. package/deploy/unraid/sanctuary.ouro/product/PRODUCT.md +13 -0
  54. package/deploy/unraid/sanctuary.ouro/provider-readiness.json +11 -0
  55. package/deploy/unraid/sanctuary.ouro/psyche/ASPIRATIONS.md +5 -0
  56. package/deploy/unraid/sanctuary.ouro/psyche/IDENTITY.md +7 -0
  57. package/deploy/unraid/sanctuary.ouro/psyche/LORE.md +7 -0
  58. package/deploy/unraid/sanctuary.ouro/psyche/SOUL.md +15 -0
  59. package/deploy/unraid/sanctuary.ouro/psyche/TACIT.md +3 -0
  60. package/deploy/unraid/sanctuary.ouro/state/policy/steward.json +7 -0
  61. package/deploy/unraid/sanctuary.ouro/tool-profiles.json +253 -0
  62. package/deploy/unraid/sanctuary.xml +30 -0
  63. package/dist/a2a/card.js +57 -0
  64. package/dist/a2a/client.js +290 -0
  65. package/dist/a2a/config.js +50 -0
  66. package/dist/a2a/delegated-command-grants.js +93 -0
  67. package/dist/a2a/delegated-command.js +197 -0
  68. package/dist/a2a/delegation-stores.js +56 -0
  69. package/dist/a2a/did-resolution.js +205 -0
  70. package/dist/a2a/escalation-grants.js +84 -0
  71. package/dist/a2a/escalation-wiring.js +60 -0
  72. package/dist/a2a/identity.js +258 -0
  73. package/dist/a2a/inbound-share.js +131 -0
  74. package/dist/a2a/mission-result-wire.js +265 -0
  75. package/dist/a2a/onboarding.js +133 -0
  76. package/dist/a2a/operator-trust.js +399 -0
  77. package/dist/a2a/outbox-client.js +59 -0
  78. package/dist/a2a/outbox-store.js +245 -0
  79. package/dist/a2a/outbox-wire.js +106 -0
  80. package/dist/a2a/pin-store.js +167 -0
  81. package/dist/a2a/refusals.js +53 -0
  82. package/dist/a2a/relay-client.js +106 -0
  83. package/dist/a2a/relay-config-vault.js +64 -0
  84. package/dist/a2a/relay-contacts.js +120 -0
  85. package/dist/a2a/relay-inbox.js +360 -0
  86. package/dist/a2a/relay-retirements.js +89 -0
  87. package/dist/a2a/replay-grant-holders.js +33 -0
  88. package/dist/a2a/replay-harness.js +188 -0
  89. package/dist/a2a/resolution-proof.js +53 -0
  90. package/dist/a2a/sealed-chat.js +114 -0
  91. package/dist/a2a/seen-ledger.js +214 -0
  92. package/dist/a2a/server.js +804 -0
  93. package/dist/a2a/task-store.js +69 -0
  94. package/dist/a2a/transport.js +100 -0
  95. package/dist/a2a/trust-commands.js +203 -0
  96. package/dist/a2a/trusted-files.js +185 -0
  97. package/dist/a2a/types.js +3 -0
  98. package/dist/arc/attention-types.js +8 -0
  99. package/dist/arc/cares.js +360 -0
  100. package/dist/arc/episodes.js +118 -0
  101. package/dist/arc/evolution.js +490 -0
  102. package/dist/arc/flight-recorder.js +1030 -0
  103. package/dist/arc/intentions.js +134 -0
  104. package/dist/arc/json-store.js +117 -0
  105. package/dist/arc/obligations.js +386 -0
  106. package/dist/arc/packets.js +336 -0
  107. package/dist/arc/presence.js +185 -0
  108. package/dist/arc/task-lifecycle.js +57 -0
  109. package/dist/commerce/store.js +755 -0
  110. package/dist/commerce/types.js +3 -0
  111. package/dist/gateway/keys.js +117 -0
  112. package/dist/gateway/server.js +429 -0
  113. package/dist/heart/active-work.js +431 -44
  114. package/dist/heart/agent-entry.js +253 -3
  115. package/dist/heart/approval-files.js +94 -0
  116. package/dist/heart/approval-store.js +957 -0
  117. package/dist/heart/atomic-file.js +115 -0
  118. package/dist/heart/attachments/downloaded-store.js +89 -0
  119. package/dist/heart/attachments/image-normalize.js +201 -0
  120. package/dist/heart/attachments/materialize.js +97 -0
  121. package/dist/heart/attachments/originals.js +102 -0
  122. package/dist/heart/attachments/render.js +29 -0
  123. package/dist/heart/attachments/sources/bluebubbles.js +155 -0
  124. package/dist/heart/attachments/sources/cli-local-file.js +78 -0
  125. package/dist/heart/attachments/sources/downloaded.js +76 -0
  126. package/dist/heart/attachments/sources/index.js +19 -0
  127. package/dist/heart/attachments/store.js +132 -0
  128. package/dist/heart/attachments/transcribe-audio.js +172 -0
  129. package/dist/heart/attachments/types.js +93 -0
  130. package/dist/heart/attachments/understand.js +121 -0
  131. package/dist/heart/auth/auth-flow.js +589 -0
  132. package/dist/heart/auth/github-device-login.js +104 -0
  133. package/dist/heart/autonomy-budget.js +478 -0
  134. package/dist/heart/awaiting/a2a-await-delivery.js +109 -0
  135. package/dist/heart/awaiting/await-alert.js +152 -0
  136. package/dist/heart/awaiting/await-expiry.js +143 -0
  137. package/dist/heart/awaiting/await-loader.js +91 -0
  138. package/dist/heart/awaiting/await-parser.js +152 -0
  139. package/dist/heart/awaiting/await-runtime-state.js +130 -0
  140. package/dist/heart/awaiting/await-scheduler.js +403 -0
  141. package/dist/heart/background-operations.js +281 -0
  142. package/dist/heart/bluebubbles-host-account.js +78 -0
  143. package/dist/heart/bridges/manager.js +137 -17
  144. package/dist/heart/bridges/store.js +14 -2
  145. package/dist/heart/bundle-state.js +168 -0
  146. package/dist/heart/chat-interaction.js +38 -0
  147. package/dist/heart/commitments.js +44 -14
  148. package/dist/heart/config-registry.js +331 -0
  149. package/dist/heart/config.js +179 -131
  150. package/dist/heart/context-loss-gauntlet.js +387 -0
  151. package/dist/heart/context-loss-sentinel.js +1200 -0
  152. package/dist/heart/core.js +2521 -611
  153. package/dist/heart/cross-chat-delivery.js +29 -22
  154. package/dist/heart/daemon/agent-config-check.js +474 -0
  155. package/dist/heart/daemon/agent-discovery.js +304 -3
  156. package/dist/heart/daemon/agent-home.js +409 -0
  157. package/dist/heart/daemon/agent-service.js +542 -0
  158. package/dist/heart/daemon/agentic-repair.js +548 -0
  159. package/dist/heart/daemon/await-private-wake.js +59 -0
  160. package/dist/heart/daemon/bluebubbles-cli-integration.js +71 -0
  161. package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
  162. package/dist/heart/daemon/bluebubbles-host-protocol.js +433 -0
  163. package/dist/heart/daemon/bluebubbles-host.js +273 -0
  164. package/dist/heart/daemon/boot-sync-probe.js +223 -0
  165. package/dist/heart/daemon/cadence.js +180 -0
  166. package/dist/heart/daemon/cli-arg-redaction.js +26 -0
  167. package/dist/heart/daemon/cli-defaults.js +956 -0
  168. package/dist/heart/daemon/cli-desk.js +331 -0
  169. package/dist/heart/daemon/cli-exec.js +9598 -0
  170. package/dist/heart/daemon/cli-gate.js +170 -0
  171. package/dist/heart/daemon/cli-help.js +788 -0
  172. package/dist/heart/daemon/cli-manifest.js +126 -0
  173. package/dist/heart/daemon/cli-parse.js +3529 -0
  174. package/dist/heart/daemon/cli-render-doctor.js +57 -0
  175. package/dist/heart/daemon/cli-render.js +823 -0
  176. package/dist/heart/daemon/cli-types.js +8 -0
  177. package/dist/heart/daemon/compile-cache.js +69 -0
  178. package/dist/heart/daemon/connect-bay.js +323 -0
  179. package/dist/heart/daemon/container-credential-bootstrap.js +273 -0
  180. package/dist/heart/daemon/container-healthcheck.js +112 -0
  181. package/dist/heart/daemon/container-runtime.js +97 -0
  182. package/dist/heart/daemon/container-spec-auditor-main.js +187 -0
  183. package/dist/heart/daemon/container-spec-auditor.js +257 -0
  184. package/dist/heart/daemon/daemon-bootstrap-startup.js +115 -0
  185. package/dist/heart/daemon/daemon-cli.js +29 -2377
  186. package/dist/heart/daemon/daemon-entry.js +1116 -11
  187. package/dist/heart/daemon/daemon-health.js +186 -0
  188. package/dist/heart/daemon/daemon-rollup.js +57 -0
  189. package/dist/heart/daemon/daemon-runtime-sync.js +88 -13
  190. package/dist/heart/daemon/daemon-tombstone.js +236 -0
  191. package/dist/heart/daemon/daemon.js +2147 -104
  192. package/dist/heart/daemon/desk-admin.js +420 -0
  193. package/dist/heart/daemon/dns-workflow.js +394 -0
  194. package/dist/heart/daemon/doctor-types.js +8 -0
  195. package/dist/heart/daemon/doctor.js +1890 -0
  196. package/dist/heart/daemon/freshness.js +345 -0
  197. package/dist/heart/daemon/habit-private-wake.js +61 -0
  198. package/dist/heart/daemon/health-monitor.js +209 -12
  199. package/dist/heart/daemon/home-filesystem.js +93 -0
  200. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  201. package/dist/heart/daemon/hooks/bundle-meta.js +135 -1
  202. package/dist/heart/daemon/http-health-probe.js +80 -0
  203. package/dist/heart/daemon/human-command-screens.js +234 -0
  204. package/dist/heart/daemon/human-readiness.js +114 -0
  205. package/dist/heart/daemon/inner-status.js +78 -0
  206. package/dist/heart/daemon/interactive-repair.js +394 -0
  207. package/dist/heart/daemon/launchd.js +40 -8
  208. package/dist/heart/daemon/linux-service.js +366 -0
  209. package/dist/heart/daemon/log-tailer.js +79 -10
  210. package/dist/heart/daemon/logs-prune.js +132 -0
  211. package/dist/heart/daemon/mcp-canary.js +525 -0
  212. package/dist/heart/daemon/message-router.js +65 -5
  213. package/dist/heart/daemon/migrate-to-desk.js +848 -0
  214. package/dist/heart/daemon/os-cron-deps.js +139 -0
  215. package/dist/heart/daemon/os-cron.js +45 -15
  216. package/dist/heart/daemon/ouro-bot-entry.js +8 -3
  217. package/dist/heart/daemon/ouro-entry.js +32 -11
  218. package/dist/heart/daemon/plugin-cli.js +432 -0
  219. package/dist/heart/daemon/portable-git-install.js +265 -0
  220. package/dist/heart/daemon/portable-git.js +179 -0
  221. package/dist/heart/daemon/presence-daemon.js +265 -0
  222. package/dist/heart/daemon/presence-roster.js +259 -0
  223. package/dist/heart/daemon/presence.js +462 -0
  224. package/dist/heart/daemon/process-manager.js +763 -61
  225. package/dist/heart/daemon/provider-discovery.js +171 -0
  226. package/dist/heart/daemon/provider-ping-progress.js +83 -0
  227. package/dist/heart/daemon/prunable-bundle.js +144 -0
  228. package/dist/heart/daemon/pulse.js +511 -0
  229. package/dist/heart/daemon/readiness-repair.js +365 -0
  230. package/dist/heart/daemon/run-hooks.js +2 -0
  231. package/dist/heart/daemon/runtime-logging.js +48 -14
  232. package/dist/heart/daemon/runtime-metadata.js +2 -30
  233. package/dist/heart/daemon/runtime-mode.js +13 -2
  234. package/dist/heart/daemon/safe-mode.js +161 -0
  235. package/dist/heart/daemon/sanctuary-acceptance-adapter.js +2659 -0
  236. package/dist/heart/daemon/sanctuary-acceptance-harness.js +1832 -0
  237. package/dist/heart/daemon/sanctuary-acceptance-marker.js +267 -0
  238. package/dist/heart/daemon/sanctuary-acceptance-scenarios.js +956 -0
  239. package/dist/heart/daemon/sanctuary-authority-codec.js +86 -0
  240. package/dist/heart/daemon/sanctuary-authority-epoch.js +291 -0
  241. package/dist/heart/daemon/sanctuary-authority-installation.js +161 -0
  242. package/dist/heart/daemon/sanctuary-authority-ledger.js +241 -0
  243. package/dist/heart/daemon/sanctuary-authority-root-lifecycle.js +1348 -0
  244. package/dist/heart/daemon/sanctuary-authority-vault-migration.js +79 -0
  245. package/dist/heart/daemon/sanctuary-bundle-migration.js +974 -0
  246. package/dist/heart/daemon/sanctuary-host-authority.js +1008 -0
  247. package/dist/heart/daemon/sanctuary-host-detached-supervisor.js +493 -0
  248. package/dist/heart/daemon/sanctuary-host-executor.js +670 -0
  249. package/dist/heart/daemon/sanctuary-host-linux-kernel.js +334 -0
  250. package/dist/heart/daemon/sanctuary-host-supervisor-entry.js +207 -0
  251. package/dist/heart/daemon/sanctuary-host-supervisor.js +95 -0
  252. package/dist/heart/daemon/sanctuary-package-management.js +113 -0
  253. package/dist/heart/daemon/sanctuary-scheduler-liveness.js +227 -0
  254. package/dist/heart/daemon/sanctuary-scheduler-origin.js +132 -0
  255. package/dist/heart/daemon/sanctuary-telegram-authority-entry.js +478 -0
  256. package/dist/heart/daemon/sanctuary-telegram-authority-gateway.js +614 -0
  257. package/dist/heart/daemon/sanctuary-telegram-authority-service.js +763 -0
  258. package/dist/heart/daemon/sanctuary-telegram-test-driver-entry.js +94 -0
  259. package/dist/heart/daemon/sanctuary-telegram-test-driver.js +294 -0
  260. package/dist/heart/daemon/sense-manager.js +899 -58
  261. package/dist/heart/daemon/session-id-resolver.js +131 -0
  262. package/dist/heart/daemon/skill-management-installer.js +1 -1
  263. package/dist/heart/daemon/socket-client.js +180 -12
  264. package/dist/heart/daemon/stale-bundle-prune.js +113 -0
  265. package/dist/heart/daemon/startup-tui.js +339 -0
  266. package/dist/heart/daemon/supercronic-supervisor.js +282 -0
  267. package/dist/heart/daemon/task-scheduler.js +117 -39
  268. package/dist/heart/daemon/terminal-ui.js +503 -0
  269. package/dist/heart/daemon/thoughts.js +138 -54
  270. package/dist/heart/daemon/up-progress.js +366 -0
  271. package/dist/heart/daemon/vault-items.js +56 -0
  272. package/dist/heart/delegation.js +1 -4
  273. package/dist/heart/external-events/router.js +1556 -0
  274. package/dist/heart/failure-reports.js +398 -0
  275. package/dist/heart/file-lock.js +109 -0
  276. package/dist/heart/frontend-approval-runtime.js +506 -0
  277. package/dist/heart/frontend-journal.js +215 -0
  278. package/dist/heart/frontend-session-service.js +330 -0
  279. package/dist/heart/frontend-socket-client.js +173 -0
  280. package/dist/heart/frontend-socket.js +434 -0
  281. package/dist/heart/frontend-turn-errors.js +20 -0
  282. package/dist/heart/habits/habit-cancel.js +810 -0
  283. package/dist/heart/habits/habit-lifecycle.js +1324 -0
  284. package/dist/heart/habits/habit-migration.js +194 -0
  285. package/dist/heart/habits/habit-parser.js +278 -0
  286. package/dist/heart/habits/habit-runtime-state.js +93 -0
  287. package/dist/heart/habits/habit-scheduler.js +667 -0
  288. package/dist/heart/habits/habit-session-summary.js +318 -0
  289. package/dist/heart/habits/habit-session.js +636 -0
  290. package/dist/heart/{daemon → hatch}/hatch-flow.js +68 -62
  291. package/dist/heart/{daemon → hatch}/hatch-specialist.js +6 -8
  292. package/dist/heart/{daemon → hatch}/specialist-prompt.js +13 -9
  293. package/dist/heart/{daemon → hatch}/specialist-tools.js +100 -20
  294. package/dist/heart/identity.js +365 -59
  295. package/dist/heart/kept-notes.js +289 -0
  296. package/dist/heart/kicks.js +1 -1
  297. package/dist/heart/machine-identity.js +175 -0
  298. package/dist/heart/mail-import-discovery.js +356 -0
  299. package/dist/heart/mailbox/mailbox-http-hooks.js +99 -0
  300. package/dist/heart/mailbox/mailbox-http-response.js +7 -0
  301. package/dist/heart/mailbox/mailbox-http-routes.js +406 -0
  302. package/dist/heart/mailbox/mailbox-http-static.js +103 -0
  303. package/dist/heart/mailbox/mailbox-http-transport.js +272 -0
  304. package/dist/heart/mailbox/mailbox-http.js +99 -0
  305. package/dist/heart/mailbox/mailbox-read.js +41 -0
  306. package/dist/heart/mailbox/mailbox-supervision.js +131 -0
  307. package/dist/heart/mailbox/mailbox-types.js +27 -0
  308. package/dist/heart/mailbox/mailbox-view.js +197 -0
  309. package/dist/heart/mailbox/readers/agent-machine.js +428 -0
  310. package/dist/heart/mailbox/readers/continuity-readers.js +329 -0
  311. package/dist/heart/mailbox/readers/mail.js +375 -0
  312. package/dist/heart/mailbox/readers/runtime-readers.js +823 -0
  313. package/dist/heart/mailbox/readers/sessions.js +231 -0
  314. package/dist/heart/mailbox/readers/shared.js +111 -0
  315. package/dist/heart/mcp/mcp-server.js +760 -0
  316. package/dist/heart/migrate-config.js +100 -0
  317. package/dist/heart/model-capabilities.js +83 -16
  318. package/dist/heart/optional-packages.js +77 -0
  319. package/dist/heart/orientation-frame.js +381 -0
  320. package/dist/heart/platform.js +81 -0
  321. package/dist/heart/primitives.js +1 -1
  322. package/dist/heart/private-runtime/decision-renderer.js +158 -0
  323. package/dist/heart/private-runtime/index.js +18 -0
  324. package/dist/heart/private-runtime/ledger.js +212 -0
  325. package/dist/heart/private-runtime/policy.js +295 -0
  326. package/dist/heart/private-runtime/types.js +2 -0
  327. package/dist/heart/progress-story.js +1 -1
  328. package/dist/heart/provider-attempt.js +137 -0
  329. package/dist/heart/provider-binding-resolver.js +273 -0
  330. package/dist/heart/provider-credentials.js +449 -0
  331. package/dist/heart/provider-failover.js +260 -29
  332. package/dist/heart/provider-fallback.js +228 -0
  333. package/dist/heart/provider-models.js +96 -0
  334. package/dist/heart/provider-ping-child.js +125 -0
  335. package/dist/heart/provider-ping-entry.js +8 -0
  336. package/dist/heart/provider-ping.js +247 -76
  337. package/dist/heart/provider-readiness-cache.js +119 -0
  338. package/dist/heart/provider-visibility.js +188 -0
  339. package/dist/heart/providers/account-pool.js +717 -0
  340. package/dist/heart/providers/anthropic-token.js +131 -0
  341. package/dist/heart/providers/anthropic.js +303 -86
  342. package/dist/heart/providers/azure.js +20 -32
  343. package/dist/heart/providers/error-classification.js +129 -0
  344. package/dist/heart/providers/github-copilot.js +112 -36
  345. package/dist/heart/providers/minimax-vlm.js +189 -0
  346. package/dist/heart/providers/minimax.js +20 -28
  347. package/dist/heart/providers/openai-codex-token.js +349 -0
  348. package/dist/heart/providers/openai-codex.js +47 -58
  349. package/dist/heart/providers/openai-compatible.js +177 -0
  350. package/dist/heart/quota/fleet-readings.js +222 -0
  351. package/dist/heart/quota/tranche.js +59 -0
  352. package/dist/heart/reach-channel.js +85 -0
  353. package/dist/heart/reply-style.js +52 -0
  354. package/dist/heart/run-ledger.js +247 -0
  355. package/dist/heart/runtime-capability-check.js +170 -0
  356. package/dist/heart/runtime-credentials.js +647 -0
  357. package/dist/heart/runtime-cwd.js +87 -0
  358. package/dist/heart/sense-truth.js +26 -4
  359. package/dist/heart/session-activity.js +94 -24
  360. package/dist/heart/session-events.js +1596 -0
  361. package/dist/heart/session-playback-cli-main.js +5 -0
  362. package/dist/heart/session-playback-cli.js +36 -0
  363. package/dist/heart/session-playback.js +231 -0
  364. package/dist/heart/session-redaction-repair-cli-main.js +31 -0
  365. package/dist/heart/session-redaction-repair.js +552 -0
  366. package/dist/heart/session-stats-cli-main.js +5 -0
  367. package/dist/heart/session-stats.js +183 -0
  368. package/dist/heart/session-transcript.js +133 -0
  369. package/dist/heart/shelf-claims.js +88 -0
  370. package/dist/heart/shepherd/custody-types.js +2 -0
  371. package/dist/heart/shepherd/mandates.js +352 -0
  372. package/dist/heart/shepherd/operation-commands.js +19 -0
  373. package/dist/heart/shepherd/operations.js +137 -0
  374. package/dist/heart/shepherd/supervision.js +114 -0
  375. package/dist/heart/shepherd/types.js +2 -0
  376. package/dist/heart/shepherd-config.js +113 -0
  377. package/dist/heart/source-grounding.js +313 -0
  378. package/dist/heart/sqlite.js +18 -0
  379. package/dist/heart/start-of-turn-packet.js +372 -0
  380. package/dist/heart/steward-policy.js +656 -0
  381. package/dist/heart/streaming.js +624 -206
  382. package/dist/heart/structured-output.js +196 -0
  383. package/dist/heart/sync-classification.js +176 -0
  384. package/dist/heart/sync-health.js +152 -0
  385. package/dist/heart/sync-lock.js +431 -0
  386. package/dist/heart/sync.js +1579 -0
  387. package/dist/heart/target-resolution.js +11 -7
  388. package/dist/heart/tempo.js +93 -0
  389. package/dist/heart/temporal-view.js +41 -0
  390. package/dist/heart/timeouts.js +101 -0
  391. package/dist/heart/tool-activity-callbacks.js +59 -0
  392. package/dist/heart/tool-approval.js +382 -0
  393. package/dist/heart/tool-description.js +155 -0
  394. package/dist/heart/tool-friction.js +55 -0
  395. package/dist/heart/tool-images.js +42 -0
  396. package/dist/heart/tool-loop.js +13 -1
  397. package/dist/heart/tool-output-budget.js +41 -0
  398. package/dist/heart/turn-context.js +503 -0
  399. package/dist/heart/turn-execution-lease.js +30 -0
  400. package/dist/heart/versioning/host-self-update.js +118 -0
  401. package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
  402. package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +3 -2
  403. package/dist/heart/versioning/ouro-path-installer.js +432 -0
  404. package/dist/heart/versioning/ouro-recovery-launcher.js +76 -0
  405. package/dist/heart/versioning/ouro-version-manager.js +432 -0
  406. package/dist/heart/versioning/release-sources.js +185 -0
  407. package/dist/heart/versioning/self-update-defaults.js +397 -0
  408. package/dist/heart/versioning/self-update.js +241 -0
  409. package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
  410. package/dist/heart/{daemon → versioning}/update-checker.js +12 -35
  411. package/dist/heart/versioning/update-hooks.js +160 -0
  412. package/dist/heart/versioning/update-state.js +134 -0
  413. package/dist/heart/versioning/updater-launchd.js +150 -0
  414. package/dist/heart/versioning/version-intent.js +114 -0
  415. package/dist/heart/work-card.js +380 -0
  416. package/dist/mailbox-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  417. package/dist/mailbox-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  418. package/dist/mailbox-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  419. package/dist/mailbox-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  420. package/dist/mailbox-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  421. package/dist/mailbox-ui/assets/index-BI1pAais.css +1 -0
  422. package/dist/mailbox-ui/assets/index-DqdAt_p5.js +1 -0
  423. package/dist/mailbox-ui/assets/vendor-mqLhL5Io.js +65 -0
  424. package/dist/mailbox-ui/index.html +16 -0
  425. package/dist/mailroom/attention.js +167 -0
  426. package/dist/mailroom/autonomy.js +209 -0
  427. package/dist/mailroom/azure-sdk.js +27 -0
  428. package/dist/mailroom/blob-store.js +889 -0
  429. package/dist/mailroom/body-cache.js +61 -0
  430. package/dist/mailroom/cache-sync-cli.js +58 -0
  431. package/dist/mailroom/core.js +805 -0
  432. package/dist/mailroom/entry.js +160 -0
  433. package/dist/mailroom/file-store.js +568 -0
  434. package/dist/mailroom/hosted-cache-sync.js +384 -0
  435. package/dist/mailroom/mbox-import.js +393 -0
  436. package/dist/mailroom/migration.js +164 -0
  437. package/dist/mailroom/outbound.js +380 -0
  438. package/dist/mailroom/policy.js +263 -0
  439. package/dist/mailroom/reader.js +291 -0
  440. package/dist/mailroom/search-cache.js +513 -0
  441. package/dist/mailroom/search-relevance.js +319 -0
  442. package/dist/mailroom/smtp-ingress.js +176 -0
  443. package/dist/mailroom/source-state.js +176 -0
  444. package/dist/mailroom/thread.js +109 -0
  445. package/dist/mailroom/travel-extract.js +89 -0
  446. package/dist/mind/bundle-manifest.js +25 -2
  447. package/dist/mind/context.js +328 -139
  448. package/dist/mind/desk-section.js +342 -0
  449. package/dist/mind/diary-integrity.js +60 -0
  450. package/dist/mind/{memory.js → diary.js} +68 -77
  451. package/dist/mind/embedding-provider.js +60 -0
  452. package/dist/mind/file-state.js +179 -0
  453. package/dist/mind/friend-link-codes.js +209 -0
  454. package/dist/mind/friend-merge.js +336 -0
  455. package/dist/mind/house-names.js +43 -0
  456. package/dist/mind/{associative-recall.js → note-search.js} +47 -58
  457. package/dist/mind/obligation-steering.js +15 -9
  458. package/dist/mind/outbound-record.js +168 -0
  459. package/dist/mind/pending.js +36 -10
  460. package/dist/mind/prompt-budget.js +511 -0
  461. package/dist/mind/prompt-refresh.js +3 -2
  462. package/dist/mind/prompt.js +1148 -231
  463. package/dist/mind/provenance-trust.js +26 -0
  464. package/dist/mind/record-paths.js +312 -0
  465. package/dist/mind/scrutiny.js +160 -0
  466. package/dist/mind/session-transaction.js +619 -0
  467. package/dist/mind/token-estimate.js +17 -0
  468. package/dist/mind/where-am-i.js +147 -0
  469. package/dist/nerves/cli-logging.js +7 -1
  470. package/dist/nerves/coverage/audit-rules.js +15 -6
  471. package/dist/nerves/coverage/audit.js +28 -2
  472. package/dist/nerves/coverage/cli.js +1 -1
  473. package/dist/nerves/coverage/contract.js +5 -5
  474. package/dist/nerves/coverage/file-completeness.js +152 -5
  475. package/dist/nerves/coverage/run-artifacts.js +55 -35
  476. package/dist/nerves/coverage/source-scanner.js +4 -4
  477. package/dist/nerves/event-buffer.js +111 -0
  478. package/dist/nerves/index.js +293 -9
  479. package/dist/nerves/observation.js +20 -0
  480. package/dist/nerves/redact.js +79 -0
  481. package/dist/nerves/review/cli-main.js +5 -0
  482. package/dist/nerves/review/cli.js +156 -0
  483. package/dist/nerves/review/core.js +159 -0
  484. package/dist/nerves/runtime.js +17 -1
  485. package/dist/repertoire/ado-client.js +15 -56
  486. package/dist/repertoire/ado-semantic.js +19 -12
  487. package/dist/repertoire/api-client.js +97 -0
  488. package/dist/repertoire/auth-required.js +22 -0
  489. package/dist/repertoire/bitwarden-native.js +458 -0
  490. package/dist/repertoire/bitwarden-store.js +1296 -0
  491. package/dist/repertoire/bundle-templates.js +71 -0
  492. package/dist/repertoire/bw-installer.js +268 -0
  493. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  494. package/dist/repertoire/coding/context-pack.js +80 -3
  495. package/dist/repertoire/coding/feedback.js +26 -5
  496. package/dist/repertoire/coding/index.js +15 -3
  497. package/dist/repertoire/coding/manager.js +19 -11
  498. package/dist/repertoire/coding/spawner.js +22 -5
  499. package/dist/repertoire/coding/tools.js +116 -16
  500. package/dist/repertoire/coding/workbench-client.js +272 -0
  501. package/dist/repertoire/coding/workbench-manager.js +346 -0
  502. package/dist/repertoire/commerce-errors.js +109 -0
  503. package/dist/repertoire/commerce-self-test.js +156 -0
  504. package/dist/repertoire/credential-access.js +183 -0
  505. package/dist/repertoire/desk/classifier.js +362 -0
  506. package/dist/repertoire/duffel-client.js +185 -0
  507. package/dist/repertoire/github-client.js +14 -55
  508. package/dist/repertoire/graph-client.js +11 -52
  509. package/dist/repertoire/guardrails.js +1040 -69
  510. package/dist/repertoire/house-sweep.js +471 -0
  511. package/dist/repertoire/mcp-client.js +58 -5
  512. package/dist/repertoire/mcp-manager.js +427 -139
  513. package/dist/repertoire/mcp-tools.js +148 -0
  514. package/dist/repertoire/mcp-write-guard.js +46 -0
  515. package/dist/repertoire/plugin-mcp.js +175 -0
  516. package/dist/repertoire/plugins.js +253 -0
  517. package/dist/repertoire/relationship-authorization.js +322 -0
  518. package/dist/repertoire/sanctuary-container-policy.js +50 -0
  519. package/dist/repertoire/shell-sessions.js +135 -0
  520. package/dist/repertoire/skill-summaries.js +108 -0
  521. package/dist/repertoire/skills.js +48 -4
  522. package/dist/repertoire/stripe-client.js +163 -0
  523. package/dist/repertoire/tool-arguments.js +180 -0
  524. package/dist/repertoire/tool-limits.js +20 -0
  525. package/dist/repertoire/tool-results.js +29 -0
  526. package/dist/repertoire/tools-a2a.js +742 -0
  527. package/dist/repertoire/tools-app-sessions.js +143 -0
  528. package/dist/repertoire/tools-attachments.js +276 -0
  529. package/dist/repertoire/tools-awaiting.js +904 -0
  530. package/dist/repertoire/tools-base.js +85 -1378
  531. package/dist/repertoire/tools-bridge.js +144 -0
  532. package/dist/repertoire/tools-bundle.js +917 -0
  533. package/dist/repertoire/tools-chat.js +166 -0
  534. package/dist/repertoire/tools-commerce.js +253 -0
  535. package/dist/repertoire/tools-config.js +186 -0
  536. package/dist/repertoire/tools-continuity.js +607 -0
  537. package/dist/repertoire/tools-credential.js +383 -0
  538. package/dist/repertoire/tools-escalation.js +92 -0
  539. package/dist/repertoire/tools-evolution.js +527 -0
  540. package/dist/repertoire/tools-files.js +463 -0
  541. package/dist/repertoire/tools-flight.js +290 -0
  542. package/dist/repertoire/tools-flow.js +119 -0
  543. package/dist/repertoire/tools-friend-link.js +57 -0
  544. package/dist/repertoire/tools-github.js +7 -10
  545. package/dist/repertoire/tools-habits.js +103 -0
  546. package/dist/repertoire/tools-house-care.js +174 -0
  547. package/dist/repertoire/tools-mail.js +1828 -0
  548. package/dist/repertoire/tools-notes.js +501 -0
  549. package/dist/repertoire/tools-obligations.js +182 -0
  550. package/dist/repertoire/tools-orientation.js +31 -0
  551. package/dist/repertoire/tools-record.js +482 -0
  552. package/dist/repertoire/tools-rsvp.js +139 -0
  553. package/dist/repertoire/tools-runtime.js +238 -0
  554. package/dist/repertoire/tools-sanctuary-host.js +202 -0
  555. package/dist/repertoire/tools-session.js +1162 -0
  556. package/dist/repertoire/tools-shell.js +248 -0
  557. package/dist/repertoire/tools-shepherd-guidance.js +171 -0
  558. package/dist/repertoire/tools-shepherd.js +325 -0
  559. package/dist/repertoire/tools-steward-policy.js +147 -0
  560. package/dist/repertoire/tools-stripe.js +224 -0
  561. package/dist/repertoire/tools-surface.js +393 -0
  562. package/dist/repertoire/tools-teams.js +19 -45
  563. package/dist/repertoire/tools-telegram-contacts.js +37 -0
  564. package/dist/repertoire/tools-travel.js +125 -0
  565. package/dist/repertoire/tools-trip.js +982 -0
  566. package/dist/repertoire/tools-unraid.js +559 -0
  567. package/dist/repertoire/tools-user-profile.js +146 -0
  568. package/dist/repertoire/tools-vault.js +40 -0
  569. package/dist/repertoire/tools-voice-local.js +198 -0
  570. package/dist/repertoire/tools-voice.js +145 -0
  571. package/dist/repertoire/tools-web.js +230 -0
  572. package/dist/repertoire/tools.js +533 -157
  573. package/dist/repertoire/travel-api-client.js +360 -0
  574. package/dist/repertoire/unraid-client.js +155 -0
  575. package/dist/repertoire/unraid-restart.js +342 -0
  576. package/dist/repertoire/user-profile.js +131 -0
  577. package/dist/repertoire/vault-setup.js +298 -0
  578. package/dist/repertoire/vault-unlock.js +816 -0
  579. package/dist/rsvp/aisleplanner-client.js +354 -0
  580. package/dist/rsvp/cli.js +936 -0
  581. package/dist/rsvp/config.js +327 -0
  582. package/dist/rsvp/cutover.js +453 -0
  583. package/dist/rsvp/diagnostics.js +232 -0
  584. package/dist/rsvp/diff-renderer.js +176 -0
  585. package/dist/rsvp/habit-policy.js +110 -0
  586. package/dist/rsvp/habit-stage.js +123 -0
  587. package/dist/rsvp/incident-bundle.js +97 -0
  588. package/dist/rsvp/migration.js +204 -0
  589. package/dist/rsvp/native-habit-runner.js +630 -0
  590. package/dist/rsvp/outbound-state.js +628 -0
  591. package/dist/rsvp/query.js +118 -0
  592. package/dist/rsvp/replay.js +233 -0
  593. package/dist/rsvp/snapshot.js +232 -0
  594. package/dist/rsvp/spend-ledger.js +175 -0
  595. package/dist/scripts/claude-code-hook.js +41 -0
  596. package/dist/scripts/claude-code-stop-hook.js +47 -0
  597. package/dist/senses/a2a-entry.js +140 -0
  598. package/dist/senses/acp-server.js +386 -0
  599. package/dist/senses/app-sessions/app-interface.js +345 -0
  600. package/dist/senses/app-sessions/client.js +672 -0
  601. package/dist/senses/app-sessions/digest-cards.js +187 -0
  602. package/dist/senses/app-sessions/digest-push.js +105 -0
  603. package/dist/senses/app-sessions/digest-sources.js +204 -0
  604. package/dist/senses/app-sessions/digest.js +284 -0
  605. package/dist/senses/app-sessions/handoff.js +185 -0
  606. package/dist/senses/app-sessions/prompts.js +101 -0
  607. package/dist/senses/app-sessions/retire.js +85 -0
  608. package/dist/senses/app-sessions/sense.js +314 -0
  609. package/dist/senses/app-sessions/size-watch.js +255 -0
  610. package/dist/senses/app-sessions/store.js +176 -0
  611. package/dist/senses/app-sessions/waiting-prompts.js +137 -0
  612. package/dist/senses/app-sessions/waiting-status.js +23 -0
  613. package/dist/senses/app-sessions/wake-runner-state.js +57 -0
  614. package/dist/senses/app-sessions/wake-runner.js +194 -0
  615. package/dist/senses/app-sessions-entry.js +86 -0
  616. package/dist/senses/attention-queue.js +186 -0
  617. package/dist/senses/await-turn-message.js +65 -0
  618. package/dist/senses/bluebubbles/active-turns.js +216 -0
  619. package/dist/senses/bluebubbles/attachment-cache.js +53 -0
  620. package/dist/senses/bluebubbles/attachment-download.js +143 -0
  621. package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +373 -43
  622. package/dist/senses/bluebubbles/context-packet.js +207 -0
  623. package/dist/senses/bluebubbles/context-smoke.js +144 -0
  624. package/dist/senses/bluebubbles/entry.js +90 -0
  625. package/dist/senses/bluebubbles/host-account-verifier.js +88 -0
  626. package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +21 -3
  627. package/dist/senses/bluebubbles/index.js +4065 -0
  628. package/dist/senses/bluebubbles/latest-turn.js +311 -0
  629. package/dist/senses/bluebubbles/media.js +256 -0
  630. package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +147 -30
  631. package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +24 -13
  632. package/dist/senses/bluebubbles/outbound-state.js +335 -0
  633. package/dist/senses/bluebubbles/processed-log.js +133 -0
  634. package/dist/senses/bluebubbles/reactions.js +18 -0
  635. package/dist/senses/bluebubbles/replay.js +284 -0
  636. package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +30 -2
  637. package/dist/senses/bluebubbles/semantic-receipts.js +1983 -0
  638. package/dist/senses/bluebubbles/send-file.js +20 -0
  639. package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
  640. package/dist/senses/bluebubbles/webhook-registration.js +257 -0
  641. package/dist/senses/bluebubbles-meta-guard.js +39 -0
  642. package/dist/senses/chat-file.js +75 -0
  643. package/dist/senses/cli/bracketed-paste.js +82 -0
  644. package/dist/senses/cli/image-paste.js +287 -0
  645. package/dist/senses/cli/image-ref-navigation.js +75 -0
  646. package/dist/senses/cli/ink-app.js +156 -0
  647. package/dist/senses/cli/inline-diff.js +64 -0
  648. package/dist/senses/cli/input-keys.js +174 -0
  649. package/dist/senses/cli/kill-ring.js +86 -0
  650. package/dist/senses/cli/message-list.js +51 -0
  651. package/dist/senses/cli/ouro-tui.js +607 -0
  652. package/dist/senses/cli/spinner-imperative.js +135 -0
  653. package/dist/senses/cli/spinner.js +101 -0
  654. package/dist/senses/cli/status-line.js +60 -0
  655. package/dist/senses/cli/streaming-markdown.js +526 -0
  656. package/dist/senses/cli/tool-display.js +85 -0
  657. package/dist/senses/cli/tool-render.js +85 -0
  658. package/dist/senses/cli/tui-store.js +252 -0
  659. package/dist/senses/cli/virtual-list.js +35 -0
  660. package/dist/senses/cli-entry.js +60 -8
  661. package/dist/senses/cli.js +607 -352
  662. package/dist/senses/commands.js +66 -3
  663. package/dist/senses/context-packet-ledger.js +367 -0
  664. package/dist/senses/context-packets.js +154 -0
  665. package/dist/senses/habit-lifecycle-guard.js +24 -0
  666. package/dist/senses/habit-turn-message.js +160 -0
  667. package/dist/senses/ingress-evidence.js +2 -0
  668. package/dist/senses/mail-entry.js +68 -0
  669. package/dist/senses/mail.js +524 -0
  670. package/dist/senses/ordinary-owner-decision.js +97 -0
  671. package/dist/senses/pipeline.js +1139 -273
  672. package/dist/senses/private-runtime-worker.js +857 -0
  673. package/dist/senses/private-runtime.js +1686 -0
  674. package/dist/senses/proactive-content-guard.js +51 -0
  675. package/dist/senses/repeat-while.js +36 -0
  676. package/dist/senses/root-host-approval-port.js +345 -0
  677. package/dist/senses/root-host-approval-runtime.js +393 -0
  678. package/dist/senses/sanctuary-authority-resident.js +102 -0
  679. package/dist/senses/sanctuary-download-credit-presentation.js +31 -0
  680. package/dist/senses/sanctuary-full-visibility-contract.js +302 -0
  681. package/dist/senses/sanctuary-grounding.js +118 -0
  682. package/dist/senses/sanctuary-health-acceptance-probe-entry.js +12 -0
  683. package/dist/senses/sanctuary-health-acceptance-probe.js +786 -0
  684. package/dist/senses/sanctuary-health-runner.js +106 -0
  685. package/dist/senses/sanctuary-health.js +442 -0
  686. package/dist/senses/sanctuary-house.js +97 -0
  687. package/dist/senses/sanctuary-install-state-contract.js +169 -0
  688. package/dist/senses/sanctuary-interactive-control.js +410 -0
  689. package/dist/senses/sanctuary-media-catalog-contract.js +268 -0
  690. package/dist/senses/sanctuary-media-optimization.js +517 -0
  691. package/dist/senses/sanctuary-runtime.js +390 -0
  692. package/dist/senses/sanctuary-sab.js +85 -0
  693. package/dist/senses/sanctuary-storage-optimization-contract.js +32 -0
  694. package/dist/senses/shared-turn.js +827 -0
  695. package/dist/senses/shepherd/agent-presentation.js +88 -0
  696. package/dist/senses/shepherd/attention-page.js +166 -0
  697. package/dist/senses/shepherd/attention-sidebar.js +76 -0
  698. package/dist/senses/shepherd/attention.js +295 -0
  699. package/dist/senses/shepherd/checkin-config.js +76 -0
  700. package/dist/senses/shepherd/checkin-store.js +383 -0
  701. package/dist/senses/shepherd/client.js +196 -0
  702. package/dist/senses/shepherd/cmux.js +483 -0
  703. package/dist/senses/shepherd/composer.js +336 -0
  704. package/dist/senses/shepherd/feedback-reply.js +108 -0
  705. package/dist/senses/shepherd/feedback-source.js +20 -0
  706. package/dist/senses/shepherd/feedback-store.js +328 -0
  707. package/dist/senses/shepherd/feedback-submit.js +182 -0
  708. package/dist/senses/shepherd/feedback-worker.js +208 -0
  709. package/dist/senses/shepherd/guidance.js +273 -0
  710. package/dist/senses/shepherd/herdr.js +427 -0
  711. package/dist/senses/shepherd/host.js +14 -0
  712. package/dist/senses/shepherd/human-decision-guard.js +29 -0
  713. package/dist/senses/shepherd/judge-evaluation-command.js +183 -0
  714. package/dist/senses/shepherd/judge-evaluation-entry.js +13 -0
  715. package/dist/senses/shepherd/judge-evaluation.js +155 -0
  716. package/dist/senses/shepherd/judge.js +210 -0
  717. package/dist/senses/shepherd/notice-outbox.js +254 -0
  718. package/dist/senses/shepherd/observation-publisher.js +320 -0
  719. package/dist/senses/shepherd/operations-defaults.js +86 -0
  720. package/dist/senses/shepherd/operations.js +159 -0
  721. package/dist/senses/shepherd/owner-notice.js +492 -0
  722. package/dist/senses/shepherd/prompt-state.js +60 -0
  723. package/dist/senses/shepherd/recovery.js +543 -0
  724. package/dist/senses/shepherd/redact.js +66 -0
  725. package/dist/senses/shepherd/returns.js +79 -0
  726. package/dist/senses/shepherd/sense.js +862 -0
  727. package/dist/senses/shepherd/shepherd-judge-corpus-v1.json +170 -0
  728. package/dist/senses/shepherd/surface.js +125 -0
  729. package/dist/senses/shepherd/target-binding.js +13 -0
  730. package/dist/senses/shepherd/terminal-process.js +147 -0
  731. package/dist/senses/shepherd-entry.js +98 -0
  732. package/dist/senses/surface-tool.js +109 -0
  733. package/dist/senses/teams-attachments.js +68 -0
  734. package/dist/senses/teams-entry.js +78 -8
  735. package/dist/senses/teams-image.js +128 -0
  736. package/dist/senses/teams-off-turn.js +198 -0
  737. package/dist/senses/teams-outbox.js +242 -0
  738. package/dist/senses/teams.js +1157 -368
  739. package/dist/senses/telegram-admission.js +700 -0
  740. package/dist/senses/telegram-approval-runtime.js +793 -0
  741. package/dist/senses/telegram-attachments.js +128 -0
  742. package/dist/senses/telegram-audit-ledger.js +220 -0
  743. package/dist/senses/telegram-authority-transport.js +233 -0
  744. package/dist/senses/telegram-chat-actions.js +54 -0
  745. package/dist/senses/telegram-client.js +1799 -0
  746. package/dist/senses/telegram-effect-adapter.js +907 -0
  747. package/dist/senses/telegram-entry.js +86 -0
  748. package/dist/senses/telegram-handoff.js +150 -0
  749. package/dist/senses/telegram-identity-key.js +143 -0
  750. package/dist/senses/telegram.js +2370 -0
  751. package/dist/senses/terminal-handoff.js +44 -0
  752. package/dist/senses/trust-gate.js +104 -9
  753. package/dist/senses/voice/audio-playback.js +237 -0
  754. package/dist/senses/voice/audio-routing.js +119 -0
  755. package/dist/senses/voice/call-auth.js +250 -0
  756. package/dist/senses/voice/elevenlabs.js +202 -0
  757. package/dist/senses/voice/floor-control.js +431 -0
  758. package/dist/senses/voice/floor-controller.js +115 -0
  759. package/dist/senses/voice/golden-path.js +116 -0
  760. package/dist/senses/voice/index.js +29 -0
  761. package/dist/senses/voice/local-audio-control.js +344 -0
  762. package/dist/senses/voice/local-audio-devices.js +516 -0
  763. package/dist/senses/voice/local-audio-disclosure.js +174 -0
  764. package/dist/senses/voice/local-audio-identity.js +103 -0
  765. package/dist/senses/voice/local-audio-join.js +325 -0
  766. package/dist/senses/voice/local-audio-mute.js +199 -0
  767. package/dist/senses/voice/local-audio-notify.js +124 -0
  768. package/dist/senses/voice/local-audio-prompts.js +116 -0
  769. package/dist/senses/voice/local-audio-transport.js +427 -0
  770. package/dist/senses/voice/local-audio.js +281 -0
  771. package/dist/senses/voice/local-media-stream.js +145 -0
  772. package/dist/senses/voice/meeting.js +113 -0
  773. package/dist/senses/voice/outbound.js +190 -0
  774. package/dist/senses/voice/phone.js +33 -0
  775. package/dist/senses/voice/playback.js +139 -0
  776. package/dist/senses/voice/process-guards.js +51 -0
  777. package/dist/senses/voice/realtime-eval.js +496 -0
  778. package/dist/senses/voice/realtime-tool-schema.js +195 -0
  779. package/dist/senses/voice/realtime-trace.js +531 -0
  780. package/dist/senses/voice/transcript.js +70 -0
  781. package/dist/senses/voice/turn.js +191 -0
  782. package/dist/senses/voice/twilio-phone-runtime.js +836 -0
  783. package/dist/senses/voice/twilio-phone.js +5454 -0
  784. package/dist/senses/voice/types.js +2 -0
  785. package/dist/senses/voice/whisper.js +153 -0
  786. package/dist/senses/voice-entry.js +83 -0
  787. package/dist/senses/voice-realtime-eval-command.js +99 -0
  788. package/dist/senses/voice-realtime-eval-entry.js +21 -0
  789. package/dist/senses/voice-twilio-entry.js +87 -0
  790. package/dist/trips/core.js +138 -0
  791. package/dist/trips/store.js +265 -0
  792. package/dist/util/frontmatter.js +69 -0
  793. package/node_modules/@ouro.bot/friends/LICENSE +201 -0
  794. package/node_modules/@ouro.bot/friends/README.md +674 -0
  795. package/node_modules/@ouro.bot/friends/changelog.json +125 -0
  796. package/node_modules/@ouro.bot/friends/dist/a2a-client/a2a-message.d.ts +39 -0
  797. package/node_modules/@ouro.bot/friends/dist/a2a-client/a2a-message.js +54 -0
  798. package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.d.ts +117 -0
  799. package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.js +202 -0
  800. package/node_modules/@ouro.bot/friends/dist/a2a-client/agent-card.d.ts +50 -0
  801. package/node_modules/@ouro.bot/friends/dist/a2a-client/agent-card.js +32 -0
  802. package/node_modules/@ouro.bot/friends/dist/a2a-client/did-key.d.ts +38 -0
  803. package/node_modules/@ouro.bot/friends/dist/a2a-client/did-key.js +120 -0
  804. package/node_modules/@ouro.bot/friends/dist/a2a-client/did-verifier.d.ts +195 -0
  805. package/node_modules/@ouro.bot/friends/dist/a2a-client/did-verifier.js +342 -0
  806. package/node_modules/@ouro.bot/friends/dist/a2a-client/did-web.d.ts +26 -0
  807. package/node_modules/@ouro.bot/friends/dist/a2a-client/did-web.js +140 -0
  808. package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.d.ts +62 -0
  809. package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.js +79 -0
  810. package/node_modules/@ouro.bot/friends/dist/a2a-client/index.d.ts +26 -0
  811. package/node_modules/@ouro.bot/friends/dist/a2a-client/index.js +82 -0
  812. package/node_modules/@ouro.bot/friends/dist/a2a-client/jcs.d.ts +5 -0
  813. package/node_modules/@ouro.bot/friends/dist/a2a-client/jcs.js +84 -0
  814. package/node_modules/@ouro.bot/friends/dist/a2a-client/reachability.d.ts +22 -0
  815. package/node_modules/@ouro.bot/friends/dist/a2a-client/reachability.js +17 -0
  816. package/node_modules/@ouro.bot/friends/dist/a2a-client/roster-verify.d.ts +15 -0
  817. package/node_modules/@ouro.bot/friends/dist/a2a-client/roster-verify.js +61 -0
  818. package/node_modules/@ouro.bot/friends/dist/a2a-client/seal.d.ts +47 -0
  819. package/node_modules/@ouro.bot/friends/dist/a2a-client/seal.js +95 -0
  820. package/node_modules/@ouro.bot/friends/dist/a2a-client/sealed-envelope.d.ts +58 -0
  821. package/node_modules/@ouro.bot/friends/dist/a2a-client/sealed-envelope.js +113 -0
  822. package/node_modules/@ouro.bot/friends/dist/a2a-client/sign.d.ts +42 -0
  823. package/node_modules/@ouro.bot/friends/dist/a2a-client/sign.js +87 -0
  824. package/node_modules/@ouro.bot/friends/dist/a2a-client/sodium.d.ts +5 -0
  825. package/node_modules/@ouro.bot/friends/dist/a2a-client/sodium.js +19 -0
  826. package/node_modules/@ouro.bot/friends/dist/account-roster.d.ts +52 -0
  827. package/node_modules/@ouro.bot/friends/dist/account-roster.js +108 -0
  828. package/node_modules/@ouro.bot/friends/dist/agent-peer.d.ts +26 -0
  829. package/node_modules/@ouro.bot/friends/dist/agent-peer.js +138 -0
  830. package/node_modules/@ouro.bot/friends/dist/audit.d.ts +42 -0
  831. package/node_modules/@ouro.bot/friends/dist/audit.js +86 -0
  832. package/node_modules/@ouro.bot/friends/dist/channel.d.ts +11 -0
  833. package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/channel.js +80 -3
  834. package/node_modules/@ouro.bot/friends/dist/connect-authority.d.ts +43 -0
  835. package/node_modules/@ouro.bot/friends/dist/connect-authority.js +84 -0
  836. package/node_modules/@ouro.bot/friends/dist/connect.d.ts +56 -0
  837. package/node_modules/@ouro.bot/friends/dist/connect.js +163 -0
  838. package/node_modules/@ouro.bot/friends/dist/consent.d.ts +34 -0
  839. package/node_modules/@ouro.bot/friends/dist/consent.js +65 -0
  840. package/node_modules/@ouro.bot/friends/dist/coordination.d.ts +116 -0
  841. package/node_modules/@ouro.bot/friends/dist/coordination.js +329 -0
  842. package/node_modules/@ouro.bot/friends/dist/delegation-grant.d.ts +21 -0
  843. package/node_modules/@ouro.bot/friends/dist/delegation-grant.js +39 -0
  844. package/node_modules/@ouro.bot/friends/dist/file-bundle.d.ts +17 -0
  845. package/node_modules/@ouro.bot/friends/dist/file-bundle.js +27 -0
  846. package/node_modules/@ouro.bot/friends/dist/friend-lookup.d.ts +9 -0
  847. package/node_modules/@ouro.bot/friends/dist/friend-lookup.js +69 -0
  848. package/node_modules/@ouro.bot/friends/dist/grant-store-file.d.ts +16 -0
  849. package/node_modules/@ouro.bot/friends/dist/grant-store-file.js +136 -0
  850. package/node_modules/@ouro.bot/friends/dist/grant-store.d.ts +7 -0
  851. package/node_modules/@ouro.bot/friends/dist/grant-store.js +8 -0
  852. package/node_modules/@ouro.bot/friends/dist/grants.d.ts +39 -0
  853. package/node_modules/@ouro.bot/friends/dist/grants.js +84 -0
  854. package/node_modules/@ouro.bot/friends/dist/group-context.d.ts +21 -0
  855. package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/group-context.js +5 -4
  856. package/node_modules/@ouro.bot/friends/dist/identity.d.ts +17 -0
  857. package/node_modules/@ouro.bot/friends/dist/identity.js +68 -0
  858. package/node_modules/@ouro.bot/friends/dist/index.d.ts +73 -0
  859. package/node_modules/@ouro.bot/friends/dist/index.js +161 -0
  860. package/node_modules/@ouro.bot/friends/dist/link-identity.d.ts +14 -0
  861. package/node_modules/@ouro.bot/friends/dist/link-identity.js +157 -0
  862. package/node_modules/@ouro.bot/friends/dist/mailbox/index.d.ts +105 -0
  863. package/node_modules/@ouro.bot/friends/dist/mailbox/index.js +205 -0
  864. package/node_modules/@ouro.bot/friends/dist/mcp/bin.d.ts +2 -0
  865. package/node_modules/@ouro.bot/friends/dist/mcp/bin.js +16 -0
  866. package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.d.ts +40 -0
  867. package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.js +549 -0
  868. package/node_modules/@ouro.bot/friends/dist/mcp/index.d.ts +6 -0
  869. package/node_modules/@ouro.bot/friends/dist/mcp/index.js +14 -0
  870. package/node_modules/@ouro.bot/friends/dist/mcp/run-main.d.ts +7 -0
  871. package/node_modules/@ouro.bot/friends/dist/mcp/run-main.js +48 -0
  872. package/node_modules/@ouro.bot/friends/dist/mcp/schemas.d.ts +10 -0
  873. package/node_modules/@ouro.bot/friends/dist/mcp/schemas.js +445 -0
  874. package/node_modules/@ouro.bot/friends/dist/mcp/server.d.ts +30 -0
  875. package/node_modules/@ouro.bot/friends/dist/mcp/server.js +194 -0
  876. package/node_modules/@ouro.bot/friends/dist/message.d.ts +75 -0
  877. package/node_modules/@ouro.bot/friends/dist/message.js +99 -0
  878. package/node_modules/@ouro.bot/friends/dist/mission-result.d.ts +82 -0
  879. package/node_modules/@ouro.bot/friends/dist/mission-result.js +200 -0
  880. package/node_modules/@ouro.bot/friends/dist/mission-share.d.ts +94 -0
  881. package/node_modules/@ouro.bot/friends/dist/mission-share.js +232 -0
  882. package/node_modules/@ouro.bot/friends/dist/mission-store-file.d.ts +18 -0
  883. package/node_modules/@ouro.bot/friends/dist/mission-store-file.js +161 -0
  884. package/node_modules/@ouro.bot/friends/dist/mission-store.d.ts +10 -0
  885. package/node_modules/@ouro.bot/friends/dist/mission-store.js +9 -0
  886. package/node_modules/@ouro.bot/friends/dist/missions.d.ts +31 -0
  887. package/node_modules/@ouro.bot/friends/dist/missions.js +98 -0
  888. package/node_modules/@ouro.bot/friends/dist/notes.d.ts +11 -0
  889. package/node_modules/@ouro.bot/friends/dist/notes.js +90 -0
  890. package/node_modules/@ouro.bot/friends/dist/observability.d.ts +27 -0
  891. package/node_modules/@ouro.bot/friends/dist/observability.js +31 -0
  892. package/node_modules/@ouro.bot/friends/dist/outcomes.d.ts +9 -0
  893. package/node_modules/@ouro.bot/friends/dist/outcomes.js +51 -0
  894. package/node_modules/@ouro.bot/friends/dist/resolver.d.ts +59 -0
  895. package/node_modules/@ouro.bot/friends/dist/resolver.js +276 -0
  896. package/node_modules/@ouro.bot/friends/dist/results.d.ts +10 -0
  897. package/node_modules/@ouro.bot/friends/dist/results.js +2 -0
  898. package/node_modules/@ouro.bot/friends/dist/room.d.ts +22 -0
  899. package/node_modules/@ouro.bot/friends/dist/room.js +40 -0
  900. package/node_modules/@ouro.bot/friends/dist/roster-store-file.d.ts +16 -0
  901. package/node_modules/@ouro.bot/friends/dist/roster-store-file.js +125 -0
  902. package/node_modules/@ouro.bot/friends/dist/roster-store-memory.d.ts +9 -0
  903. package/node_modules/@ouro.bot/friends/dist/roster-store-memory.js +20 -0
  904. package/node_modules/@ouro.bot/friends/dist/roster-store.d.ts +29 -0
  905. package/node_modules/@ouro.bot/friends/dist/roster-store.js +9 -0
  906. package/node_modules/@ouro.bot/friends/dist/roster-verifier.d.ts +23 -0
  907. package/node_modules/@ouro.bot/friends/dist/roster-verifier.js +47 -0
  908. package/node_modules/@ouro.bot/friends/dist/share.d.ts +108 -0
  909. package/node_modules/@ouro.bot/friends/dist/share.js +278 -0
  910. package/node_modules/@ouro.bot/friends/dist/standing.d.ts +83 -0
  911. package/node_modules/@ouro.bot/friends/dist/standing.js +111 -0
  912. package/node_modules/@ouro.bot/friends/dist/store-file.d.ts +82 -0
  913. package/node_modules/@ouro.bot/friends/dist/store-file.js +1074 -0
  914. package/node_modules/@ouro.bot/friends/dist/store.d.ts +43 -0
  915. package/node_modules/@ouro.bot/friends/dist/tokens.d.ts +8 -0
  916. package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/tokens.js +2 -2
  917. package/node_modules/@ouro.bot/friends/dist/trust-explanation.d.ts +22 -0
  918. package/node_modules/@ouro.bot/friends/dist/trust-explanation.js +90 -0
  919. package/node_modules/@ouro.bot/friends/dist/trust-mutation.d.ts +16 -0
  920. package/node_modules/@ouro.bot/friends/dist/trust-mutation.js +67 -0
  921. package/node_modules/@ouro.bot/friends/dist/types.d.ts +321 -0
  922. package/node_modules/@ouro.bot/friends/dist/types.js +55 -0
  923. package/node_modules/@ouro.bot/friends/dist/util/cap-string.d.ts +7 -0
  924. package/node_modules/@ouro.bot/friends/dist/util/cap-string.js +35 -0
  925. package/node_modules/@ouro.bot/friends/dist/verifier.d.ts +11 -0
  926. package/node_modules/@ouro.bot/friends/dist/verifier.js +29 -0
  927. package/node_modules/@ouro.bot/friends/dist/whoami.d.ts +7 -0
  928. package/node_modules/@ouro.bot/friends/dist/whoami.js +39 -0
  929. package/node_modules/@ouro.bot/friends/package.json +81 -0
  930. package/node_modules/libsodium/LICENSE +16 -0
  931. package/node_modules/libsodium/README.md +281 -0
  932. package/node_modules/libsodium/dist/modules/libsodium.js +1 -0
  933. package/node_modules/libsodium/dist/modules-esm/libsodium.mjs +1 -0
  934. package/node_modules/libsodium/package.json +54 -0
  935. package/node_modules/libsodium-wrappers/LICENSE +16 -0
  936. package/node_modules/libsodium-wrappers/README.md +281 -0
  937. package/node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.d.ts +2155 -0
  938. package/node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.js +1 -0
  939. package/node_modules/libsodium-wrappers/dist/modules-esm/libsodium-wrappers.d.mts +2743 -0
  940. package/node_modules/libsodium-wrappers/dist/modules-esm/libsodium-wrappers.mjs +1 -0
  941. package/node_modules/libsodium-wrappers/package.json +74 -0
  942. package/npm-shrinkwrap.json +8789 -0
  943. package/package.json +92 -14
  944. package/skills/agent-commerce.md +113 -0
  945. package/skills/browser-navigation.md +117 -0
  946. package/skills/commerce-setup-guide.md +116 -0
  947. package/skills/commerce-setup.md +84 -0
  948. package/skills/configure-dev-tools.md +99 -0
  949. package/skills/sense-setup.md +56 -0
  950. package/skills/travel-planning.md +138 -0
  951. package/dist/heart/daemon/auth-flow.js +0 -430
  952. package/dist/heart/daemon/ouro-path-installer.js +0 -205
  953. package/dist/heart/daemon/ouro-version-manager.js +0 -171
  954. package/dist/heart/daemon/update-hooks.js +0 -138
  955. package/dist/heart/obligations.js +0 -197
  956. package/dist/heart/safe-workspace.js +0 -381
  957. package/dist/heart/session-recall.js +0 -216
  958. package/dist/mind/friends/resolver.js +0 -84
  959. package/dist/mind/friends/store-file.js +0 -190
  960. package/dist/mind/friends/trust-explanation.js +0 -74
  961. package/dist/mind/friends/types.js +0 -29
  962. package/dist/repertoire/tasks/board.js +0 -134
  963. package/dist/repertoire/tasks/index.js +0 -224
  964. package/dist/repertoire/tasks/lifecycle.js +0 -80
  965. package/dist/repertoire/tasks/middleware.js +0 -65
  966. package/dist/repertoire/tasks/parser.js +0 -173
  967. package/dist/repertoire/tasks/scanner.js +0 -132
  968. package/dist/repertoire/tasks/transitions.js +0 -144
  969. package/dist/repertoire/tools-bluebubbles.js +0 -93
  970. package/dist/senses/bluebubbles-entry.js +0 -13
  971. package/dist/senses/bluebubbles-media.js +0 -339
  972. package/dist/senses/bluebubbles.js +0 -1199
  973. package/dist/senses/debug-activity.js +0 -154
  974. package/dist/senses/inner-dialog-worker.js +0 -90
  975. package/dist/senses/inner-dialog.js +0 -536
  976. package/subagents/README.md +0 -7
  977. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  978. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  979. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  980. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  981. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  982. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  983. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  984. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  985. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  986. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  987. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  988. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
  989. /package/dist/{repertoire/tasks/types.js → heart/attachments/sources/adapter.js} +0 -0
  990. /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
  991. /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
  992. /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
  993. /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
  994. /package/{dist/mind/friends → node_modules/@ouro.bot/friends/dist}/store.js +0 -0
@@ -0,0 +1 @@
1
+ import{r as i,t as _s,c as Os,j as e,B as Gt,M as bt,C as Ds,a as Ps,b as vt,d as Us,e as dt,f as Bs,g as zs,h as Hs,i as qs,k as Fs,S as Jt,l as Ws,m as Ks,n as Vs,o as Zt,p as Ys,q as Qs,s as Xs,u as Gs,v as Js,D as Zs,w as eo,x as to,y as so,z as oo,A as no,E as ro,F as ao,G as io,H as lo,I as co,J as uo,T as xo,K as mo,L as po,N as ho,O as fo}from"./vendor-mqLhL5Io.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&n(c)}).observe(document,{childList:!0,subtree:!0});function o(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(r){if(r.ep)return;r.ep=!0;const a=o(r);fetch(r.href,a)}})();const es="/api";async function P(t,s){const o=await fetch(`${es}${t}`,{headers:{accept:"application/json"},signal:s==null?void 0:s.signal});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return o.json()}function go(t,s){const o=new EventSource(`${es}/events`);let n=!1;s==null||s("connecting");const r=a=>{if(!(n||!(a instanceof MessageEvent)))try{const c=JSON.parse(a.data);t("state-changed",c)}catch{t("state-changed",{})}};return o.addEventListener("state-changed",r),o.onopen=()=>{n||(s==null||s("connected"),t("connected",{}))},o.onerror=()=>{n||s==null||s("reconnecting")},()=>{n=!0,o.removeEventListener("state-changed",r),o.onopen=null,o.onerror=null,o.close()}}function U(t){if(!t)return"unknown";const s=Date.now()-new Date(t).getTime();return s<0||s<6e4?"just now":s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:`${Math.floor(s/864e5)}d ago`}function Y(t,s){if(!t)return"";if(t.length<=s)return t;const o=t.lastIndexOf(" ",s);return(o>s*.6?t.slice(0,o):t.slice(0,s))+"…"}const ts=i.createContext(()=>{});function ge(){return i.useContext(ts)}const bo=new Set(["overview","mail","sessions","work","connections","inner","notes","runtime"]);function ss(t){const s=t.replace(/^#\/?/,"");if(!s.startsWith("agent/"))return null;const o=s.split("/"),n=o[1]?decodeURIComponent(o[1]):"";if(!n)return null;const r=o[2]??"overview",a=bo.has(r)?r:"overview",c=o.slice(3),f=c.length>0?c.map(decodeURIComponent).join("/"):void 0;return{agent:n,tab:a,focus:f}}function Ue(t){let s=`#/agent/${encodeURIComponent(t.agent)}`;return(t.tab!=="overview"||t.focus)&&(s+=`/${t.tab}`),t.focus&&(s+=`/${t.focus.split("/").map(encodeURIComponent).join("/")}`),s}function jt(t){const s=t.replace(/^#\/?/,"").split("/");if(s[0]!=="supervision"||s.length>3)return null;try{const o=s[1]?decodeURIComponent(s[1]):null;return o&&!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(o)?null:{agent:o,...s[2]?{focus:decodeURIComponent(s[2])}:{}}}catch{return null}}function wt(t,s){return`#/supervision${t?`/${encodeURIComponent(t)}`:""}`}function se(t,s,o){/* istanbul ignore else @preserve -- the else path exists only in production bundles; scripts/dev-strip.test.mjs covers it */throw new Error(`[ouro-ui] ${t}: ${s}`)}function de(t,s,o,n){i.useRef(!1),i.useEffect(()=>{},[t,s,o,n])}function z(...t){return _s(Os(t))}function oe(t,s){i.useRef({}),i.useEffect(()=>{})}const vo="sr-only text-base leading-5 focus-visible:top-2 focus-visible:start-2 focus-visible:z-20 focus-visible:m-0 focus-visible:size-auto focus-visible:overflow-visible focus-visible:[clip-path:none] focus-visible:px-4 focus-visible:py-2.5 focus-visible:whitespace-nowrap focus-visible:rounded-lg focus-visible:bg-background focus-visible:text-foreground focus-visible:font-medium focus-visible:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid",jo="z-10 col-start-1 row-start-1 box-border bg-background max-sm:sticky max-sm:top-0 max-sm:flex max-sm:min-h-14 max-sm:items-center max-sm:border-0 max-sm:border-b max-sm:border-solid max-sm:border-border max-sm:ps-[max(0.5rem,env(safe-area-inset-left,0px))] sm:sticky sm:top-0 sm:row-span-2 sm:h-dvh",wo="sticky top-0 z-10 col-start-2 row-start-1 box-border flex min-w-0 items-center gap-2 border-0 border-b border-solid border-border bg-background ps-2 pe-[max(1rem,env(safe-area-inset-right,0px))] sm:ps-6";function No(t){const{sidebar:s,header:o,children:n,as:r,bleed:a,skipLabel:c="Skip to content",className:f,ref:d,navbar:b}=t;de("SidebarLayout",f,""),oe();const x=i.useId(),w=r==="div"?"div":"main",y=o!==void 0?"header":"div",u=i.useRef(null);return e.jsxs("div",{ref:d,"data-ouro":"sidebar-layout",className:z("relative grid min-h-dvh grid-cols-[auto_minmax(0,1fr)] grid-rows-[auto_minmax(0,1fr)] bg-background text-foreground",f),children:[e.jsx("a",{href:`#${x}`,"data-ouro-control":"sidebar-layout","data-ouro-part":"skip-link",onClick:()=>u.current.focus(),className:vo,children:c}),e.jsx("div",{"data-ouro-sidebar-layout-sidebar":"",className:jo,children:s}),e.jsx(y,{"data-ouro-sidebar-layout-header":"",className:z(wo,o!==void 0?"min-h-14":"sm:hidden"),children:o}),e.jsx(w,{ref:u,id:x,tabIndex:-1,className:z("col-span-2 row-start-2 box-border min-w-0 outline-none sm:col-span-1 sm:col-start-2",!a&&"p-4 sm:p-6"),children:n})]})}function Nt(t){const s=t.replace(/[?#].*$/,"").replace(/\/+$/,"");return s===""?"/":s}function yo(t,s){if(s===void 0)return;const o=Nt(s);let n,r=-1;for(const a of t){const c=Nt(a);if(c===o)return a;c!=="/"&&o.startsWith(`${c}/`)&&c.length>r&&(n=a,r=c.length)}return n}const ko=t=>i.createElement("a",t),Co=i.createContext({linkComponent:ko});function os(){return i.useContext(Co)}const So=/^([a-z][a-z\d+.-]*:|\/\/)/i;function $o(t){return So.test(t)}function Ao(t){const s=new Set((t??"").split(/\s+/).filter(Boolean));return s.add("noopener"),s.add("noreferrer"),[...s].join(" ")}function qe({href:t,target:s,rel:o,reloadDocument:n,...r}){const{linkComponent:a}=os(),c=$o(t),f={...r,href:t,target:s,rel:c&&s==="_blank"?Ao(o):o},d=r.download!==void 0&&r.download!==null&&r.download!==!1;return c||n||d?i.createElement("a",f):i.createElement(a,f)}function ns(t,s){const o=i.useCallback(r=>{if(typeof matchMedia!="function")return()=>{};const a=matchMedia(t);return a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[t]),n=i.useCallback(()=>typeof matchMedia=="function"?matchMedia(t).matches:s,[t,s]);return i.useSyncExternalStore(o,n,()=>s)}let te,ve;const yt=100;function Eo(){return te!=null&&te.isConnected||(te=document.createElement("div"),te.setAttribute("role","status"),te.setAttribute("aria-live","polite"),te.setAttribute("aria-atomic","true"),te.setAttribute("data-ouro-announcer",""),Object.assign(te.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",border:"0",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap"}),document.body.append(te)),te}function To(t,{delayMs:s=yt,onWrite:o}={}){/* istanbul ignore if @preserve -- server only */if(typeof document>"u")return;const n=Eo();n.textContent="",clearTimeout(ve);const r=setTimeout(()=>{ve=void 0,n.textContent=t,o==null||o()},Math.max(yt,s));return ve=r,()=>{ve===r&&(clearTimeout(r),ve=void 0)}}const Ro=new Set([" ","PageUp","PageDown","Home","End","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab"]),Lo=1e3,Io=200,Mo=1e3,We=["Enter"," "],kt=["ArrowDown","ArrowUp"],pe=new Set;let rt=0,at=0,le=0,rs,he,as,Ct,xe,Oe=null;function ut(t){Oe??(Oe=t.style.scrollBehavior),t.style.scrollBehavior="auto"}function is(t){Oe!==null&&t.style.scrollBehavior==="auto"&&(t.style.scrollBehavior=Oe),Oe=null}const _o=()=>he!==void 0||[...pe].some(t=>t.querySelector("[data-open]")!==null);function ls(t){pe.size>0||he!==void 0||(rt=t.scrollX,at=t.scrollY,rs=Do(t))}function xt(t){pe.size>0||he!==void 0||(rs(),is(t.document.documentElement))}function Be(){clearTimeout(he),he=void 0,xe==null||xe.trigger.removeEventListener("click",cs),xe=void 0}function cs(){const{view:t}=xe;Be(),xt(t)}function St(t,s,o){if(s===Ct||(Ct=s,t.getAttribute("aria-expanded")==="true"))return;const n=t.ownerDocument.defaultView;n.scrollTo({left:n.scrollX,top:n.scrollY,behavior:"instant"}),ls(n),Be(),he=setTimeout(()=>{Be(),xt(n)},Mo),le=0,o?(xe={trigger:t,view:n},t.addEventListener("click",cs)):ut(n.document.documentElement)}function je(t,s=!1,o=n=>n.button===0){const n=new Set(t);return{onPointerDown:r=>{o(r)&&St(r.currentTarget,r.nativeEvent,s)},onKeyDown:r=>{n.has(r.key)&&(as=r.nativeEvent,St(r.currentTarget,r.nativeEvent,s))}}}const ce={button:je(We),listButton:je([...We,...kt]),listInput:je(kt),dialog:je(We,!0),contextMenu:je([],!1,t=>t.button===2)};function Oo(t){const s=t.ownerDocument.defaultView;return ls(s),Be(),le=0,ut(s.document.documentElement),pe.add(t),()=>{pe.delete(t),xt(s)}}function Do(t){const s=t.document,o=()=>{le=performance.now()+Lo,is(s.documentElement)},n=d=>{(d.target===s.documentElement||d.button===1)&&o()},r=d=>{[...pe].some(b=>b.contains(d.target))&&o()},a=d=>{d!==as&&(d.defaultPrevented?(le=0,ut(s.documentElement)):Ro.has(d.key)&&o())},c=()=>{const d=performance.now(),b=d<le;if(b&&(le=Math.max(le,d+Io)),b||!_o()){rt=t.scrollX,at=t.scrollY;return}t.scrollTo({left:rt,top:at,behavior:"instant"})},f={capture:!0,passive:!0};return s.addEventListener("wheel",o,f),s.addEventListener("touchmove",o,f),s.addEventListener("pointerdown",n,f),s.addEventListener("click",r,f),t.addEventListener("keydown",a),s.addEventListener("scroll",c),()=>{s.removeEventListener("wheel",o,f),s.removeEventListener("touchmove",o,f),s.removeEventListener("pointerdown",n,f),s.removeEventListener("click",r,f),t.removeEventListener("keydown",a),s.removeEventListener("scroll",c)}}function ze(t,s){if(typeof t=="function"){const o=t(s);return typeof o=="function"?o:()=>t(null)}return t?(t.current=s,()=>{t.current=null}):()=>{}}function Ee(t,s){return i.useCallback(o=>{const n=ze(s,o),r=ze(t,o);return()=>{n(),r()}},[t,s])}function He(){return e.jsx("span",{"aria-hidden":"true","data-ouro-touch-target":"",className:"absolute top-1/2 left-1/2 hidden size-[max(100%,44px)] -translate-1/2 pointer-coarse:block"})}const Po="press relative box-border inline-flex shrink-0 items-center justify-center align-middle rounded-lg border border-solid font-medium whitespace-nowrap no-underline select-none touch-manipulation [-webkit-tap-highlight-color:transparent] outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid before:pointer-events-none before:absolute before:-inset-px before:rounded-[inherit] before:[corner-shape:inherit] before:bg-current before:opacity-0 before:transition-opacity before:duration-(--ouro-duration-fast) before:ease-[ease] not-data-disabled:not-active:pointer-fine:hover:before:opacity-8 not-data-disabled:active:before:opacity-14 bg-(--ouro-bg) border-(--ouro-bd) [--ouro-sq-w:1px] [--ouro-sq-r:calc(var(--radius-lg)/var(--ouro-corner-fallback,1))] not-data-disabled:not-active:pointer-fine:hover:[--ouro-state:0.08] not-data-disabled:active:[--ouro-state:0.14] motion-safe:not-data-disabled:active:scale-(--ouro-press-scale) disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-progress",Ke="h-(--ouro-button-h) px-(--ouro-button-px)",$t={sm:`${Ke} gap-1.5 text-sm [--ouro-button-h:calc(var(--spacing)*9)] [--ouro-button-px:calc(var(--spacing)*3)] sm:[--ouro-button-h:calc(var(--spacing)*8)] sm:[--ouro-button-px:calc(var(--spacing)*2.5)]`,md:`${Ke} gap-2 text-base sm:text-sm [--ouro-button-h:calc(var(--spacing)*11)] [--ouro-button-px:calc(var(--spacing)*4)] sm:[--ouro-button-h:calc(var(--spacing)*9)] sm:[--ouro-button-px:calc(var(--spacing)*3.5)]`,lg:`${Ke} gap-2 text-base [--ouro-button-h:calc(var(--spacing)*12)] [--ouro-button-px:calc(var(--spacing)*5)] sm:[--ouro-button-h:calc(var(--spacing)*11)]`,inline:"h-auto min-w-6 px-1 py-[3px] -my-1 gap-1 rounded-md align-baseline text-[length:inherit] leading-[inherit]"},Ve={solid:{primary:"[--ouro-bd:transparent] [--ouro-bg:var(--ouro-action,var(--primary))] text-(--ouro-action-foreground,var(--primary-foreground)) not-data-disabled:not-active:pointer-fine:hover:[--ouro-bg:var(--ouro-action-hover,var(--ouro-action,var(--primary)))] not-data-disabled:active:[--ouro-bg:var(--ouro-action-active,var(--ouro-action,var(--primary)))] data-disabled:[--ouro-bg:var(--ouro-action-disabled,var(--ouro-action,var(--primary)))] data-disabled:text-(--ouro-action-disabled-foreground,var(--ouro-action-foreground,var(--primary-foreground))) disabled:opacity-(--ouro-action-disabled-opacity,0.5)",secondary:"[--ouro-bd:transparent] [--ouro-bg:var(--secondary)] text-secondary-foreground",destructive:"[--ouro-bd:transparent] [--ouro-bg:var(--destructive)] text-destructive-foreground",success:"[--ouro-bd:transparent] [--ouro-bg:var(--success)] text-success-foreground",warning:"[--ouro-bd:transparent] [--ouro-bg:var(--warning)] text-warning-foreground"},soft:{primary:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--primary)_10%,transparent)] text-[color-mix(in_oklab,var(--primary)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]",secondary:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--secondary)_50%,transparent)] text-secondary-foreground contrast-more:[--ouro-bd:currentColor]",destructive:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--destructive)_10%,transparent)] text-[color-mix(in_oklab,var(--destructive)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]",success:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--success)_10%,transparent)] text-[color-mix(in_oklab,var(--success)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]",warning:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--warning)_10%,transparent)] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]"},outline:{primary:"[--ouro-bd:color-mix(in_oklab,var(--primary)_45%,transparent)] [--ouro-bg:transparent] text-foreground",secondary:"[--ouro-bd:var(--border)] [--ouro-bg:transparent] text-foreground",destructive:"[--ouro-bd:color-mix(in_oklab,var(--destructive)_45%,transparent)] [--ouro-bg:transparent] text-destructive",success:"[--ouro-bd:color-mix(in_oklab,var(--success)_45%,transparent)] [--ouro-bg:transparent] text-success",warning:"[--ouro-bd:color-mix(in_oklab,var(--warning)_45%,transparent)] [--ouro-bg:transparent] text-warning"},plain:{primary:"[--ouro-bd:transparent] [--ouro-bg:transparent] text-primary",secondary:"[--ouro-bd:transparent] [--ouro-bg:transparent] text-foreground",destructive:"[--ouro-bd:transparent] [--ouro-bg:transparent] text-destructive",success:"[--ouro-bd:transparent] [--ouro-bg:transparent] text-success",warning:"[--ouro-bd:transparent] [--ouro-bg:transparent] text-warning"}},At="size-[1.25em] shrink-0",Uo="[&>[data-ouro-label]>svg:not([class*='size-'])]:size-[1.25em] [&>[data-ouro-label]>svg]:shrink-0",Bo=["button","submit","reset"];function zo(){return e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center transition-opacity duration-(--ouro-duration-base) ease-(--ouro-ease-out) starting:opacity-0",children:e.jsxs("svg",{"data-ouro-spinner":"",viewBox:"0 0 24 24",fill:"none",className:"size-[1.25em] animate-[ouro-spin_0.8s_linear_infinite] motion-reduce:animate-[ouro-pulse_1.6s_ease-in-out_infinite]",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.25"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})})}const Et=t=>t.preventDefault(),Ho="button,a[href],select,[contenteditable]:not([contenteditable=false]),input:is([type=button],[type=submit],[type=reset],[type=checkbox],[type=radio],[type=file]),[role=button],[role=link],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=option],[role=checkbox],[role=radio],[role=switch],[role=tab],[role=treeitem],[aria-expanded=true]";function qo(t,s){if(t.key!=="Enter"||t.defaultPrevented||t.isComposing||t.keyCode===229||t.shiftKey||t.altKey)return!1;const o=t.target;return s.contains(o)?o.matches("textarea")?t.metaKey||t.ctrlKey:!o.matches(Ho):!1}function Fo(t){const{tone:s="primary",variant:o="solid",size:n="md",fullWidth:r,loading:a,loadingLabel:c="Loading",startIcon:f,endIcon:d,children:b,className:x,isLoading:w,color:y,asChild:u,leftIcon:g,rightIcon:m,reloadDocument:j,default:N,...v}=t,E=Object.hasOwn(Ve.solid,s)?s:"primary",l=Object.hasOwn(Ve,o)?o:"solid",S=Object.hasOwn($t,n)?n:"md";de("Button",x,""),oe();const R=i.useRef(a);i.useEffect(()=>{a&&!R.current&&To(c),R.current=a},[a,c]);const T=i.useRef(null),M=i.useRef(void 0),h=v.onClick;i.useEffect(()=>{M.current=h});const p=N&&v.href===void 0&&!v.disabled&&!a;i.useEffect(()=>{const W=p?T.current.closest("[role=dialog],[role=alertdialog]"):null;if(!W)return;const V=K=>{var O,q;if(!qo(K,W))return;K.preventDefault(),(O=M.current)==null||O.call(M,K);const C=T.current;C.type==="submit"&&((q=C.form)==null||q.requestSubmit(C))};return W.ownerDocument.addEventListener("keydown",V),()=>W.ownerDocument.removeEventListener("keydown",V)},[p]);const k=Ee(v.ref,T),L=z(Po,Uo,$t[S],Ve[l][E],r&&"w-full",x),I=e.jsxs(e.Fragment,{children:[e.jsx(He,{}),e.jsx("span",{"data-ouro-surface":"","aria-hidden":"true"}),e.jsxs("span",{"data-ouro-label":"",className:z("relative inline-flex items-center gap-[inherit] transition-opacity duration-(--ouro-duration-fast) ease-(--ouro-ease-out)",a&&"opacity-0"),children:[f&&e.jsx(f,{"aria-hidden":"true",className:z(At,"-ms-0.5")}),b,d&&e.jsx(d,{"aria-hidden":"true",className:z(At,"-me-0.5")})]}),a&&e.jsx(zo,{})]});if(v.href!==void 0){const{onClick:W,type:V,disabled:K,...C}=v;return e.jsx(qe,{"data-ouro-control":"button","data-ouro-part":"root",...C,reloadDocument:j,onClick:a?Et:W,onAuxClick:a?Et:C.onAuxClick,className:L,"data-ouro":"button","data-ouro-squircle":"","data-variant":l,"data-tone":E,"data-loading":a?"":void 0,"data-disabled":a?"":void 0,"aria-busy":a||C["aria-busy"],"aria-disabled":a||C["aria-disabled"],children:I})}const{ref:A,disabled:F,type:Q="button",...H}=v,X=H["aria-haspopup"]==="dialog"?{onPointerDown:W=>{var V;(V=H.onPointerDown)==null||V.call(H,W),ce.dialog.onPointerDown(W)},onKeyDown:W=>{var V;(V=H.onKeyDown)==null||V.call(H,W),ce.dialog.onKeyDown(W)}}:{},G=Bo.includes(Q)?Q:"button";return e.jsx(Gt,{"data-ouro-control":"button","data-ouro-part":"root",...H,...X,ref:k,type:G,disabled:!!(F||a),focusableWhenDisabled:!!(a&&!F),className:L,"data-ouro":"button","data-ouro-squircle":"","data-variant":l,"data-tone":E,"data-loading":a?"":void 0,"data-default":N?"":void 0,"aria-keyshortcuts":N?"Enter":H["aria-keyshortcuts"],"aria-busy":a||H["aria-busy"],children:I})}const Wo={mod:["Control","Meta"],cmd:["Meta"],command:["Meta"],meta:["Meta"],ctrl:["Control"],control:["Control"],alt:["Alt"],option:["Alt"],shift:["Shift"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"],arrowup:["ArrowUp"],arrowdown:["ArrowDown"],arrowleft:["ArrowLeft"],arrowright:["ArrowRight"],esc:["Escape"],escape:["Escape"],enter:["Enter"],return:["Enter"],del:["Delete"],delete:["Delete"],space:["Space"]};function Ko(t){let s=[[]];for(const o of t){const n=Wo[o.toLowerCase()]??[o.charAt(0).toUpperCase()+o.slice(1)];s=s.flatMap(r=>n.map(a=>[...r,a]))}return s.map(o=>o.join("+")).join(" ")}const Vo=["top","bottom","left","right"],ds=["start","center","end"];function us(t,s){return Vo.includes(t)?t:s}function Yo(t){return ds.includes(t)?t:"center"}const xs="relative isolate z-(--ouro-layer)",Qo="origin-(--transform-origin) [transition:transform_var(--ouro-floating-duration,var(--ouro-duration-base))_var(--ouro-ease-out),opacity_var(--ouro-floating-duration,var(--ouro-duration-base))_var(--ouro-ease-out)] data-starting-style:[transform:scale(0.96)] data-starting-style:opacity-0 data-ending-style:[transform:scale(0.96)] data-ending-style:opacity-0 data-ending-style:duration-(--ouro-duration-fast) motion-reduce:[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] motion-reduce:data-starting-style:[transform:none] motion-reduce:data-ending-style:[transform:none]";function Xo(t){const s=ns("(min-width: 640px)",!0);return t==="sheet"||t==="auto"&&!s}const ms=i.createContext(!1),Go=i.createContext(!1),Jo=i.createContext(!1);function mt({children:t}){return i.createElement(ms.Provider,{value:!0},t)}const Zo=()=>()=>{},en=t=>t&&"current"in t?t.current??void 0:t;function ps(t,s=!1){const{portalContainer:o}=os(),n=i.useContext(ms),r=i.useSyncExternalStore(Zo,()=>en(o),()=>{}),a=i.useRef(void 0),[c]=i.useState(()=>{const f=b=>{var x;(x=a.current)==null||x.call(a),a.current=b?Oo(b):void 0};return{hold:f,check:b=>{s&&f(b)}}});return n?s?{ref:c.hold}:{}:{...r?{container:r}:{},ref:c.check}}const Tt={mod:["⌘","Command","Ctrl"],cmd:["⌘","Command","Win"],ctrl:["⌃","Control","Ctrl"],alt:["⌥","Option","Alt"],shift:["⇧","Shift","Shift"],enter:["↩","Return","Enter"],escape:["Esc","","Esc"],tab:["⇥","Tab","Tab"],backspace:["⌫","Delete","Backspace"],delete:["⌦","Forward delete","Del"],space:["Space","","Space"],up:["↑","Up arrow","↑","Up arrow"],down:["↓","Down arrow","↓","Down arrow"],left:["←","Left arrow","←","Left arrow"],right:["→","Right arrow","→","Right arrow"]},Rt={meta:"cmd",command:"cmd",control:"ctrl",option:"alt",return:"enter",esc:"escape",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right"};function tn(){var o;const t=navigator,s=((o=t.userAgentData)==null?void 0:o.platform)??t.platform;return/mac|iphone|ipad|ipod|ios/i.test(s)?"apple":/^win/i.test(s)?"windows":"other"}const sn={ctrl:0,alt:1,shift:2,mod:3,cmd:3},on={cmd:0,mod:1,ctrl:1,alt:2,shift:3};function hs(t){const s=t.toLowerCase();return Object.hasOwn(Rt,s)?Rt[s]:s}const nn=()=>()=>{},rn=()=>"unknown";function Lt(t){return new RegExp("^(?!\\p{ASCII})\\p{Emoji}$","u").test(t)?`${t}︎`:t}function an(t,s){const o=hs(t);if(o==="cmd"&&s!=="apple")return{text:s==="windows"?"Win":"Ctrl",name:void 0};if(!Object.hasOwn(Tt,o))return{text:Lt(t.length===1?t.toUpperCase():t),name:void 0};const[n,r,a,c]=Tt[o];return s==="apple"?{text:Lt(n),name:r||void 0}:{text:a,name:c}}function ln(t){const{keys:s,className:o,children:n,shortcut:r,...a}=t,c=i.useSyncExternalStore(nn,tn,rn),f=typeof s=="string"?s.split("+"):s??[];de("Kbd",o,""),oe();const d=c==="apple",b=d?sn:on,x=y=>b[hs(y)]??4,w=[...f].sort((y,u)=>x(y)-x(u));return e.jsx("kbd",{...a,"data-ouro":"kbd","data-platform":d?"apple":c==="unknown"?"unknown":"other",className:z("box-border inline-flex h-[1.6em] min-w-[1.6em] items-center justify-center gap-[0.15em] align-[0.1em] rounded-sm border border-solid border-border bg-muted px-[0.35em] [font-family:inherit] text-[0.85em]/none font-medium text-foreground whitespace-nowrap select-none",o),children:w.map((y,u)=>{const{text:g,name:m}=an(y,c);return e.jsxs(i.Fragment,{children:[!d&&u>0&&"+",e.jsx("kbd",{className:"m-0 [font:inherit]",children:m?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true","data-glyph":"",children:g}),e.jsx("span",{className:"sr-only",children:m})]}):g})]},u)})})}const cn="outline-none",dn="outline-none fixed! inset-x-0! top-auto! bottom-0! w-auto! transform-none!",un="box-border min-w-48 max-w-(--available-width) max-h-(--available-height) overflow-y-auto overscroll-contain p-1 rounded-lg bg-popover text-popover-foreground outline-none ring-1 ring-border/60 shadow-(--shadow-lg) has-[[data-ouro-menu-indicator]]:[--ouro-menu-inset:1.5rem] origin-(--transform-origin) [transition:transform_var(--ouro-duration-fast)_var(--ouro-ease-out),opacity_var(--ouro-duration-fast)_var(--ouro-ease-out)] data-ending-style:[transform:scale(0.96)] data-ending-style:opacity-0 motion-reduce:[transition:opacity_var(--ouro-duration-fast)_var(--ouro-ease-out)] motion-reduce:data-ending-style:[transform:none] data-instant:[transition:none]",xn="box-border w-full max-h-[min(80dvh,calc(100dvh-4rem))] overflow-y-auto overscroll-contain px-2 pt-2 pb-[calc(env(safe-area-inset-bottom,0px)+0.5rem)] rounded-t-xl bg-popover text-popover-foreground outline-none [box-shadow:var(--ouro-shadow-sheet-bottom)] has-[[data-ouro-menu-indicator]]:[--ouro-menu-inset:1.5rem] [transition:transform_var(--ouro-duration-sheet)_var(--ouro-ease-drawer),opacity_var(--ouro-duration-fast)_var(--ouro-ease-out)] data-starting-style:[transform:translateY(100%)] data-ending-style:[transform:translateY(100%)] data-ending-style:duration-(--ouro-duration-base) motion-reduce:[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] motion-reduce:data-starting-style:[transform:none] motion-reduce:data-ending-style:[transform:none] motion-reduce:data-starting-style:opacity-0 motion-reduce:data-ending-style:opacity-0",mn="fixed inset-0 bg-(--ouro-backdrop-color) opacity-(--ouro-backdrop-max) transition-opacity duration-(--ouro-duration-base) ease-(--ouro-ease-out) data-starting-style:opacity-0 data-ending-style:opacity-0",fe="relative m-0 box-border flex w-full min-h-11 pointer-fine:min-h-8 cursor-default items-center gap-3 rounded-md py-1.5 pe-2 ps-[calc(0.5rem+var(--ouro-menu-inset,0px))] text-start text-base leading-5 pointer-fine:text-sm text-popover-foreground no-underline outline-none select-none [-webkit-tap-highlight-color:transparent] data-highlighted:bg-accent data-highlighted:text-accent-foreground active:bg-accent active:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground forced-colors:data-highlighted:bg-[Highlight] forced-colors:data-highlighted:text-[HighlightText] forced-colors:data-popup-open:bg-[Highlight] forced-colors:data-popup-open:text-[HighlightText] aria-[current=page]:font-medium aria-[current=page]:before:absolute aria-[current=page]:before:inset-y-2 aria-[current=page]:before:start-0 aria-[current=page]:before:w-0.5 aria-[current=page]:before:rounded-full aria-[current=page]:before:bg-current aria-[current=page]:before:content-[''] forced-colors:aria-[current=page]:before:border-s-2 forced-colors:aria-[current=page]:before:border-solid forced-colors:aria-[current=page]:before:border-current data-[tone=destructive]:text-[color-mix(in_oklab,var(--destructive)_80%,var(--foreground))] data-[tone=destructive]:data-highlighted:bg-destructive/10 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",fs="absolute start-2 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center",gs="box-border py-1.5 pe-2 ps-[calc(0.5rem+var(--ouro-menu-inset,0px))] text-xs leading-4 font-medium text-muted-foreground select-none",bs="-mx-1 my-1 h-px border-0 bg-border",pn="absolute",hn="relative m-0 box-border inline-flex h-11 pointer-fine:h-8 items-center rounded-md border-0 bg-transparent px-3 font-[inherit] text-base pointer-fine:text-sm leading-5 font-medium text-foreground cursor-default select-none [-webkit-tap-highlight-color:transparent] outline-ring focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-solid pointer-fine:hover:bg-accent pointer-fine:hover:text-accent-foreground active:bg-accent active:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground data-disabled:opacity-50",fn="data-ouro-pressing:select-none data-ouro-pressing:[-webkit-touch-callout:none]",it=i.createContext(null),vs=i.createContext(!1),js=i.createContext(!1);function be(t,s){const o=i.useContext(it);return o||se(t,"must be rendered inside <Menu>"),o}function lt(t){return t.map((s,o)=>{switch(s.type){case"separator":return e.jsx(kn,{},o);case"checkbox":return e.jsx(vn,{checked:s.checked,defaultChecked:s.defaultChecked,onCheckedChange:s.onCheckedChange,shortcut:s.shortcut,disabled:s.disabled,axAction:s.axAction,children:s.label},o);case"radio":return e.jsx(jn,{label:s.label,value:s.value,defaultValue:s.defaultValue,onValueChange:s.onValueChange,children:s.options.map(n=>e.jsx(wn,{value:n.value,shortcut:n.shortcut,disabled:n.disabled,children:n.label},n.value))},o);case"group":return e.jsx(Nn,{label:s.label,children:lt(s.items)},o);case"submenu":return e.jsx(yn,{label:s.label,disabled:s.disabled,backLabel:s.backLabel,children:lt(s.items)},o);default:return e.jsxs(Ns,{onClick:s.onClick,href:s.href,shortcut:s.shortcut,tone:s.tone,disabled:s.disabled,axAction:s.axAction,children:[s.icon!==void 0&&e.jsx("span",{"aria-hidden":"true","data-ouro-menu-icon":"",className:"flex shrink-0",children:s.icon}),s.label]},o)}})}function Ye(t){return s=>s.currentTarget.toggleAttribute("data-ouro-pressing",t)}function De({sheet:t,context:s,side:o,align:n,className:r,children:a,closeLabel:c,anchor:f,point:d,label:b,finalFocus:x}){const w=s?Hs:qs,y=ps("Menu",!0),u=i.useContext(it)!==null,g=i.useContext(vs),m=u||g,j=i.useRef(null);i.useLayoutEffect(()=>{const v=j.current;if(v===null)return;const E=()=>{for(const S of v.querySelectorAll("[data-base-ui-focus-guard][role]"))S.removeAttribute("role"),S.setAttribute("aria-hidden","true")},l=new MutationObserver(E);return l.observe(v,{subtree:!0,attributeFilter:["role"]}),()=>l.disconnect()},[]);const N=e.jsx(Bs,{...y,"data-ouro":"menu-portal",className:xs,children:e.jsxs(mt,{children:[t&&e.jsx(zs,{"data-ouro":"menu-backdrop",className:mn}),e.jsx(w,{"data-ouro":"menu-positioner",className:t?dn:cn,sideOffset:s||d?0:4,collisionPadding:8,...f!==void 0?{anchor:f}:{},...f!==void 0?{positionMethod:"fixed"}:{},...o?{side:o}:{},...n?{align:n}:{},children:e.jsxs(Fs,{"data-ouro":"menu","data-ouro-presentation":t?"sheet":"menu","aria-label":b,...x!==void 0?{finalFocus:x}:{},className:z(t?xn:un,t?void 0:r),children:[e.jsx(it.Provider,{value:{sheet:t},children:a}),t&&c!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx(Jt,{className:bs}),e.jsx(dt,{"data-ouro-menu-close":"","data-ouro-control":"menu","data-ouro-part":"close",className:fe,children:e.jsx("span",{"data-ouro-menu-label":"",children:c})})]})]})})]})});return m?e.jsx("span",{ref:j,"data-ouro-menu-guards":"",className:pn,children:N}):N}function gn(t){const{trigger:s,contextTrigger:o,label:n,anchor:r,"aria-label":a,returnFocus:c,items:f,children:d,side:b,align:x,className:w,closeLabel:y="Close",modal:u,open:g,onOpenChange:m,isOpen:j,onClose:N,placement:v,asChild:E,options:l}=t,S=i.useContext(vs),R=[s,o,n,r].filter(K=>K!==void 0).length;R===0&&se("Menu","needs trigger, contextTrigger, label or anchor"),R>1&&se("Menu","takes one of trigger, contextTrigger, label and anchor"),r!==void 0&&g===void 0&&se("Menu","anchor needs open: the app opens a menu it anchors"),r!==void 0&&!a&&se("Menu","anchor needs aria-label: no button names the menu"),S&&n===void 0&&se("Menu","a Menu inside <MenuBar> takes label, not trigger or contextTrigger"),!S&&n!==void 0&&se("Menu","label is for a Menu inside <MenuBar>"),f===void 0&&d===void 0&&se("Menu","needs items or children"),f!==void 0&&d!==void 0&&se("Menu","takes items or children, not both"),g!==void 0&&typeof m!="function"&&se("Menu","open needs onOpenChange");const T=o!==void 0,M=r!==void 0&&!("getBoundingClientRect"in r)?r:void 0,h=us(b,"bottom"),p=ds.includes(x)?x:"start";de("Menu",w,""),oe();const k=Xo(T||M!==void 0?"menu":"auto"),L=f!==void 0?lt(f):d,[I,A]=i.useState(!1),F=g??I,Q=i.useRef(null),H=i.useRef(null),X=i.useRef(null);i.useEffect(()=>{var O;const K=r!==void 0?document:(O=X.current)==null?void 0:O.ownerDocument;if(!F||K===void 0)return;H.current=null;const C=q=>{var D;const $=q.target;(D=X.current)!=null&&D.contains($)||$.closest('[data-ouro="menu-positioner"], [data-base-ui-focus-guard]')||(H.current=$,Q.current.close())};return K.addEventListener("focusin",C),()=>K.removeEventListener("focusin",C)},[F,r]);const G=i.useRef(c);i.useLayoutEffect(()=>{G.current=c});const W=K=>{A(K),m==null||m(K),!(r===void 0||K)&&setTimeout(()=>{var O,q;const C=document.activeElement;C!==document.body&&C.closest('[data-ouro="menu-positioner"]')===null||(q=(O=H.current)!=null&&O.isConnected?H.current:G.current)==null||q.focus({preventScroll:!0})})},V=g!==void 0?{open:g,onOpenChange:W}:{onOpenChange:W};if(r!==void 0){const K=M===void 0?r:{getBoundingClientRect:()=>new DOMRect(M.x,M.y,0,0)},C=()=>!1;return e.jsx(bt,{...V,actionsRef:Q,modal:k,children:e.jsx(De,{sheet:k,context:!1,side:h,align:M===void 0?p:"start",className:w,closeLabel:y,anchor:K,point:M!==void 0,label:a,finalFocus:C,children:L})})}return T?e.jsxs(Ds,{...V,children:[e.jsx(Ps,{render:o,className:fn,...ce.contextMenu,style:{WebkitTouchCallout:void 0},onTouchStart:Ye(!0),onTouchEnd:Ye(!1),onTouchCancel:Ye(!1)}),e.jsx(De,{sheet:!1,context:!0,className:w,children:L})]}):e.jsxs(bt,{...V,actionsRef:Q,modal:n===void 0?k||u:void 0,children:[n!==void 0?e.jsx(vt,{"data-ouro-control":"menu","data-ouro-part":"bar-trigger",className:hn,...ce.listButton,children:n}):e.jsx(vt,{ref:X,render:s,...ce.listButton}),e.jsx(De,{sheet:k,context:!1,side:h,align:p,className:w,closeLabel:y,finalFocus:bn,children:L})]})}function bn(){if(document.querySelector('[data-ouro="menu"][data-open]')!==null)return!1;const t=document.activeElement;return t===document.body||t.closest('[data-ouro="menu"]')!==null}function ws(t){return typeof t=="string"?t.split("+"):t}function pt(t){const s=ws(t);return s?{"aria-keyshortcuts":Ko(s)}:{}}function ht({children:t,shortcut:s}){const o=ws(s);return e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-ouro-menu-label":"",className:"flex min-w-0 flex-1 items-center gap-2",children:t}),o&&e.jsx(ln,{keys:o,"aria-hidden":"true",className:"ms-auto"})]})}function Ns(t){const{children:s,onClick:o,href:n,current:r,shortcut:a,tone:c,disabled:f,axAction:d,onSelect:b,variant:x,asChild:w,checked:y}=t;be("MenuItem");const u=c==="destructive"?"destructive":void 0;oe();const g={className:fe,"data-ouro-control":"menu","data-ouro-part":"item","data-tone":u,"data-ax-action":d,...pt(a),...o?{onClick:j=>o(j)}:{}},m=e.jsx(ht,{shortcut:a,children:s});return n!==void 0&&!f?e.jsx(Us,{...g,"aria-current":r?"page":void 0,closeOnClick:!0,render:e.jsx(qe,{href:n}),children:m}):e.jsx(dt,{...g,disabled:f,children:m})}function ys(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M3.5 8.5 6.5 11.5 12.5 4.5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function vn({children:t,shortcut:s,onCheckedChange:o,axAction:n,...r}){return be("MenuCheckboxItem"),oe(),e.jsxs(Gs,{"data-ouro-control":"menu","data-ouro-part":"checkbox-item","data-ax-action":n,...r,...pt(s),...o?{onCheckedChange:a=>o(a)}:{},className:fe,children:[e.jsx("span",{"data-ouro-menu-indicator":"",className:fs,children:e.jsx(Js,{className:"flex",children:e.jsx(ys,{})})}),e.jsx(ht,{shortcut:s,children:t})]})}function jn({children:t,label:s,onValueChange:o,...n}){return be("MenuRadioGroup"),e.jsxs(Ys,{...n,...o?{onValueChange:r=>o(r)}:{},children:[s!==void 0&&e.jsx(Zt,{className:gs,children:s}),e.jsx(js.Provider,{value:!0,children:t})]})}function wn({children:t,shortcut:s,...o}){return i.useContext(js)||se("MenuRadioItem","must be rendered inside <MenuRadioGroup>"),oe(),e.jsxs(Qs,{"data-ouro-control":"menu","data-ouro-part":"radio-item",...o,...pt(s),className:fe,children:[e.jsx("span",{"data-ouro-menu-indicator":"",className:fs,children:e.jsx(Xs,{className:"flex",children:e.jsx(ys,{})})}),e.jsx(ht,{shortcut:s,children:t})]})}function Nn({label:t,children:s}){return be("MenuGroup"),oe(),e.jsxs(Vs,{children:[e.jsx(Zt,{className:gs,children:t}),s]})}function It({back:t}){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",fill:"none",className:t?"rotate-180 rtl:rotate-0":"ms-auto rtl:rotate-180",children:e.jsx("path",{d:"M6 3.5 10.5 8 6 12.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function yn({label:t,children:s,disabled:o,backLabel:n="Back"}){const{sheet:r}=be("MenuSub"),[a,c]=i.useState(!1);return e.jsxs(Ws,{open:a,onOpenChange:c,disabled:o,children:[e.jsxs(Ks,{"data-ouro-control":"menu","data-ouro-part":"submenu-trigger",className:fe,disabled:o,openOnHover:!r,children:[e.jsx("span",{"data-ouro-menu-label":"",className:"flex min-w-0 flex-1 items-center gap-2",children:t}),e.jsx(It,{})]}),e.jsxs(De,{sheet:r,context:!1,children:[r&&e.jsxs(dt,{"data-ouro-menu-back":"","data-ouro-control":"menu","data-ouro-part":"back",className:fe,closeOnClick:!1,onClick:()=>c(!1),children:[e.jsx(It,{back:!0}),e.jsx("span",{"data-ouro-menu-label":"",children:n})]}),s]})]})}function kn(){return be("MenuSeparator"),e.jsx(Jt,{className:bs})}function Cn(t){return i.useCallback(s=>{if(!CSS.supports("-webkit-touch-callout","none"))return ze(t,s);const o=()=>{const a=Number.parseFloat(s.style.getPropertyValue("--ouro-backdrop-top"))||0;s.style.setProperty("--ouro-backdrop-top",`${a-s.getBoundingClientRect().top}px`)};o();const n=requestAnimationFrame(o);addEventListener("scroll",o,{passive:!0}),addEventListener("resize",o);const r=ze(t,s);return()=>{cancelAnimationFrame(n),removeEventListener("scroll",o),removeEventListener("resize",o),r()}},[t])}function Sn(t){return i.useCallback(s=>{if(!s||!t)return;const o=()=>{const c=s.scrollWidth>s.clientWidth&&/auto|scroll/.test(getComputedStyle(s).overflowX);s.scrollHeight>s.clientHeight||c?s.setAttribute("tabindex","0"):s!==s.ownerDocument.activeElement&&s.removeAttribute("tabindex")},n=new ResizeObserver(o),r=()=>{n.disconnect(),n.observe(s);for(const c of s.children)n.observe(c)},a=new MutationObserver(r);return r(),a.observe(s,{childList:!0,subtree:!0,characterData:!0}),s.addEventListener("blur",o),()=>{n.disconnect(),a.disconnect(),s.removeEventListener("blur",o)}},[t])}const $n=["bottom","top","left","right"],An="supports-[-webkit-touch-callout:none]:absolute supports-[-webkit-touch-callout:none]:inset-x-0 supports-[-webkit-touch-callout:none]:top-[var(--ouro-backdrop-top,0px)] supports-[-webkit-touch-callout:none]:bottom-auto supports-[-webkit-touch-callout:none]:h-lvh",En="box-border flex shrink-0 justify-end gap-3 px-5 pt-3 pb-5 max-sm:flex-col max-sm:*:w-full";function Tn(){const t=[...["--ouro-sheet-x","--ouro-sheet-y","--ouro-sheet-grab"].map(s=>({name:s,syntax:"<length>",inherits:!1,initialValue:"0px"})),{name:"--ouro-sheet-transform",syntax:"*",inherits:!1},...["--drawer-swipe-movement-x","--drawer-swipe-movement-y","--drawer-snap-point-offset"].map(s=>({name:s,syntax:"<length>",inherits:!1,initialValue:"0px"})),{name:"--drawer-swipe-progress",syntax:"<number>",inherits:!1,initialValue:"0"},{name:"--drawer-swipe-strength",syntax:"<number>",inherits:!1,initialValue:"1"},{name:"--drawer-frontmost-height",syntax:"*",inherits:!1}];for(const s of t)try{CSS.registerProperty(s)}catch{}}const ks=i.createContext(null),Rn={bottom:"down",top:"up",left:"left",right:"right"};Tn();const Ln="fixed inset-0 z-1000 min-h-dvh bg-(--ouro-backdrop-color) opacity-[calc(var(--ouro-backdrop-max)*(1-var(--drawer-swipe-progress,0)))] [transition:opacity_var(--ouro-duration-sheet)_var(--ouro-ease-drawer)] data-starting-style:opacity-0 data-ending-style:opacity-0 data-ending-style:duration-(--ouro-duration-slow) data-ending-style:ease-(--ouro-ease-out) data-swiping:duration-0 data-swipe-dismiss:data-ending-style:duration-(--ouro-duration-fast) "+An,In={bottom:"items-end justify-center",top:"items-start justify-center",left:"[justify-content:left]",right:"[justify-content:right]"},Mn="[--ouro-sheet-stretch:3.5] [--ouro-sheet-slack:calc(var(--ouro-sheet-stretch)*0.25px)] [--ouro-sheet-gap:2rem] relative box-border flex min-h-0 flex-col outline-none touch-none bg-popover text-popover-foreground [-webkit-tap-highlight-color:transparent] [transition:transform_calc(var(--ouro-duration-sheet)*var(--drawer-swipe-strength,1))_var(--ouro-ease-drawer)] will-change-transform [transform:var(--ouro-sheet-transform)] data-swiping:select-none data-swiping:[transform:var(--ouro-sheet-transform)]! not-data-swiping:[--ouro-sheet-grab:0px]! after:pointer-events-none after:absolute after:bg-inherit motion-reduce:[transition:transform_0s,opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] motion-reduce:data-starting-style:[transform:var(--ouro-sheet-transform)] motion-reduce:data-starting-style:opacity-0 motion-reduce:data-ending-style:[transform:var(--ouro-sheet-transform)] motion-reduce:data-ending-style:opacity-0",_n={bottom:"w-full max-w-[40rem] max-h-[calc(100dvh-var(--ouro-sheet-gap))] ps-[env(safe-area-inset-left,0px)] pe-[env(safe-area-inset-right,0px)] [--ouro-sheet-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px))] [--ouro-sheet-transform:translateY(calc(max(var(--ouro-sheet-y),0px)+min(var(--ouro-sheet-y)+var(--ouro-sheet-slack),0px)*var(--ouro-sheet-stretch)+var(--ouro-sheet-grab,0px)))] rounded-t-xl [box-shadow:var(--ouro-shadow-sheet-bottom)] after:inset-x-0 after:top-[calc(100%-1px)] after:h-[50dvh] data-starting-style:[transform:translateY(calc(100%+2px))] data-ending-style:[transform:translateY(calc(100%+2px))]",top:"w-full max-w-[40rem] max-h-[calc(100dvh-var(--ouro-sheet-gap))] ps-[env(safe-area-inset-left,0px)] pe-[env(safe-area-inset-right,0px)] [--ouro-sheet-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px))] [--ouro-sheet-transform:translateY(calc(min(var(--ouro-sheet-y),0px)+max(var(--ouro-sheet-y)-var(--ouro-sheet-slack),0px)*var(--ouro-sheet-stretch)+var(--ouro-sheet-grab,0px)))] rounded-b-xl [box-shadow:var(--ouro-shadow-sheet-top)] pt-[env(safe-area-inset-top,0px)] after:inset-x-0 after:bottom-[calc(100%-1px)] after:h-[50dvh] data-starting-style:[transform:translateY(calc(-100%-2px))] data-ending-style:[transform:translateY(calc(-100%-2px))]",left:"h-full w-[min(22rem,calc(100vw-3rem))] pt-[env(safe-area-inset-top,0px)] pb-[calc(env(safe-area-inset-bottom,0px)+var(--drawer-keyboard-inset,0px))] [--ouro-sheet-x:var(--drawer-swipe-movement-x,0px)] [--ouro-sheet-transform:translateX(calc(min(var(--ouro-sheet-x),0px)+max(var(--ouro-sheet-x)-var(--ouro-sheet-slack),0px)*var(--ouro-sheet-stretch)+var(--ouro-sheet-grab,0px)))] rounded-r-xl [box-shadow:var(--ouro-shadow-sheet-left)] pl-[env(safe-area-inset-left,0px)] after:inset-y-0 after:right-[calc(100%-1px)] after:w-[50vw] data-starting-style:[transform:translateX(calc(-100%-2px))] data-ending-style:[transform:translateX(calc(-100%-2px))]",right:"h-full w-[min(22rem,calc(100vw-3rem))] pt-[env(safe-area-inset-top,0px)] pb-[calc(env(safe-area-inset-bottom,0px)+var(--drawer-keyboard-inset,0px))] [--ouro-sheet-x:var(--drawer-swipe-movement-x,0px)] [--ouro-sheet-transform:translateX(calc(max(var(--ouro-sheet-x),0px)+min(var(--ouro-sheet-x)+var(--ouro-sheet-slack),0px)*var(--ouro-sheet-stretch)+var(--ouro-sheet-grab,0px)))] rounded-l-xl [box-shadow:var(--ouro-shadow-sheet-right)] pr-[env(safe-area-inset-right,0px)] after:inset-y-0 after:left-[calc(100%-1px)] after:w-[50vw] data-starting-style:[transform:translateX(calc(100%+2px))] data-ending-style:[transform:translateX(calc(100%+2px))]"},On={fit:"pb-[calc(env(safe-area-inset-bottom,0px)+var(--drawer-keyboard-inset,0px))]",snap:"h-[calc(100dvh-var(--ouro-sheet-gap))] pb-[calc(env(safe-area-inset-bottom,0px)+var(--drawer-keyboard-inset,0px)+max(0px,var(--drawer-snap-point-offset,0px)))]"};function ne(t,s){const o=i.useContext(ks);return o||se(t,"must be rendered inside <SheetRoot>"),o}function Dn({side:t="bottom",snapPoints:s,...o}){const n=o.modal!==!1,r=$n.includes(t)?t:"bottom";oe();const a=!!(s&&s.length>0);return e.jsx(ks.Provider,{value:{side:r,snap:a,modal:n},children:e.jsx(Zs,{...o,disablePointerDismissal:o.disablePointerDismissal??!n,...s?{snapPoints:s}:{},swipeDirection:Rn[r]})})}function Pn({onPointerDown:t,onKeyDown:s,...o}){return ne("SheetTrigger"),e.jsx(eo,{...o.render===void 0?{className:"forced-colors:border forced-colors:border-solid","data-ouro-control":"sheet","data-ouro-part":"trigger"}:{},...o,onPointerDown:n=>{t==null||t(n),ce.dialog.onPointerDown(n)},onKeyDown:n=>{s==null||s(n),ce.dialog.onKeyDown(n)}})}function Un(t){return ne("SheetPortal"),e.jsx(to,{children:e.jsx(so,{...t,"data-ouro":"sheet-portal",className:"relative isolate z-(--ouro-layer) [--drawer-keyboard-inset:0px]",children:e.jsx(mt,{children:t.children})})})}function Bn({ref:t,...s}){ne("SheetBackdrop");const o=Cn(t);return e.jsx(oo,{...s,ref:o,"data-ouro":"sheet-backdrop",className:Ln})}function zn(t){return i.useCallback(s=>{const o=t==="left"||t==="right";let n=!1;const r=()=>{const d=s.querySelector('[data-ouro="sheet"]');if(!d||d.style.transitionProperty==="none")return!1;const b=getComputedStyle(d),x=new DOMMatrixReadOnly(b.transform),w=o?0:parseFloat(b.getPropertyValue("--drawer-snap-point-offset"));return d.style.setProperty("--ouro-sheet-grab",`${(o?x.m41:x.m42)-w}px`),d.getAnimations().length>0},a=d=>{n=s.contains(d.target)&&r()},c=()=>{n&&(n=r())},f=()=>{n=!1};return addEventListener("pointerdown",a,!0),addEventListener("pointermove",c,!0),addEventListener("pointerup",f,!0),addEventListener("pointercancel",f,!0),()=>{removeEventListener("pointerdown",a,!0),removeEventListener("pointermove",c,!0),removeEventListener("pointerup",f,!0),removeEventListener("pointercancel",f,!0)}},[t])}function Hn({ref:t,...s}){const{side:o,modal:n}=ne("SheetViewport"),r=Ee(t,zn(o));return e.jsx(no,{...s,ref:r,"data-ouro":"sheet-viewport","data-side":o,className:z("fixed inset-0 z-1000 flex overflow-clip touch-none",!n&&"pointer-events-none",In[o])})}function qn({className:t,...s}){const{side:o,snap:n,modal:r}=ne("SheetPopup");return e.jsx(ro,{...s,className:z(Mn,_n[o],o==="bottom"&&On[n?"snap":"fit"],o==="top"&&n&&"h-[calc(100dvh-var(--ouro-sheet-gap))]",!r&&"pointer-events-auto",t),"aria-modal":r?"true":void 0,"data-ouro":"sheet","data-side":o,"data-snap-points":n?"":void 0,"data-modal":r?void 0:"false"})}function Mt(){const{side:t}=ne("SheetHandle");return t==="left"||t==="right"?null:e.jsx("div",{"aria-hidden":"true","data-ouro-sheet-handle":"",className:"flex shrink-0 justify-center py-2 touch-none",children:e.jsx("div",{className:"h-1.25 w-9 rounded-full bg-border"})})}function Fn({visuallyHidden:t,...s}){return ne("SheetTitle"),e.jsx(co,{...s,"data-ouro-sheet-title":"",className:t?"sr-only":"m-0 font-[family-name:var(--font-heading,inherit)] text-lg leading-6 font-semibold text-balance text-popover-foreground"})}function Wn(t){return ne("SheetDescription"),e.jsx(ao,{...t,"data-ouro-sheet-description":"",className:"m-0 text-sm leading-5 text-muted-foreground"})}function Kn({className:t,ref:s,...o}){const n=Ee(s,Sn(o.tabIndex===void 0));return ne("SheetContent"),de("SheetContent",t,""),e.jsxs("div",{className:"relative box-border flex min-h-0 flex-1 flex-col",children:[e.jsx(io,{"data-ouro-control":"sheet","data-ouro-part":"content",...o,ref:n,"data-ouro-sheet-content":"",className:z("peer box-border min-h-0 flex-1 overflow-y-auto overscroll-contain touch-auto px-5 pt-2 pb-5 outline-none focus-visible:isolate","forced-colors:[&[tabindex='0']]:outline-1 forced-colors:[&[tabindex='0']]:outline-solid forced-colors:[&[tabindex='0']]:-outline-offset-1",t)}),e.jsx("span",{"aria-hidden":"true","data-sheet-focus-ring":"",className:"pointer-events-none absolute inset-0 hidden rounded-[inherit] outline-ring -outline-offset-2 peer-focus-visible:block peer-focus-visible:outline-2 peer-focus-visible:outline-solid"})]})}function Vn(t){return ne("SheetClose"),e.jsx(lo,{...t.render===void 0?{className:"forced-colors:border forced-colors:border-solid","data-ouro-control":"sheet","data-ouro-part":"close"}:{},...t})}const Yn="press absolute end-3 z-1 m-0 box-border inline-flex size-8 cursor-default items-center justify-center rounded-lg border-0 bg-transparent p-0 text-muted-foreground outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid pointer-fine:hover:bg-muted pointer-fine:hover:text-foreground motion-safe:active:scale-(--ouro-press-scale) forced-colors:border forced-colors:border-solid disabled:cursor-not-allowed disabled:opacity-50";function Qn({title:t,hideTitle:s,closeLabel:o,description:n,side:r,snapPoints:a,modal:c=!0,children:f,className:d,trigger:b,open:x,onOpenChange:w,footer:y,presentation:u,finalFocus:g,closeDisabled:m,keepMounted:j,onOpenChangeComplete:N}){const v=!s||n!==void 0||!c,E=e.jsx(Fn,{visuallyHidden:s,children:t});return e.jsxs(Dn,{side:r,snapPoints:a,modal:c,...x!==void 0?{open:x,onOpenChange:l=>w(l)}:{},...N?{onOpenChangeComplete:N}:{},children:[b!==void 0&&e.jsx(Pn,{render:b}),e.jsxs(Un,{keepMounted:j,children:[c&&e.jsx(Bn,{}),e.jsx(Hn,{children:e.jsxs(qn,{className:d,"data-ouro-presentation":u,...g?{finalFocus:g}:{},children:[r==="bottom"&&e.jsx(Mt,{}),v?e.jsxs("div",{"data-ouro-sheet-header":"",className:"grid min-h-12 shrink-0 gap-1 ps-5 pe-14 pt-3 pb-2",children:[E,n!==void 0&&e.jsx(Wn,{children:n})]}):E,e.jsx(Kn,{children:f}),y!==void 0&&e.jsx("div",{"data-ouro-footer":"",className:En,children:y}),r==="top"&&e.jsx(Mt,{}),e.jsxs(Vn,{"data-ouro-sheet-close":"",disabled:m,className:`${Yn} ${r==="bottom"&&v?"top-8.25":"top-3"}`,children:[e.jsx(He,{}),e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",fill:"none",className:"size-4",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),e.jsx("span",{className:"sr-only",children:o})]})]})})]})]})}let Pe="";function Xn(){return Pe}/* istanbul ignore else @preserve -- the else path is server rendering, which has no document */typeof document<"u"&&(document.addEventListener("pointerdown",t=>Pe=t.pointerType,!0),document.addEventListener("keydown",()=>Pe="keyboard",!0),document.addEventListener("pointermove",t=>{(t.pointerType==="mouse"||t.pointerType==="pen")&&(Pe=t.pointerType)},!0));const Gn=t=>(t==null?void 0:t.$$typeof)===Symbol.for("react.lazy");function Jn(t){const s=[];return i.Children.forEach(t,o=>s.push(o)),s}function Zn(t){if(!Gn(t))return t;const s=Jn(t);return s.length===1&&i.isValidElement(s[0])?s[0]:t}const er=Qo+" box-border max-w-xs rounded-md bg-foreground px-2 py-1 text-xs leading-4 text-balance text-background [--ouro-floating-duration:var(--ouro-duration-fast)] data-instant:duration-0",tr=600,sr=400,_t=100,we={count:0,closedAt:Number.NEGATIVE_INFINITY};function Ot(t){const{content:s,children:o,side:n,align:r,title:a,delayDuration:c,delay:f,asChild:d,placement:b,ref:x,...w}=t,y=us(n,"top"),u=Yo(r);i.useRef({});const g=i.useRef(null),m=Zn(o),j=Ee(m.props.ref,Ee(x,g));oe(),i.useEffect(()=>{});const N=i.useCallback(A=>{},[]),v=i.useContext(Jo),[E,l]=i.useState(!1),[S,R]=i.useState(!1),T=i.useRef(void 0),M=A=>{Xn()!=="touch"&&R(A)},h=(A,F)=>{clearTimeout(T.current),T.current=setTimeout(F,A)},p=()=>{clearTimeout(T.current),R(!1)};i.useEffect(()=>{if(S)return we.count+=1,()=>{we.count-=1,we.closedAt=performance.now()}},[S]);const k=i.useContext(Go);i.useLayoutEffect(()=>{k&&p()},[k]);const L=ps(),I=i.cloneElement(m,uo(w,m.props,{ref:j,"data-popup-open":S?"":void 0,"data-base-ui-tooltip-trigger":"",onPointerEnter:A=>{A.pointerType!=="touch"&&(l(!0),v&&(we.count>0||A.timeStamp-we.closedAt<sr)?M("delay"):h(tr,()=>M("now")))},onPointerLeave:()=>h(_t,()=>R(!1)),onFocus:A=>{A.currentTarget.matches(":focus-visible")&&(l(!0),clearTimeout(T.current),M("focus"))},onBlur:p,onKeyDown:A=>{A.key!=="Escape"||!S||(p(),A.preventDefault(),A.stopPropagation())},onPointerDown:p}));return E?e.jsxs(e.Fragment,{children:[I,e.jsx(xo,{open:S!==!1,onOpenChange:p,children:e.jsx(mo,{...L,"data-ouro":"tooltip-portal",className:xs,children:e.jsx(mt,{children:e.jsx(po,{anchor:g,side:y,align:u,sideOffset:6,collisionPadding:8,"data-ouro":"tooltip-positioner",children:e.jsx(ho,{ref:N,"data-ouro":"tooltip","data-instant":S==="focus"||S==="delay"?S:void 0,onPointerEnter:()=>clearTimeout(T.current),onPointerLeave:()=>h(_t,()=>R(!1)),className:er,children:s})})})})})]}):I}const or="box-border flex h-full w-(--ouro-sidebar-w) flex-col overflow-hidden border-0 border-e border-solid border-border bg-background text-foreground [--ouro-sidebar-w:16rem] data-collapsed:[--ouro-sidebar-w:calc(3.75rem+1px)] max-sm:hidden",Dt="ms-auto shrink-0 rounded-sm bg-muted px-1.5 text-xs leading-5 font-medium text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))] tabular-nums",Ne="relative m-0 box-border flex w-full min-h-11 pointer-fine:min-h-9 cursor-pointer items-center gap-3 rounded-md border-0 forced-colors:border forced-colors:border-solid bg-transparent px-3 py-2 text-start font-[inherit] text-base pointer-fine:text-sm leading-5 font-medium text-muted-foreground no-underline select-none touch-manipulation [-webkit-tap-highlight-color:transparent] transition-colors duration-(--ouro-duration-fast) ease-[ease] pointer-fine:hover:bg-accent pointer-fine:hover:text-accent-foreground active:bg-accent active:text-accent-foreground aria-[current=page]:font-semibold aria-[current=page]:text-foreground aria-[current=page]:before:absolute aria-[current=page]:before:inset-y-2 aria-[current=page]:before:start-0 aria-[current=page]:before:w-0.5 aria-[current=page]:before:rounded-full aria-[current=page]:before:bg-current aria-[current=page]:before:content-[''] forced-colors:aria-[current=page]:before:border-s-2 forced-colors:aria-[current=page]:before:border-solid forced-colors:aria-[current=page]:before:border-current outline-ring -outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid",Re="justify-center px-0",Pt="flex size-5 shrink-0 items-center justify-center text-sm [&_svg]:size-5 [&_svg]:shrink-0",Ut="m-0 grid list-none gap-1 p-0";function nr(t){const{label:s,sections:o,currentPath:n,header:r,footer:a,collapsible:c=!0,collapsed:f,defaultCollapsed:d=!1,onCollapsedChange:b,collapseLabel:x="Collapse sidebar",menuLabel:w="Menu",closeLabel:y="Close",className:u,ref:g,items:m,isCollapsed:j,pathname:N,children:v}=t;de("Sidebar",u,""),o.flatMap(C=>C.items).find(C=>C.items!==void 0),oe();const E=ns("(min-width: 640px)",!0),[l,S]=i.useState(!1),R=i.useRef(null);E&&l&&S(!1);const[T,M]=i.useState(d),h=f??T,p=()=>{M(!h),b==null||b(!h)},L=o.flatMap(C=>C.items.flatMap(O=>O.items!==void 0?O.items:[O])).filter(C=>C.href!==void 0),I=L.some(C=>C.current)?void 0:yo(L.map(C=>C.href),n),A=C=>C.href!==void 0&&(!!C.current||C.href===I),[F,Q]=i.useState({}),H=(C,O)=>F[C]??O.items.some(A),X=i.useId(),G=(C,O)=>e.jsxs(e.Fragment,{children:[(C.icon!==void 0||O)&&e.jsx("span",{"aria-hidden":"true",className:Pt,children:C.icon!==void 0?C.icon:C.label.charAt(0).toUpperCase()}),e.jsx("span",{className:O?"sr-only":"min-w-0 flex-1 truncate",children:C.label}),C.badge!==void 0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{"data-ouro-sidebar-badge":"",className:O?"sr-only":Dt,children:C.badge})]})]}),W=(C,O,q)=>C?e.jsx(Ot,{content:O,side:"right",children:q}):q,V=(C,O,q)=>W(O,C.label,C.href!==void 0?e.jsx(qe,{href:C.href,"aria-current":A(C)?"page":void 0,"data-ouro-control":"sidebar","data-ouro-part":"link",onClick:$=>{var D;q==null||q(),(D=C.onClick)==null||D.call(C,$)},className:z(Ne,O&&Re),children:G(C,O)}):e.jsx("button",{type:"button","data-ouro-control":"sidebar","data-ouro-part":"button",onClick:$=>{q==null||q(),C.onClick($)},className:z(Ne,O&&Re),children:G(C,O)})),K=(C,O,q)=>o.map(($,D)=>e.jsxs("div",{className:z("grid gap-1",D>0&&"border-0 border-t border-solid border-border pt-4"),children:[$.label!==void 0&&e.jsx("p",{id:`${X}${C}${D}`,className:O?"sr-only":"m-0 px-3 py-1 text-sm leading-5 font-semibold text-foreground",children:$.label}),e.jsx("ul",{"aria-labelledby":$.label!==void 0?`${X}${C}${D}`:void 0,className:Ut,children:$.items.map((B,J)=>{if(B.items===void 0)return e.jsx("li",{children:V(B,O,q)},J);const Z=B.items.some(A);if(O)return e.jsx("li",{children:e.jsx(gn,{side:"right",closeLabel:y,trigger:e.jsx(Ot,{content:B.label,side:"right",children:e.jsx("button",{type:"button","data-current":Z?"":void 0,"data-ouro-control":"sidebar","data-ouro-part":"group",className:z(Ne,"data-current:text-foreground",Re),children:G(B,!0)})}),children:B.items.map((ae,Fe)=>e.jsxs(Ns,{href:ae.href,current:A(ae),onClick:ae.onClick,children:[ae.label,ae.badge!==void 0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{className:z(Dt,"ms-2"),children:ae.badge})]})]},Fe))})},J);const ee=`${D}-${J}`,ie=H(ee,B);return e.jsxs("li",{children:[e.jsxs("button",{type:"button","aria-expanded":ie,"aria-controls":`${X}${C}${ee}`,"data-ouro-control":"sidebar","data-ouro-part":"group","data-current":Z&&!ie?"":void 0,onClick:()=>Q({...F,[ee]:!ie}),className:z(Ne,"data-current:text-foreground"),children:[G(B,!1),e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:z("size-4 shrink-0 rtl:-scale-x-100",B.badge===void 0&&"ms-auto",ie&&"rotate-90 rtl:-rotate-90"),children:e.jsx("path",{d:"m6 4 4 4-4 4"})})]}),ie&&e.jsx("ul",{id:`${X}${C}${ee}`,className:z(Ut,"ms-5 mt-1 border-0 border-s border-solid border-border ps-2"),children:B.items.map((ae,Fe)=>e.jsx("li",{children:V(ae,!1,q)},Fe))})]},J)})})]},D));return e.jsxs("div",{ref:g,"data-ouro":"sidebar","data-collapsed":h?"":void 0,className:z("max-sm:inline-flex sm:h-full",u),children:[e.jsx(Fo,{ref:R,"data-ouro-sidebar-menu":"","data-ouro-control":"sidebar","data-ouro-part":"menu",variant:"plain",tone:"secondary","aria-label":w,"aria-haspopup":E?void 0:"dialog","aria-expanded":l,onClick:()=>S(!0),className:"w-11 px-0 sm:hidden",children:e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:"size-5",children:e.jsx("path",{d:"M3 5.5h14M3 10h14M3 14.5h14"})})}),E&&e.jsxs("nav",{"aria-label":s,"data-collapsed":h?"":void 0,className:or,children:[r!==void 0&&e.jsx("div",{className:"flex min-h-14 shrink-0 items-center overflow-hidden px-3 py-2",children:r}),e.jsx("div",{"data-ouro-sidebar-scroll":"",className:"grid min-h-0 flex-1 content-start gap-6 overflow-y-auto overscroll-contain p-2",children:K("c",h)}),c&&e.jsx("div",{className:"shrink-0 p-2",children:e.jsxs("button",{type:"button","aria-pressed":h,"data-ouro-control":"sidebar","data-ouro-part":"collapse",onClick:p,className:z(Ne,h&&Re),children:[e.jsx("span",{"aria-hidden":"true",className:Pt,children:e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"rtl:-scale-x-100",children:[e.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),e.jsx("path",{d:"M8 4v12"})]})}),e.jsx("span",{className:h?"sr-only":"min-w-0 flex-1 truncate",children:x})]})}),a!==void 0&&e.jsx("div",{className:"flex min-h-14 shrink-0 items-center overflow-hidden border-0 border-t border-solid border-border px-3 py-2",children:a})]}),e.jsx(Qn,{title:w,hideTitle:r!==void 0,closeLabel:y,side:"left",open:l,onOpenChange:S,finalFocus:R,children:e.jsxs("div",{className:"grid gap-4",children:[r!==void 0&&e.jsx("div",{className:"flex min-h-11 items-center px-3",children:r}),e.jsx("nav",{"aria-label":s,className:"grid gap-6",children:K("d",!1,()=>S(!1))}),a!==void 0&&e.jsx("div",{className:"flex min-h-11 items-center border-0 border-t border-solid border-border px-3 pt-4",children:a})]})})]})}const Qe="relative isolate box-border inline-flex shrink-0 items-center gap-1 align-middle h-6 rounded-md border border-solid px-2 text-xs/none font-medium whitespace-nowrap no-underline bg-(--ouro-bg) border-(--ouro-bd) [--ouro-sq-w:1px] [--ouro-sq-r:calc(var(--radius-md)/var(--ouro-corner-fallback,1))]",Bt="press cursor-pointer select-none touch-manipulation [-webkit-tap-highlight-color:transparent] outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid before:pointer-events-none before:absolute before:-inset-px before:rounded-[inherit] before:[corner-shape:inherit] before:bg-current before:opacity-0 before:transition-opacity before:duration-(--ouro-duration-fast) before:ease-[ease] not-data-disabled:not-active:pointer-fine:hover:before:opacity-8 not-data-disabled:active:before:opacity-14 not-data-disabled:not-active:pointer-fine:hover:[--ouro-state:0.08] not-data-disabled:active:[--ouro-state:0.14] motion-safe:not-data-disabled:active:scale-(--ouro-press-scale) disabled:cursor-not-allowed disabled:opacity-50",Xe={solid:{primary:"[--ouro-bd:transparent] [--ouro-bg:var(--primary)] text-primary-foreground",secondary:"[--ouro-bd:transparent] [--ouro-bg:var(--secondary)] text-secondary-foreground",destructive:"[--ouro-bd:transparent] [--ouro-bg:var(--destructive)] text-destructive-foreground",success:"[--ouro-bd:transparent] [--ouro-bg:var(--success)] text-success-foreground",warning:"[--ouro-bd:transparent] [--ouro-bg:var(--warning)] text-warning-foreground"},soft:{primary:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--primary)_10%,transparent)] text-[color-mix(in_oklab,var(--primary)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]",secondary:"[--ouro-bd:transparent] [--ouro-bg:var(--muted)] text-foreground contrast-more:[--ouro-bd:currentColor]",destructive:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--destructive)_10%,transparent)] text-[color-mix(in_oklab,var(--destructive)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]",success:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--success)_10%,transparent)] text-[color-mix(in_oklab,var(--success)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]",warning:"[--ouro-bd:transparent] [--ouro-bg:color-mix(in_oklab,var(--warning)_10%,transparent)] text-[color-mix(in_oklab,var(--warning)_80%,var(--foreground))] contrast-more:[--ouro-bd:currentColor]"},outline:{primary:"[--ouro-bd:color-mix(in_oklab,var(--primary)_45%,transparent)] [--ouro-bg:transparent] text-primary",secondary:"[--ouro-bd:var(--border)] [--ouro-bg:transparent] text-foreground",destructive:"[--ouro-bd:color-mix(in_oklab,var(--destructive)_45%,transparent)] [--ouro-bg:transparent] text-destructive",success:"[--ouro-bd:color-mix(in_oklab,var(--success)_45%,transparent)] [--ouro-bg:transparent] text-success",warning:"[--ouro-bd:color-mix(in_oklab,var(--warning)_45%,transparent)] [--ouro-bg:transparent] text-warning"}};function rr(t){const{tone:s="secondary",variant:o="solid",icon:n,onClick:r,children:a,className:c,color:f,asChild:d,...b}=t,x=Object.hasOwn(Xe.solid,s)?s:"secondary",w=Object.hasOwn(Xe,o)?o:"solid";de("Badge",c,""),oe();const y=Xe[w][x],u=n&&e.jsx(n,{"aria-hidden":"true",className:"relative -ms-0.5 size-3.5 shrink-0"});if(b.href!==void 0){const{type:R,disabled:T,...M}=b;return e.jsxs(qe,{"data-ouro-control":"badge","data-ouro-part":"root",...M,onClick:r,"data-ouro":"badge","data-ouro-squircle":"",className:z(Qe,Bt,y,c),children:[e.jsx(He,{}),e.jsx("span",{"data-ouro-surface":"","aria-hidden":"true",style:{zIndex:-1}}),u,a]})}const{ref:g,type:m="button",disabled:j,...N}=b;if(r!==void 0)return e.jsxs(Gt,{"data-ouro-control":"badge","data-ouro-part":"root",...N,onClick:r,disabled:j,ref:g,type:m,"data-ouro":"badge","data-ouro-squircle":"",className:z(Qe,Bt,y,c),children:[e.jsx(He,{}),e.jsx("span",{"data-ouro-surface":"","aria-hidden":"true",style:{zIndex:-1}}),u,a]});const{name:v,value:E,form:l,...S}=N;return e.jsxs("span",{...S,ref:g,"data-ouro":"badge","data-ouro-squircle":"",className:z(Qe,y,c),children:[e.jsx("span",{"data-ouro-surface":"","aria-hidden":"true",style:{zIndex:-1}}),u,a]})}const ar={lime:"success",red:"destructive",yellow:"warning",zinc:"secondary"};function _({color:t,children:s}){return e.jsx(rr,{tone:t&&ar[t]||"secondary",children:s})}function ir(t){i.useEffect(()=>{if(!t)return;const s=t;function o(n){if(!(n.target instanceof HTMLInputElement||n.target instanceof HTMLTextAreaElement))switch(n.key){case"1":s({tab:"overview"});break;case"2":s({tab:"mail"});break;case"3":s({tab:"sessions"});break;case"4":s({tab:"work"});break;case"5":s({tab:"connections"});break;case"6":s({tab:"inner"});break;case"7":s({tab:"notes"});break;case"8":s({tab:"runtime"});break;case"Escape":{document.activeElement instanceof HTMLElement&&document.activeElement.blur();break}}}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t])}const lr={"owed-reply":"red","blocking-obligation":"red","broken-return":"red","stale-delegation":"yellow","return-ready":"lime","overdue-habit":"yellow"},cr={"owed-reply":"owed reply","blocking-obligation":"blocking","broken-return":"broken return","stale-delegation":"stale","return-ready":"ready to return","overdue-habit":"overdue"},dr={"owed-reply":"Someone spoke last and is waiting for your response","blocking-obligation":"This obligation is open and blocking forward progress","broken-return":"Work was done but the result was never returned to the requester","stale-delegation":"This was delegated to you and hasn't been addressed","return-ready":"The result is ready — deliver it to close the loop","overdue-habit":"This routine is past its scheduled cadence"},ur=new Set(["stale-delegation"]),xr=new Set(["owed-reply","blocking-obligation","broken-return","return-ready","overdue-habit"]),mr=new Set(["spawning","running","waiting_input","stalled"]);function pr({view:t,deskPrefs:s,refreshGeneration:o}){const n=ge(),[r,a]=i.useState(null),[c,f]=i.useState(null),[d,b]=i.useState(null),[x,w]=i.useState(null),[y,u]=i.useState(null),g=t.agent,m=t.work,j=t.inner,N=t.activity,v=g.degraded,E=g.attention,l=m.tasks,S=m.obligations,R=m.sessions,T=m.coding,M=g.senses,h=m.bridges;return i.useEffect(()=>{P(`/agents/${encodeURIComponent(g.agentName)}/needs-me`).then(a),P(`/agents/${encodeURIComponent(g.agentName)}/coding`).then(f),P(`/agents/${encodeURIComponent(g.agentName)}/continuity`).then(b).catch(()=>{}),P(`/agents/${encodeURIComponent(g.agentName)}/orientation`).then(w).catch(()=>{}),P(`/agents/${encodeURIComponent(g.agentName)}/changes`).then(u).catch(()=>{})},[g.agentName,o]),e.jsxs("div",{className:"space-y-6",children:[r&&r.items.length>0&&(()=>{const p=r.items.filter(L=>xr.has(L.urgency)),k=r.items.filter(L=>ur.has(L.urgency));return e.jsxs("div",{className:"space-y-3",children:[p.length>0&&e.jsxs("div",{className:"rounded-xl bg-ouro-fang/5 p-4 ring-1 ring-ouro-fang/15",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-fang",children:["Action now (",p.length,")"]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:p.map((L,I)=>e.jsx(zt,{item:L,nav:n,agentName:g.agentName,onDismiss:()=>{a(A=>A&&{items:A.items.filter((F,Q)=>r.items.indexOf(L)!==Q)})}},`action-${I}`))})]}),k.length>0&&e.jsxs("div",{className:"rounded-xl bg-ouro-gold/5 p-4 ring-1 ring-ouro-gold/15",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-gold",children:["Stale (",k.length,")"]}),e.jsx("button",{onClick:async()=>{var L;for(const I of k)(L=I.ref)!=null&&L.focus&&await fetch(`/api/agents/${encodeURIComponent(g.agentName)}/dismiss-obligation`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({obligationId:I.ref.focus})});P(`/agents/${encodeURIComponent(g.agentName)}/needs-me`).then(a)},className:"text-xs text-ouro-gold underline underline-offset-2 hover:text-ouro-bone transition-colors",children:"Clear all stale"})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:k.map((L,I)=>e.jsx(zt,{item:L,nav:n,agentName:g.agentName,onDismiss:()=>{P(`/agents/${encodeURIComponent(g.agentName)}/needs-me`).then(a)}},`stale-${I}`))})]})]})})(),(s==null?void 0:s.carrying)&&e.jsxs("div",{className:"rounded-xl bg-ouro-moss/10 p-4 ring-1 ring-ouro-glow/8",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"What I'm carrying"}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-ouro-bone",children:s.carrying})]}),(()=>{const p=(s==null?void 0:s.pinnedConstellations)??[];return p.length===0?null:e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Pinned threads"}),e.jsx("div",{className:"mt-2 space-y-2",children:p.map((k,L)=>e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-2.5 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"font-medium text-ouro-bone",children:k.label}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[k.friendIds.map(I=>e.jsxs("button",{onClick:()=>n({tab:"sessions"}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:["friend:",I.slice(0,8),"…"]},I)),k.taskRefs.map(I=>e.jsxs("button",{onClick:()=>n({tab:"work"}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:["task:",I]},I)),k.bridgeIds.map(I=>e.jsxs("button",{onClick:()=>n({tab:"connections",focus:I}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:["bridge:",I.slice(0,8),"…"]},I))]})]},L))})]})})(),e.jsxs("div",{className:"rounded-xl bg-ouro-moss/15 p-4 ring-1 ring-ouro-glow/10 sm:p-5",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Center of gravity"}),e.jsx("p",{className:"mt-1 font-display text-xl italic font-semibold text-ouro-bone sm:text-2xl",children:E.label}),e.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-ouro-mist",children:[g.agentName," has"," ",e.jsxs(Le,{tab:"work",children:[l.liveCount," live tasks"]}),","," ",e.jsxs(Le,{tab:"work",children:[S.openCount," obligations"]}),","," ",e.jsxs(Le,{tab:"work",children:[T.activeCount," coding lanes"]}),", and"," ",e.jsxs(Le,{tab:"sessions",children:[R.liveCount," live sessions"]}),"."]}),v.status==="degraded"&&v.issues.length>0&&e.jsxs("div",{className:"mt-3 space-y-1",children:[v.issues.slice(0,5).map((p,k)=>e.jsxs("button",{onClick:()=>n({tab:"runtime"}),className:"flex w-full items-start gap-2 rounded-lg bg-ouro-fang/5 px-3 py-2 text-left text-sm ring-1 ring-ouro-fang/10 hover:ring-ouro-fang/25 transition-colors",children:[e.jsx("span",{className:"mt-0.5 h-2 w-2 shrink-0 rounded-full bg-ouro-fang"}),e.jsxs("span",{className:"text-ouro-mist",children:[e.jsx("span",{className:"font-semibold text-ouro-fang",children:p.code}),e.jsxs("span",{className:"text-ouro-shadow",children:[" — ",Y(p.detail,80)]})]})]},k)),v.issues.length>5&&e.jsxs("button",{onClick:()=>n({tab:"runtime"}),className:"text-xs text-ouro-glow underline underline-offset-2",children:["+",v.issues.length-5," more issues"]})]})]}),x===null&&e.jsx("div",{"aria-hidden":"true",className:"min-h-40"}),x&&e.jsxs("div",{className:"rounded-xl bg-ouro-moss/10 p-4 ring-1 ring-ouro-glow/8",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Orientation"}),(()=>{const p=x.currentSession;return p?e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(_,{color:"lime",children:"active session"}),e.jsxs("button",{onClick:()=>n({tab:"sessions",focus:`${p.friendId}/${p.channel}/${p.key}`}),className:"text-sm text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:[p.channel,"/",p.key]}),p.lastActivityAt&&e.jsx("span",{className:"text-xs text-ouro-shadow",children:U(p.lastActivityAt)})]}):null})(),x.primaryObligation&&e.jsxs("div",{className:"mt-2 rounded-lg bg-ouro-void/40 px-3 py-2 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{color:"yellow",children:x.primaryObligation.status}),e.jsx("span",{className:"text-sm font-medium text-ouro-bone",children:Y(x.primaryObligation.content,80)})]}),x.primaryObligation.nextAction&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-mist",children:["Next: ",x.primaryObligation.nextAction]}),x.primaryObligation.waitingOn&&e.jsxs("p",{className:"mt-0.5 text-xs text-ouro-shadow",children:["Waiting on: ",x.primaryObligation.waitingOn]})]}),x.resumeHandle&&e.jsxs("div",{className:"mt-2 rounded-lg bg-ouro-void/40 px-3 py-2 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Resume handle"}),e.jsxs("div",{className:"mt-1 space-y-0.5 text-sm",children:[x.resumeHandle.lane&&e.jsxs("p",{className:"text-ouro-bone",children:["Lane: ",x.resumeHandle.lane]}),x.resumeHandle.artifact&&e.jsxs("p",{className:"text-ouro-mist",children:["Artifact: ",x.resumeHandle.artifact]}),x.resumeHandle.nextAction&&e.jsxs("p",{className:"text-ouro-mist",children:["Next: ",x.resumeHandle.nextAction]}),x.resumeHandle.blockerOrWaitingOn&&e.jsxs("p",{className:"text-ouro-shadow",children:["Blocked: ",x.resumeHandle.blockerOrWaitingOn]}),e.jsxs(_,{color:x.resumeHandle.confidence==="high"?"lime":x.resumeHandle.confidence==="medium"?"yellow":"zinc",children:[x.resumeHandle.confidence," confidence"]})]})]}),x.otherActiveSessions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-ouro-shadow",children:["Other sessions (",x.otherActiveSessions.length,")"]}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:x.otherActiveSessions.slice(0,5).map(p=>e.jsx("button",{onClick:()=>n({tab:"sessions",focus:`${p.friendId}/${p.channel}/${p.key}`}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2",children:p.friendName},`${p.friendId}/${p.channel}/${p.key}`))})]})]}),y&&y.changeCount>0&&e.jsxs("div",{className:"rounded-xl bg-ouro-gold/5 p-4 ring-1 ring-ouro-gold/15",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-gold",children:["What changed (",y.changeCount,")"]}),y.snapshotAge&&e.jsxs("p",{className:"mt-0.5 text-xs text-ouro-shadow",children:["Since ",U(y.snapshotAge)]}),e.jsxs("div",{className:"mt-2 space-y-1",children:[y.items.slice(0,8).map((p,k)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_,{color:p.kind.includes("status")?"yellow":"zinc",children:p.kind.replace(/_/g," ")}),e.jsx("span",{className:"truncate text-ouro-mist",children:p.summary})]},k)),y.items.length>8&&e.jsxs("p",{className:"text-xs text-ouro-shadow",children:["+",y.items.length-8," more changes"]})]})]}),d===null&&e.jsx("div",{"aria-hidden":"true",className:"min-h-40"}),d&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/20",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Presence"}),d.presence.self?e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-ouro-bone",children:d.presence.self.availability}),d.presence.self.lane&&e.jsxs("p",{className:"text-xs text-ouro-shadow",children:["Lane: ",d.presence.self.lane]}),d.presence.self.tempo&&e.jsxs("p",{className:"text-xs text-ouro-shadow",children:["Tempo: ",d.presence.self.tempo]})]}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No presence data"}),d.presence.peers.length>0&&e.jsxs("div",{className:"mt-2 border-t border-ouro-moss/20 pt-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-ouro-shadow",children:"Peers"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:d.presence.peers.map(p=>e.jsx(_,{color:p.availability==="active"?"lime":"zinc",children:p.agentName},p.agentName))})]})]}),e.jsxs("div",{className:"rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/20",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:["Cares (",d.cares.activeCount,")"]}),d.cares.items.length>0?e.jsx("div",{className:"mt-2 space-y-1.5",children:d.cares.items.slice(0,5).map(p=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{color:p.salience==="high"?"red":p.salience==="medium"?"yellow":"zinc",children:p.salience}),e.jsx("p",{className:"truncate text-sm text-ouro-bone",children:p.label})]},p.id))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No active cares"})]}),e.jsxs("div",{className:"rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/20",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:["Episodes (",d.episodes.recentCount,")"]}),d.episodes.items.length>0?e.jsx("div",{className:"mt-2 space-y-1.5",children:d.episodes.items.slice(0,5).map(p=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_,{color:"zinc",children:p.kind}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-ouro-bone",children:p.summary}),e.jsx("p",{className:"text-xs text-ouro-shadow",children:U(p.timestamp)})]})]},p.id))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No recent episodes"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(Ie,{label:"Tasks",value:l.liveCount,sub:`${l.blockedCount} blocked`,onClick:()=>n({tab:"work"})}),e.jsx(Ie,{label:"Obligations",value:S.openCount,sub:`${R.liveCount} sessions`,onClick:()=>n({tab:"work"})}),e.jsx(Ie,{label:"Coding",value:T.activeCount,sub:`${T.blockedCount} blocked`,onClick:()=>n({tab:"work"})}),e.jsx(Ie,{label:"Private Runtime",value:j.status,sub:Y(j.summary??"",30),onClick:()=>n({tab:"inner"})})]}),c&&c.items.length>0&&(()=>{const p=c.items.filter(k=>mr.has(k.status));return p.length===0?null:e.jsx(ye,{title:`Active coding (${p.length})`,children:e.jsx("div",{className:"space-y-1.5",children:p.map(k=>e.jsxs("button",{onClick:()=>n({tab:"work"}),className:"flex w-full items-center gap-2 rounded-lg bg-ouro-void/40 px-3 py-2 text-left ring-1 ring-ouro-moss/15 hover:ring-ouro-glow/20 transition-colors",children:[e.jsx(_,{color:k.status==="running"?"lime":k.status==="waiting_input"?"yellow":"zinc",children:k.status}),e.jsxs("span",{className:"truncate text-sm text-ouro-bone",children:[k.runner," — ",Y(k.workdir,40)]}),e.jsx("span",{className:"shrink-0 text-xs text-ouro-shadow",children:U(k.lastActivityAt)})]},k.id))})})})(),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(ye,{title:"Senses",children:M.length>0?e.jsx(hr,{items:M}):e.jsx(Ge,{children:"No active senses"})}),e.jsx(ye,{title:"Bridges",children:h.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:h.map(p=>e.jsx("button",{onClick:()=>n({tab:"connections",focus:p}),children:e.jsx(_,{color:"lime",children:p})},p))}):e.jsx(Ge,{children:"No active bridges"})})]}),(()=>{const p=S.items.filter(k=>k.status==="fulfilled");return p.length===0?null:e.jsx(ye,{title:"Recently closed",children:e.jsx("div",{className:"space-y-1",children:p.slice(0,3).map((k,L)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2 bg-ouro-glow/5 ring-1 ring-ouro-glow/10",children:[e.jsx(_,{color:"lime",children:"closed"}),e.jsx("p",{className:"text-sm text-ouro-mist truncate",children:Y(k.content,80)}),e.jsx("span",{className:"shrink-0 text-xs text-ouro-shadow",children:U(k.updatedAt)})]},L))})})})(),e.jsx(ye,{title:"Recent activity",children:N.recent.length>0?e.jsx("div",{className:"space-y-1",children:N.recent.map((p,k)=>{const L=p.kind==="coding"||p.kind==="obligation"?"work":p.kind==="session"?"sessions":"inner";return e.jsxs("button",{onClick:()=>n({tab:L}),className:"flex w-full flex-col gap-0.5 rounded-lg px-3 py-2.5 text-left hover:bg-ouro-moss/10 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{children:p.kind}),e.jsx("span",{className:"text-xs text-ouro-shadow",children:U(p.at)})]}),e.jsx("p",{className:"truncate text-sm font-medium text-ouro-bone",children:Y(p.label,100)}),e.jsx("p",{className:"truncate text-xs text-ouro-shadow",children:Y(p.detail,80)})]},k)})}):e.jsx(Ge,{children:"No recent activity yet."})})]})}function zt({item:t,nav:s,agentName:o,onDismiss:n}){var c;const r=t.urgency==="return-ready",a=(c=t.ref)==null?void 0:c.focus;return e.jsxs("div",{className:`flex w-full items-start gap-2.5 rounded-lg px-3 py-2.5 text-left ring-1 transition-colors ${r?"bg-ouro-glow/5 ring-ouro-glow/15":"bg-ouro-void/40 ring-ouro-moss/10"}`,children:[e.jsxs("button",{onClick:()=>t.ref&&s({tab:t.ref.tab,focus:t.ref.focus}),className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx(_,{color:lr[t.urgency]??"zinc",children:cr[t.urgency]??t.urgency}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`text-sm font-medium ${r?"text-ouro-glow":"text-ouro-bone"}`,children:t.label}),e.jsx("p",{className:"text-xs text-ouro-shadow truncate",children:t.detail}),e.jsx("p",{className:"text-[10px] italic text-ouro-shadow/60 mt-0.5",children:dr[t.urgency]??""})]}),t.ageMs!=null&&e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-ouro-shadow",children:t.ageMs<36e5?`${Math.floor(t.ageMs/6e4)}m`:t.ageMs<864e5?`${Math.floor(t.ageMs/36e5)}h`:`${Math.floor(t.ageMs/864e5)}d`})]}),a&&e.jsx("button",{onClick:async f=>{f.stopPropagation(),await fetch(`/api/agents/${encodeURIComponent(o)}/dismiss-obligation`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({obligationId:a})}),n()},className:"shrink-0 text-xs text-ouro-shadow hover:text-ouro-fang transition-colors",title:"Dismiss",children:"✕"})]})}function Le({tab:t,children:s}){const o=ge();return e.jsx("button",{onClick:()=>o({tab:t}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow transition-colors",children:s})}function Ie({label:t,value:s,sub:o,onClick:n}){return e.jsxs("button",{onClick:n,className:"rounded-xl bg-ouro-void/50 p-3 text-left ring-1 ring-ouro-moss/20 hover:ring-ouro-glow/20 transition-all",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("p",{className:"mt-1 text-xl font-semibold tabular-nums text-ouro-bone",children:s}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-ouro-shadow",children:o})]})}function ye({title:t,children:s}){return e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:t}),e.jsx("div",{className:"mt-2",children:s})]})}function hr({items:t}){return e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(s=>e.jsx(_,{color:"lime",children:s},s))})}function Ge({children:t}){return e.jsx("p",{className:"text-sm text-ouro-shadow",children:t})}function Ae(t){return t.length>0?t.join(", "):"(unknown)"}function fr(t,s){if(s==="all")return!0;if(["imbox","screener","discarded","quarantine"].includes(s))return t.placement===s;if(s==="native"||s==="delegated")return t.compartmentKind===s;if(s.startsWith("source:")){const o=s.slice(7),n=o.indexOf(":");if(n===-1)return t.source===o;const r=o.slice(0,n),a=o.slice(n+1);return t.source===r&&(t.ownerEmail??"unknown-owner")===a}return!1}function Cs(t){return t.subject||"(no subject)"}function gr(t,s){return{status:"error",agentName:t,mailboxAddress:null,generatedAt:new Date().toISOString(),store:null,folders:[],messages:[],screener:[],outbound:[],recovery:{discardedCount:0,quarantineCount:0,undecryptableCount:0,missingKeyIds:[]},accessLog:[],error:s}}function br(t,s,o){return{status:"error",agentName:t,mailboxAddress:s,generatedAt:new Date().toISOString(),message:null,accessLog:[],error:o}}function Ss(t){return t.provenance.compartmentKind==="delegated"?`delegated human mailbox · ${t.provenance.ownerEmail??"unknown owner"} / ${t.provenance.source??"unknown source"}`:"native agent mailbox"}function vr(t){return t.mailboxRole==="delegated-human-mailbox"?`delegated human mailbox · ${t.ownerEmail??"unknown owner"} / ${t.source??"unknown source"}`:t.mailboxRole==="agent-native-mailbox"?"native agent mailbox":"mailbox"}function jr(t){return t.sendAuthority==="agent-native"?"native agent mailbox":t.mailboxRole}function wr(t){return t.transport??t.provider??"not sent"}function Nr(t){return t.deliveredAt??t.failedAt??t.acceptedAt??t.sentAt??t.submittedAt??t.updatedAt}function ft(t){return t==="screener"?"bg-[#fff7d6] text-[#6f5200] ring-[#e7c85c]":t==="discarded"||t==="quarantine"?"bg-[#ffe8e2] text-[#8a2f1f] ring-[#ef9a84]":t==="sent"?"bg-[#dff7ea] text-[#17613a] ring-[#82caa1]":t==="draft"?"bg-[#e7ecff] text-[#263f95] ring-[#a7b5f5]":"bg-[#e9f3ef] text-[#1e5840] ring-[#9fc7b5]"}function yr(t){return(t==null?void 0:t.messages.length)??0}function kr({agentName:t,focus:s,onFocusConsumed:o,refreshGeneration:n}){var N;const[r,a]=i.useState(null),[c,f]=i.useState("all"),[d,b]=i.useState(s??null),[x,w]=i.useState(null),[y,u]=i.useState(!1);i.useEffect(()=>{f("all"),b(s??null),w(null)},[t]),i.useEffect(()=>{a(null),P(`/agents/${encodeURIComponent(t)}/mail`).then(a).catch(()=>a(gr(t,"mail unavailable")))},[t,n]),i.useEffect(()=>{s&&(b(s),o==null||o())},[s,o]),i.useEffect(()=>{if(!d){w(null);return}u(!0),P(`/agents/${encodeURIComponent(t)}/mail/${encodeURIComponent(d)}`).then(w).catch(()=>w(br(t,(r==null?void 0:r.mailboxAddress)??null,"message unavailable"))).finally(()=>u(!1))},[t,d,n]);const g=i.useMemo(()=>{const v=(r==null?void 0:r.folders)??[];return[{id:"all",label:"All",count:yr(r)},...v]},[r]),m=i.useMemo(()=>((r==null?void 0:r.messages)??[]).filter(v=>fr(v,c)),[c,r]),j=i.useMemo(()=>c!=="draft"&&c!=="sent"?[]:((r==null?void 0:r.outbound)??[]).filter(v=>c==="draft"?v.status==="draft":v.status!=="draft"),[c,r]);return r?r.status!=="ready"?e.jsx("div",{className:"mailbox-shell grid min-h-[58vh] place-items-center rounded-md bg-[#f2f6ef] p-8 text-[#1f2720] ring-1 ring-black/10",children:e.jsxs("div",{className:"max-w-lg text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-[#667067]",children:"Mailbox"}),e.jsx("h2",{className:"mt-2 text-2xl font-semibold",children:r.status==="auth-required"?"Locked":"Unavailable"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[#59645c]",children:r.error})]})}):e.jsxs("div",{className:"mailbox-shell overflow-hidden rounded-md bg-[#f2f6ef] text-[#172018] ring-1 ring-black/10",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[#cbd8c8] bg-[#e4ecdf] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-[#687062]",children:"Agent mailbox"}),e.jsx("p",{className:"truncate text-sm text-[#2d3a30]",children:r.mailboxAddress})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{color:"zinc",children:"read-only"}),e.jsxs("span",{className:"text-xs tabular-nums text-[#687062]",children:[r.messages.length," messages"]}),e.jsxs("span",{className:"text-xs tabular-nums text-[#687062]",children:[r.outbound.length," outbound"]})]})]}),e.jsxs("div",{className:"grid min-h-[66vh] grid-cols-1 lg:grid-cols-[14.5rem_minmax(19rem,25rem)_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"border-b border-[#cbd8c8] bg-[#e4ecdf] p-3 lg:border-b-0 lg:border-r",children:[e.jsx(Cr,{folders:g,activeFolder:c,setActiveFolder:f}),e.jsx(Sr,{discarded:r.recovery.discardedCount,quarantine:r.recovery.quarantineCount,undecryptable:r.recovery.undecryptableCount,missingKeyIds:r.recovery.missingKeyIds}),e.jsx($r,{candidates:r.screener,onOpen:v=>{f("screener"),b(v)}}),e.jsx(Ar,{entries:r.accessLog})]}),e.jsxs("section",{className:"border-b border-[#cbd8c8] bg-[#fbfdf8] lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"border-b border-[#d8e2d4] px-4 py-3",children:[e.jsx("p",{className:"text-sm font-semibold text-[#172018]",children:((N=g.find(v=>v.id===c))==null?void 0:N.label)??"All"}),e.jsx("p",{className:"text-xs text-[#687062]",children:j.length>0?`${j.length} outbound records`:`${m.length} messages`})]}),e.jsxs("div",{className:"max-h-[66vh] overflow-y-auto",children:[j.map(v=>e.jsx(Tr,{record:v},v.id)),j.length===0&&m.map(v=>e.jsx(Er,{message:v,selected:d===v.id,onSelect:()=>b(v.id)},v.id)),j.length===0&&m.length===0&&e.jsx("div",{className:"px-4 py-10 text-center text-sm text-[#687062]",children:"No records here."})]})]}),e.jsxs("main",{className:"min-w-0 bg-[#fbfdf8]",children:[!d&&e.jsx(Lr,{}),d&&y&&e.jsx(Ht,{label:"Opening message"}),d&&!y&&(x==null?void 0:x.status)!=="ready"&&e.jsx("div",{className:"grid min-h-[54vh] place-items-center p-8 text-center",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[#172018]",children:"Message unavailable"}),e.jsx("p",{className:"mt-2 text-sm text-[#687062]",children:x==null?void 0:x.error})]})}),(x==null?void 0:x.status)==="ready"&&x.message&&e.jsx(Rr,{detail:x})]})]})]}):e.jsx(Ht,{label:"Opening mailbox"})}function Cr({folders:t,activeFolder:s,setActiveFolder:o}){return e.jsx("div",{className:"space-y-1",children:t.map(n=>e.jsxs("button",{type:"button",onClick:()=>o(n.id),className:`flex h-9 w-full items-center justify-between rounded px-3 text-left text-sm transition-colors ${s===n.id?"bg-[#fbfdf8] text-[#172018] shadow-sm":"text-[#536157] hover:bg-[#fbfdf8]/65"}`,children:[e.jsx("span",{className:"truncate",children:n.label}),e.jsx("span",{className:"text-xs tabular-nums text-[#687062]",children:n.count})]},n.id))})}function Sr({discarded:t,quarantine:s,undecryptable:o,missingKeyIds:n}){return e.jsxs("div",{className:"mt-5 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#687062]",children:"Recovery drawers"}),e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2",children:[e.jsx("p",{className:"text-xs text-[#687062]",children:"Discarded"}),e.jsx("p",{className:"text-lg font-semibold tabular-nums text-[#172018]",children:t})]}),e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2",children:[e.jsx("p",{className:"text-xs text-[#687062]",children:"Quarantine"}),e.jsx("p",{className:"text-lg font-semibold tabular-nums text-[#172018]",children:s})]}),e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2",children:[e.jsx("p",{className:"text-xs text-[#687062]",children:"Undecryptable"}),e.jsx("p",{className:"text-lg font-semibold tabular-nums text-[#172018]",children:o})]})]}),o>0&&e.jsxs("p",{className:"mt-2 text-[11px] leading-4 text-[#687062]",children:["missing key ",n[0],n.length>1?` +${n.length-1} more`:""]})]})}function $r({candidates:t,onOpen:s}){return e.jsxs("div",{className:"mt-5 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#687062]",children:"Screener"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[t.slice(0,5).map(o=>e.jsxs("button",{type:"button",onClick:()=>s(o.messageId),className:"block w-full rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2 text-left hover:border-[#9fb8a7]",children:[e.jsx("p",{className:"truncate text-xs font-semibold text-[#172018]",children:o.senderEmail}),e.jsx("p",{className:"mt-1 truncate text-xs text-[#687062]",children:o.trustReason})]},o.id)),t.length===0&&e.jsx("p",{className:"text-xs text-[#687062]",children:"No pending senders."})]})]})}function Ar({entries:t}){return e.jsxs("div",{className:"mt-5 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-[11px] font-semibold text-[#687062]",children:"Access audit"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[t.slice(0,4).map(s=>e.jsxs("div",{className:"text-xs leading-4 text-[#687062]",children:[e.jsx("p",{className:"truncate font-medium text-[#3f4b42]",children:s.tool}),e.jsx("p",{className:"truncate",children:vr(s)}),e.jsx("p",{className:"truncate",children:s.reason})]},s.id)),t.length===0&&e.jsx("p",{className:"text-xs text-[#687062]",children:"No reads yet."})]})]})}function Er({message:t,selected:s,onSelect:o}){return e.jsxs("button",{type:"button",onClick:o,className:`block w-full border-b border-[#d8e2d4] px-4 py-3 text-left transition-colors ${s?"bg-[#eaf4ee]":"hover:bg-[#eef4ec]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-semibold text-[#172018]",children:Ae(t.from)}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-[#687062]",children:U(t.receivedAt)})]}),e.jsx("p",{className:"mt-1 truncate text-sm text-[#26352a]",children:Cs(t)}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-[#687062]",children:Y(t.snippet,150)}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`rounded px-2 py-0.5 text-[11px] ring-1 ${ft(t.placement)}`,children:t.placement}),e.jsx("span",{className:"truncate text-[11px] text-[#687062]",children:Ss(t)})]})]})}function Tr({record:t}){const s=t.deliveryEvents[t.deliveryEvents.length-1];return e.jsxs("div",{className:"border-b border-[#d8e2d4] px-4 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 truncate text-sm font-semibold text-[#172018]",children:t.subject||"(no subject)"}),e.jsx("span",{className:`shrink-0 rounded px-2 py-0.5 text-[11px] ring-1 ${ft(t.status)}`,children:t.status})]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[#536157]",children:["to ",Ae(t.to)]}),e.jsxs("p",{className:"mt-1 text-xs text-[#687062]",children:[wr(t)," · ",U(Nr(t))]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[#687062]",children:[jr(t)," · ",t.sendMode??"mode unknown",t.policyDecision?` · policy ${t.policyDecision.code} / ${t.policyDecision.fallback}`:""]}),(t.providerMessageId||t.providerRequestId)&&e.jsxs("p",{className:"mt-1 truncate text-xs text-[#687062]",children:["provider ",t.providerMessageId??"unknown",t.providerRequestId?` · request ${t.providerRequestId}`:""]}),s&&e.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-5 text-[#687062]",children:s.bodySafeSummary})]})}function Rr({detail:t}){const s=t.message;return e.jsxs("article",{className:"min-h-[66vh]",children:[e.jsxs("header",{className:"border-b border-[#cbd8c8] bg-[#fbfdf8] px-6 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("h2",{className:"min-w-0 text-xl font-semibold leading-tight text-[#172018]",children:Cs(s)}),e.jsx("span",{className:`rounded px-2 py-0.5 text-xs ring-1 ${ft(s.placement)}`,children:s.placement})]}),e.jsxs("div",{className:"mt-4 grid gap-1 text-sm text-[#536157]",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"From:"})," ",Ae(s.from)]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"To:"})," ",Ae(s.to)]}),s.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Cc:"})," ",Ae(s.cc)]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Received:"})," ",new Date(s.receivedAt).toLocaleString()]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Provenance:"})," ",Ss(s)]})]})]}),e.jsx("div",{className:"border-b border-[#f0d0bd] bg-[#fff4e4] px-6 py-3 text-sm text-[#8a4a18]",children:s.untrustedContentWarning}),e.jsxs("div",{className:"px-6 py-6",children:[e.jsx("pre",{className:"whitespace-pre-wrap break-words font-body text-sm leading-7 text-[#26352a]",children:s.text||"(no text body)"}),s.bodyTruncated&&e.jsx("p",{className:"mt-4 text-xs text-[#687062]",children:"Body truncated in Mailbox."}),e.jsxs("div",{className:"mt-6 grid gap-3 border-t border-[#cbd8c8] pt-4 text-xs text-[#687062] md:grid-cols-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Read reason:"})," ",s.access.reason]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium text-[#172018]",children:"Read at:"})," ",new Date(s.access.accessedAt).toLocaleString()]})]}),s.attachments.length>0&&e.jsxs("div",{className:"mt-6 border-t border-[#cbd8c8] pt-4",children:[e.jsx("p",{className:"text-xs font-semibold text-[#687062]",children:"Attachments"}),e.jsx("div",{className:"mt-2 space-y-2",children:s.attachments.map(o=>e.jsxs("div",{className:"rounded border border-[#cbd8c8] bg-[#fbfdf8] px-3 py-2 text-sm text-[#3f4b42]",children:[o.filename," · ",o.contentType," · ",o.size.toLocaleString()," bytes"]},`${o.filename}-${o.size}`))})]})]})]})}function Lr(){return e.jsx("div",{className:"grid min-h-[54vh] place-items-center p-8 text-center",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[#172018]",children:"No message selected"}),e.jsx("p",{className:"mt-2 text-sm text-[#687062]",children:"Reading pane idle."})]})})}function Ht({label:t}){return e.jsxs("div",{className:"flex items-center gap-2 p-6",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-[#2f8f4e]"}),e.jsxs("span",{className:"text-xs text-[#687062]",children:[t,"..."]})]})}function ct(t){const s=t.function.name,o=Ir(t.function.arguments);return s==="settle"?{kind:"response",name:s,id:t.id,deliveredText:o.answer??null,delegatedThought:null,metadata:o.intent??null,rawArgs:null}:s==="ponder"?{kind:"delegation",name:s,id:t.id,deliveredText:o.say??null,delegatedThought:o.thought??null,metadata:null,rawArgs:null}:s==="rest"?{kind:"rest",name:s,id:t.id,deliveredText:null,delegatedThought:null,metadata:null,rawArgs:null}:s==="observe"?{kind:"observe",name:s,id:t.id,deliveredText:null,delegatedThought:null,metadata:o.reason??null,rawArgs:null}:s==="surface"?{kind:"surface",name:s,id:t.id,deliveredText:o.content??null,delegatedThought:null,metadata:o.delegationId??o.friendId??null,rawArgs:null}:{kind:"action",name:s,id:t.id,deliveredText:null,delegatedThought:null,metadata:null,rawArgs:t.function.arguments}}function Ir(t){try{const s=JSON.parse(t);if(s&&typeof s=="object")return s}catch{}return{}}const Mr=48;function _r(t){return t.scrollHeight-t.scrollTop-t.clientHeight<=Mr}function $s(t){const s=i.useRef(null),o=i.useRef(!0),n=i.useCallback(()=>{const a=s.current;a&&(o.current=_r(a))},[]),r=i.useCallback(()=>{o.current=!1},[]);return i.useEffect(()=>{const a=s.current;!a||!o.current||(a.scrollTop=a.scrollHeight)},[t]),{ref:s,onScroll:n,preserveScroll:r}}function Or(t){return typeof t=="string"?t:Array.isArray(t)?t.map(s=>s.type==="text"&&typeof s.text=="string"?s.text:"").filter(s=>s.length>0).join(""):""}function Te(t){return Or(t.content)}function As(t){return t.time.authoredAt??t.time.observedAt??t.time.recordedAt}const Es=t=>/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(t),Ts=t=>/^[a-f0-9]{64}$/.test(t);function qt(t,s){return!Es(t)||s!==void 0&&!Ts(s)?null:s===void 0?`ouro shepherd status --agent '${t}' --json`:`ouro shepherd inspect --agent '${t}' --id '${s}' --json`}function Dr(t,s,o){return!Es(t)||!Ts(s)||o===null||!Number.isSafeInteger(o)||o<0?null:`ouro shepherd reconcile --agent '${t}' --id '${s}' --resolution retired --expected-revision ${o} --request-id 'supervision-retire-${s}-r${o}' --json`}const Pr="This alpha retains unqualified legacy automation. Legacy immediate/network automation may still type text without mandate enforcement. Automatic keys are refused. Absent or revoked mandates do not disable those text paths. Disable Shepherd to stop legacy automation.",Ft={"needs-reply":{color:"red",label:"needs reply"},"on-hold":{color:"yellow",label:"on hold"},monitoring:{color:"zinc",label:"monitoring"},idle:{color:"zinc",label:"idle"}};function Rs(t){return t==="bluebubbles"?"iMessage":t==="teams"?"Teams":t==="cli"?"CLI":t==="mail"?"Mail":t==="voice"?"Voice":t}function Ur(t){return t==="bluebubbles"?"imessage":t==="teams"?"teams":t==="cli"?"terminal":"default"}function Br(t){return t==="imessage"?"overflow-hidden rounded-xl bg-[#f5f5f7] text-[#1d1d1f] ring-1 ring-black/10":t==="teams"?"overflow-hidden rounded-xl bg-[#f7f5ff] text-[#242424] ring-1 ring-[#d8d1ff]":t==="terminal"?"overflow-hidden rounded-lg bg-[#050807] font-mono text-[#d1fae5] ring-1 ring-[#1f3a2c]":"overflow-hidden rounded-lg bg-ouro-void/60 text-ouro-bone ring-1 ring-ouro-moss/15"}function zr(t){return t==="imessage"?"border-b border-black/10 bg-[#fbfbfd] px-4 py-3 text-center":t==="teams"?"border-b border-[#d8d1ff] bg-[#4f3bb3] px-4 py-3 text-white":t==="terminal"?"border-b border-[#1f3a2c] bg-[#101815] px-4 py-2 text-[#86efac]":"border-b border-ouro-moss/15 px-4 py-3"}function Hr(t){return t==="imessage"?"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-bl-md bg-[#e9e9eb] px-3.5 py-2 text-[#1d1d1f]":t==="teams"?"max-w-[85%] sm:max-w-[75%] rounded-md bg-white px-3.5 py-2 text-[#242424] shadow-sm ring-1 ring-[#e5e5e5]":t==="terminal"?"max-w-full rounded-none border-l-2 border-[#60a5fa] bg-transparent px-3 py-2 text-[#dbeafe]":"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-bl-sm bg-ouro-moss/25 px-3.5 py-2 ring-1 ring-ouro-moss/15"}function Me(t,s="normal"){return t==="imessage"?"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-br-md bg-[#0a84ff] px-3.5 py-2 text-white":t==="teams"?"max-w-[85%] sm:max-w-[75%] rounded-md bg-[#ede9fe] px-3.5 py-2 text-[#242424] shadow-sm ring-1 ring-[#c4b5fd]":t==="terminal"?"max-w-full rounded-none border-l-2 border-[#22c55e] bg-transparent px-3 py-2 text-[#bbf7d0]":s==="surface"?"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-br-sm bg-ouro-scale/12 px-3.5 py-2 ring-1 ring-ouro-scale/15":"max-w-[85%] sm:max-w-[75%] rounded-2xl rounded-br-sm bg-ouro-glow/8 px-3.5 py-2 ring-1 ring-ouro-glow/12"}function Se(t,s){return t==="imessage"?s==="agent"?"font-mono text-[9px] text-white/70":"font-mono text-[9px] text-[#6b7280]":t==="teams"?"font-mono text-[9px] uppercase tracking-wider text-[#5b5fc7]":t==="terminal"?s==="agent"?"font-mono text-[11px] text-[#22c55e]":"font-mono text-[11px] text-[#60a5fa]":s==="surface"||s==="agent"?"font-mono text-[9px] uppercase tracking-wider text-ouro-glow/70":"font-mono text-[9px] uppercase tracking-wider text-ouro-gold/70"}function $e(t,s="agent"){return t==="imessage"?"text-sm leading-relaxed whitespace-pre-wrap break-words":t==="teams"?"text-sm leading-relaxed text-[#242424] whitespace-pre-wrap break-words":t==="terminal"?`font-mono text-[12px] leading-6 whitespace-pre-wrap break-words ${s==="agent"?"text-[#bbf7d0]":"text-[#dbeafe]"}`:"text-sm leading-relaxed text-ouro-bone whitespace-pre-wrap break-words"}function qr(t){return As(t)}function me(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(qr(t)))}function Fr({agentName:t,focus:s,onFocusConsumed:o,deskPrefs:n,refreshGeneration:r}){ge();const[a,c]=i.useState(null),[f,d]=i.useState(null),[b,x]=i.useState(null),[w,y]=i.useState(!1),u=i.useRef(null);i.useEffect(()=>{P(`/agents/${encodeURIComponent(t)}/sessions`).then(c)},[t,r]),i.useEffect(()=>{s&&(u.current=null,d(s),x(null),y(!0),o==null||o())},[t,s,o]),i.useEffect(()=>{if(!f)return;const l=`${f}:${r}`;if(u.current===l)return;u.current=l,y(!0);const[S,R,T]=f.split("/");P(`/agents/${encodeURIComponent(t)}/sessions/${encodeURIComponent(S)}/${encodeURIComponent(R)}/${encodeURIComponent(T)}`).then(x).catch(()=>x(null)).finally(()=>y(!1))},[t,f,r,s]);function g(l){if(f===l){d(null),x(null),u.current=null;return}d(l),x(null),y(!0)}const m=new Set((n==null?void 0:n.starredFriends)??[]);if(!a)return e.jsx(Ls,{label:"Loading sessions"});const j=new Map;for(const l of a.items)j.has(l.friendId)||j.set(l.friendId,[]),j.get(l.friendId).push(l);const N=[...j.entries()].sort((l,S)=>{const R=m.has(l[0])?0:1,T=m.has(S[0])?0:1;return R!==T?R-T:S[1].length-l[1].length}),v=[],E=new Map;for(const[l,S]of N)E.set(v.length,{name:S[0].friendName,channels:S.length,starred:m.has(l)}),v.push(...S);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:[a.totalCount," sessions · ",a.activeCount," active · ",a.staleCount," stale"]}),e.jsx("div",{className:"space-y-1.5",children:v.map((l,S)=>{var A;const R=E.get(S),T=m.has(l.friendId),M=`${l.friendId}/${l.channel}/${l.key}`,h=f===M,p=Ft[l.replyState]??Ft.idle,k=((A=l.lastUsage)==null?void 0:A.total_tokens)??l.estimatedTokens??0,I=k>0?Math.min(100,Math.round(k/8e4*100)):0;return e.jsxs("div",{children:[R&&R.channels>1&&e.jsxs("div",{className:"flex items-center gap-2 pt-3 pb-1",children:[R.starred&&e.jsx("span",{className:"text-ouro-gold text-sm",children:"★"}),e.jsx("span",{className:"font-medium text-ouro-bone text-sm",children:R.name}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:[R.channels," channels"]})]}),e.jsxs("button",{onClick:()=>g(M),className:`flex w-full flex-col gap-1.5 rounded-lg px-3 py-3 text-left transition-colors ring-1 ${h?"bg-ouro-moss/15 ring-ouro-glow/20":"ring-ouro-moss/15 hover:bg-ouro-moss/8"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[T&&e.jsx("span",{className:"text-ouro-gold",title:"Starred",children:"★"}),e.jsx("span",{className:"truncate font-medium text-ouro-bone",children:l.friendName}),e.jsxs("span",{className:"shrink-0 text-xs text-ouro-shadow",children:["via ",Rs(l.channel)]}),e.jsx(_,{color:p.color,children:p.label})]}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-ouro-shadow",children:U(l.lastActivityAt)})]}),l.latestUserExcerpt&&e.jsxs("p",{className:"truncate text-xs text-ouro-gold/70",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider",children:"in:"})," ",Y(l.latestUserExcerpt,100)]}),l.latestAssistantExcerpt&&e.jsxs("p",{className:"truncate text-xs text-ouro-glow/60",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider",children:"out:"})," ",Y(l.latestAssistantExcerpt,100)]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-ouro-shadow",children:[e.jsxs("span",{className:"tabular-nums",children:[l.messageCount," msgs"]}),l.lastUsage&&e.jsxs("span",{className:"tabular-nums",children:[l.lastUsage.total_tokens.toLocaleString()," tok"]}),I>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-1 max-w-32",title:"Context pressure — steady state oscillates between 80-100%",children:[e.jsx("div",{className:"h-1 flex-1 rounded-full bg-ouro-moss/20",children:e.jsx("div",{className:`h-1 rounded-full transition-all ${I>100?"bg-ouro-fang":I>80?"bg-ouro-gold":"bg-ouro-glow"}`,style:{width:`${Math.min(100,I)}%`}})}),e.jsxs("span",{className:"tabular-nums text-[10px]",children:[I,"%"]})]})]})]}),h&&e.jsx(Wr,{loading:w,transcript:b})]},M)})})]})}function Wr({loading:t,transcript:s}){var a;const o=((a=s==null?void 0:s.messages[s.messages.length-1])==null?void 0:a.id)??null,{ref:n,onScroll:r}=$s(o);return e.jsxs("div",{ref:n,"data-testid":"session-transcript-scroll",onScroll:r,className:"mt-1 max-h-[70vh] overflow-y-auto rounded-lg",children:[t&&!s&&e.jsx(Ls,{label:"Loading transcript"}),s&&e.jsx(Kr,{transcript:s})]})}function Kr({transcript:t}){const{messages:s,lastUsage:o}=t,n=Ur(t.channel),r=s.filter(b=>b.role==="system"),a=s.filter(b=>b.role!=="system"),[c,f]=i.useState(!1),d=new Map;for(const b of a)b.role==="tool"&&b.toolCallId&&d.set(b.toolCallId,b);return e.jsxs("div",{className:Br(n),children:[e.jsxs("div",{className:zr(n),children:[e.jsx("p",{className:n==="terminal"?"font-mono text-xs":"text-sm font-semibold",children:Rs(t.channel)}),e.jsxs("p",{className:n==="terminal"?"mt-0.5 font-mono text-[10px] text-[#6ee7b7]":"mt-0.5 text-xs opacity-70",children:[t.friendName," · ",t.messageCount," messages"]})]}),e.jsxs("div",{className:"space-y-0.5 p-3",children:[o&&e.jsxs("p",{className:n==="terminal"?"pb-2 font-mono text-[10px] text-[#6ee7b7]":"pb-2 font-mono text-[10px] opacity-60",children:[o.input_tokens.toLocaleString()," in · ",o.output_tokens.toLocaleString()," out · ",o.total_tokens.toLocaleString()," total"]}),t.truncatedHistory&&e.jsx("p",{className:n==="terminal"?"pb-2 font-mono text-[10px] text-[#facc15]":"pb-2 font-mono text-[10px] text-ouro-gold/80",children:"Model context is trimmed; retained history is shown below."}),r.length>0&&e.jsxs("div",{className:"pb-2 mb-2 border-b border-current/10",children:[e.jsxs("button",{onClick:()=>f(!c),className:"font-mono text-[10px] uppercase tracking-wider opacity-60 transition-opacity hover:opacity-90",children:[c?"▼":"▶"," system context (",r.length,")"]}),c&&r.map(b=>e.jsxs("div",{className:"mt-2 max-h-60 overflow-y-auto rounded bg-black/5 p-2 text-xs opacity-75 whitespace-pre-wrap break-words",children:[e.jsx("p",{className:"mb-1 font-mono text-[9px] opacity-70",children:me(b)}),Te(b)]},b.id))]}),a.map(b=>b.role==="tool"?null:b.role==="user"?e.jsx(Vr,{msg:b,surface:n},b.id):b.role==="assistant"?e.jsx(Yr,{msg:b,toolResults:d,surface:n},b.id):null)]})]})}function Vr({msg:t,surface:s}){const o=Te(t);return e.jsx("div",{className:"flex justify-start py-1",children:e.jsxs("div",{className:Hr(s),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:Se(s,"user"),children:s==="terminal"?"human $":"user"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",t.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:me(t)})]}),e.jsx("p",{className:$e(s,"user"),children:o})]})})}function Yr({msg:t,toolResults:s,surface:o}){const n=Te(t),r=(t.toolCalls??[]).map(ct),a=r.filter(d=>d.kind!=="action"),c=r.filter(d=>d.kind==="action"),f=[];for(const d of a)d.kind==="response"?f.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:Me(o),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:Se(o,"agent"),children:o==="terminal"?"agent >":"agent"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:me(t)})]}),e.jsx("p",{className:$e(o),children:d.deliveredText}),d.metadata&&d.metadata!=="complete"&&e.jsxs("p",{className:"mt-1 font-mono text-[9px] text-ouro-shadow",children:["intent: ",d.metadata]})]})},d.id)):d.kind==="delegation"?f.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:Me(o),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:Se(o,"agent"),children:o==="terminal"?"agent >":"agent"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:me(t)})]}),d.deliveredText&&e.jsx("p",{className:$e(o),children:d.deliveredText}),d.delegatedThought&&e.jsxs("div",{className:"mt-2 rounded bg-black/10 px-2.5 py-1.5 ring-1 ring-current/10",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider opacity-70",children:"→ private runtime"}),e.jsx("p",{className:"mt-0.5 text-xs opacity-80",children:d.delegatedThought})]})]})},d.id)):d.kind==="surface"?f.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:Me(o,"surface"),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:Se(o,"surface"),children:"surfaced"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:me(t)})]}),e.jsx("p",{className:$e(o),children:d.deliveredText}),d.metadata&&e.jsxs("p",{className:"mt-1 font-mono text-[9px] text-ouro-shadow",children:["→ ",d.metadata]})]})},d.id)):d.kind==="rest"?f.push(e.jsx("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-shadow/50",children:"— resting —"},d.id)):d.kind==="observe"&&f.push(e.jsxs("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-shadow/50",children:["— observed",d.metadata?`: ${d.metadata}`:""," —"]},d.id));return n&&a.length===0&&f.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:Me(o),children:[e.jsxs("div",{className:"mb-0.5 flex items-center gap-2",children:[e.jsx("p",{className:Se(o,"agent"),children:o==="terminal"?"agent >":"agent"}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:me(t)})]}),e.jsx("p",{className:$e(o),children:n})]})},`${t.id}-content`)),c.length>0&&f.push(e.jsx("div",{className:"flex justify-end py-1",children:e.jsx("div",{className:"max-w-[85%] sm:max-w-[75%] space-y-1",children:c.map(d=>e.jsx(Qr,{call:d,result:s.get(d.id),surface:o},d.id))})},`${t.id}-tools`)),e.jsx(e.Fragment,{children:f})}function Qr({call:t,result:s,surface:o}){const[n,r]=i.useState(!1),a=s?Te(s):null;return e.jsxs("button",{onClick:()=>r(!n),className:`w-full text-left rounded px-2.5 py-1.5 text-sm transition-colors ${o==="terminal"?"bg-[#0f1a15] font-mono text-[#bbf7d0] ring-1 ring-[#1f3a2c] hover:ring-[#22c55e]/40":o==="teams"?"bg-white text-[#242424] ring-1 ring-[#d8d1ff] hover:ring-[#5b5fc7]/40":o==="imessage"?"bg-white text-[#1d1d1f] ring-1 ring-black/10 hover:ring-[#0a84ff]/30":"bg-ouro-moss/10 ring-1 ring-ouro-moss/12 hover:ring-ouro-glow/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-ouro-glow",children:t.name}),!n&&e.jsx("span",{className:"text-[10px] text-ouro-shadow",children:"tap to inspect"})]}),n&&e.jsxs(e.Fragment,{children:[t.rawArgs&&e.jsx("pre",{className:"mt-1.5 max-h-24 overflow-y-auto rounded bg-ouro-void/40 p-1.5 font-mono text-[11px] text-ouro-shadow whitespace-pre-wrap break-words",children:t.rawArgs}),s&&e.jsxs("div",{className:"mt-1.5 border-t border-ouro-moss/15 pt-1.5",children:[e.jsx(_,{children:"result"}),e.jsx("pre",{className:"mt-1 max-h-32 overflow-y-auto rounded bg-ouro-void/40 p-1.5 font-mono text-[11px] text-ouro-mist whitespace-pre-wrap break-words",children:a})]})]})]})}function Ls({label:t}){return e.jsxs("div",{className:"flex items-center gap-2 py-6",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-ouro-glow"}),e.jsxs("span",{className:"font-mono text-xs text-ouro-shadow",children:[t,"…"]})]})}function Xr({agentName:t,view:s,focus:o,onFocusConsumed:n,refreshGeneration:r}){var T,M;const a=ge(),[c,f]=i.useState(null),[d,b]=i.useState(null),[x,w]=i.useState(null),[y,u]=i.useState(null),[g,m]=i.useState(null),j=s.work,N=j.obligations,v=j.tasks;i.useEffect(()=>{let h=!1;return f(null),b(null),w(null),u(null),m(null),P(`/agents/${encodeURIComponent(t)}/coding`).then(p=>{h||f(p)}).catch(()=>{}),P(`/agents/${encodeURIComponent(t)}/obligations`).then(p=>{h||b(p)}).catch(()=>{}),P(`/agents/${encodeURIComponent(t)}/self-fix`).then(p=>{h||w(p)}).catch(()=>{}),P(`/agents/${encodeURIComponent(t)}/sentinel`).then(p=>{h||(u(p),m(null))}).catch(p=>{h||(u(null),m(p instanceof Error?p.message:"sentinel unavailable"))}),()=>{h=!0}},[t,r]);const E=(d==null?void 0:d.items)??N.items,l=(d==null?void 0:d.openCount)??N.openCount,S=(c==null?void 0:c.items)??[],R=new Map;for(const h of S){const p=h.obligationId;if(p){const k=R.get(p);k?k.push(h):R.set(p,[h])}}return e.jsxs("div",{className:"space-y-8",children:[(y||g)&&e.jsxs("section",{children:[e.jsx(ke,{label:"Recovery Sentinel"}),e.jsx(Gr,{view:y,error:g})]}),e.jsxs("section",{children:[e.jsx(ke,{label:`Obligations (${l} open)`}),(d==null?void 0:d.primarySelectionReason)&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-shadow",children:["Primary: ",d.primarySelectionReason]}),E.length>0?e.jsx("div",{className:"mt-3 space-y-3",children:E.map(h=>{const p=R.get(h.id)??[],k=ta(h)?h:null,L=(k==null?void 0:k.isPrimary)??!1,I=(k==null?void 0:k.meaning)??null,A=h.origin;return e.jsxs("div",{className:`rounded-lg px-3 py-3 ring-1 ${L?"bg-ouro-glow/5 ring-ouro-glow/20":"bg-ouro-void/40 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[L&&e.jsx(_,{color:"lime",children:"primary"}),e.jsx(_,{color:h.status==="pending"?"yellow":h.status==="fulfilled"?"lime":"zinc",children:h.status}),e.jsx("span",{className:"text-sm font-medium text-ouro-bone",children:Y(h.content,120)})]}),A&&e.jsxs("button",{onClick:()=>a({tab:"sessions",focus:`${A.friendId}/${A.channel}/${A.key}`}),className:"mt-2 flex w-full items-center gap-2 rounded-md bg-ouro-moss/8 px-2.5 py-1.5 text-left text-xs ring-1 ring-ouro-moss/10 hover:ring-ouro-glow/20 transition-colors",children:[e.jsx("span",{className:"text-ouro-shadow",children:"from"}),e.jsx("span",{className:"font-medium text-ouro-glow",children:A.channel}),e.jsx("span",{className:"text-ouro-shadow",children:"→"}),e.jsx("span",{className:"text-ouro-mist truncate",children:A.key}),e.jsx("span",{className:"ml-auto text-ouro-shadow",children:"open session →"})]}),h.currentSurface&&e.jsxs("div",{className:"mt-1 text-xs text-ouro-mist",children:["surface: ",e.jsx("span",{className:"text-ouro-bone",children:h.currentSurface.kind})," — ",h.currentSurface.label]}),(I==null?void 0:I.waitingOn)&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-shadow",children:["Waiting on: ",I.waitingOn]}),p.length>0&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Linked coding"}),p.map(F=>e.jsxs("div",{className:"flex items-center gap-2 rounded bg-ouro-moss/10 px-2 py-1 text-xs",children:[e.jsx(_,{color:F.status==="failed"?"red":F.status==="running"?"lime":"zinc",children:F.status}),e.jsxs("span",{className:"text-ouro-mist truncate",children:[F.runner," — ",F.workdir]})]},F.id))]}),h.nextAction&&e.jsxs("p",{className:"mt-1.5 text-xs text-ouro-mist",children:["Next: ",h.nextAction]}),e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow",children:U(h.updatedAt)})]},h.id)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No open obligations."})]}),x&&x.steps.length>0&&e.jsxs("section",{children:[e.jsx(ke,{label:`Self-fix ${x.active?"(active)":"(inactive)"}`}),x.currentStep&&e.jsxs("p",{className:"mt-1 text-xs text-ouro-glow",children:["Current: ",x.currentStep]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:x.steps.map((h,p)=>e.jsxs("div",{className:`flex items-center gap-2.5 rounded-lg px-3 py-2 ring-1 ${h.status==="active"?"bg-ouro-glow/5 ring-ouro-glow/20":h.status==="done"?"bg-ouro-void/40 ring-ouro-glow/10":"bg-ouro-void/40 ring-ouro-moss/10"}`,children:[e.jsx(_,{color:h.status==="done"?"lime":h.status==="active"?"yellow":(h.status==="skipped","zinc"),children:h.status}),e.jsx("span",{className:`text-sm ${h.status==="active"?"font-medium text-ouro-bone":"text-ouro-mist"}`,children:h.label}),h.detail&&e.jsx("span",{className:"ml-auto text-xs text-ouro-shadow",children:h.detail})]},p))})]}),e.jsxs("section",{children:[e.jsx(ke,{label:`Coding lanes (${S.length})`}),S.length>0?e.jsx("div",{className:"mt-3 space-y-2",children:S.map(h=>{const p=h.status,k=p==="failed",L=h.failure,I=h.obligationId,A=h.originSession;return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{color:k?"red":p==="running"?"lime":p==="completed"?"zinc":"yellow",children:p}),e.jsx("span",{className:"text-sm font-medium text-ouro-bone",children:h.runner}),e.jsx("span",{className:"truncate text-xs text-ouro-shadow",children:h.workdir})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-2",children:[I&&e.jsxs("button",{onClick:()=>a({tab:"work",focus:I}),className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["obligation: ",I.slice(0,20),"…"]}),h.taskRef&&e.jsxs("span",{className:"text-xs text-ouro-glow",children:["task: ",h.taskRef]}),A&&e.jsx("button",{onClick:()=>{a({tab:"sessions",focus:`${A.friendId}/${A.channel}/${A.key}`})},className:"text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:"origin session"})]}),h.checkpoint&&e.jsx("p",{className:"mt-1.5 text-xs text-ouro-mist",children:Y(h.checkpoint,100)}),e.jsxs("p",{className:"mt-1 text-xs text-ouro-shadow",children:["pid ",h.pid??"–"," · restarts ",h.restartCount," · ",U(h.lastActivityAt)]}),k&&L&&e.jsxs("div",{className:"mt-2 rounded bg-ouro-fang/5 p-2 text-xs ring-1 ring-ouro-fang/15",children:[e.jsx("span",{className:"font-semibold text-ouro-fang",children:"FAILURE:"})," ",e.jsxs("span",{className:"text-ouro-mist",children:[L.command," exited ",String(L.code??L.signal)]}),L.stderrTail&&e.jsx("pre",{className:"mt-1 max-h-20 overflow-y-auto font-mono text-[11px] text-ouro-shadow whitespace-pre-wrap",children:L.stderrTail})]})]},h.id)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No coding sessions."})]}),e.jsxs("section",{children:[e.jsx(ke,{label:`Tasks (${v.liveCount} live, ${v.blockedCount} blocked)`}),((T=v.liveTaskNames)==null?void 0:T.length)>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:v.liveTaskNames.map(h=>e.jsx(_,{children:h},h))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No live tasks."}),((M=v.actionRequired)==null?void 0:M.length)>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-fang",children:"Action required"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:v.actionRequired.map(h=>e.jsx(_,{color:"red",children:h},h))})]})]})]})}function ke({label:t}){return e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:t})}function Gr({view:t,error:s}){const o=(t==null?void 0:t.latest)??null,n=(t==null?void 0:t.latestReady)??null,r=new Set([o,n].filter(c=>!!c).map(Je)),a=((t==null?void 0:t.history)??[]).filter(c=>!r.has(Je(c)));return e.jsx("div",{className:"mt-3 rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:s&&!t?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_,{color:"red",children:"unavailable"}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-sm text-ouro-mist",children:s})]}):t?e.jsxs(e.Fragment,{children:[s&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2 border-b border-ouro-moss/10 pb-2",children:[e.jsx(_,{color:"red",children:"unavailable"}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-xs text-ouro-mist",children:s})]}),o?e.jsx(Wt,{label:"Latest",receipt:o,prominent:!0}):e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_,{children:"missing"}),e.jsx("span",{className:"text-sm text-ouro-shadow",children:"Latest"})]}),n&&e.jsx("div",{className:"mt-3 border-t border-ouro-moss/10 pt-3",children:e.jsx(Wt,{label:"Latest ready",receipt:n})}),a.length>0&&e.jsxs("div",{className:"mt-3 border-t border-ouro-moss/10 pt-3",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"History"}),e.jsx("div",{className:"mt-2 divide-y divide-ouro-moss/10",children:a.map(c=>e.jsx(Zr,{receipt:c},Je(c)))})]}),t.degraded.issues.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-ouro-moss/10 pt-3",children:[e.jsx(_,{color:"yellow",children:"degraded"}),t.degraded.issues.map(c=>e.jsx("span",{className:"break-words text-xs text-ouro-shadow",children:c},c))]})]}):null})}function Wt({label:t,receipt:s,prominent:o=!1}){return e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx(_,{color:Is(s.verdict),children:s.verdict}),e.jsx("span",{className:"font-mono text-xs text-ouro-bone",children:Ms(s.trigger)}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:["updated ",U(s.generatedAt)]})]}),e.jsx("p",{className:`${o?"mt-2 text-sm font-medium text-ouro-bone":"mt-1.5 text-sm text-ouro-mist"} break-words`,children:s.summary}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsx(Kt,{label:"Current ask",value:s.recoveryAnchor.currentAsk}),e.jsx(Kt,{label:"Next safe action",value:s.recoveryAnchor.nextSafeAction})]}),s.signals.length>0&&e.jsx("div",{className:"mt-3 divide-y divide-ouro-moss/10 border-t border-ouro-moss/10 pt-1",children:s.signals.map(n=>e.jsx(Jr,{signal:n},n.id))}),Vt(s.sourceLocators).length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Sources"}),Vt(s.sourceLocators).map(n=>e.jsx("span",{className:"max-w-full truncate font-mono text-[10px] text-ouro-moss",children:n},n))]})]})}function Kt({label:t,value:s}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("p",{className:"mt-1 break-words text-sm text-ouro-bone",children:s?Y(s,140):"unknown"})]})}function Jr({signal:t}){return e.jsxs("div",{className:"grid gap-2 py-2 md:grid-cols-[150px_1fr] md:items-start",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_,{color:ea(t),children:t.status}),e.jsx("span",{className:"font-mono text-[10px] text-ouro-shadow",children:t.kind.replace(/_/g," ")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"break-words text-xs text-ouro-mist",children:t.summary}),e.jsx("p",{className:"mt-1 truncate font-mono text-[10px] text-ouro-moss",children:t.source.locator}),t.repair&&e.jsxs("p",{className:"mt-1 break-words text-xs text-ouro-shadow",children:[t.repair.actor,": ",t.repair.command??t.repair.detail]})]})]})}function Zr({receipt:t}){var o;const s=((o=t.signals[0])==null?void 0:o.summary)??null;return e.jsxs("div",{className:"grid gap-2 py-2 md:grid-cols-[120px_110px_1fr] md:items-start",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(_,{color:Is(t.verdict),children:t.verdict})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono text-xs text-ouro-bone",children:Ms(t.trigger)}),e.jsx("p",{className:"text-[10px] text-ouro-shadow",children:U(t.generatedAt)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"break-words text-xs text-ouro-mist",children:t.summary}),s&&e.jsx("p",{className:"mt-1 break-words text-xs text-ouro-shadow",children:s}),e.jsx("p",{className:"mt-1 truncate font-mono text-[10px] text-ouro-moss",children:t.receiptLocator})]})]})}function Is(t){return t==="ready"?"lime":t==="watch"?"yellow":"red"}function ea(t){return t.status==="fail"||t.severity==="critical"?"red":t.status==="warn"||t.severity==="warn"?"yellow":"lime"}function Je(t){return t.receiptLocator||t.id}function Vt(t){return Array.from(new Set(t.filter(Boolean)))}function Ms(t){return t.replace(/_/g," ")}function ta(t){return"isPrimary"in t}function sa({agentName:t,focus:s,onFocusConsumed:o,refreshGeneration:n}){const r=ge(),[a,c]=i.useState(null),[f,d]=i.useState(null),[b,x]=i.useState(null);i.useEffect(()=>{const g=`/agents/${encodeURIComponent(t)}`;Promise.all([P(`${g}/attention`).then(c),P(`${g}/bridges`).then(d),P(`${g}/friends`).then(x)])},[t,n]);const w=(a==null?void 0:a.queueItems)??[],y=(f==null?void 0:f.items)??[],u=(b==null?void 0:b.friends)??[];return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsx(Ze,{label:`Who is waiting (${(a==null?void 0:a.queueLength)??0})`}),w.length>0?e.jsx("div",{className:"mt-3 space-y-2",children:w.map((g,m)=>{const j=g.bridgeId,N=g.obligationId;return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>r({tab:"sessions"}),className:"font-medium text-ouro-bone hover:text-ouro-glow transition-colors",children:g.friendName}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:["via ",g.channel]}),e.jsxs(_,{color:"yellow",children:["waiting ",U(new Date(g.timestamp).toISOString())]})]}),e.jsx("p",{className:"mt-1 text-sm text-ouro-mist",children:Y(g.delegatedContent,140)}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-2 text-xs",children:[j&&e.jsxs("button",{onClick:()=>r({tab:"connections",focus:j}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["bridge: ",j.slice(0,12),"…"]}),N&&e.jsxs("button",{onClick:()=>r({tab:"work",focus:N}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["obligation: ",N.slice(0,16),"…"]})]})]},m)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"Nobody waiting."})]}),e.jsxs("section",{children:[e.jsx(Ze,{label:`Bridges (${(f==null?void 0:f.totalCount)??0})`}),y.length>0?e.jsx("div",{className:"mt-3 space-y-3",children:y.map(g=>{const m=g.attachedSessions,j=g.task,N=g.lifecycle==="active";return e.jsxs("div",{className:`rounded-lg px-3 py-3 ring-1 ${N?"bg-ouro-moss/10 ring-ouro-glow/12":"bg-ouro-void/40 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_,{color:N?"lime":"zinc",children:g.lifecycle}),e.jsx("p",{className:"font-medium text-ouro-bone",children:g.objective})]}),g.summary&&e.jsx("p",{className:"mt-1 text-sm text-ouro-mist",children:Y(g.summary,160)}),m.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:m.map((v,E)=>e.jsxs("button",{onClick:()=>r({tab:"sessions",focus:`${v.friendId}/${v.channel}/${v.key}`}),className:"rounded-md bg-ouro-moss/10 px-2 py-0.5 font-mono text-[11px] text-ouro-glow ring-1 ring-ouro-moss/12 hover:ring-ouro-glow/25 transition-colors",children:[v.friendId,"/",v.channel,"/",v.key]},E))}),j&&e.jsxs("p",{className:"mt-1.5 text-xs",children:[e.jsxs("button",{onClick:()=>r({tab:"work"}),className:"text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["task: ",j.taskName]}),e.jsxs("span",{className:"text-ouro-shadow",children:[" (",j.mode,")"]})]}),e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow",children:U(g.updatedAt)})]},g.id)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No bridges."})]}),e.jsxs("section",{children:[e.jsx(Ze,{label:`Friends (${(b==null?void 0:b.totalFriends)??0})`}),u.length>0?e.jsx("div",{className:"mt-3 space-y-1.5",children:u.map(g=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-ouro-void/40 px-3 py-2.5 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("button",{onClick:()=>r({tab:"sessions"}),className:"font-medium text-ouro-bone hover:text-ouro-glow transition-colors",children:g.friendName}),e.jsxs("p",{className:"text-xs text-ouro-shadow",children:[g.channels.join(", ")," · ",g.sessionCount," sessions",g.lastActivityAt&&e.jsxs(e.Fragment,{children:[" · ",U(g.lastActivityAt)]})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("p",{className:"tabular-nums text-sm font-medium text-ouro-bone",children:g.totalTokens.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-ouro-shadow",children:"tokens"})]})]},g.friendId))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No friends."})]})]})}function Ze({label:t}){return e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:t})}function oa(t){return As(t)}function Ce(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(oa(t)))}function na({agentName:t,view:s,refreshGeneration:o}){const n=ge(),[r,a]=i.useState(null),[c,f]=i.useState(null),[d,b]=i.useState(!1),[x,w]=i.useState(null),[y,u]=i.useState(!1),g=i.useRef(null),m=s.inner;i.useEffect(()=>{P(`/agents/${encodeURIComponent(t)}/habits`).then(a)},[t,o]),i.useEffect(()=>{let h=!1;return b(!1),f(null),P(`/agents/${encodeURIComponent(t)}/habit-runs`).then(p=>{h||f(p)}).catch(()=>{h||b(!0)}),()=>{h=!0}},[t,o]),i.useEffect(()=>{x&&g.current!==o&&(g.current=o,P(`/agents/${encodeURIComponent(t)}/inner-transcript`).then(w))},[t,o,x!==null]);function j(){if(x){u(!y);return}P(`/agents/${encodeURIComponent(t)}/inner-transcript`).then(h=>{g.current=o,w(h),u(!0)})}const N=(r==null?void 0:r.items)??[],v=(c==null?void 0:c.items)??[],E=N.filter(h=>h.isOverdue),l=N.filter(h=>h.status==="active"&&!h.isOverdue),S=N.filter(h=>h.status==="paused"),R=m.mode==="deep"?m.origin:null,T=m.mode==="deep"?m.obligationStatus:null,M=N.find(h=>h.name.toLowerCase()==="heartbeat");return e.jsxs("div",{className:"space-y-8",children:[M&&e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Heartbeat"}),e.jsx("div",{className:`mt-2 rounded-xl p-4 ring-1 ${M.isOverdue?"bg-ouro-fang/5 ring-ouro-fang/15":"bg-ouro-moss/10 ring-ouro-glow/10"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${M.isOverdue?"bg-ouro-fang animate-pulse":"bg-ouro-glow"}`}),e.jsx("span",{className:"font-medium text-ouro-bone",children:M.isOverdue?"Overdue":"Healthy"}),e.jsxs("span",{className:"text-xs text-ouro-shadow",children:["every ",M.cadence??"unknown"," · last ",M.lastRun?U(M.lastRun):"never"]})]})})]}),e.jsx("section",{children:e.jsxs("div",{className:"rounded-xl bg-ouro-moss/15 p-4 ring-1 ring-ouro-glow/10",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-ouro-glow",children:"Private runtime work"}),e.jsx("p",{className:"mt-1 font-display text-xl italic font-semibold text-ouro-bone",children:m.status}),m.summary&&e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-ouro-mist",children:m.summary}),e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:m.hasPending?"Private runtime work queued.":"No private runtime work."}),(m.returnObligationQueue.queuedCount>0||m.returnObligationQueue.runningCount>0)&&e.jsxs("p",{className:"mt-1 text-sm text-ouro-mist",children:["Held work items:"," ",e.jsx("span",{className:"font-medium text-ouro-bone",children:m.returnObligationQueue.queuedCount+m.returnObligationQueue.runningCount})," ","(",m.returnObligationQueue.queuedCount," queued",m.returnObligationQueue.runningCount>0?`, ${m.returnObligationQueue.runningCount} running`:"",")",m.returnObligationQueue.oldestActiveAt!==null&&e.jsxs("span",{className:"text-ouro-shadow",children:[" · oldest ",U(new Date(m.returnObligationQueue.oldestActiveAt).toISOString())]})]}),R&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:"Triggered from"}),e.jsxs("button",{onClick:()=>{n({tab:"sessions",focus:`${R.friendId}/${R.channel}/${R.key}`})},className:"mt-1 text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:[R.friendId.slice(0,8),"…/",R.channel,"/",R.key]}),T&&e.jsxs("button",{onClick:()=>n({tab:"work"}),className:"ml-2 text-xs text-ouro-glow underline decoration-ouro-glow/30 underline-offset-2 hover:decoration-ouro-glow",children:["obligation: ",T]})]})]})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Habit sessions"}),e.jsx("p",{className:"mt-1 text-xs text-ouro-shadow",children:c?`${c.totalCount} recorded`:d?"Run history unavailable":"Loading runs"})]}),c&&c.totalCount>v.length&&e.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-ouro-shadow",children:["showing ",v.length,"/",c.totalCount]})]}),c?v.length>0?e.jsx("div",{className:"mt-3 space-y-2",children:v.map(h=>e.jsx(ia,{run:h},h.runId))}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No habit sessions recorded."}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:d?"Habit sessions unavailable.":"Loading habit sessions."})]}),e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:["Private runtime ",x?`(${x.messages.length} total)`:""]}),x?e.jsx(la,{messages:x.messages}):e.jsx("button",{onClick:j,className:"mt-2 w-full rounded-lg px-3 py-2.5 text-left font-mono text-xs text-ouro-glow ring-1 ring-ouro-moss/15 hover:ring-ouro-glow/20 transition-colors",children:"Load private runtime"})]}),e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:["Habits (",(r==null?void 0:r.totalCount)??0,")"]}),E.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-fang mb-1.5",children:["Overdue (",E.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:E.map(h=>e.jsx(tt,{h},h.name))})]}),l.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-glow mb-1.5",children:["Running fine (",l.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:l.map(h=>e.jsx(tt,{h},h.name))})]}),S.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-shadow mb-1.5",children:["Paused (",S.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:S.map(h=>e.jsx(tt,{h},h.name))})]}),N.length===0&&e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No habits configured."})]})]})}function ra(t){return t==="error"||t==="blocked"?"bad":t==="surfaced"||t==="wrote_arc"||t==="updated_desk"||t==="wrote_record"?"good":t==="no_change"?"quiet":"warn"}function aa(t){const s=ra(t);return s==="bad"?"bg-ouro-fang/10 text-ouro-fang ring-ouro-fang/20":s==="good"?"bg-ouro-scale/10 text-ouro-glow ring-ouro-scale/20":s==="warn"?"bg-ouro-gold/10 text-ouro-gold ring-ouro-gold/20":"bg-ouro-void/60 text-ouro-shadow ring-ouro-moss/15"}function ia({run:t}){const s=t.permissionEnvelope.returnRoutes,o=t.surfaceAttempts,n=t.errors??[],r=Array.from(new Set([...t.permissionEnvelope.deniedTools,...t.toolPolicy.deniedTools]));return e.jsxs("article",{className:"rounded-lg bg-ouro-void/45 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`rounded-md px-2 py-0.5 font-mono text-[10px] font-medium uppercase tracking-wider ring-1 ${aa(t.outcome)}`,children:t.outcome}),e.jsx("span",{className:"min-w-0 break-all font-medium text-ouro-bone",children:t.habitName}),e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-shadow",children:t.trigger})]}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-ouro-shadow break-all",children:t.runId})]}),e.jsxs("div",{className:"shrink-0 text-left sm:text-right",children:[e.jsx("p",{className:"font-mono text-[10px] text-ouro-shadow",children:U(t.endedAt)}),t.nextRunAt&&e.jsxs("p",{className:"font-mono text-[10px] text-ouro-glow",children:["next ",U(t.nextRunAt)]})]})]}),e.jsxs("div",{className:"mt-3 grid gap-2 lg:grid-cols-3",children:[e.jsxs(et,{label:"routes",children:[s.length>0?e.jsx("div",{className:"space-y-1.5",children:s.map((a,c)=>e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-moss/20 px-1.5 py-0.5 font-mono text-[10px] text-ouro-mist ring-1 ring-ouro-moss/20",children:a.kind}),e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-void/60 px-1.5 py-0.5 font-mono text-[10px] text-ouro-shadow ring-1 ring-ouro-moss/15",children:a.status})]}),e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-ouro-shadow break-all",children:a.recipient}),(a.friendId||a.channel||a.key)&&[a.friendId,a.channel,a.key].filter(Boolean).join("/")!==a.recipient&&e.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-ouro-mist break-all",children:[a.friendId,a.channel,a.key].filter(Boolean).join("/")}),a.reason&&e.jsx("p",{className:"mt-0.5 text-[11px] text-ouro-shadow break-words",children:a.reason})]},`${a.kind}-${a.recipient}-${c}`))}):e.jsx("span",{className:"text-ouro-shadow",children:"none"}),e.jsxs("p",{className:"mt-1 text-[11px] text-ouro-shadow",children:["outward ",t.permissionEnvelope.canMessageOutward?"allowed":"closed"]}),t.permissionEnvelope.warnings.length>0&&e.jsx("div",{className:"mt-1.5 space-y-1",children:t.permissionEnvelope.warnings.map((a,c)=>e.jsx("p",{className:"text-[11px] text-ouro-gold break-words",children:a},`${a}-${c}`))})]}),e.jsx(et,{label:"attempts",children:o.length>0?e.jsx("div",{className:"space-y-1",children:o.map((a,c)=>e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"rounded bg-ouro-moss/20 px-1.5 py-0.5 font-mono text-[10px] text-ouro-bone ring-1 ring-ouro-moss/20",children:a.result}),e.jsx("span",{className:"text-[11px] text-ouro-shadow",children:a.reason})]}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10px] text-ouro-shadow break-all",children:[a.recipient,"/",a.channel,a.error?` - ${a.error}`:""]})]},`${a.recipient}-${a.channel}-${c}`))}):e.jsx("span",{className:"text-ouro-shadow",children:"none"})}),e.jsxs(et,{label:"tools",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.toolPolicy.grantedTools.map(a=>e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-scale/10 px-1.5 py-0.5 font-mono text-[10px] text-ouro-glow ring-1 ring-ouro-scale/15",children:a},`granted-${a}`)),r.map(a=>e.jsx("span",{className:"max-w-full break-all rounded bg-ouro-fang/8 px-1.5 py-0.5 font-mono text-[10px] text-ouro-fang ring-1 ring-ouro-fang/15",children:a},`denied-${a}`)),t.toolPolicy.grantedTools.length===0&&r.length===0&&e.jsx("span",{className:"text-ouro-shadow",children:"none"})]}),t.errorCount>0&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] text-ouro-fang",children:[t.errorCount," error",t.errorCount===1?"":"s"]}),n.length>0&&e.jsx("div",{className:"mt-1 space-y-1",children:n.map((a,c)=>e.jsx("p",{className:"max-w-full break-words font-mono text-[10px] text-ouro-fang",children:a},`${t.runId}-error-${c}`))})]})]}),(t.producedRefs.length>0||t.receiptLocator)&&e.jsxs("div",{className:"mt-3 border-t border-ouro-moss/15 pt-2",children:[t.producedRefs.length>0&&e.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:t.producedRefs.map((a,c)=>e.jsxs("span",{className:"max-w-full break-all rounded bg-ouro-void/60 px-1.5 py-0.5 font-mono text-[10px] text-ouro-shadow ring-1 ring-ouro-moss/10",children:[a.kind,": ",a.locator]},`${a.kind}-${a.locator}-${c}`))}),e.jsx("p",{className:"font-mono text-[10px] text-ouro-shadow break-all",children:t.receiptLocator})]})]})}function et({label:t,children:s}){return e.jsxs("div",{className:"min-w-0 border-l border-ouro-moss/15 pl-2.5",children:[e.jsx("p",{className:"mb-1 font-mono text-[9px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("div",{className:"min-w-0 text-xs text-ouro-mist",children:s})]})}function la({messages:t}){var y;const s=t.filter(u=>u.role!=="system"&&u.role!=="tool"),[o,n]=i.useState(!1),r=o?s:s.slice(-30),a=s.length-r.length,c=((y=r[r.length-1])==null?void 0:y.id)??null,{ref:f,onScroll:d,preserveScroll:b}=$s(c),x=[];for(const u of s){if(u.role!=="assistant")continue;const g=(u.toolCalls??[]).map(ct);for(const m of g)m.kind==="surface"&&x.push({index:u.sequence,kind:"surfaced",label:Y(m.deliveredText??"",40)}),m.kind==="rest"&&x.push({index:u.sequence,kind:"resting",label:"resting"}),m.kind==="delegation"&&x.push({index:u.sequence,kind:"delegated",label:"continued thinking"})}function w(u){var m;const g=(m=f.current)==null?void 0:m.querySelector(`[data-msg-index="${u}"]`);g&&g.scrollIntoView({behavior:"smooth",block:"center"})}return e.jsxs("div",{children:[x.length>0&&e.jsx("div",{className:"mt-2 mb-1 flex flex-wrap gap-1",children:x.map((u,g)=>e.jsxs("button",{onClick:()=>{b(),n(!0),setTimeout(()=>w(u.index),100)},className:`rounded-md px-2 py-0.5 text-[10px] font-mono ring-1 transition-colors ${u.kind==="surfaced"?"bg-ouro-scale/10 text-ouro-glow ring-ouro-scale/20 hover:ring-ouro-glow/30":u.kind==="resting"?"bg-ouro-void/40 text-ouro-shadow ring-ouro-moss/10":"bg-ouro-gold/5 text-ouro-gold ring-ouro-gold/10"}`,children:[u.kind==="surfaced"?"★":u.kind==="resting"?"—":"→"," #",u.index]},g))}),e.jsxs("div",{ref:f,"data-testid":"inner-transcript-scroll",onScroll:d,className:"max-h-[60vh] overflow-y-auto rounded-lg bg-ouro-void/60 p-3 ring-1 ring-ouro-moss/15 space-y-1",children:[a>0&&e.jsxs("button",{onClick:()=>{b(),n(!0)},className:"w-full rounded-lg px-3 py-2 text-center font-mono text-xs text-ouro-shadow hover:text-ouro-mist ring-1 ring-ouro-moss/10 hover:ring-ouro-moss/20 transition-colors mb-2",children:["Load ",a," earlier messages"]}),r.map(u=>{const g=Te(u);if(u.role==="user"){const m=g.includes("[pending from")||g.includes("[delegated"),j=g.includes("waking up")||g.includes("world-state checkpoint");return e.jsx("div",{"data-msg-index":u.sequence,className:"flex justify-start py-1",children:e.jsxs("div",{className:`max-w-[85%] rounded-2xl rounded-bl-sm px-3 py-2 ring-1 ${m?"bg-ouro-gold/8 ring-ouro-gold/15":j?"bg-ouro-moss/20 ring-ouro-moss/15":"bg-ouro-moss/25 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider",style:{color:m?"var(--color-ouro-gold)":"var(--color-ouro-shadow)"},children:m?"★ delegated":j?"heartbeat":"prompt"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",u.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Ce(u)})]}),e.jsx("p",{className:"text-sm leading-relaxed text-ouro-bone whitespace-pre-wrap break-words",children:g})]})},u.id)}if(u.role==="assistant"){const m=(u.toolCalls??[]).map(ct),j=m.filter(E=>E.kind==="surface"),N=m.filter(E=>E.kind==="rest"),v=m.filter(E=>E.kind==="delegation");return e.jsxs("div",{"data-msg-index":u.sequence,children:[j.map(E=>e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:"max-w-[85%] rounded-2xl rounded-br-sm bg-ouro-scale/15 px-3 py-2 ring-1 ring-ouro-scale/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-glow",children:"★ surfaced outward"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",u.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Ce(u)})]}),e.jsx("p",{className:"text-sm leading-relaxed text-ouro-bone whitespace-pre-wrap break-words",children:E.deliveredText}),E.metadata&&e.jsxs("p",{className:"mt-1 font-mono text-[9px] text-ouro-shadow",children:["→ ",E.metadata]})]})},E.id)),v.length>0&&e.jsxs("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-gold/50",children:["— still thinking — #",u.sequence," · ",Ce(u)]}),N.length>0&&e.jsxs("div",{className:"py-1 text-center font-mono text-[10px] text-ouro-shadow/40",children:["— resting — #",u.sequence," · ",Ce(u)]}),j.length===0&&N.length===0&&v.length===0&&g&&e.jsx("div",{className:"flex justify-end py-1",children:e.jsxs("div",{className:"max-w-[85%] rounded-2xl rounded-br-sm bg-ouro-glow/6 px-3 py-2 ring-1 ring-ouro-glow/8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"font-mono text-[9px] uppercase tracking-wider text-ouro-glow/50",children:"thinking"}),e.jsxs("span",{className:"font-mono text-[9px] text-ouro-shadow/40",children:["#",u.sequence]}),e.jsx("span",{className:"font-mono text-[9px] text-ouro-shadow/60",children:Ce(u)})]}),e.jsx("p",{className:"text-sm leading-relaxed text-ouro-mist whitespace-pre-wrap break-words",children:g})]})})]},u.id)}return null})]})]})}function tt({h:t}){const s=t.isOverdue,o=t.isDegraded,n=t.status;return e.jsxs("div",{className:`rounded-lg px-3 py-2.5 ring-1 ${s?"bg-ouro-fang/5 ring-ouro-fang/15":o?"bg-ouro-gold/5 ring-ouro-gold/15":n==="paused"?"bg-ouro-void/30 ring-ouro-moss/10":"bg-ouro-void/40 ring-ouro-moss/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{color:s?"red":o?"yellow":n==="active"?"lime":"zinc",children:s?"overdue":o?"degraded":n}),e.jsx("span",{className:"font-medium text-ouro-bone",children:t.title})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-3 text-xs text-ouro-shadow",children:[t.cadence&&e.jsxs("span",{children:["every ",t.cadence]}),e.jsx("span",{children:t.lastRun?`last ${U(t.lastRun)}`:"never run"}),o&&t.degradedReason&&e.jsx("span",{className:"text-ouro-gold",children:t.degradedReason}),!s&&!o&&n==="active"&&t.lastRun&&e.jsx("span",{className:"text-ouro-glow",children:"on schedule"}),s&&t.overdueMs&&e.jsxs("span",{className:"text-ouro-fang",children:[Math.floor(t.overdueMs/6e4),"m overdue"]}),!t.lastRun&&n==="active"&&e.jsx("span",{className:"text-ouro-gold",children:"never fired — may be misconfigured"})]}),t.bodyExcerpt&&e.jsx("p",{className:"mt-1 text-xs text-ouro-mist",children:t.bodyExcerpt})]})}function ca({agentName:t,refreshGeneration:s}){const[o,n]=i.useState(null),[r,a]=i.useState(null),[c,f]=i.useState("diary");if(i.useEffect(()=>{P(`/agents/${encodeURIComponent(t)}/notes`).then(n),P(`/agents/${encodeURIComponent(t)}/note-decisions`).then(a).catch(()=>{})},[t,s]),!o)return e.jsxs("div",{className:"flex items-center gap-2 py-6",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-ouro-glow"}),e.jsx("span",{className:"font-mono text-xs text-ouro-shadow",children:"Loading…"})]});const d=o.recentDiaryEntries,b=o.recentCanonicalNotes;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>f("diary"),className:`font-mono text-xs uppercase tracking-wider transition-colors ${c==="diary"?"text-ouro-glow":"text-ouro-shadow hover:text-ouro-mist"}`,children:["Diary (",o.diaryEntryCount,")"]}),e.jsx("span",{className:"text-ouro-shadow/30",children:"|"}),e.jsxs("button",{onClick:()=>f("notes"),className:`font-mono text-xs uppercase tracking-wider transition-colors ${c==="notes"?"text-ouro-glow":"text-ouro-shadow hover:text-ouro-mist"}`,children:["Notes (",o.canonicalNoteCount,")"]}),e.jsx("span",{className:"text-ouro-shadow/30",children:"|"}),e.jsxs("button",{onClick:()=>f("decisions"),className:`font-mono text-xs uppercase tracking-wider transition-colors ${c==="decisions"?"text-ouro-glow":"text-ouro-shadow hover:text-ouro-mist"}`,children:["Decisions (",(r==null?void 0:r.totalCount)??0,")"]})]}),c==="diary"&&e.jsx("div",{children:d.length>0?e.jsx("div",{className:"space-y-3",children:d.map(x=>e.jsxs("article",{className:"rounded-xl bg-ouro-void/40 px-4 py-3.5 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"text-sm leading-relaxed text-ouro-bone",children:x.text}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-ouro-shadow",children:[e.jsx(_,{children:x.source}),e.jsx("span",{children:U(x.createdAt)})]})]},x.id))}):e.jsx("p",{className:"text-sm text-ouro-shadow italic",children:"No diary entries yet. The agent hasn't written anything down."})}),c==="notes"&&e.jsx("div",{children:b.length>0?e.jsx("div",{className:"space-y-3",children:b.map(x=>e.jsxs("article",{className:"rounded-xl bg-ouro-void/40 px-4 py-3.5 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"font-medium text-ouro-bone",children:x.title}),e.jsx("span",{className:"text-xs text-ouro-shadow",children:U(x.writtenAt)})]}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-ouro-mist",children:x.preview}),x.tags.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:x.tags.map(w=>e.jsx(_,{children:w},w))})]},x.filename))}):e.jsx("p",{className:"text-sm text-ouro-shadow italic",children:"No canonical notes yet."})}),c==="decisions"&&e.jsx("div",{children:r&&r.items.length>0?e.jsx("div",{className:"space-y-2",children:r.items.map((x,w)=>e.jsxs("div",{className:"rounded-xl bg-ouro-void/40 px-4 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{color:x.decision==="saved"?"lime":"zinc",children:x.decision}),e.jsx(_,{children:x.kind.replace(/_/g," ")}),e.jsx("span",{className:"text-xs text-ouro-shadow",children:U(x.timestamp)})]}),x.reason&&e.jsx("p",{className:"mt-1 text-sm text-ouro-mist",children:x.reason}),x.excerpt&&e.jsx("p",{className:"mt-0.5 text-xs text-ouro-shadow italic truncate",children:x.excerpt})]},w))}):e.jsx("p",{className:"text-sm text-ouro-shadow italic",children:"No note decisions logged yet."})})]})}function da({agentName:t,view:s,refreshGeneration:o}){var g;const[n,r]=i.useState(null),[a,c]=i.useState(null),f=s.agent,d=f.degraded,b=f.freshness,x=((g=f.providers)==null?void 0:g.lanes)??[];i.useEffect(()=>{Promise.all([P("/machine/health").then(r).catch(()=>null),P("/machine/logs").then(c).catch(()=>null)])},[t,o]);const w=ba(n)?n:null,y=(w==null?void 0:w.degradedComponents)??[],u=(a==null?void 0:a.entries)??[];return e.jsxs("div",{className:"space-y-8",children:[d.status==="degraded"&&d.issues.length>0&&e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-fang",children:["Agent issues (",d.issues.length,")"]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:d.issues.map((m,j)=>e.jsxs("div",{className:"rounded-lg bg-ouro-fang/5 px-3 py-2.5 ring-1 ring-ouro-fang/15",children:[e.jsx("p",{className:"font-mono text-xs font-semibold text-ouro-fang",children:m.code}),e.jsx("p",{className:"mt-0.5 text-xs text-ouro-mist break-all",children:m.detail})]},j))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Agent config"}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3",children:[e.jsx(ue,{label:"Provider lanes",value:ua(x)}),e.jsx(ue,{label:"Enabled",value:f.enabled?"yes":"no"}),e.jsx(ue,{label:"Freshness",value:`${b.status}${b.ageMs!=null?` (${Math.floor(b.ageMs/6e4)}m)`:""}`})]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Provider lanes"}),x.length>0?e.jsx("div",{className:"mt-3 grid gap-2 lg:grid-cols-2",children:x.map(m=>{const j=ha(m);return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-3 ring-1 ring-ouro-moss/15",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"font-mono text-xs font-semibold uppercase tracking-wider text-ouro-bone",children:m.lane}),e.jsx(_,{color:fa(m),children:m.status}),e.jsx(_,{color:ga(m.readiness.status),children:m.readiness.status})]}),e.jsx("p",{className:"mt-2 text-sm font-medium text-ouro-bone",children:xa(m)}),e.jsxs("div",{className:"mt-2 space-y-1 text-xs text-ouro-mist",children:[e.jsxs("p",{children:["source: ",m.source]}),e.jsxs("p",{children:["readiness: ",ma(m.readiness)]}),m.readiness.attempts!==void 0&&e.jsxs("p",{children:["attempts: ",m.readiness.attempts]}),m.readiness.checkedAt&&e.jsxs("p",{children:["checked: ",U(m.readiness.checkedAt)]}),e.jsxs("p",{children:["credentials: ",pa(m.credential)]}),m.credential.revision&&e.jsxs("p",{children:["revision: ",m.credential.revision]}),Yt(m)&&e.jsxs("p",{children:["reason: ",Yt(m)]}),j&&e.jsxs("p",{className:"break-all text-ouro-fang",children:["repair: ",j]}),m.warnings.map((N,v)=>e.jsxs("p",{className:"break-words text-ouro-gold",children:["warning: ",N]},v))]})]},m.lane)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No provider lane data loaded."})]}),e.jsxs("section",{children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:"Daemon health"}),w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3",children:[e.jsx(ue,{label:"Status",value:w.status}),e.jsx(ue,{label:"Mode",value:w.mode}),e.jsx(ue,{label:"Uptime",value:`${Math.floor(w.uptimeSeconds/60)}m`})]}),y.length>0&&e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-fang",children:"Degraded components"}),y.map((m,j)=>e.jsxs("div",{className:"rounded-lg bg-ouro-fang/5 px-3 py-2 ring-1 ring-ouro-fang/15",children:[e.jsx("p",{className:"text-xs font-semibold text-ouro-fang",children:m.component}),e.jsx("p",{className:"text-xs text-ouro-mist",children:m.reason})]},j))]})]}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No health file found. This is normal when not running under the daemon."})]}),e.jsxs("section",{children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.15em] text-ouro-glow",children:["Recent logs (",(a==null?void 0:a.totalLines)??0," total)"]}),u.length>0?e.jsx("div",{className:"mt-3 max-h-96 overflow-y-auto rounded-lg bg-ouro-void/40 ring-1 ring-ouro-moss/15",children:[...u].reverse().slice(0,50).map((m,j)=>{const N=m.level;return e.jsxs("div",{className:"border-b border-ouro-moss/10 px-3 py-1.5 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(_,{color:N==="error"?"red":N==="warn"?"yellow":"zinc",children:N}),e.jsx("span",{className:"text-ouro-shadow",children:U(m.ts)}),e.jsx("span",{className:"font-mono text-ouro-glow",children:m.event})]}),e.jsx("p",{className:"truncate text-xs text-ouro-mist",children:m.message})]},j)})}):e.jsx("p",{className:"mt-2 text-sm text-ouro-shadow",children:"No log entries."})]})]})}function ue({label:t,value:s}){return e.jsxs("div",{className:"rounded-lg bg-ouro-void/40 px-3 py-2.5 ring-1 ring-ouro-moss/15",children:[e.jsx("p",{className:"font-mono text-[10px] uppercase tracking-wider text-ouro-shadow",children:t}),e.jsx("p",{className:"mt-1 text-sm font-medium text-ouro-bone",children:s})]})}function ua(t){return t.length===0?"none":`${t.filter(o=>o.status==="configured").length}/${t.length} configured`}function xa(t){return t.status==="unconfigured"?"unconfigured":`${t.provider} / ${t.model}`}function ma(t){return t.status==="failed"?t.error?`failed: ${t.error}`:"failed":t.status==="stale"?t.reason?`stale: ${t.reason}`:"stale":t.status==="unknown"?t.reason?`unknown: ${t.reason}`:"unknown":t.status}function pa(t){return t.status==="present"?t.source??"vault":t.status==="invalid-pool"?"vault unavailable":"missing"}function ha(t){return t.status==="unconfigured"?t.repairCommand:t.credential.repairCommand}function Yt(t){return t.status==="unconfigured"?t.reason:t.readiness.reason}function fa(t){return t.status==="configured"?"green":"yellow"}function ga(t){return t==="ready"?"green":t==="failed"?"red":t==="stale"?"amber":"zinc"}function ba(t){return!!(t&&"degradedComponents"in t)}const st=[{id:"overview",label:"Overview"},{id:"mail",label:"Mailbox"},{id:"sessions",label:"Sessions"},{id:"work",label:"Work"},{id:"connections",label:"Connections"},{id:"inner",label:"Private Runtime"},{id:"notes",label:"Desk Record"},{id:"runtime",label:"Runtime"}];function va(t){return t==="degraded"||t==="blocked"?"red":t==="stale"?"yellow":t==="active"?"lime":"zinc"}function ja({agentName:t,view:s,deskPrefs:o,refreshGeneration:n,initialRoute:r,onNavigate:a}){const[c,f]=i.useState((r==null?void 0:r.tab)??"overview"),[d,b]=i.useState(r==null?void 0:r.focus),x=i.useRef(t);i.useEffect(()=>{const j=x.current!==t;if(x.current=t,(r==null?void 0:r.agent)===t){f(r.tab),b(r.focus);return}j&&(f("overview"),b(void 0))},[t,r==null?void 0:r.agent,r==null?void 0:r.focus,r==null?void 0:r.tab]);const w=i.useCallback(j=>{const N={agent:t,tab:j.tab,focus:j.focus};f(j.tab),b(j.focus),window.history.pushState(null,"",Ue(N)),a==null||a(N)},[t,a]),y=i.useCallback(j=>{const N={agent:t,tab:j,focus:void 0};f(j),b(void 0),window.history.pushState(null,"",Ue(N)),a==null||a(N)},[t,a]),u=i.useCallback(()=>b(void 0),[]);if(ir(w),!s||!t)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[e.jsx("p",{className:"font-display text-2xl italic text-ouro-bone",children:"Choose an agent"}),e.jsx("p",{className:"mt-2 text-sm text-ouro-mist",children:"Select an agent from the sidebar to inspect its state."})]});const m=s.agent.attention;return e.jsx(ts.Provider,{value:w,children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex min-h-[4.5rem] flex-wrap items-start justify-between gap-3 pb-4 border-b border-ouro-moss/30",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"font-display text-2xl italic font-semibold text-ouro-bone sm:text-3xl",children:t})}),e.jsx(_,{color:va(m.level),children:m.label})]}),e.jsx("nav",{className:"mt-4 flex gap-0.5 overflow-x-auto border-b border-ouro-moss/20 -mx-1",children:(()=>{const j=o==null?void 0:o.tabOrder;if(!j)return st;const N=j.map(E=>st.find(l=>l.id===E)).filter(E=>E!==void 0),v=st.filter(E=>!j.includes(E.id));return[...N,...v]})().map(j=>e.jsx("button",{type:"button",onClick:()=>y(j.id),className:`shrink-0 px-3 py-2 text-xs font-mono uppercase tracking-wider transition-colors rounded-t-md ${c===j.id?"bg-ouro-moss/20 text-ouro-glow border-b-2 border-ouro-glow":"text-ouro-shadow hover:text-ouro-mist hover:bg-ouro-moss/10"}`,children:j.label},j.id))}),e.jsxs("div",{className:"mt-6",children:[c==="overview"&&e.jsx(pr,{view:s,deskPrefs:o,refreshGeneration:n}),c==="mail"&&e.jsx(kr,{agentName:t,focus:d,onFocusConsumed:u,refreshGeneration:n}),c==="sessions"&&e.jsx(Fr,{agentName:t,focus:d,onFocusConsumed:u,deskPrefs:o,refreshGeneration:n}),c==="work"&&e.jsx(Xr,{agentName:t,view:s,focus:d,onFocusConsumed:u,refreshGeneration:n}),c==="connections"&&e.jsx(sa,{agentName:t,focus:d,onFocusConsumed:u,refreshGeneration:n}),c==="inner"&&e.jsx(na,{agentName:t,view:s,refreshGeneration:n}),c==="notes"&&e.jsx(ca,{agentName:t,refreshGeneration:n}),c==="runtime"&&e.jsx(da,{agentName:t,view:s,refreshGeneration:n})]})]})})}const Qt={observation:"Observation",judgment:"Judgment",input_admitted:"Input admitted",input_unknown:"Input unknown",legacy_input_reported:"Legacy input report (unqualified)",notification_queued:"Notification queued",notification_delivered:"Notification transport acceptance",notification_unknown:"Notification unknown",recovery:"Acknowledged recovery"};function gt(t,s){const o=t===null?NaN:s-Date.parse(t);return Number.isFinite(o)&&o>=0?o:null}function Xt(t,s){const o=gt(t,s);return o===null?"unknown":`${Math.floor(o/1e3)}s`}function _e(t,s){const o=gt(t,s);return o!==null&&o<=3e4}const re="rounded-xl bg-ouro-void/50 p-4 ring-1 ring-ouro-moss/25";function ot({command:t,label:s}){const[o,n]=i.useState(null);if(!t)return null;const r=async()=>{try{await navigator.clipboard.writeText(t),n("copied")}catch{n("failed")}};return e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("code",{className:"block select-text break-all rounded-md bg-ouro-void p-2 text-xs",children:t}),e.jsxs("button",{type:"button",onClick:()=>{r()},className:"text-xs text-ouro-glow underline",children:["Copy ",s," command"]}),o==="copied"&&e.jsx("span",{role:"status",className:"ml-2 text-xs text-ouro-mist",children:"Copied for local execution; nothing was run."}),o==="failed"&&e.jsx("p",{role:"alert",className:"text-xs text-ouro-gold",children:"Copy failed. Select the command text and copy it manually."})]})}function wa({agents:t,agentName:s,focus:o,refreshGeneration:n,onSelectOwner:r}){const[a,c]=i.useState(null),[f,d]=i.useState(null),[b,x]=i.useState(Date.now),w=i.useRef(null),y=i.useRef(n);i.useEffect(()=>{if(!s){w.current=null;return}const l=s;let S=!0,R=!1,T=!1,M=null;const h=async()=>{if(S){if(R){T=!0;return}R=!0,M=new AbortController;try{const A=await P(`/agents/${encodeURIComponent(l)}/supervision`,{signal:M.signal});if(!S)return;if(A.agentName!==l)throw new Error("the observation belongs to another agent");if(A.schemaVersion!==1)throw new Error("unsupported observation schema");c(A),d(null),x(Date.now())}catch(A){S&&!M.signal.aborted&&d({agent:l,message:A instanceof Error?A.message:String(A)})}finally{R=!1,S&&T&&(T=!1,h())}}},p=()=>{h()};w.current=p,p();const k=window.setInterval(()=>{document.visibilityState!=="hidden"&&p()},5e3),L=window.setInterval(()=>x(Date.now()),1e3),I=()=>{x(Date.now()),document.visibilityState!=="hidden"&&p()};return document.addEventListener("visibilitychange",I),()=>{S=!1,M==null||M.abort(),window.clearInterval(k),window.clearInterval(L),document.removeEventListener("visibilitychange",I),w.current===p&&(w.current=null)}},[s]),i.useEffect(()=>{var l;y.current!==n&&(y.current=n,(l=w.current)==null||l.call(w))},[n]);const u=(a==null?void 0:a.agentName)===s?a:null,g=(f==null?void 0:f.agent)===s?f.message:null,m=(u==null?void 0:u.freshness.status)==="fresh"&&_e(u.freshness.observedAt,b),j=!u||u.freshness.status==="unknown"||gt(u.freshness.observedAt,b)===null?"unknown":m?"fresh":"stale",N=(u==null?void 0:u.sessions.items.map(l=>({...l,activity:m&&l.freshness.status==="fresh"&&_e(l.observedAt,b)?l.activity:"unknown",authority:m&&_e(l.observedAt,b)?l.authority:"unknown",capability:m&&_e(l.observedAt,b)?l.capability:"unknown"})))??[],v=u!=null&&u.counts?{working:0,idle:0,shell:0,unknown:0}:null;if(v)for(const l of N)v[l.activity]+=1;const E=(u==null?void 0:u.custody.claims.items.filter(l=>(l.state==="unknown"||l.state==="claimed")&&!l.retired))??[];return e.jsxs("div",{className:"space-y-6 text-ouro-bone",children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-semibold",children:"Supervision"}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm text-ouro-mist",children:"What Shepherd can observe, why it acted or withheld input, and what still needs the owner. Quiet terminals and judgments are not proof of merge, publication or deployment."})]}),e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm text-ouro-mist",children:["Owning Ouro agent",e.jsxs("select",{"aria-label":"Owning Ouro agent",value:s??"",onChange:l=>r(l.target.value||null),className:"max-w-full rounded-lg border border-ouro-moss/40 bg-ouro-deep px-3 py-2 text-ouro-bone",children:[e.jsx("option",{value:"",children:"Choose an owner"}),s&&!t.includes(s)&&e.jsxs("option",{value:s,children:[s," (not in machine inventory)"]}),t.map(l=>e.jsx("option",{value:l,children:l},l))]})]})]}),e.jsxs("aside",{className:`${re} text-sm text-ouro-gold`,"aria-label":"Alpha automation boundary",children:[e.jsx("p",{className:"font-semibold",children:"Alpha automation boundary"}),e.jsx("p",{className:"mt-1",children:Pr})]}),s?e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{role:"alert",className:`${re} text-ouro-gold`,children:["Could not load supervision for ",s,": ",g,".",u&&e.jsxs(e.Fragment,{children:[" Showing the last successful observation for ",s,"; its age continues to increase."]}),e.jsx("button",{type:"button",className:"ml-2 underline",onClick:()=>{var l;return(l=w.current)==null?void 0:l.call(w)},children:"Retry observation"})]}),!u&&!g&&e.jsxs("p",{role:"status",children:["Loading supervision for ",s,"..."]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:re,"aria-label":"Observation health",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(_,{color:j==="fresh"?"lime":"yellow",children:e.jsxs("span",{"data-testid":"supervision-freshness",children:[j," observation"]})}),e.jsx(_,{color:u.health==="ok"?"zinc":"yellow",children:u.health==="ok"?"Sources readable":"Sources degraded"}),e.jsxs("p",{className:"text-sm",children:["Observation age: ",Xt(u.freshness.observedAt,b)]}),e.jsx("button",{type:"button",onClick:()=>{var l;return(l=w.current)==null?void 0:l.call(w)},className:"text-sm text-ouro-glow underline",children:"Refresh observation"})]}),u.freshness.observedAt&&e.jsxs("p",{className:"mt-2 break-words font-mono text-xs text-ouro-mist",children:["Observed at ",e.jsx("time",{dateTime:u.freshness.observedAt,children:u.freshness.observedAt}),". Reading this page does not refresh the observation."]}),e.jsx("dl",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-ouro-mist",children:Object.entries(u.sourceHealth).map(([l,S])=>e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("dt",{children:[l,":"]}),e.jsx("dd",{children:S})]},l))}),u.sourceErrors.length>0&&e.jsx("ul",{className:"mt-3 space-y-1 text-sm text-ouro-gold",children:u.sourceErrors.map((l,S)=>e.jsxs("li",{className:"break-words",children:[l.source,": ",l.detail]},`${l.source}:${l.code}:${S}`))})]}),e.jsx("section",{"aria-label":"Terminal counts",className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:["working","idle","shell","unknown"].map(l=>e.jsxs("div",{className:re,children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-ouro-mist",children:l}),e.jsx("p",{"data-testid":`supervision-count-${l}`,className:"mt-1 text-2xl tabular-nums",children:(v==null?void 0:v[l])??"Unknown"})]},l))}),e.jsxs("p",{className:"text-sm text-ouro-mist",children:["Showing ",N.length," of ",u.sessions.totalCount??"unknown"," terminals.",u.sessions.truncated&&" Inventory is truncated."," Counts above describe only the displayed rows."]}),e.jsxs("section",{"aria-label":"Supervised terminals",className:"grid min-w-0 gap-4 xl:grid-cols-2",children:[N.map(l=>{const S=`${l.host}:${l.session}`,R=u.timeline.items.filter(T=>T.host===l.host&&T.session===l.session);return e.jsxs("article",{className:`${re} min-w-0 space-y-3`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h2",{className:"min-w-0 break-words text-lg font-semibold",children:l.label}),e.jsx(_,{color:l.activity==="working"?"lime":l.activity==="unknown"?"yellow":"zinc",children:l.activity})]}),e.jsxs("dl",{className:"space-y-1 break-words text-sm text-ouro-mist",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Terminal: "}),e.jsxs("dd",{className:"inline font-mono",children:[l.host," / ",l.session]})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Harness: "}),e.jsx("dd",{className:"inline",children:l.harness??"Unknown / no identified coding harness"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Project: "}),e.jsx("dd",{className:"inline font-mono",children:l.project??"Unknown"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Process instance: "}),e.jsx("dd",{className:"inline font-mono",children:l.instance??"Unknown"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"inline",children:"Last observed: "}),e.jsxs("dd",{className:"inline",children:[Xt(l.observedAt,b)," ago"]})]})]}),e.jsxs("p",{className:"text-sm",children:["Stored mandate / pause state: ",l.authority,". Guarded input: ",l.capability,"."]}),e.jsxs("p",{className:"break-words text-sm text-ouro-gold",children:["Stored policy assessment, not an enforced dispatch decision: ",l.withheldReason??"Unknown."]}),e.jsxs("p",{className:"text-sm",children:["Last recorded judgment: ",e.jsx("span",{children:l.lastDecisionLabel??"None recorded"})]}),e.jsxs("p",{className:"break-words text-sm text-ouro-mist",children:["Last recorded action: ",l.lastAction==="respond"?"Reported terminal response":l.lastAction==="let_through"?"Let through without a response":"None recorded",".",l.lastReason&&e.jsxs(e.Fragment,{children:[" ",l.lastReason]}),l.lastActionAt&&e.jsxs(e.Fragment,{children:[" ",e.jsx("time",{dateTime:l.lastActionAt,children:l.lastActionAt})]})]}),e.jsx("a",{className:"inline-block text-xs text-ouro-glow underline",href:`#/supervision/${encodeURIComponent(s)}/${encodeURIComponent(S)}`,children:"Link to this terminal"}),e.jsxs("details",{open:o===S||void 0,className:"border-t border-ouro-moss/25 pt-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm text-ouro-glow",children:["Timeline for ",l.label]}),R.length===0&&e.jsx("p",{className:"mt-2 text-sm text-ouro-mist",children:"No retained events for this terminal."}),e.jsx("ol",{className:"mt-3 space-y-3",children:R.map(T=>e.jsxs("li",{className:"break-words text-sm",children:[e.jsxs("p",{children:[Qt[T.kind],": ",T.summary]}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-ouro-mist",children:[e.jsx("time",{dateTime:T.at,children:T.at})," | ",T.instance?`instance ${T.instance}`:"instance not recorded"]})]},T.id))})]})]},S)}),N.length===0&&e.jsx("p",{className:re,children:u.counts===null?"Terminal inventory is unavailable, not empty.":"No terminals were present in this observation."})]}),e.jsxs("section",{className:re,"aria-label":"Custody and held inputs",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Replay barriers and unknown inputs"}),e.jsx("p",{className:"mt-2 text-sm text-ouro-gold",children:"Unknown effects remain held: do not retry blindly. Owner administration is local-only; this browser cannot resolve or retry claims."}),e.jsx("div",{className:"mt-3",children:e.jsx(ot,{command:qt(s),label:"status"},s)}),e.jsxs("p",{className:"mt-2 text-xs text-ouro-mist",children:["Run commands locally as the existing owner. Local administration is same-UID authority, not proof of human presence."," ","Read current status and inspect the exact claim before changing anything. A stale revision will be rejected."]}),e.jsxs("p",{className:"mt-2 text-xs text-ouro-mist",children:["Custody revision: ",u.custody.revision??"unknown","."," ","Storage: ",u.custody.bytes===null?"unknown":`${u.custody.bytes.toLocaleString()} bytes`," (",u.custody.capacity,")."," ","Showing ",u.custody.claims.items.length," of ",u.custody.claims.totalCount??"unknown"," retained barriers.",u.custody.claims.truncated&&" Custody inventory is truncated."]}),E.map(l=>e.jsxs("div",{className:"mt-3 space-y-1 break-words border-t border-ouro-moss/25 pt-3 text-sm",children:[e.jsxs("p",{children:["Original state: ",l.state," | ",l.host," / ",l.session]}),e.jsx("p",{className:"break-all font-mono text-xs",children:l.id}),e.jsxs("p",{className:"text-ouro-mist",children:[l.reason??"No outcome evidence is recorded."," Acknowledgments in the timeline do not rewrite the original state."]}),e.jsx(ot,{command:qt(s,l.id),label:"inspection"}),e.jsxs("details",{className:"pt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-ouro-glow",children:"Local recovery after terminal retirement"}),e.jsxs("p",{className:"my-2 text-xs text-ouro-mist",children:["The entire terminal must be absent from a strict host inventory."," ","A different foreground process is not proof of retirement. This command never confirms delivery or retries input."," ","Confirmed-delivery recovery remains unsupported until native receipt lookup is qualified."]}),e.jsx(ot,{command:Dr(s,l.id,u.custody.revision),label:"retirement"},`${l.id}:${u.custody.revision}`),u.custody.revision===null&&e.jsx("p",{className:"text-xs text-ouro-gold",children:"No retirement command is available until a custody revision is known."})]})]},l.id)),u.custody.claims.totalCount===null&&e.jsx("p",{className:"mt-3 text-sm",children:"Custody availability is unknown; zero held inputs cannot be established."})]}),e.jsxs("details",{className:re,children:[e.jsx("summary",{className:"cursor-pointer text-sm text-ouro-glow",children:"All retained events, including closed terminals"}),e.jsx("ol",{className:"mt-3 space-y-3",children:u.timeline.items.map(l=>e.jsxs("li",{className:"break-words text-sm",children:[e.jsxs("p",{children:[l.host," / ",l.session,": ",Qt[l.kind],": ",l.summary]}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-ouro-mist",children:[e.jsx("time",{dateTime:l.at,children:l.at})," | ",l.instance??"instance not recorded"]})]},l.id))})]}),e.jsxs("p",{className:"text-xs text-ouro-mist",children:["Retained timeline: ",u.timeline.items.length," of ",u.timeline.totalCount??"unknown"," events.",u.timeline.truncated&&" History is truncated; absence from this view is not proof that an event never occurred."]})]})]}):e.jsx("p",{className:re,children:"Choose an owning Ouro agent to inspect its terminal supervision. No fleet counts are available until an owner is selected."})]})}function nt(){return ss(window.location.hash)}function Na(t){return t==="degraded"||t==="blocked"?"red":t==="stale"?"yellow":t==="active"?"lime":"zinc"}function ya(){var q;const[t,s]=i.useState(()=>jt(window.location.hash)),o=i.useRef(t!==null),[n,r]=i.useState(null),[a,c]=i.useState(((q=nt())==null?void 0:q.agent)??""),[f,d]=i.useState(null),[b,x]=i.useState(null),[w,y]=i.useState(null),[u,g]=i.useState(null),[m,j]=i.useState(null),[N,v]=i.useState(null),[E,l]=i.useState("connecting"),[S,R]=i.useState(0),T=i.useRef(0),M=i.useRef(nt()),[h,p]=i.useState(nt),k=i.useRef(a),L=i.useRef(!0),I=i.useRef(0),A=i.useRef(0),F=i.useRef(null),Q=i.useRef(null),H=i.useCallback($=>{var D;k.current!==$&&(k.current=$,A.current+=1,T.current+=1,(D=Q.current)==null||D.abort(),c($),d(null),x(null),g(null),v(null))},[]),X=i.useCallback(async()=>{var B,J;const $=++I.current;(B=F.current)==null||B.abort();const D=new AbortController;F.current=D;try{const Z=await P("/machine",{signal:D.signal});if(!L.current||$!==I.current)return;if(r(Z),y(null),j(new Date().toISOString()),!o.current&&!k.current&&Z.agents.length>0){const ee=((J=M.current)==null?void 0:J.agent)??Z.agents[0].agentName;H(ee)}}catch(Z){if(!L.current||D.signal.aborted||$!==I.current)return;y(Z instanceof Error?Z.message:String(Z))}},[H]),G=i.useCallback(async $=>{var Z;if(!$)return;const D=++A.current;(Z=Q.current)==null||Z.abort();const B=new AbortController;Q.current=B;const J=()=>L.current&&D===A.current&&k.current===$;try{const[ee,ie]=await Promise.all([P(`/agents/${encodeURIComponent($)}`,{signal:B.signal}),P(`/agents/${encodeURIComponent($)}/desk-prefs`,{signal:B.signal})]);if(!J())return;if(ee.agent.agentName!==$)throw new Error("the response belongs to another agent");d(ee),x(ie),g(null),v(new Date().toISOString())}catch(ee){if(!J()||B.signal.aborted)return;g(ee instanceof Error?ee.message:String(ee))}},[]);i.useEffect(()=>(L.current=!0,()=>{var $,D;L.current=!1,I.current+=1,A.current+=1,T.current+=1,($=F.current)==null||$.abort(),(D=Q.current)==null||D.abort()}),[]),i.useEffect(()=>{X()},[X]),i.useEffect(()=>{a&&G(a)},[a,G]);const W=i.useCallback(async()=>{const $=++T.current,D=o.current?"":k.current;await Promise.all([X(),D?G(D):Promise.resolve()]),L.current&&T.current===$&&R(B=>B+1)},[X,G]);i.useEffect(()=>go(()=>{W()},l),[W]),i.useEffect(()=>{const $=()=>{const D=jt(window.location.hash);if(D){o.current=!0,s(D);return}const B=ss(window.location.hash);B&&(o.current=!1,p(B),s(null),H(B.agent))};return window.addEventListener("hashchange",$),()=>window.removeEventListener("hashchange",$)},[H]);const V=i.useCallback($=>{const D={agent:$,tab:"overview",focus:void 0};p(D),o.current=!1,s(null),H($),window.history.pushState(null,"",Ue(D))},[H]),K=i.useCallback($=>{o.current=!0,s({agent:$}),window.history.pushState(null,"",wt($))},[]);if(!n)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-ouro-void",children:e.jsx("div",{className:"text-center",children:w?e.jsxs("div",{role:"alert",children:[e.jsxs("p",{className:"text-ouro-bone",children:["Could not connect to Mailbox: ",w]}),e.jsx("button",{type:"button",onClick:()=>{W()},className:"mt-3 text-ouro-glow underline",children:"Retry connection"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-auto mb-4 h-4 w-4 animate-pulse rounded-full bg-ouro-glow shadow-[0_0_20px_theme(--color-ouro-glow)]"}),e.jsx("p",{role:"status",className:"font-mono text-sm text-ouro-mist",children:"Connecting to Mailbox…"})]})})});const C=n.overview.totals,O=(f==null?void 0:f.agent.agentName)===a?f:null;return e.jsxs(No,{header:e.jsx(_,{color:n.overview.daemon.mode==="dev"?"yellow":"lime",children:n.overview.daemon.mode}),sidebar:e.jsx(nr,{label:"Mailbox",header:e.jsxs("div",{className:"space-y-3 border-b border-ouro-moss/30 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full bg-ouro-glow shadow-[0_0_16px_theme(--color-ouro-glow)]"}),e.jsx("p",{className:"truncate font-display text-lg italic font-semibold text-ouro-bone",children:"Ouro Mailbox"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:[{v:C.liveTasks??0,l:"Tasks",alert:(C.blockedTasks??0)>0},{v:C.openObligations??0,l:"Oblig."},{v:C.activeCodingAgents??0,l:"Coding"}].map($=>e.jsxs("div",{className:"rounded-md bg-ouro-void/60 px-2 py-1.5 text-center ring-1 ring-ouro-moss/20",children:[e.jsx("div",{className:`text-base font-semibold tabular-nums ${$.alert?"text-ouro-fang":"text-ouro-bone"}`,children:$.v}),e.jsx("div",{className:"text-[9px] uppercase tracking-widest text-ouro-shadow",children:$.l})]},$.l))})]}),sections:[{label:"Machine",items:[{label:"Supervision",href:wt(null),current:t!==null,onClick:$=>{$.preventDefault(),K(null)}}]},{label:"Agents",items:n.agents.map($=>({label:$.agentName,href:Ue({agent:$.agentName,tab:"overview",focus:void 0}),current:t===null&&$.agentName===a,onClick:D=>{D.preventDefault(),V($.agentName)},badge:e.jsx(_,{color:Na($.attention.level),children:$.attention.label})}))}],footer:e.jsxs("div",{className:"space-y-2 border-t border-ouro-moss/20 pt-3 text-xs text-ouro-shadow",children:[e.jsxs("div",{className:"px-2",children:[e.jsx("p",{className:"font-mono",children:n.overview.runtime.version}),e.jsxs("p",{className:"mt-0.5",children:[n.overview.daemon.mode," · ",n.overview.freshness.status]})]}),t===null&&a&&O&&e.jsx("p",{className:"px-2 italic text-ouro-mist",children:(()=>{const $=b==null?void 0:b.statusLine;if($)return $;const D=O.inner;if(D.status==="running"||D.hasPending)return"thinking through something privately";const J=O.work.obligations.openCount;return J>2?"a few loose ends":J>0?"carrying something":"steady"})()})]})}),children:[e.jsxs("div",{role:"status",className:"mb-4 min-h-12 text-xs text-ouro-mist sm:min-h-8",children:[E==="connected"?"Live connection":E==="reconnecting"?"Disconnected - reconnecting. Displayed snapshots may be stale.":"Connecting to live updates. Displayed snapshots may be stale.",m&&e.jsxs(e.Fragment,{children:[" Last machine snapshot received ",e.jsx("time",{dateTime:m,children:new Date(m).toLocaleTimeString()}),"."]})]}),w&&e.jsxs("div",{role:"alert",className:"mb-4 text-sm text-ouro-gold",children:["Could not refresh the machine snapshot: ",w,". Showing the last successful machine snapshot.",e.jsx("button",{type:"button",onClick:()=>{W()},className:"ml-2 underline",children:"Retry"})]}),t===null&&u&&e.jsxs("div",{role:"alert",className:"mb-4 text-sm text-ouro-gold",children:["Could not load ",a,": ",u,".",O&&e.jsxs(e.Fragment,{children:[" Showing the last successful snapshot for ",a,N&&e.jsxs(e.Fragment,{children:[" received ",e.jsx("time",{dateTime:N,children:new Date(N).toLocaleTimeString()})]}),"."]}),e.jsx("button",{type:"button",onClick:()=>{G(a)},className:"ml-2 underline",children:"Retry agent"})]}),t?e.jsx(wa,{agents:n.agents.map($=>$.agentName),agentName:t.agent,focus:t.focus,refreshGeneration:S,onSelectOwner:K}):O||!a?e.jsx(ja,{agentName:a,view:O,deskPrefs:b,refreshGeneration:S,initialRoute:(h==null?void 0:h.agent)===a?h:void 0,onNavigate:p},a):e.jsxs("div",{className:"min-h-[60vh]",children:[e.jsx("div",{className:"flex min-h-[4.5rem] items-start border-b border-ouro-moss/30 pb-4",children:!u&&e.jsx("h1",{className:"font-display text-2xl italic font-semibold text-ouro-bone sm:text-3xl",children:a})}),e.jsx("div",{className:"mt-4 h-9 border-b border-ouro-moss/20","aria-hidden":"true"}),e.jsx("p",{role:"status",className:"mt-4 text-ouro-mist",children:u?`No snapshot available for ${a}.`:`Loading ${a}...`})]})]})}fo.createRoot(document.getElementById("app")).render(e.jsx(i.StrictMode,{children:e.jsx(ya,{})}));