@lincyaw/aegis-ui 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/dist/agent/ask/AskPanel.cjs +1 -1
  2. package/dist/agent/ask/AskPanel.cjs.map +1 -1
  3. package/dist/agent/ask/AskPanel.d.ts +5 -0
  4. package/dist/agent/ask/AskPanel.js +107 -100
  5. package/dist/agent/ask/AskPanel.js.map +1 -1
  6. package/dist/commands/commandContext.cjs.map +1 -1
  7. package/dist/commands/commandContext.d.ts +4 -1
  8. package/dist/commands/commandContext.js.map +1 -1
  9. package/dist/components/ui/AgentPanel.cjs +1 -1
  10. package/dist/components/ui/AgentPanel.cjs.map +1 -1
  11. package/dist/components/ui/AgentPanel.js +15 -14
  12. package/dist/components/ui/AgentPanel.js.map +1 -1
  13. package/dist/components/ui/Avatar.cjs +1 -1
  14. package/dist/components/ui/Avatar.cjs.map +1 -1
  15. package/dist/components/ui/Avatar.js +21 -19
  16. package/dist/components/ui/Avatar.js.map +1 -1
  17. package/dist/components/ui/BlastRadiusBar.cjs +1 -1
  18. package/dist/components/ui/BlastRadiusBar.cjs.map +1 -1
  19. package/dist/components/ui/BlastRadiusBar.d.ts +16 -4
  20. package/dist/components/ui/BlastRadiusBar.js +27 -23
  21. package/dist/components/ui/BlastRadiusBar.js.map +1 -1
  22. package/dist/components/ui/ChatComposer.cjs +1 -1
  23. package/dist/components/ui/ChatComposer.cjs.map +1 -1
  24. package/dist/components/ui/ChatComposer.js +32 -31
  25. package/dist/components/ui/ChatComposer.js.map +1 -1
  26. package/dist/components/ui/ChatSessionList.cjs +1 -1
  27. package/dist/components/ui/ChatSessionList.cjs.map +1 -1
  28. package/dist/components/ui/ChatSessionList.js +68 -66
  29. package/dist/components/ui/ChatSessionList.js.map +1 -1
  30. package/dist/components/ui/Checkbox.cjs +1 -1
  31. package/dist/components/ui/Checkbox.cjs.map +1 -1
  32. package/dist/components/ui/Checkbox.d.ts +6 -2
  33. package/dist/components/ui/Checkbox.js +21 -17
  34. package/dist/components/ui/Checkbox.js.map +1 -1
  35. package/dist/components/ui/ChoiceCardGroup.cjs +1 -1
  36. package/dist/components/ui/ChoiceCardGroup.cjs.map +1 -1
  37. package/dist/components/ui/ChoiceCardGroup.d.ts +13 -4
  38. package/dist/components/ui/ChoiceCardGroup.js +47 -35
  39. package/dist/components/ui/ChoiceCardGroup.js.map +1 -1
  40. package/dist/components/ui/CodeEditor.cjs +1 -1
  41. package/dist/components/ui/CodeEditor.cjs.map +1 -1
  42. package/dist/components/ui/CodeEditor.d.ts +11 -1
  43. package/dist/components/ui/CodeEditor.js +100 -74
  44. package/dist/components/ui/CodeEditor.js.map +1 -1
  45. package/dist/components/ui/CommandInvocationCard.cjs +1 -1
  46. package/dist/components/ui/CommandInvocationCard.cjs.map +1 -1
  47. package/dist/components/ui/CommandInvocationCard.js +28 -31
  48. package/dist/components/ui/CommandInvocationCard.js.map +1 -1
  49. package/dist/components/ui/CommandPalette.cjs +1 -1
  50. package/dist/components/ui/CommandPalette.cjs.map +1 -1
  51. package/dist/components/ui/CommandPalette.d.ts +3 -3
  52. package/dist/components/ui/CommandPalette.js +75 -75
  53. package/dist/components/ui/CommandPalette.js.map +1 -1
  54. package/dist/components/ui/CommitGraph.cjs +1 -1
  55. package/dist/components/ui/CommitGraph.cjs.map +1 -1
  56. package/dist/components/ui/CommitGraph.d.ts +3 -1
  57. package/dist/components/ui/CommitGraph.js +77 -74
  58. package/dist/components/ui/CommitGraph.js.map +1 -1
  59. package/dist/components/ui/ContentInspectorDialog.cjs +1 -1
  60. package/dist/components/ui/ContentInspectorDialog.cjs.map +1 -1
  61. package/dist/components/ui/ContentInspectorDialog.js +25 -31
  62. package/dist/components/ui/ContentInspectorDialog.js.map +1 -1
  63. package/dist/components/ui/ContentPreview.cjs +2 -2
  64. package/dist/components/ui/ContentPreview.cjs.map +1 -1
  65. package/dist/components/ui/ContentPreview.js +55 -56
  66. package/dist/components/ui/ContentPreview.js.map +1 -1
  67. package/dist/components/ui/DangerZone.cjs +1 -1
  68. package/dist/components/ui/DangerZone.cjs.map +1 -1
  69. package/dist/components/ui/DangerZone.js +13 -12
  70. package/dist/components/ui/DangerZone.js.map +1 -1
  71. package/dist/components/ui/DataList.cjs +1 -1
  72. package/dist/components/ui/DataList.cjs.map +1 -1
  73. package/dist/components/ui/DataList.js +25 -24
  74. package/dist/components/ui/DataList.js.map +1 -1
  75. package/dist/components/ui/DataTable.cjs +1 -1
  76. package/dist/components/ui/DataTable.cjs.map +1 -1
  77. package/dist/components/ui/DataTable.js +41 -41
  78. package/dist/components/ui/DataTable.js.map +1 -1
  79. package/dist/components/ui/DropdownMenu.cjs +1 -1
  80. package/dist/components/ui/DropdownMenu.cjs.map +1 -1
  81. package/dist/components/ui/DropdownMenu.js +41 -40
  82. package/dist/components/ui/DropdownMenu.js.map +1 -1
  83. package/dist/components/ui/EnvironmentSwitcher.cjs +1 -1
  84. package/dist/components/ui/EnvironmentSwitcher.cjs.map +1 -1
  85. package/dist/components/ui/EnvironmentSwitcher.js +26 -24
  86. package/dist/components/ui/EnvironmentSwitcher.js.map +1 -1
  87. package/dist/components/ui/EventTable.cjs +1 -1
  88. package/dist/components/ui/EventTable.cjs.map +1 -1
  89. package/dist/components/ui/EventTable.js +60 -53
  90. package/dist/components/ui/EventTable.js.map +1 -1
  91. package/dist/components/ui/FileDropzone.cjs +1 -1
  92. package/dist/components/ui/FileDropzone.cjs.map +1 -1
  93. package/dist/components/ui/FileDropzone.js +38 -40
  94. package/dist/components/ui/FileDropzone.js.map +1 -1
  95. package/dist/components/ui/FilePreview.cjs +1 -1
  96. package/dist/components/ui/FilePreview.cjs.map +1 -1
  97. package/dist/components/ui/FilePreview.js +60 -61
  98. package/dist/components/ui/FilePreview.js.map +1 -1
  99. package/dist/components/ui/FolderDropzone.cjs +1 -1
  100. package/dist/components/ui/FolderDropzone.cjs.map +1 -1
  101. package/dist/components/ui/FolderDropzone.js +114 -84
  102. package/dist/components/ui/FolderDropzone.js.map +1 -1
  103. package/dist/components/ui/ForgotPasswordForm.cjs +1 -1
  104. package/dist/components/ui/ForgotPasswordForm.cjs.map +1 -1
  105. package/dist/components/ui/ForgotPasswordForm.js +22 -21
  106. package/dist/components/ui/ForgotPasswordForm.js.map +1 -1
  107. package/dist/components/ui/FormRow.cjs +1 -1
  108. package/dist/components/ui/FormRow.cjs.map +1 -1
  109. package/dist/components/ui/FormRow.d.ts +32 -11
  110. package/dist/components/ui/FormRow.js +24 -15
  111. package/dist/components/ui/FormRow.js.map +1 -1
  112. package/dist/components/ui/InboxPage.cjs +1 -1
  113. package/dist/components/ui/InboxPage.cjs.map +1 -1
  114. package/dist/components/ui/InboxPage.d.ts +12 -3
  115. package/dist/components/ui/InboxPage.js +91 -77
  116. package/dist/components/ui/InboxPage.js.map +1 -1
  117. package/dist/components/ui/LoginForm.cjs +1 -1
  118. package/dist/components/ui/LoginForm.cjs.map +1 -1
  119. package/dist/components/ui/LoginForm.js +43 -43
  120. package/dist/components/ui/LoginForm.js.map +1 -1
  121. package/dist/components/ui/MonoValue.cjs +1 -1
  122. package/dist/components/ui/MonoValue.cjs.map +1 -1
  123. package/dist/components/ui/MonoValue.d.ts +5 -1
  124. package/dist/components/ui/MonoValue.js +17 -17
  125. package/dist/components/ui/MonoValue.js.map +1 -1
  126. package/dist/components/ui/NotificationBell.cjs +1 -1
  127. package/dist/components/ui/NotificationBell.cjs.map +1 -1
  128. package/dist/components/ui/NotificationBell.d.ts +17 -1
  129. package/dist/components/ui/NotificationBell.js +129 -75
  130. package/dist/components/ui/NotificationBell.js.map +1 -1
  131. package/dist/components/ui/NumberField.cjs +1 -1
  132. package/dist/components/ui/NumberField.cjs.map +1 -1
  133. package/dist/components/ui/NumberField.d.ts +3 -1
  134. package/dist/components/ui/NumberField.js +52 -49
  135. package/dist/components/ui/NumberField.js.map +1 -1
  136. package/dist/components/ui/ObjectBrowser.cjs +1 -1
  137. package/dist/components/ui/ObjectBrowser.cjs.map +1 -1
  138. package/dist/components/ui/ObjectBrowser.js +83 -78
  139. package/dist/components/ui/ObjectBrowser.js.map +1 -1
  140. package/dist/components/ui/PageSizeSelect.cjs +1 -1
  141. package/dist/components/ui/PageSizeSelect.cjs.map +1 -1
  142. package/dist/components/ui/PageSizeSelect.js +30 -29
  143. package/dist/components/ui/PageSizeSelect.js.map +1 -1
  144. package/dist/components/ui/Panel.cjs.map +1 -1
  145. package/dist/components/ui/Panel.d.ts +5 -2
  146. package/dist/components/ui/Panel.js.map +1 -1
  147. package/dist/components/ui/ParquetViewer.cjs +1 -1
  148. package/dist/components/ui/ParquetViewer.cjs.map +1 -1
  149. package/dist/components/ui/ParquetViewer.js +69 -74
  150. package/dist/components/ui/ParquetViewer.js.map +1 -1
  151. package/dist/components/ui/PasswordField.cjs +1 -1
  152. package/dist/components/ui/PasswordField.cjs.map +1 -1
  153. package/dist/components/ui/PasswordField.js +28 -27
  154. package/dist/components/ui/PasswordField.js.map +1 -1
  155. package/dist/components/ui/PickerField.cjs +1 -1
  156. package/dist/components/ui/PickerField.cjs.map +1 -1
  157. package/dist/components/ui/PickerField.d.ts +25 -6
  158. package/dist/components/ui/PickerField.js +20 -17
  159. package/dist/components/ui/PickerField.js.map +1 -1
  160. package/dist/components/ui/ProjectSelector.cjs +1 -1
  161. package/dist/components/ui/ProjectSelector.cjs.map +1 -1
  162. package/dist/components/ui/ProjectSelector.js +40 -37
  163. package/dist/components/ui/ProjectSelector.js.map +1 -1
  164. package/dist/components/ui/QueryAutocomplete.cjs +1 -1
  165. package/dist/components/ui/QueryAutocomplete.cjs.map +1 -1
  166. package/dist/components/ui/QueryAutocomplete.d.ts +7 -1
  167. package/dist/components/ui/QueryAutocomplete.js +141 -134
  168. package/dist/components/ui/QueryAutocomplete.js.map +1 -1
  169. package/dist/components/ui/RegisterForm.cjs +1 -1
  170. package/dist/components/ui/RegisterForm.cjs.map +1 -1
  171. package/dist/components/ui/RegisterForm.js +41 -40
  172. package/dist/components/ui/RegisterForm.js.map +1 -1
  173. package/dist/components/ui/ResizableSidePanel.cjs +1 -1
  174. package/dist/components/ui/ResizableSidePanel.cjs.map +1 -1
  175. package/dist/components/ui/ResizableSidePanel.js +41 -40
  176. package/dist/components/ui/ResizableSidePanel.js.map +1 -1
  177. package/dist/components/ui/SavedQueryBar.cjs +1 -1
  178. package/dist/components/ui/SavedQueryBar.cjs.map +1 -1
  179. package/dist/components/ui/SavedQueryBar.d.ts +1 -1
  180. package/dist/components/ui/SavedQueryBar.js +375 -277
  181. package/dist/components/ui/SavedQueryBar.js.map +1 -1
  182. package/dist/components/ui/SearchInput.cjs +1 -1
  183. package/dist/components/ui/SearchInput.cjs.map +1 -1
  184. package/dist/components/ui/SearchInput.d.ts +5 -1
  185. package/dist/components/ui/SearchInput.js +28 -24
  186. package/dist/components/ui/SearchInput.js.map +1 -1
  187. package/dist/components/ui/Select.cjs +1 -1
  188. package/dist/components/ui/Select.cjs.map +1 -1
  189. package/dist/components/ui/Select.d.ts +3 -1
  190. package/dist/components/ui/Select.js +21 -19
  191. package/dist/components/ui/Select.js.map +1 -1
  192. package/dist/components/ui/ServiceMap.cjs +1 -1
  193. package/dist/components/ui/ServiceMap.cjs.map +1 -1
  194. package/dist/components/ui/ServiceMap.d.ts +9 -3
  195. package/dist/components/ui/ServiceMap.js +291 -231
  196. package/dist/components/ui/ServiceMap.js.map +1 -1
  197. package/dist/components/ui/Slider.cjs +1 -1
  198. package/dist/components/ui/Slider.cjs.map +1 -1
  199. package/dist/components/ui/Slider.d.ts +3 -1
  200. package/dist/components/ui/Slider.js +11 -9
  201. package/dist/components/ui/Slider.js.map +1 -1
  202. package/dist/components/ui/SparkLine.cjs +1 -1
  203. package/dist/components/ui/SparkLine.cjs.map +1 -1
  204. package/dist/components/ui/SparkLine.js +24 -23
  205. package/dist/components/ui/SparkLine.js.map +1 -1
  206. package/dist/components/ui/Steps.cjs +1 -1
  207. package/dist/components/ui/Steps.cjs.map +1 -1
  208. package/dist/components/ui/Steps.js +25 -29
  209. package/dist/components/ui/Steps.js.map +1 -1
  210. package/dist/components/ui/Terminal.cjs +1 -1
  211. package/dist/components/ui/Terminal.cjs.map +1 -1
  212. package/dist/components/ui/Terminal.js +18 -17
  213. package/dist/components/ui/Terminal.js.map +1 -1
  214. package/dist/components/ui/TextField.cjs +1 -1
  215. package/dist/components/ui/TextField.cjs.map +1 -1
  216. package/dist/components/ui/TextField.js +6 -6
  217. package/dist/components/ui/TextField.js.map +1 -1
  218. package/dist/components/ui/ThemeToggle.cjs +1 -1
  219. package/dist/components/ui/ThemeToggle.cjs.map +1 -1
  220. package/dist/components/ui/ThemeToggle.js +15 -18
  221. package/dist/components/ui/ThemeToggle.js.map +1 -1
  222. package/dist/components/ui/TimeDisplay.cjs +1 -1
  223. package/dist/components/ui/TimeDisplay.cjs.map +1 -1
  224. package/dist/components/ui/TimeDisplay.js +12 -12
  225. package/dist/components/ui/TimeDisplay.js.map +1 -1
  226. package/dist/components/ui/TimeRangePicker.cjs +1 -1
  227. package/dist/components/ui/TimeRangePicker.cjs.map +1 -1
  228. package/dist/components/ui/TimeRangePicker.js +128 -111
  229. package/dist/components/ui/TimeRangePicker.js.map +1 -1
  230. package/dist/components/ui/TraceSpanInspector.cjs +1 -1
  231. package/dist/components/ui/TraceSpanInspector.cjs.map +1 -1
  232. package/dist/components/ui/TraceSpanInspector.js +43 -46
  233. package/dist/components/ui/TraceSpanInspector.js.map +1 -1
  234. package/dist/components/ui/TraceTree.cjs +1 -1
  235. package/dist/components/ui/TraceTree.cjs.map +1 -1
  236. package/dist/components/ui/TraceTree.d.ts +1 -1
  237. package/dist/components/ui/TraceTree.js +33 -33
  238. package/dist/components/ui/TraceTree.js.map +1 -1
  239. package/dist/components/ui/UploadQueue.cjs +1 -1
  240. package/dist/components/ui/UploadQueue.cjs.map +1 -1
  241. package/dist/components/ui/UploadQueue.js +59 -70
  242. package/dist/components/ui/UploadQueue.js.map +1 -1
  243. package/dist/components/ui/authValidation.cjs +1 -1
  244. package/dist/components/ui/authValidation.cjs.map +1 -1
  245. package/dist/components/ui/authValidation.d.ts +2 -2
  246. package/dist/components/ui/authValidation.js +4 -5
  247. package/dist/components/ui/authValidation.js.map +1 -1
  248. package/dist/components/ui/classifyContent.cjs +3 -3
  249. package/dist/components/ui/classifyContent.cjs.map +1 -1
  250. package/dist/components/ui/classifyContent.d.ts +2 -1
  251. package/dist/components/ui/classifyContent.js +52 -54
  252. package/dist/components/ui/classifyContent.js.map +1 -1
  253. package/dist/components/ui/relativeTime.cjs +1 -1
  254. package/dist/components/ui/relativeTime.cjs.map +1 -1
  255. package/dist/components/ui/relativeTime.d.ts +5 -3
  256. package/dist/components/ui/relativeTime.js +15 -6
  257. package/dist/components/ui/relativeTime.js.map +1 -1
  258. package/dist/hooks/popoverOverflow.cjs +2 -0
  259. package/dist/hooks/popoverOverflow.cjs.map +1 -0
  260. package/dist/hooks/popoverOverflow.d.ts +8 -0
  261. package/dist/hooks/popoverOverflow.js +9 -0
  262. package/dist/hooks/popoverOverflow.js.map +1 -0
  263. package/dist/hooks/useDialogPopover.cjs +2 -0
  264. package/dist/hooks/useDialogPopover.cjs.map +1 -0
  265. package/dist/hooks/useDialogPopover.d.ts +23 -0
  266. package/dist/hooks/useDialogPopover.js +48 -0
  267. package/dist/hooks/useDialogPopover.js.map +1 -0
  268. package/dist/hooks/useMenuPopover.cjs +1 -1
  269. package/dist/hooks/useMenuPopover.cjs.map +1 -1
  270. package/dist/hooks/useMenuPopover.d.ts +0 -8
  271. package/dist/hooks/useMenuPopover.js +17 -22
  272. package/dist/hooks/useMenuPopover.js.map +1 -1
  273. package/dist/hooks/useSavedQueries.cjs +1 -1
  274. package/dist/hooks/useSavedQueries.cjs.map +1 -1
  275. package/dist/hooks/useSavedQueries.js +29 -28
  276. package/dist/hooks/useSavedQueries.js.map +1 -1
  277. package/dist/index.d.ts +1 -1
  278. package/dist/layouts/shell/AegisShell.cjs +1 -1
  279. package/dist/layouts/shell/AegisShell.cjs.map +1 -1
  280. package/dist/layouts/shell/AegisShell.js +41 -41
  281. package/dist/layouts/shell/AegisShell.js.map +1 -1
  282. package/dist/layouts/shell/AppSwitcher.cjs +1 -1
  283. package/dist/layouts/shell/AppSwitcher.cjs.map +1 -1
  284. package/dist/layouts/shell/AppSwitcher.js +53 -36
  285. package/dist/layouts/shell/AppSwitcher.js.map +1 -1
  286. package/dist/layouts/shell/AuthRequiredCard.cjs +1 -1
  287. package/dist/layouts/shell/AuthRequiredCard.cjs.map +1 -1
  288. package/dist/layouts/shell/AuthRequiredCard.js +24 -22
  289. package/dist/layouts/shell/AuthRequiredCard.js.map +1 -1
  290. package/dist/layouts/shell/RouteErrorBoundary.cjs +1 -1
  291. package/dist/layouts/shell/RouteErrorBoundary.cjs.map +1 -1
  292. package/dist/layouts/shell/RouteErrorBoundary.d.ts +4 -1
  293. package/dist/layouts/shell/RouteErrorBoundary.js +15 -10
  294. package/dist/layouts/shell/RouteErrorBoundary.js.map +1 -1
  295. package/dist/layouts/shell/ShellInboxPage.cjs +1 -1
  296. package/dist/layouts/shell/ShellInboxPage.cjs.map +1 -1
  297. package/dist/layouts/shell/ShellInboxPage.js +17 -16
  298. package/dist/layouts/shell/ShellInboxPage.js.map +1 -1
  299. package/dist/layouts/shell/ShellNotificationBell.cjs +1 -1
  300. package/dist/layouts/shell/ShellNotificationBell.cjs.map +1 -1
  301. package/dist/layouts/shell/ShellNotificationBell.js +20 -14
  302. package/dist/layouts/shell/ShellNotificationBell.js.map +1 -1
  303. package/dist/layouts/shell/TopHeader.cjs +1 -1
  304. package/dist/layouts/shell/TopHeader.cjs.map +1 -1
  305. package/dist/layouts/shell/TopHeader.js +74 -74
  306. package/dist/layouts/shell/TopHeader.js.map +1 -1
  307. package/dist/layouts/shell/useShellUser.cjs +1 -1
  308. package/dist/layouts/shell/useShellUser.cjs.map +1 -1
  309. package/dist/layouts/shell/useShellUser.js +15 -13
  310. package/dist/layouts/shell/useShellUser.js.map +1 -1
  311. package/dist/lib/chart.cjs +1 -1
  312. package/dist/lib/chart.cjs.map +1 -1
  313. package/dist/lib/chart.d.ts +5 -7
  314. package/dist/lib/chart.js +49 -34
  315. package/dist/lib/chart.js.map +1 -1
  316. package/dist/lib/timeRange.cjs +1 -1
  317. package/dist/lib/timeRange.cjs.map +1 -1
  318. package/dist/lib/timeRange.d.ts +14 -4
  319. package/dist/lib/timeRange.js +41 -40
  320. package/dist/lib/timeRange.js.map +1 -1
  321. package/dist/locale/strings.cjs +1 -1
  322. package/dist/locale/strings.cjs.map +1 -1
  323. package/dist/locale/strings.d.ts +241 -2
  324. package/dist/locale/strings.js +543 -26
  325. package/dist/locale/strings.js.map +1 -1
  326. package/dist/notifications/notificationContext.cjs.map +1 -1
  327. package/dist/notifications/notificationContext.d.ts +12 -2
  328. package/dist/notifications/notificationContext.js.map +1 -1
  329. package/dist/style.css +1 -1
  330. package/dist/theme/antdTheme.cjs +1 -1
  331. package/dist/theme/antdTheme.cjs.map +1 -1
  332. package/dist/theme/antdTheme.js +2 -0
  333. package/dist/theme/antdTheme.js.map +1 -1
  334. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),g=require("react"),L=require("../../components/ui/ChatComposer.cjs"),A=require("../../components/ui/Chip.cjs"),R=require("../../hooks/useIsomorphicLayoutEffect.cjs"),C=require("../core/aegisRuntimeContext.cjs");;/* empty css */const I=8,P=8,H=160;function M(a,r,o,c){if(typeof window>"u")return null;const u=window.innerWidth,m=window.innerHeight,n=P,l=I,k=a?.x??r?.left??n,i=a?.y??r?.bottom??n,f=m-i-n,h=i-n,w=u-k-n,d=k-n,N=f>=h,j=Math.max(N?f:h,H),v=Math.min(c,j-l);let _=N?i+l:i-l-v,e=w>=d?k+l:k-l-o;return e=Math.max(n,Math.min(e,u-o-n)),_=Math.max(n,Math.min(_,m-v-n)),{left:e,top:_,maxHeight:v}}function b(a,r,o){if(r)return r;if(!a)return[];if(o.entity){const c=a.inspect({kind:"entity",entityId:o.entity.id});if(c)return c.actions}if(o.surface){const c=a.inspect({kind:"surface",surfaceId:o.surface.id});if(c)return c.actions}return a.listActions()}function q({context:a,tools:r,anchorRect:o,anchorPoint:c,onClose:u,onSend:m,sending:n=!1,popover:l=!0}){const i=g.useContext(C.AegisRuntimeContext)?.runtime??null,f=g.useRef(null),[h,w]=g.useState(null),[d,N]=g.useState(()=>b(i,r,a));g.useEffect(()=>{const e=()=>{N(b(i,r,a))};if(e(),!(r!==void 0||!i))return i.subscribe(t=>{(t.type==="registry.changed"||t.type==="snapshot.changed")&&e()})},[i,r,a]);const j=g.useCallback(e=>{const t={prompt:e,context:a,tools:d,history:[]};i?.emitAskSubmit(t),m?.(t)},[i,a,d,m]);g.useEffect(()=>{if(!l)return;const e=p=>{p.key==="Escape"&&(p.stopPropagation(),u())},t=p=>{const x=f.current;x&&(p.target instanceof Node&&x.contains(p.target)||u())};return window.addEventListener("keydown",e,!0),window.addEventListener("mousedown",t,!0),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("mousedown",t,!0)}},[u,l]),R.useIsomorphicLayoutEffect(()=>{if(!l){w(null);return}const e=()=>{const t=f.current;if(!t)return;const p=t.scrollHeight||t.offsetHeight,x=t.offsetWidth,E=M(c??null,o??null,x,p);w(E)};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[l,c,o,d,a]);const v=l?h?{position:"fixed",left:h.left,top:h.top,maxHeight:h.maxHeight}:{position:"fixed",left:-9999,top:-9999,visibility:"hidden"}:{},_=a.entity?.label??a.entity?.id,y=a.surface?.label??a.surface?.id;return s.jsxs("div",{ref:f,className:"aegis-ask-panel",role:"dialog","aria-label":"Ask AI","data-aegis-ask-panel":"open","data-ask-origin":a.origin,style:v,children:[s.jsxs("header",{className:"aegis-ask-panel__header",children:[s.jsx("div",{className:"aegis-ask-panel__title",children:"Ask AI"}),s.jsx("button",{type:"button",className:"aegis-ask-panel__close","aria-label":"Close",onClick:u,children:"×"})]}),s.jsxs("div",{className:"aegis-ask-panel__meta",children:[y&&s.jsxs("div",{className:"aegis-ask-panel__meta-row",children:[s.jsx("span",{className:"aegis-ask-panel__meta-label",children:"Surface"}),s.jsx("span",{className:"aegis-ask-panel__meta-value",children:y})]}),_&&s.jsxs("div",{className:"aegis-ask-panel__meta-row",children:[s.jsx("span",{className:"aegis-ask-panel__meta-label",children:"Entity"}),s.jsx("span",{className:"aegis-ask-panel__meta-value",children:_})]})]}),a.suggestions.length>0&&s.jsxs("div",{className:"aegis-ask-panel__section",children:[s.jsx("div",{className:"aegis-ask-panel__section-label",children:"Suggestions"}),s.jsx("div",{className:"aegis-ask-panel__chips",children:a.suggestions.map(e=>s.jsx(A.Chip,{tone:"ghost",onClick:m&&!n?()=>{j(e)}:void 0,children:e},e))})]}),s.jsxs("div",{className:"aegis-ask-panel__section",children:[s.jsxs("div",{className:"aegis-ask-panel__section-label",children:["Tools available (",d.length,")"]}),d.length===0?s.jsx("div",{className:"aegis-ask-panel__empty",children:"No tools in scope."}):s.jsx("ul",{className:"aegis-ask-panel__tools",children:d.slice(0,8).map(e=>s.jsxs("li",{className:"aegis-ask-panel__tool",children:[s.jsx("span",{className:"aegis-ask-panel__tool-id",children:e.id}),s.jsx("span",{className:"aegis-ask-panel__tool-label",children:e.label})]},e.id))})]}),m?s.jsx(L.ChatComposer,{className:"aegis-ask-panel__composer",onSend:j,sending:n,placeholder:"Ask about this…"}):s.jsx("p",{className:"aegis-ask-panel__note",children:"No agent is connected."})]})}exports.AskPanel=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),m=require("react"),T=require("../../components/ui/ChatComposer.cjs"),A=require("../../components/ui/Chip.cjs"),R=require("../../hooks/useIsomorphicLayoutEffect.cjs"),q=require("../core/aegisRuntimeContext.cjs");;/* empty css */const C=require("../../locale/useStrings.cjs"),H=8,M=8,I=160;function S(a,r,c,o){if(typeof window>"u")return null;const f=window.innerWidth,h=window.innerHeight,i=M,l=H,t=a?.x??r?.left??i,N=a?.y??r?.bottom??i,u=h-N-i,g=N-i,p=f-t-i,x=t-i,d=u>=g,b=Math.max(d?u:g,I),k=Math.min(o,b-l);let v=d?N+l:N-l-k,w=p>=x?t+l:t-l-c;return w=Math.max(i,Math.min(w,f-c-i)),v=Math.max(i,Math.min(v,h-k-i)),{left:w,top:v,maxHeight:k}}function L(a,r,c){if(r)return r;if(!a)return[];if(c.entity){const o=a.inspect({kind:"entity",entityId:c.entity.id});if(o)return o.actions}if(c.surface){const o=a.inspect({kind:"surface",surfaceId:c.surface.id});if(o)return o.actions}return a.listActions()}function F({context:a,tools:r,anchorRect:c,anchorPoint:o,onClose:f,onSend:h,sending:i=!1,popover:l=!0}){const t=C.useStrings(),u=m.useContext(q.AegisRuntimeContext)?.runtime??null,g=m.useRef(null),[p,x]=m.useState(null),[d,b]=m.useState(()=>L(u,r,a));m.useEffect(()=>{const e=()=>{b(L(u,r,a))};if(e(),!(r!==void 0||!u))return u.subscribe(n=>{(n.type==="registry.changed"||n.type==="snapshot.changed")&&e()})},[u,r,a]);const k=m.useCallback(e=>{const n={prompt:e,context:a,tools:d,history:[]};u?.emitAskSubmit(n),h?.(n)},[u,a,d,h]);m.useEffect(()=>{if(!l)return;const e=_=>{_.key==="Escape"&&(_.stopPropagation(),f())},n=_=>{const y=g.current;y&&(_.target instanceof Node&&y.contains(_.target)||f())};return window.addEventListener("keydown",e,!0),window.addEventListener("mousedown",n,!0),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("mousedown",n,!0)}},[f,l]);const v=!l||p!==null;m.useEffect(()=>{if(!v)return;const e=document.activeElement,n=g.current;return(n?.querySelector("textarea:not(:disabled)")??n)?.focus(),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus()}},[v]),R.useIsomorphicLayoutEffect(()=>{if(!l){x(null);return}const e=()=>{const n=g.current;if(!n)return;const _=n.scrollHeight||n.offsetHeight,y=n.offsetWidth,P=S(o??null,c??null,y,_);x(P)};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[l,o,c,d,a]);const j=l?p?{position:"fixed",left:p.left,top:p.top,maxHeight:p.maxHeight}:{position:"fixed",left:-9999,top:-9999,visibility:"hidden"}:{},w=a.entity?.label??a.entity?.id,E=a.surface?.label??a.surface?.id;return s.jsxs("div",{ref:g,className:"aegis-ask-panel",role:"dialog","aria-label":t.askPanelTitle,tabIndex:-1,"data-aegis-ask-panel":"open","data-ask-origin":a.origin,style:j,children:[s.jsxs("header",{className:"aegis-ask-panel__header",children:[s.jsx("div",{className:"aegis-ask-panel__title",children:t.askPanelTitle}),s.jsx("button",{type:"button",className:"aegis-ask-panel__close","aria-label":t.close,onClick:f,children:"×"})]}),s.jsxs("div",{className:"aegis-ask-panel__meta",children:[E&&s.jsxs("div",{className:"aegis-ask-panel__meta-row",children:[s.jsx("span",{className:"aegis-ask-panel__meta-label",children:t.askSurface}),s.jsx("span",{className:"aegis-ask-panel__meta-value",children:E})]}),w&&s.jsxs("div",{className:"aegis-ask-panel__meta-row",children:[s.jsx("span",{className:"aegis-ask-panel__meta-label",children:t.askEntity}),s.jsx("span",{className:"aegis-ask-panel__meta-value",children:w})]})]}),a.suggestions.length>0&&s.jsxs("div",{className:"aegis-ask-panel__section",children:[s.jsx("div",{className:"aegis-ask-panel__section-label",children:t.suggestions}),s.jsx("div",{className:"aegis-ask-panel__chips",children:a.suggestions.map(e=>s.jsx(A.Chip,{tone:"ghost",onClick:h&&!i?()=>{k(e)}:void 0,children:e},e))})]}),s.jsxs("div",{className:"aegis-ask-panel__section",children:[s.jsx("div",{className:"aegis-ask-panel__section-label",children:t.askToolsAvailable(d.length)}),d.length===0?s.jsx("div",{className:"aegis-ask-panel__empty",children:t.askNoTools}):s.jsx("ul",{className:"aegis-ask-panel__tools",children:d.slice(0,8).map(e=>s.jsxs("li",{className:"aegis-ask-panel__tool",children:[s.jsx("span",{className:"aegis-ask-panel__tool-id",children:e.id}),s.jsx("span",{className:"aegis-ask-panel__tool-label",children:e.label})]},e.id))})]}),h?s.jsx(T.ChatComposer,{className:"aegis-ask-panel__composer",onSend:k,sending:i,placeholder:t.askPlaceholder}):s.jsx("p",{className:"aegis-ask-panel__note",children:t.askNoAgent})]})}exports.AskPanel=F;
2
2
  //# sourceMappingURL=AskPanel.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AskPanel.cjs","sources":["../../../src/agent/ask/AskPanel.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ChatComposer } from '../../components/ui/ChatComposer';\nimport { Chip } from '../../components/ui/Chip';\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { AegisRuntimeContext } from '../core/aegisRuntimeContext';\nimport type { AegisRuntime } from '../core/runtime';\nimport type {\n AegisActionDescriptor,\n AskContext,\n AskRequest,\n} from '../core/types';\nimport './AskPanel.css';\n\nexport interface AskPanelProps {\n context: AskContext;\n /** Tools the agent could invoke. Defaults to deriving from snapshot. */\n tools?: AegisActionDescriptor[];\n /** Optional anchor — the panel positions itself near this rect. */\n anchorRect?: DOMRect | null;\n /** Preferred anchor point (e.g. mouse position). Wins over anchorRect. */\n anchorPoint?: { x: number; y: number } | null;\n onClose: () => void;\n /**\n * Hands the question to the agent. Without it the panel shows the\n * context and its tools but offers no way to ask.\n */\n onSend?: (request: AskRequest) => void;\n /** True while the agent is still answering; holds the composer. */\n sending?: boolean;\n /**\n * When true (default), a fixed popover that closes on Escape and on a\n * click outside it; when false, inline.\n */\n popover?: boolean;\n}\n\nconst PANEL_OFFSET_PX = 8;\nconst VIEWPORT_MARGIN_PX = 8;\nconst PANEL_MIN_HEIGHT_PX = 160;\n\ninterface Placement {\n left: number;\n top: number;\n maxHeight: number;\n}\n\nfunction placeNear(\n point: { x: number; y: number } | null,\n rect: DOMRect | null | undefined,\n panelWidth: number,\n panelHeight: number,\n): Placement | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = VIEWPORT_MARGIN_PX;\n const offset = PANEL_OFFSET_PX;\n\n // Anchor: prefer mouse point; fall back to rect's bottom-left corner.\n const ax = point?.x ?? rect?.left ?? margin;\n const ay = point?.y ?? rect?.bottom ?? margin;\n\n const spaceBelow = vh - ay - margin;\n const spaceAbove = ay - margin;\n const spaceRight = vw - ax - margin;\n const spaceLeft = ax - margin;\n\n // Pick vertical side with more room; allow shrinking max-height to fit.\n const placeBelow = spaceBelow >= spaceAbove;\n const verticalRoom = Math.max(\n placeBelow ? spaceBelow : spaceAbove,\n PANEL_MIN_HEIGHT_PX,\n );\n const maxHeight = Math.min(panelHeight, verticalRoom - offset);\n\n let top = placeBelow ? ay + offset : ay - offset - maxHeight;\n // Pick horizontal side with more room.\n const placeRight = spaceRight >= spaceLeft;\n let left = placeRight ? ax + offset : ax - offset - panelWidth;\n\n // Clamp into viewport.\n left = Math.max(margin, Math.min(left, vw - panelWidth - margin));\n top = Math.max(margin, Math.min(top, vh - maxHeight - margin));\n\n return { left, top, maxHeight };\n}\n\nfunction resolveTools(\n runtime: AegisRuntime | null,\n tools: AegisActionDescriptor[] | undefined,\n context: AskContext,\n): AegisActionDescriptor[] {\n if (tools) {\n return tools;\n }\n if (!runtime) {\n return [];\n }\n if (context.entity) {\n const r = runtime.inspect({ kind: 'entity', entityId: context.entity.id });\n if (r) {\n return r.actions;\n }\n }\n if (context.surface) {\n const r = runtime.inspect({\n kind: 'surface',\n surfaceId: context.surface.id,\n });\n if (r) {\n return r.actions;\n }\n }\n return runtime.listActions();\n}\n\nexport function AskPanel({\n context,\n tools,\n anchorRect,\n anchorPoint,\n onClose,\n onSend,\n sending = false,\n popover = true,\n}: AskPanelProps): ReactElement {\n const ctx = useContext(AegisRuntimeContext);\n const runtime = ctx?.runtime ?? null;\n const rootRef = useRef<HTMLDivElement>(null);\n const [placement, setPlacement] = useState<Placement | null>(null);\n\n const [resolvedTools, setResolvedTools] = useState<AegisActionDescriptor[]>(\n () => resolveTools(runtime, tools, context),\n );\n\n useEffect(() => {\n const refresh = (): void => {\n setResolvedTools(resolveTools(runtime, tools, context));\n };\n refresh();\n if (tools !== undefined || !runtime) {\n return;\n }\n return runtime.subscribe((e) => {\n if (e.type === 'registry.changed' || e.type === 'snapshot.changed') {\n refresh();\n }\n });\n }, [runtime, tools, context]);\n\n const ask = useCallback(\n (prompt: string) => {\n const request: AskRequest = {\n prompt,\n context,\n tools: resolvedTools,\n history: [],\n };\n runtime?.emitAskSubmit(request);\n onSend?.(request);\n },\n [runtime, context, resolvedTools, onSend],\n );\n\n useEffect(() => {\n if (!popover) {\n return;\n }\n const onKey = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n onClose();\n }\n };\n const onDown = (e: MouseEvent): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n if (e.target instanceof Node && el.contains(e.target)) {\n return;\n }\n onClose();\n };\n window.addEventListener('keydown', onKey, true);\n window.addEventListener('mousedown', onDown, true);\n return () => {\n window.removeEventListener('keydown', onKey, true);\n window.removeEventListener('mousedown', onDown, true);\n };\n }, [onClose, popover]);\n\n useIsomorphicLayoutEffect(() => {\n if (!popover) {\n setPlacement(null);\n return;\n }\n const compute = (): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n // Use the natural (unconstrained) size as the desired height; the\n // placement function will clamp it to the larger viewport gap.\n const naturalHeight = el.scrollHeight || el.offsetHeight;\n const width = el.offsetWidth;\n const next = placeNear(\n anchorPoint ?? null,\n anchorRect ?? null,\n width,\n naturalHeight,\n );\n setPlacement(next);\n };\n compute();\n window.addEventListener('resize', compute);\n window.addEventListener('scroll', compute, true);\n return () => {\n window.removeEventListener('resize', compute);\n window.removeEventListener('scroll', compute, true);\n };\n }, [popover, anchorPoint, anchorRect, resolvedTools, context]);\n\n const style: CSSProperties = popover\n ? placement\n ? {\n position: 'fixed',\n left: placement.left,\n top: placement.top,\n maxHeight: placement.maxHeight,\n }\n : // First paint before measurement: render off-screen to avoid flicker.\n {\n position: 'fixed',\n left: -9999,\n top: -9999,\n visibility: 'hidden',\n }\n : {};\n\n const headerLabel = context.entity?.label ?? context.entity?.id;\n const surfaceLabel = context.surface?.label ?? context.surface?.id;\n\n return (\n <div\n ref={rootRef}\n className=\"aegis-ask-panel\"\n role=\"dialog\"\n aria-label=\"Ask AI\"\n data-aegis-ask-panel=\"open\"\n data-ask-origin={context.origin}\n style={style}\n >\n <header className=\"aegis-ask-panel__header\">\n <div className=\"aegis-ask-panel__title\">Ask AI</div>\n <button\n type=\"button\"\n className=\"aegis-ask-panel__close\"\n aria-label=\"Close\"\n onClick={onClose}\n >\n ×\n </button>\n </header>\n <div className=\"aegis-ask-panel__meta\">\n {surfaceLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">Surface</span>\n <span className=\"aegis-ask-panel__meta-value\">{surfaceLabel}</span>\n </div>\n )}\n {headerLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">Entity</span>\n <span className=\"aegis-ask-panel__meta-value\">{headerLabel}</span>\n </div>\n )}\n </div>\n {context.suggestions.length > 0 && (\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">Suggestions</div>\n <div className=\"aegis-ask-panel__chips\">\n {context.suggestions.map((s) => (\n <Chip\n key={s}\n tone=\"ghost\"\n onClick={\n onSend && !sending\n ? () => {\n ask(s);\n }\n : undefined\n }\n >\n {s}\n </Chip>\n ))}\n </div>\n </div>\n )}\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">\n Tools available ({resolvedTools.length})\n </div>\n {resolvedTools.length === 0 ? (\n <div className=\"aegis-ask-panel__empty\">No tools in scope.</div>\n ) : (\n <ul className=\"aegis-ask-panel__tools\">\n {resolvedTools.slice(0, 8).map((t) => (\n <li key={t.id} className=\"aegis-ask-panel__tool\">\n <span className=\"aegis-ask-panel__tool-id\">{t.id}</span>\n <span className=\"aegis-ask-panel__tool-label\">{t.label}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n {onSend ? (\n <ChatComposer\n className=\"aegis-ask-panel__composer\"\n onSend={ask}\n sending={sending}\n placeholder=\"Ask about this…\"\n />\n ) : (\n <p className=\"aegis-ask-panel__note\">No agent is connected.</p>\n )}\n </div>\n );\n}\n"],"names":["PANEL_OFFSET_PX","VIEWPORT_MARGIN_PX","PANEL_MIN_HEIGHT_PX","placeNear","point","rect","panelWidth","panelHeight","vw","vh","margin","offset","ax","ay","spaceBelow","spaceAbove","spaceRight","spaceLeft","placeBelow","verticalRoom","maxHeight","top","left","resolveTools","runtime","tools","context","r","AskPanel","anchorRect","anchorPoint","onClose","onSend","sending","popover","useContext","AegisRuntimeContext","rootRef","useRef","placement","setPlacement","useState","resolvedTools","setResolvedTools","useEffect","refresh","e","ask","useCallback","prompt","request","onKey","onDown","el","useIsomorphicLayoutEffect","compute","naturalHeight","width","next","style","headerLabel","surfaceLabel","jsxs","jsx","s","Chip","t","ChatComposer"],"mappings":"sWA6CA,MAAMA,EAAkB,EAClBC,EAAqB,EACrBC,EAAsB,IAQ5B,SAASC,EACPC,EACAC,EACAC,EACAC,EACkB,CAClB,GAAI,OAAO,OAAW,IACpB,OAAO,KAET,MAAMC,EAAK,OAAO,WACZC,EAAK,OAAO,YACZC,EAAST,EACTU,EAASX,EAGTY,EAAKR,GAAO,GAAKC,GAAM,MAAQK,EAC/BG,EAAKT,GAAO,GAAKC,GAAM,QAAUK,EAEjCI,EAAaL,EAAKI,EAAKH,EACvBK,EAAaF,EAAKH,EAClBM,EAAaR,EAAKI,EAAKF,EACvBO,EAAYL,EAAKF,EAGjBQ,EAAaJ,GAAcC,EAC3BI,EAAe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AAA,EAGd8B,EAAAA,IAAC,IAAA,CAAE,UAAU,wBAAwB,SAAA,wBAAA,CAAsB,CAAA,CAAA,CAAA,CAInE"}
1
+ {"version":3,"file":"AskPanel.cjs","sources":["../../../src/agent/ask/AskPanel.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ChatComposer } from '../../components/ui/ChatComposer';\nimport { Chip } from '../../components/ui/Chip';\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useStrings } from '../../locale';\nimport { AegisRuntimeContext } from '../core/aegisRuntimeContext';\nimport type { AegisRuntime } from '../core/runtime';\nimport type {\n AegisActionDescriptor,\n AskContext,\n AskRequest,\n} from '../core/types';\nimport './AskPanel.css';\n\nexport interface AskPanelProps {\n context: AskContext;\n /** Tools the agent could invoke. Defaults to deriving from snapshot. */\n tools?: AegisActionDescriptor[];\n /** Optional anchor — the panel positions itself near this rect. */\n anchorRect?: DOMRect | null;\n /** Preferred anchor point (e.g. mouse position). Wins over anchorRect. */\n anchorPoint?: { x: number; y: number } | null;\n onClose: () => void;\n /**\n * Hands the question to the agent. Without it the panel shows the\n * context and its tools but offers no way to ask.\n */\n onSend?: (request: AskRequest) => void;\n /** True while the agent is still answering; holds the composer. */\n sending?: boolean;\n /**\n * When true (default), a fixed popover that closes on Escape and on a\n * click outside it; when false, inline.\n */\n popover?: boolean;\n}\n\nconst PANEL_OFFSET_PX = 8;\nconst VIEWPORT_MARGIN_PX = 8;\nconst PANEL_MIN_HEIGHT_PX = 160;\n\ninterface Placement {\n left: number;\n top: number;\n maxHeight: number;\n}\n\nfunction placeNear(\n point: { x: number; y: number } | null,\n rect: DOMRect | null | undefined,\n panelWidth: number,\n panelHeight: number,\n): Placement | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = VIEWPORT_MARGIN_PX;\n const offset = PANEL_OFFSET_PX;\n\n // Anchor: prefer mouse point; fall back to rect's bottom-left corner.\n const ax = point?.x ?? rect?.left ?? margin;\n const ay = point?.y ?? rect?.bottom ?? margin;\n\n const spaceBelow = vh - ay - margin;\n const spaceAbove = ay - margin;\n const spaceRight = vw - ax - margin;\n const spaceLeft = ax - margin;\n\n // Pick vertical side with more room; allow shrinking max-height to fit.\n const placeBelow = spaceBelow >= spaceAbove;\n const verticalRoom = Math.max(\n placeBelow ? spaceBelow : spaceAbove,\n PANEL_MIN_HEIGHT_PX,\n );\n const maxHeight = Math.min(panelHeight, verticalRoom - offset);\n\n let top = placeBelow ? ay + offset : ay - offset - maxHeight;\n // Pick horizontal side with more room.\n const placeRight = spaceRight >= spaceLeft;\n let left = placeRight ? ax + offset : ax - offset - panelWidth;\n\n // Clamp into viewport.\n left = Math.max(margin, Math.min(left, vw - panelWidth - margin));\n top = Math.max(margin, Math.min(top, vh - maxHeight - margin));\n\n return { left, top, maxHeight };\n}\n\nfunction resolveTools(\n runtime: AegisRuntime | null,\n tools: AegisActionDescriptor[] | undefined,\n context: AskContext,\n): AegisActionDescriptor[] {\n if (tools) {\n return tools;\n }\n if (!runtime) {\n return [];\n }\n if (context.entity) {\n const r = runtime.inspect({ kind: 'entity', entityId: context.entity.id });\n if (r) {\n return r.actions;\n }\n }\n if (context.surface) {\n const r = runtime.inspect({\n kind: 'surface',\n surfaceId: context.surface.id,\n });\n if (r) {\n return r.actions;\n }\n }\n return runtime.listActions();\n}\n\n/**\n * Mounting it opens it: focus moves to its question field, or to the panel\n * when there is no agent to ask, and returns on unmount to the element that\n * had it.\n */\nexport function AskPanel({\n context,\n tools,\n anchorRect,\n anchorPoint,\n onClose,\n onSend,\n sending = false,\n popover = true,\n}: AskPanelProps): ReactElement {\n const strings = useStrings();\n const ctx = useContext(AegisRuntimeContext);\n const runtime = ctx?.runtime ?? null;\n const rootRef = useRef<HTMLDivElement>(null);\n const [placement, setPlacement] = useState<Placement | null>(null);\n\n const [resolvedTools, setResolvedTools] = useState<AegisActionDescriptor[]>(\n () => resolveTools(runtime, tools, context),\n );\n\n useEffect(() => {\n const refresh = (): void => {\n setResolvedTools(resolveTools(runtime, tools, context));\n };\n refresh();\n if (tools !== undefined || !runtime) {\n return;\n }\n return runtime.subscribe((e) => {\n if (e.type === 'registry.changed' || e.type === 'snapshot.changed') {\n refresh();\n }\n });\n }, [runtime, tools, context]);\n\n const ask = useCallback(\n (prompt: string) => {\n const request: AskRequest = {\n prompt,\n context,\n tools: resolvedTools,\n history: [],\n };\n runtime?.emitAskSubmit(request);\n onSend?.(request);\n },\n [runtime, context, resolvedTools, onSend],\n );\n\n useEffect(() => {\n if (!popover) {\n return;\n }\n const onKey = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n onClose();\n }\n };\n const onDown = (e: MouseEvent): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n if (e.target instanceof Node && el.contains(e.target)) {\n return;\n }\n onClose();\n };\n window.addEventListener('keydown', onKey, true);\n window.addEventListener('mousedown', onDown, true);\n return () => {\n window.removeEventListener('keydown', onKey, true);\n window.removeEventListener('mousedown', onDown, true);\n };\n }, [onClose, popover]);\n\n // A popover is hidden, and so cannot take focus, until it is placed.\n const ready = !popover || placement !== null;\n useEffect(() => {\n if (!ready) {\n return;\n }\n const returnFocusTo = document.activeElement;\n const root = rootRef.current;\n (\n root?.querySelector<HTMLElement>('textarea:not(:disabled)') ?? root\n )?.focus();\n return () => {\n if (returnFocusTo instanceof HTMLElement && returnFocusTo.isConnected) {\n returnFocusTo.focus();\n }\n };\n }, [ready]);\n\n useIsomorphicLayoutEffect(() => {\n if (!popover) {\n setPlacement(null);\n return;\n }\n const compute = (): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n // Use the natural (unconstrained) size as the desired height; the\n // placement function will clamp it to the larger viewport gap.\n const naturalHeight = el.scrollHeight || el.offsetHeight;\n const width = el.offsetWidth;\n const next = placeNear(\n anchorPoint ?? null,\n anchorRect ?? null,\n width,\n naturalHeight,\n );\n setPlacement(next);\n };\n compute();\n window.addEventListener('resize', compute);\n window.addEventListener('scroll', compute, true);\n return () => {\n window.removeEventListener('resize', compute);\n window.removeEventListener('scroll', compute, true);\n };\n }, [popover, anchorPoint, anchorRect, resolvedTools, context]);\n\n const style: CSSProperties = popover\n ? placement\n ? {\n position: 'fixed',\n left: placement.left,\n top: placement.top,\n maxHeight: placement.maxHeight,\n }\n : // First paint before measurement: render off-screen to avoid flicker.\n {\n position: 'fixed',\n left: -9999,\n top: -9999,\n visibility: 'hidden',\n }\n : {};\n\n const headerLabel = context.entity?.label ?? context.entity?.id;\n const surfaceLabel = context.surface?.label ?? context.surface?.id;\n\n return (\n <div\n ref={rootRef}\n className=\"aegis-ask-panel\"\n role=\"dialog\"\n aria-label={strings.askPanelTitle}\n tabIndex={-1}\n data-aegis-ask-panel=\"open\"\n data-ask-origin={context.origin}\n style={style}\n >\n <header className=\"aegis-ask-panel__header\">\n <div className=\"aegis-ask-panel__title\">{strings.askPanelTitle}</div>\n <button\n type=\"button\"\n className=\"aegis-ask-panel__close\"\n aria-label={strings.close}\n onClick={onClose}\n >\n ×\n </button>\n </header>\n <div className=\"aegis-ask-panel__meta\">\n {surfaceLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">\n {strings.askSurface}\n </span>\n <span className=\"aegis-ask-panel__meta-value\">{surfaceLabel}</span>\n </div>\n )}\n {headerLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">\n {strings.askEntity}\n </span>\n <span className=\"aegis-ask-panel__meta-value\">{headerLabel}</span>\n </div>\n )}\n </div>\n {context.suggestions.length > 0 && (\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">\n {strings.suggestions}\n </div>\n <div className=\"aegis-ask-panel__chips\">\n {context.suggestions.map((s) => (\n <Chip\n key={s}\n tone=\"ghost\"\n onClick={\n onSend && !sending\n ? () => {\n ask(s);\n }\n : undefined\n }\n >\n {s}\n </Chip>\n ))}\n </div>\n </div>\n )}\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">\n {strings.askToolsAvailable(resolvedTools.length)}\n </div>\n {resolvedTools.length === 0 ? (\n <div className=\"aegis-ask-panel__empty\">{strings.askNoTools}</div>\n ) : (\n <ul className=\"aegis-ask-panel__tools\">\n {resolvedTools.slice(0, 8).map((t) => (\n <li key={t.id} className=\"aegis-ask-panel__tool\">\n <span className=\"aegis-ask-panel__tool-id\">{t.id}</span>\n <span className=\"aegis-ask-panel__tool-label\">{t.label}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n {onSend ? (\n <ChatComposer\n className=\"aegis-ask-panel__composer\"\n onSend={ask}\n sending={sending}\n placeholder={strings.askPlaceholder}\n />\n ) : (\n <p className=\"aegis-ask-panel__note\">{strings.askNoAgent}</p>\n )}\n </div>\n );\n}\n"],"names":["PANEL_OFFSET_PX","VIEWPORT_MARGIN_PX","PANEL_MIN_HEIGHT_PX","placeNear","point","rect","panelWidth","panelHeight","vw","vh","margin","offset","ax","ay","spaceBelow","spaceAbove","spaceRight","spaceLeft","placeBelow","verticalRoom","maxHeight","top","left","resolveTools","runtime","tools","context","r","AskPanel","anchorRect","anchorPoint","onClose","onSend","sending","popover","strings","useStrings","useContext","AegisRuntimeContext","rootRef","useRef","placement","setPlacement","useState","resolvedTools","setResolvedTools","useEffect","refresh","e","ask","useCallback","prompt","request","onKey","onDown","el","ready","returnFocusTo","root","useIsomorphicLayoutEffect","compute","naturalHeight","width","next","style","headerLabel","surfaceLabel","jsxs","jsx","s","Chip","t","ChatComposer"],"mappings":"qZA8CMA,EAAkB,EAClBC,EAAqB,EACrBC,EAAsB,IAQ5B,SAASC,EACPC,EACAC,EACAC,EACAC,EACkB,CAClB,GAAI,OAAO,OAAW,IACpB,OAAO,KAET,MAAMC,EAAK,OAAO,WACZC,EAAK,OAAO,YACZC,EA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AI,UAAU,2BACb,SAAA,CAAAC,EAAAA,IAAC,OAAI,UAAU,iCACZ,WAAQ,kBAAkBxB,EAAc,MAAM,EACjD,EACCA,EAAc,SAAW,EACxBwB,EAAAA,IAAC,MAAA,CAAI,UAAU,yBAA0B,SAAAjC,EAAQ,UAAA,CAAW,EAE5DiC,EAAAA,IAAC,KAAA,CAAG,UAAU,yBACX,SAAAxB,EAAc,MAAM,EAAG,CAAC,EAAE,IAAK2B,GAC9BJ,EAAAA,KAAC,KAAA,CAAc,UAAU,wBACvB,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAK,UAAU,2BAA4B,SAAAG,EAAE,GAAG,EACjDH,EAAAA,IAAC,OAAA,CAAK,UAAU,8BAA+B,WAAE,KAAA,CAAM,CAAA,GAFhDG,EAAE,EAGX,CACD,CAAA,CACH,CAAA,EAEJ,EACCvC,EACCoC,EAAAA,IAACI,EAAAA,aAAA,CACC,UAAU,4BACV,OAAQvB,EACR,QAAAhB,EACA,YAAaE,EAAQ,cAAA,CAAA,EAGvBiC,EAAAA,IAAC,IAAA,CAAE,UAAU,wBAAyB,WAAQ,UAAA,CAAW,CAAA,CAAA,CAAA,CAIjE"}
@@ -25,4 +25,9 @@ export interface AskPanelProps {
25
25
  */
26
26
  popover?: boolean;
27
27
  }
28
+ /**
29
+ * Mounting it opens it: focus moves to its question field, or to the panel
30
+ * when there is no agent to ask, and returns on unmount to the element that
31
+ * had it.
32
+ */
28
33
  export declare function AskPanel({ context, tools, anchorRect, anchorPoint, onClose, onSend, sending, popover, }: AskPanelProps): ReactElement;
@@ -1,113 +1,123 @@
1
- import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
- import { useContext as R, useRef as M, useState as L, useEffect as A, useCallback as P } from "react";
3
- import { ChatComposer as T } from "../../components/ui/ChatComposer.js";
4
- import { Chip as C } from "../../components/ui/Chip.js";
5
- import { useIsomorphicLayoutEffect as x } from "../../hooks/useIsomorphicLayoutEffect.js";
6
- import { AegisRuntimeContext as S } from "../core/aegisRuntimeContext.js";
1
+ import { jsxs as m, jsx as n } from "react/jsx-runtime";
2
+ import { useContext as R, useRef as I, useState as A, useEffect as L, useCallback as C } from "react";
3
+ import { ChatComposer as x } from "../../components/ui/ChatComposer.js";
4
+ import { Chip as S } from "../../components/ui/Chip.js";
5
+ import { useIsomorphicLayoutEffect as F } from "../../hooks/useIsomorphicLayoutEffect.js";
6
+ import { AegisRuntimeContext as X } from "../core/aegisRuntimeContext.js";
7
7
  /* empty css */
8
- const X = 8, j = 8, z = 160;
9
- function B(s, o, r, c) {
8
+ import { useStrings as j } from "../../locale/useStrings.js";
9
+ const q = 8, z = 8, B = 160;
10
+ function G(s, r, o, c) {
10
11
  if (typeof window > "u")
11
12
  return null;
12
- const u = window.innerWidth, p = window.innerHeight, n = j, l = X, k = s?.x ?? o?.left ?? n, t = s?.y ?? o?.bottom ?? n, g = p - t - n, h = t - n, v = u - k - n, m = k - n, N = g >= h, b = Math.max(
13
- N ? g : h,
14
- z
15
- ), w = Math.min(c, b - l);
16
- let _ = N ? t + l : t - l - w, e = v >= m ? k + l : k - l - r;
17
- return e = Math.max(n, Math.min(e, u - r - n)), _ = Math.max(n, Math.min(_, p - w - n)), { left: e, top: _, maxHeight: w };
13
+ const f = window.innerWidth, p = window.innerHeight, i = z, l = q, t = s?.x ?? r?.left ?? i, N = s?.y ?? r?.bottom ?? i, d = p - N - i, h = N - i, g = f - t - i, y = t - i, u = d >= h, E = Math.max(
14
+ u ? d : h,
15
+ B
16
+ ), k = Math.min(c, E - l);
17
+ let w = u ? N + l : N - l - k, v = g >= y ? t + l : t - l - o;
18
+ return v = Math.max(i, Math.min(v, f - o - i)), w = Math.max(i, Math.min(w, p - k - i)), { left: v, top: w, maxHeight: k };
18
19
  }
19
- function H(s, o, r) {
20
- if (o)
21
- return o;
20
+ function H(s, r, o) {
21
+ if (r)
22
+ return r;
22
23
  if (!s)
23
24
  return [];
24
- if (r.entity) {
25
- const c = s.inspect({ kind: "entity", entityId: r.entity.id });
25
+ if (o.entity) {
26
+ const c = s.inspect({ kind: "entity", entityId: o.entity.id });
26
27
  if (c)
27
28
  return c.actions;
28
29
  }
29
- if (r.surface) {
30
+ if (o.surface) {
30
31
  const c = s.inspect({
31
32
  kind: "surface",
32
- surfaceId: r.surface.id
33
+ surfaceId: o.surface.id
33
34
  });
34
35
  if (c)
35
36
  return c.actions;
36
37
  }
37
38
  return s.listActions();
38
39
  }
39
- function V({
40
+ function Y({
40
41
  context: s,
41
- tools: o,
42
- anchorRect: r,
42
+ tools: r,
43
+ anchorRect: o,
43
44
  anchorPoint: c,
44
- onClose: u,
45
+ onClose: f,
45
46
  onSend: p,
46
- sending: n = !1,
47
+ sending: i = !1,
47
48
  popover: l = !0
48
49
  }) {
49
- const t = R(S)?.runtime ?? null, g = M(null), [h, v] = L(null), [m, N] = L(
50
- () => H(t, o, s)
50
+ const t = j(), d = R(X)?.runtime ?? null, h = I(null), [g, y] = A(null), [u, E] = A(
51
+ () => H(d, r, s)
51
52
  );
52
- A(() => {
53
+ L(() => {
53
54
  const e = () => {
54
- N(H(t, o, s));
55
+ E(H(d, r, s));
55
56
  };
56
- if (e(), !(o !== void 0 || !t))
57
- return t.subscribe((i) => {
58
- (i.type === "registry.changed" || i.type === "snapshot.changed") && e();
57
+ if (e(), !(r !== void 0 || !d))
58
+ return d.subscribe((a) => {
59
+ (a.type === "registry.changed" || a.type === "snapshot.changed") && e();
59
60
  });
60
- }, [t, o, s]);
61
- const b = P(
61
+ }, [d, r, s]);
62
+ const k = C(
62
63
  (e) => {
63
- const i = {
64
+ const a = {
64
65
  prompt: e,
65
66
  context: s,
66
- tools: m,
67
+ tools: u,
67
68
  history: []
68
69
  };
69
- t?.emitAskSubmit(i), p?.(i);
70
+ d?.emitAskSubmit(a), p?.(a);
70
71
  },
71
- [t, s, m, p]
72
+ [d, s, u, p]
72
73
  );
73
- A(() => {
74
+ L(() => {
74
75
  if (!l)
75
76
  return;
76
- const e = (f) => {
77
- f.key === "Escape" && (f.stopPropagation(), u());
78
- }, i = (f) => {
79
- const y = g.current;
80
- y && (f.target instanceof Node && y.contains(f.target) || u());
77
+ const e = (_) => {
78
+ _.key === "Escape" && (_.stopPropagation(), f());
79
+ }, a = (_) => {
80
+ const b = h.current;
81
+ b && (_.target instanceof Node && b.contains(_.target) || f());
81
82
  };
82
- return window.addEventListener("keydown", e, !0), window.addEventListener("mousedown", i, !0), () => {
83
- window.removeEventListener("keydown", e, !0), window.removeEventListener("mousedown", i, !0);
83
+ return window.addEventListener("keydown", e, !0), window.addEventListener("mousedown", a, !0), () => {
84
+ window.removeEventListener("keydown", e, !0), window.removeEventListener("mousedown", a, !0);
84
85
  };
85
- }, [u, l]), x(() => {
86
+ }, [f, l]);
87
+ const w = !l || g !== null;
88
+ L(() => {
89
+ if (!w)
90
+ return;
91
+ const e = document.activeElement, a = h.current;
92
+ return (a?.querySelector("textarea:not(:disabled)") ?? a)?.focus(), () => {
93
+ e instanceof HTMLElement && e.isConnected && e.focus();
94
+ };
95
+ }, [w]), F(() => {
86
96
  if (!l) {
87
- v(null);
97
+ y(null);
88
98
  return;
89
99
  }
90
100
  const e = () => {
91
- const i = g.current;
92
- if (!i)
101
+ const a = h.current;
102
+ if (!a)
93
103
  return;
94
- const f = i.scrollHeight || i.offsetHeight, y = i.offsetWidth, I = B(
104
+ const _ = a.scrollHeight || a.offsetHeight, b = a.offsetWidth, M = G(
95
105
  c ?? null,
96
- r ?? null,
97
- y,
98
- f
106
+ o ?? null,
107
+ b,
108
+ _
99
109
  );
100
- v(I);
110
+ y(M);
101
111
  };
102
112
  return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
103
113
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
104
114
  };
105
- }, [l, c, r, m, s]);
106
- const w = l ? h ? {
115
+ }, [l, c, o, u, s]);
116
+ const T = l ? g ? {
107
117
  position: "fixed",
108
- left: h.left,
109
- top: h.top,
110
- maxHeight: h.maxHeight
118
+ left: g.left,
119
+ top: g.top,
120
+ maxHeight: g.maxHeight
111
121
  } : (
112
122
  // First paint before measurement: render off-screen to avoid flicker.
113
123
  {
@@ -116,80 +126,77 @@ function V({
116
126
  top: -9999,
117
127
  visibility: "hidden"
118
128
  }
119
- ) : {}, _ = s.entity?.label ?? s.entity?.id, E = s.surface?.label ?? s.surface?.id;
120
- return /* @__PURE__ */ d(
129
+ ) : {}, v = s.entity?.label ?? s.entity?.id, P = s.surface?.label ?? s.surface?.id;
130
+ return /* @__PURE__ */ m(
121
131
  "div",
122
132
  {
123
- ref: g,
133
+ ref: h,
124
134
  className: "aegis-ask-panel",
125
135
  role: "dialog",
126
- "aria-label": "Ask AI",
136
+ "aria-label": t.askPanelTitle,
137
+ tabIndex: -1,
127
138
  "data-aegis-ask-panel": "open",
128
139
  "data-ask-origin": s.origin,
129
- style: w,
140
+ style: T,
130
141
  children: [
131
- /* @__PURE__ */ d("header", { className: "aegis-ask-panel__header", children: [
132
- /* @__PURE__ */ a("div", { className: "aegis-ask-panel__title", children: "Ask AI" }),
133
- /* @__PURE__ */ a(
142
+ /* @__PURE__ */ m("header", { className: "aegis-ask-panel__header", children: [
143
+ /* @__PURE__ */ n("div", { className: "aegis-ask-panel__title", children: t.askPanelTitle }),
144
+ /* @__PURE__ */ n(
134
145
  "button",
135
146
  {
136
147
  type: "button",
137
148
  className: "aegis-ask-panel__close",
138
- "aria-label": "Close",
139
- onClick: u,
149
+ "aria-label": t.close,
150
+ onClick: f,
140
151
  children: "×"
141
152
  }
142
153
  )
143
154
  ] }),
144
- /* @__PURE__ */ d("div", { className: "aegis-ask-panel__meta", children: [
145
- E && /* @__PURE__ */ d("div", { className: "aegis-ask-panel__meta-row", children: [
146
- /* @__PURE__ */ a("span", { className: "aegis-ask-panel__meta-label", children: "Surface" }),
147
- /* @__PURE__ */ a("span", { className: "aegis-ask-panel__meta-value", children: E })
155
+ /* @__PURE__ */ m("div", { className: "aegis-ask-panel__meta", children: [
156
+ P && /* @__PURE__ */ m("div", { className: "aegis-ask-panel__meta-row", children: [
157
+ /* @__PURE__ */ n("span", { className: "aegis-ask-panel__meta-label", children: t.askSurface }),
158
+ /* @__PURE__ */ n("span", { className: "aegis-ask-panel__meta-value", children: P })
148
159
  ] }),
149
- _ && /* @__PURE__ */ d("div", { className: "aegis-ask-panel__meta-row", children: [
150
- /* @__PURE__ */ a("span", { className: "aegis-ask-panel__meta-label", children: "Entity" }),
151
- /* @__PURE__ */ a("span", { className: "aegis-ask-panel__meta-value", children: _ })
160
+ v && /* @__PURE__ */ m("div", { className: "aegis-ask-panel__meta-row", children: [
161
+ /* @__PURE__ */ n("span", { className: "aegis-ask-panel__meta-label", children: t.askEntity }),
162
+ /* @__PURE__ */ n("span", { className: "aegis-ask-panel__meta-value", children: v })
152
163
  ] })
153
164
  ] }),
154
- s.suggestions.length > 0 && /* @__PURE__ */ d("div", { className: "aegis-ask-panel__section", children: [
155
- /* @__PURE__ */ a("div", { className: "aegis-ask-panel__section-label", children: "Suggestions" }),
156
- /* @__PURE__ */ a("div", { className: "aegis-ask-panel__chips", children: s.suggestions.map((e) => /* @__PURE__ */ a(
157
- C,
165
+ s.suggestions.length > 0 && /* @__PURE__ */ m("div", { className: "aegis-ask-panel__section", children: [
166
+ /* @__PURE__ */ n("div", { className: "aegis-ask-panel__section-label", children: t.suggestions }),
167
+ /* @__PURE__ */ n("div", { className: "aegis-ask-panel__chips", children: s.suggestions.map((e) => /* @__PURE__ */ n(
168
+ S,
158
169
  {
159
170
  tone: "ghost",
160
- onClick: p && !n ? () => {
161
- b(e);
171
+ onClick: p && !i ? () => {
172
+ k(e);
162
173
  } : void 0,
163
174
  children: e
164
175
  },
165
176
  e
166
177
  )) })
167
178
  ] }),
168
- /* @__PURE__ */ d("div", { className: "aegis-ask-panel__section", children: [
169
- /* @__PURE__ */ d("div", { className: "aegis-ask-panel__section-label", children: [
170
- "Tools available (",
171
- m.length,
172
- ")"
173
- ] }),
174
- m.length === 0 ? /* @__PURE__ */ a("div", { className: "aegis-ask-panel__empty", children: "No tools in scope." }) : /* @__PURE__ */ a("ul", { className: "aegis-ask-panel__tools", children: m.slice(0, 8).map((e) => /* @__PURE__ */ d("li", { className: "aegis-ask-panel__tool", children: [
175
- /* @__PURE__ */ a("span", { className: "aegis-ask-panel__tool-id", children: e.id }),
176
- /* @__PURE__ */ a("span", { className: "aegis-ask-panel__tool-label", children: e.label })
179
+ /* @__PURE__ */ m("div", { className: "aegis-ask-panel__section", children: [
180
+ /* @__PURE__ */ n("div", { className: "aegis-ask-panel__section-label", children: t.askToolsAvailable(u.length) }),
181
+ u.length === 0 ? /* @__PURE__ */ n("div", { className: "aegis-ask-panel__empty", children: t.askNoTools }) : /* @__PURE__ */ n("ul", { className: "aegis-ask-panel__tools", children: u.slice(0, 8).map((e) => /* @__PURE__ */ m("li", { className: "aegis-ask-panel__tool", children: [
182
+ /* @__PURE__ */ n("span", { className: "aegis-ask-panel__tool-id", children: e.id }),
183
+ /* @__PURE__ */ n("span", { className: "aegis-ask-panel__tool-label", children: e.label })
177
184
  ] }, e.id)) })
178
185
  ] }),
179
- p ? /* @__PURE__ */ a(
180
- T,
186
+ p ? /* @__PURE__ */ n(
187
+ x,
181
188
  {
182
189
  className: "aegis-ask-panel__composer",
183
- onSend: b,
184
- sending: n,
185
- placeholder: "Ask about this…"
190
+ onSend: k,
191
+ sending: i,
192
+ placeholder: t.askPlaceholder
186
193
  }
187
- ) : /* @__PURE__ */ a("p", { className: "aegis-ask-panel__note", children: "No agent is connected." })
194
+ ) : /* @__PURE__ */ n("p", { className: "aegis-ask-panel__note", children: t.askNoAgent })
188
195
  ]
189
196
  }
190
197
  );
191
198
  }
192
199
  export {
193
- V as AskPanel
200
+ Y as AskPanel
194
201
  };
195
202
  //# sourceMappingURL=AskPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AskPanel.js","sources":["../../../src/agent/ask/AskPanel.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ChatComposer } from '../../components/ui/ChatComposer';\nimport { Chip } from '../../components/ui/Chip';\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { AegisRuntimeContext } from '../core/aegisRuntimeContext';\nimport type { AegisRuntime } from '../core/runtime';\nimport type {\n AegisActionDescriptor,\n AskContext,\n AskRequest,\n} from '../core/types';\nimport './AskPanel.css';\n\nexport interface AskPanelProps {\n context: AskContext;\n /** Tools the agent could invoke. Defaults to deriving from snapshot. */\n tools?: AegisActionDescriptor[];\n /** Optional anchor — the panel positions itself near this rect. */\n anchorRect?: DOMRect | null;\n /** Preferred anchor point (e.g. mouse position). Wins over anchorRect. */\n anchorPoint?: { x: number; y: number } | null;\n onClose: () => void;\n /**\n * Hands the question to the agent. Without it the panel shows the\n * context and its tools but offers no way to ask.\n */\n onSend?: (request: AskRequest) => void;\n /** True while the agent is still answering; holds the composer. */\n sending?: boolean;\n /**\n * When true (default), a fixed popover that closes on Escape and on a\n * click outside it; when false, inline.\n */\n popover?: boolean;\n}\n\nconst PANEL_OFFSET_PX = 8;\nconst VIEWPORT_MARGIN_PX = 8;\nconst PANEL_MIN_HEIGHT_PX = 160;\n\ninterface Placement {\n left: number;\n top: number;\n maxHeight: number;\n}\n\nfunction placeNear(\n point: { x: number; y: number } | null,\n rect: DOMRect | null | undefined,\n panelWidth: number,\n panelHeight: number,\n): Placement | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = VIEWPORT_MARGIN_PX;\n const offset = PANEL_OFFSET_PX;\n\n // Anchor: prefer mouse point; fall back to rect's bottom-left corner.\n const ax = point?.x ?? rect?.left ?? margin;\n const ay = point?.y ?? rect?.bottom ?? margin;\n\n const spaceBelow = vh - ay - margin;\n const spaceAbove = ay - margin;\n const spaceRight = vw - ax - margin;\n const spaceLeft = ax - margin;\n\n // Pick vertical side with more room; allow shrinking max-height to fit.\n const placeBelow = spaceBelow >= spaceAbove;\n const verticalRoom = Math.max(\n placeBelow ? spaceBelow : spaceAbove,\n PANEL_MIN_HEIGHT_PX,\n );\n const maxHeight = Math.min(panelHeight, verticalRoom - offset);\n\n let top = placeBelow ? ay + offset : ay - offset - maxHeight;\n // Pick horizontal side with more room.\n const placeRight = spaceRight >= spaceLeft;\n let left = placeRight ? ax + offset : ax - offset - panelWidth;\n\n // Clamp into viewport.\n left = Math.max(margin, Math.min(left, vw - panelWidth - margin));\n top = Math.max(margin, Math.min(top, vh - maxHeight - margin));\n\n return { left, top, maxHeight };\n}\n\nfunction resolveTools(\n runtime: AegisRuntime | null,\n tools: AegisActionDescriptor[] | undefined,\n context: AskContext,\n): AegisActionDescriptor[] {\n if (tools) {\n return tools;\n }\n if (!runtime) {\n return [];\n }\n if (context.entity) {\n const r = runtime.inspect({ kind: 'entity', entityId: context.entity.id });\n if (r) {\n return r.actions;\n }\n }\n if (context.surface) {\n const r = runtime.inspect({\n kind: 'surface',\n surfaceId: context.surface.id,\n });\n if (r) {\n return r.actions;\n }\n }\n return runtime.listActions();\n}\n\nexport function AskPanel({\n context,\n tools,\n anchorRect,\n anchorPoint,\n onClose,\n onSend,\n sending = false,\n popover = true,\n}: AskPanelProps): ReactElement {\n const ctx = useContext(AegisRuntimeContext);\n const runtime = ctx?.runtime ?? null;\n const rootRef = useRef<HTMLDivElement>(null);\n const [placement, setPlacement] = useState<Placement | null>(null);\n\n const [resolvedTools, setResolvedTools] = useState<AegisActionDescriptor[]>(\n () => resolveTools(runtime, tools, context),\n );\n\n useEffect(() => {\n const refresh = (): void => {\n setResolvedTools(resolveTools(runtime, tools, context));\n };\n refresh();\n if (tools !== undefined || !runtime) {\n return;\n }\n return runtime.subscribe((e) => {\n if (e.type === 'registry.changed' || e.type === 'snapshot.changed') {\n refresh();\n }\n });\n }, [runtime, tools, context]);\n\n const ask = useCallback(\n (prompt: string) => {\n const request: AskRequest = {\n prompt,\n context,\n tools: resolvedTools,\n history: [],\n };\n runtime?.emitAskSubmit(request);\n onSend?.(request);\n },\n [runtime, context, resolvedTools, onSend],\n );\n\n useEffect(() => {\n if (!popover) {\n return;\n }\n const onKey = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n onClose();\n }\n };\n const onDown = (e: MouseEvent): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n if (e.target instanceof Node && el.contains(e.target)) {\n return;\n }\n onClose();\n };\n window.addEventListener('keydown', onKey, true);\n window.addEventListener('mousedown', onDown, true);\n return () => {\n window.removeEventListener('keydown', onKey, true);\n window.removeEventListener('mousedown', onDown, true);\n };\n }, [onClose, popover]);\n\n useIsomorphicLayoutEffect(() => {\n if (!popover) {\n setPlacement(null);\n return;\n }\n const compute = (): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n // Use the natural (unconstrained) size as the desired height; the\n // placement function will clamp it to the larger viewport gap.\n const naturalHeight = el.scrollHeight || el.offsetHeight;\n const width = el.offsetWidth;\n const next = placeNear(\n anchorPoint ?? null,\n anchorRect ?? null,\n width,\n naturalHeight,\n );\n setPlacement(next);\n };\n compute();\n window.addEventListener('resize', compute);\n window.addEventListener('scroll', compute, true);\n return () => {\n window.removeEventListener('resize', compute);\n window.removeEventListener('scroll', compute, true);\n };\n }, [popover, anchorPoint, anchorRect, resolvedTools, context]);\n\n const style: CSSProperties = popover\n ? placement\n ? {\n position: 'fixed',\n left: placement.left,\n top: placement.top,\n maxHeight: placement.maxHeight,\n }\n : // First paint before measurement: render off-screen to avoid flicker.\n {\n position: 'fixed',\n left: -9999,\n top: -9999,\n visibility: 'hidden',\n }\n : {};\n\n const headerLabel = context.entity?.label ?? context.entity?.id;\n const surfaceLabel = context.surface?.label ?? context.surface?.id;\n\n return (\n <div\n ref={rootRef}\n className=\"aegis-ask-panel\"\n role=\"dialog\"\n aria-label=\"Ask AI\"\n data-aegis-ask-panel=\"open\"\n data-ask-origin={context.origin}\n style={style}\n >\n <header className=\"aegis-ask-panel__header\">\n <div className=\"aegis-ask-panel__title\">Ask AI</div>\n <button\n type=\"button\"\n className=\"aegis-ask-panel__close\"\n aria-label=\"Close\"\n onClick={onClose}\n >\n ×\n </button>\n </header>\n <div className=\"aegis-ask-panel__meta\">\n {surfaceLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">Surface</span>\n <span className=\"aegis-ask-panel__meta-value\">{surfaceLabel}</span>\n </div>\n )}\n {headerLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">Entity</span>\n <span className=\"aegis-ask-panel__meta-value\">{headerLabel}</span>\n </div>\n )}\n </div>\n {context.suggestions.length > 0 && (\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">Suggestions</div>\n <div className=\"aegis-ask-panel__chips\">\n {context.suggestions.map((s) => (\n <Chip\n key={s}\n tone=\"ghost\"\n onClick={\n onSend && !sending\n ? () => {\n ask(s);\n }\n : undefined\n }\n >\n {s}\n </Chip>\n ))}\n </div>\n </div>\n )}\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">\n Tools available ({resolvedTools.length})\n </div>\n {resolvedTools.length === 0 ? (\n <div className=\"aegis-ask-panel__empty\">No tools in scope.</div>\n ) : (\n <ul className=\"aegis-ask-panel__tools\">\n {resolvedTools.slice(0, 8).map((t) => (\n <li key={t.id} className=\"aegis-ask-panel__tool\">\n <span className=\"aegis-ask-panel__tool-id\">{t.id}</span>\n <span className=\"aegis-ask-panel__tool-label\">{t.label}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n {onSend ? (\n <ChatComposer\n className=\"aegis-ask-panel__composer\"\n onSend={ask}\n sending={sending}\n placeholder=\"Ask about this…\"\n />\n ) : (\n <p className=\"aegis-ask-panel__note\">No agent is connected.</p>\n )}\n </div>\n );\n}\n"],"names":["PANEL_OFFSET_PX","VIEWPORT_MARGIN_PX","PANEL_MIN_HEIGHT_PX","placeNear","point","rect","panelWidth","panelHeight","vw","vh","margin","offset","ax","ay","spaceBelow","spaceAbove","spaceRight","spaceLeft","placeBelow","verticalRoom","maxHeight","top","left","resolveTools","runtime","tools","context","r","AskPanel","anchorRect","anchorPoint","onClose","onSend","sending","popover","useContext","AegisRuntimeContext","rootRef","useRef","placement","setPlacement","useState","resolvedTools","setResolvedTools","useEffect","refresh","e","ask","useCallback","prompt","request","onKey","onDown","el","useIsomorphicLayoutEffect","compute","naturalHeight","width","next","style","headerLabel","surfaceLabel","jsxs","jsx","s","Chip","t","ChatComposer"],"mappings":";;;;;;;AA6CA,MAAMA,IAAkB,GAClBC,IAAqB,GACrBC,IAAsB;AAQ5B,SAASC,EACPC,GACAC,GACAC,GACAC,GACkB;AAClB,MAAI,OAAO,SAAW;AACpB,WAAO;AAET,QAAMC,IAAK,OAAO,YACZC,IAAK,OAAO,aACZC,IAAST,GACTU,IAASX,GAGTY,IAAKR,GAAO,KAAKC,GAAM,QAAQK,GAC/BG,IAAKT,GAAO,KAAKC,GAAM,UAAUK,GAEjCI,IAAaL,IAAKI,IAAKH,GACvBK,IAAaF,IAAKH,GAClBM,IAAaR,IAAKI,IAAKF,GACvBO,IAAYL,IAAKF,GAGjBQ,IAAaJ,KAAcC,GAC3BI,IAAe,KAAK;AAAA,IACxBD,IAAaJ,IAAaC;AAAA,IAC1Bb;AAAA,EAAA,GAEIkB,IAAY,KAAK,IAAIb,GAAaY,IAAeR,CAAM;AAE7D,MAAIU,IAAMH,IAAaL,IAAKF,IAASE,IAAKF,IAASS,GAG/CE,IADeN,KAAcC,IACTL,IAAKD,IAASC,IAAKD,IAASL;AAGpD,SAAAgB,IAAO,KAAK,IAAIZ,GAAQ,KAAK,IAAIY,GAAMd,IAAKF,IAAaI,CAAM,CAAC,GAChEW,IAAM,KAAK,IAAIX,GAAQ,KAAK,IAAIW,GAAKZ,IAAKW,IAAYV,CAAM,CAAC,GAEtD,EAAE,MAAAY,GAAM,KAAAD,GAAK,WAAA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K,WAAU,4BAA4B,UAAAG,EAAE,IAAG;AAAA,YACjD,gBAAAH,EAAC,QAAA,EAAK,WAAU,+BAA+B,YAAE,MAAA,CAAM;AAAA,UAAA,KAFhDG,EAAE,EAGX,CACD,EAAA,CACH;AAAA,QAAA,GAEJ;AAAA,QACClC,IACC,gBAAA+B;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,QAAQpB;AAAA,YACR,SAAAd;AAAA,YACA,aAAY;AAAA,UAAA;AAAA,QAAA,IAGd,gBAAA8B,EAAC,KAAA,EAAE,WAAU,yBAAwB,UAAA,yBAAA,CAAsB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAInE;"}
1
+ {"version":3,"file":"AskPanel.js","sources":["../../../src/agent/ask/AskPanel.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ChatComposer } from '../../components/ui/ChatComposer';\nimport { Chip } from '../../components/ui/Chip';\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useStrings } from '../../locale';\nimport { AegisRuntimeContext } from '../core/aegisRuntimeContext';\nimport type { AegisRuntime } from '../core/runtime';\nimport type {\n AegisActionDescriptor,\n AskContext,\n AskRequest,\n} from '../core/types';\nimport './AskPanel.css';\n\nexport interface AskPanelProps {\n context: AskContext;\n /** Tools the agent could invoke. Defaults to deriving from snapshot. */\n tools?: AegisActionDescriptor[];\n /** Optional anchor — the panel positions itself near this rect. */\n anchorRect?: DOMRect | null;\n /** Preferred anchor point (e.g. mouse position). Wins over anchorRect. */\n anchorPoint?: { x: number; y: number } | null;\n onClose: () => void;\n /**\n * Hands the question to the agent. Without it the panel shows the\n * context and its tools but offers no way to ask.\n */\n onSend?: (request: AskRequest) => void;\n /** True while the agent is still answering; holds the composer. */\n sending?: boolean;\n /**\n * When true (default), a fixed popover that closes on Escape and on a\n * click outside it; when false, inline.\n */\n popover?: boolean;\n}\n\nconst PANEL_OFFSET_PX = 8;\nconst VIEWPORT_MARGIN_PX = 8;\nconst PANEL_MIN_HEIGHT_PX = 160;\n\ninterface Placement {\n left: number;\n top: number;\n maxHeight: number;\n}\n\nfunction placeNear(\n point: { x: number; y: number } | null,\n rect: DOMRect | null | undefined,\n panelWidth: number,\n panelHeight: number,\n): Placement | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = VIEWPORT_MARGIN_PX;\n const offset = PANEL_OFFSET_PX;\n\n // Anchor: prefer mouse point; fall back to rect's bottom-left corner.\n const ax = point?.x ?? rect?.left ?? margin;\n const ay = point?.y ?? rect?.bottom ?? margin;\n\n const spaceBelow = vh - ay - margin;\n const spaceAbove = ay - margin;\n const spaceRight = vw - ax - margin;\n const spaceLeft = ax - margin;\n\n // Pick vertical side with more room; allow shrinking max-height to fit.\n const placeBelow = spaceBelow >= spaceAbove;\n const verticalRoom = Math.max(\n placeBelow ? spaceBelow : spaceAbove,\n PANEL_MIN_HEIGHT_PX,\n );\n const maxHeight = Math.min(panelHeight, verticalRoom - offset);\n\n let top = placeBelow ? ay + offset : ay - offset - maxHeight;\n // Pick horizontal side with more room.\n const placeRight = spaceRight >= spaceLeft;\n let left = placeRight ? ax + offset : ax - offset - panelWidth;\n\n // Clamp into viewport.\n left = Math.max(margin, Math.min(left, vw - panelWidth - margin));\n top = Math.max(margin, Math.min(top, vh - maxHeight - margin));\n\n return { left, top, maxHeight };\n}\n\nfunction resolveTools(\n runtime: AegisRuntime | null,\n tools: AegisActionDescriptor[] | undefined,\n context: AskContext,\n): AegisActionDescriptor[] {\n if (tools) {\n return tools;\n }\n if (!runtime) {\n return [];\n }\n if (context.entity) {\n const r = runtime.inspect({ kind: 'entity', entityId: context.entity.id });\n if (r) {\n return r.actions;\n }\n }\n if (context.surface) {\n const r = runtime.inspect({\n kind: 'surface',\n surfaceId: context.surface.id,\n });\n if (r) {\n return r.actions;\n }\n }\n return runtime.listActions();\n}\n\n/**\n * Mounting it opens it: focus moves to its question field, or to the panel\n * when there is no agent to ask, and returns on unmount to the element that\n * had it.\n */\nexport function AskPanel({\n context,\n tools,\n anchorRect,\n anchorPoint,\n onClose,\n onSend,\n sending = false,\n popover = true,\n}: AskPanelProps): ReactElement {\n const strings = useStrings();\n const ctx = useContext(AegisRuntimeContext);\n const runtime = ctx?.runtime ?? null;\n const rootRef = useRef<HTMLDivElement>(null);\n const [placement, setPlacement] = useState<Placement | null>(null);\n\n const [resolvedTools, setResolvedTools] = useState<AegisActionDescriptor[]>(\n () => resolveTools(runtime, tools, context),\n );\n\n useEffect(() => {\n const refresh = (): void => {\n setResolvedTools(resolveTools(runtime, tools, context));\n };\n refresh();\n if (tools !== undefined || !runtime) {\n return;\n }\n return runtime.subscribe((e) => {\n if (e.type === 'registry.changed' || e.type === 'snapshot.changed') {\n refresh();\n }\n });\n }, [runtime, tools, context]);\n\n const ask = useCallback(\n (prompt: string) => {\n const request: AskRequest = {\n prompt,\n context,\n tools: resolvedTools,\n history: [],\n };\n runtime?.emitAskSubmit(request);\n onSend?.(request);\n },\n [runtime, context, resolvedTools, onSend],\n );\n\n useEffect(() => {\n if (!popover) {\n return;\n }\n const onKey = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n onClose();\n }\n };\n const onDown = (e: MouseEvent): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n if (e.target instanceof Node && el.contains(e.target)) {\n return;\n }\n onClose();\n };\n window.addEventListener('keydown', onKey, true);\n window.addEventListener('mousedown', onDown, true);\n return () => {\n window.removeEventListener('keydown', onKey, true);\n window.removeEventListener('mousedown', onDown, true);\n };\n }, [onClose, popover]);\n\n // A popover is hidden, and so cannot take focus, until it is placed.\n const ready = !popover || placement !== null;\n useEffect(() => {\n if (!ready) {\n return;\n }\n const returnFocusTo = document.activeElement;\n const root = rootRef.current;\n (\n root?.querySelector<HTMLElement>('textarea:not(:disabled)') ?? root\n )?.focus();\n return () => {\n if (returnFocusTo instanceof HTMLElement && returnFocusTo.isConnected) {\n returnFocusTo.focus();\n }\n };\n }, [ready]);\n\n useIsomorphicLayoutEffect(() => {\n if (!popover) {\n setPlacement(null);\n return;\n }\n const compute = (): void => {\n const el = rootRef.current;\n if (!el) {\n return;\n }\n // Use the natural (unconstrained) size as the desired height; the\n // placement function will clamp it to the larger viewport gap.\n const naturalHeight = el.scrollHeight || el.offsetHeight;\n const width = el.offsetWidth;\n const next = placeNear(\n anchorPoint ?? null,\n anchorRect ?? null,\n width,\n naturalHeight,\n );\n setPlacement(next);\n };\n compute();\n window.addEventListener('resize', compute);\n window.addEventListener('scroll', compute, true);\n return () => {\n window.removeEventListener('resize', compute);\n window.removeEventListener('scroll', compute, true);\n };\n }, [popover, anchorPoint, anchorRect, resolvedTools, context]);\n\n const style: CSSProperties = popover\n ? placement\n ? {\n position: 'fixed',\n left: placement.left,\n top: placement.top,\n maxHeight: placement.maxHeight,\n }\n : // First paint before measurement: render off-screen to avoid flicker.\n {\n position: 'fixed',\n left: -9999,\n top: -9999,\n visibility: 'hidden',\n }\n : {};\n\n const headerLabel = context.entity?.label ?? context.entity?.id;\n const surfaceLabel = context.surface?.label ?? context.surface?.id;\n\n return (\n <div\n ref={rootRef}\n className=\"aegis-ask-panel\"\n role=\"dialog\"\n aria-label={strings.askPanelTitle}\n tabIndex={-1}\n data-aegis-ask-panel=\"open\"\n data-ask-origin={context.origin}\n style={style}\n >\n <header className=\"aegis-ask-panel__header\">\n <div className=\"aegis-ask-panel__title\">{strings.askPanelTitle}</div>\n <button\n type=\"button\"\n className=\"aegis-ask-panel__close\"\n aria-label={strings.close}\n onClick={onClose}\n >\n ×\n </button>\n </header>\n <div className=\"aegis-ask-panel__meta\">\n {surfaceLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">\n {strings.askSurface}\n </span>\n <span className=\"aegis-ask-panel__meta-value\">{surfaceLabel}</span>\n </div>\n )}\n {headerLabel && (\n <div className=\"aegis-ask-panel__meta-row\">\n <span className=\"aegis-ask-panel__meta-label\">\n {strings.askEntity}\n </span>\n <span className=\"aegis-ask-panel__meta-value\">{headerLabel}</span>\n </div>\n )}\n </div>\n {context.suggestions.length > 0 && (\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">\n {strings.suggestions}\n </div>\n <div className=\"aegis-ask-panel__chips\">\n {context.suggestions.map((s) => (\n <Chip\n key={s}\n tone=\"ghost\"\n onClick={\n onSend && !sending\n ? () => {\n ask(s);\n }\n : undefined\n }\n >\n {s}\n </Chip>\n ))}\n </div>\n </div>\n )}\n <div className=\"aegis-ask-panel__section\">\n <div className=\"aegis-ask-panel__section-label\">\n {strings.askToolsAvailable(resolvedTools.length)}\n </div>\n {resolvedTools.length === 0 ? (\n <div className=\"aegis-ask-panel__empty\">{strings.askNoTools}</div>\n ) : (\n <ul className=\"aegis-ask-panel__tools\">\n {resolvedTools.slice(0, 8).map((t) => (\n <li key={t.id} className=\"aegis-ask-panel__tool\">\n <span className=\"aegis-ask-panel__tool-id\">{t.id}</span>\n <span className=\"aegis-ask-panel__tool-label\">{t.label}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n {onSend ? (\n <ChatComposer\n className=\"aegis-ask-panel__composer\"\n onSend={ask}\n sending={sending}\n placeholder={strings.askPlaceholder}\n />\n ) : (\n <p className=\"aegis-ask-panel__note\">{strings.askNoAgent}</p>\n )}\n </div>\n );\n}\n"],"names":["PANEL_OFFSET_PX","VIEWPORT_MARGIN_PX","PANEL_MIN_HEIGHT_PX","placeNear","point","rect","panelWidth","panelHeight","vw","vh","margin","offset","ax","ay","spaceBelow","spaceAbove","spaceRight","spaceLeft","placeBelow","verticalRoom","maxHeight","top","left","resolveTools","runtime","tools","context","r","AskPanel","anchorRect","anchorPoint","onClose","onSend","sending","popover","strings","useStrings","useContext","AegisRuntimeContext","rootRef","useRef","placement","setPlacement","useState","resolvedTools","setResolvedTools","useEffect","refresh","e","ask","useCallback","prompt","request","onKey","onDown","el","ready","returnFocusTo","root","useIsomorphicLayoutEffect","compute","naturalHeight","width","next","style","headerLabel","surfaceLabel","jsxs","jsx","s","Chip","t","ChatComposer"],"mappings":";;;;;;;;AA8CA,MAAMA,IAAkB,GAClBC,IAAqB,GACrBC,IAAsB;AAQ5B,SAASC,EACPC,GACAC,GACAC,GACAC,GACkB;AAClB,MAAI,OAAO,SAAW;AACpB,WAAO;AAET,QAAMC,IAAK,OAAO,YACZC,IAAK,OAAO,aACZC,IAAST,GACTU,IAASX,GAGTY,IAAKR,GAAO,KAAKC,GAAM,QAAQK,GAC/BG,IAAKT,GAAO,KAAKC,GAAM,UAAUK,GAEjCI,IAAaL,IAAKI,IAAKH,GACvBK,IAAaF,IAAKH,GAClBM,IAAaR,IAAKI,IAAKF,GACvBO,IAAYL,IAAKF,GAGjBQ,IAAaJ,KAAcC,GAC3BI,IAAe,KAAK;AAAA,IACxBD,IAAaJ,IAAaC;AAAA,IAC1Bb;AAAA,EAAA,GAEIkB,IAAY,KAAK,IAAIb,GAAaY,IAAeR,CAAM;AAE7D,MAAIU,IAAMH,IAAaL,IAAKF,IAASE,IAAKF,IAASS,GAG/CE,IADeN,KAAcC,IACTL,IAAKD,IAASC,IAAKD,IAASL;AAGpD,SAAAgB,IAAO,KAAK,IAAIZ,GAAQ,KAAK,IAAIY,GAAMd,IAAKF,IAAaI,CAAM,CAAC,GAChEW,IAAM,KAAK,IAAIX,GAAQ,KAAK,IAAIW,GAAKZ,IAAKW,IAAYV,CAAM,CAAC,GAEtD,EAAE,MAAAY,GAAM,KAAAD,GAAK,WAAAD,EAAA;AACtB;AAEA,SAASG,EACPC,GACAC,GACAC,GACyB;AACzB,MAAID;AACF,WAAOA;AAET,MAAI,CAACD;AACH,WAAO,CAAA;AAET,MAAIE,EAAQ,QAAQ;AAClB,UAAMC,IAAIH,EAAQ,QAAQ,EAAE,MAAM,UAAU,UAAUE,EAAQ,OAAO,I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A,EAAG,WAAU,0BACX,UAAAxB,EAAc,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC2B,MAC9B,gBAAAJ,EAAC,MAAA,EAAc,WAAU,yBACvB,UAAA;AAAA,YAAA,gBAAAC,EAAC,QAAA,EAAK,WAAU,4BAA4B,UAAAG,EAAE,IAAG;AAAA,YACjD,gBAAAH,EAAC,QAAA,EAAK,WAAU,+BAA+B,YAAE,MAAA,CAAM;AAAA,UAAA,KAFhDG,EAAE,EAGX,CACD,EAAA,CACH;AAAA,QAAA,GAEJ;AAAA,QACCvC,IACC,gBAAAoC;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,QAAQvB;AAAA,YACR,SAAAhB;AAAA,YACA,aAAaE,EAAQ;AAAA,UAAA;AAAA,QAAA,IAGvB,gBAAAiC,EAAC,KAAA,EAAE,WAAU,yBAAyB,YAAQ,WAAA,CAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIjE;"}
@@ -1 +1 @@
1
- {"version":3,"file":"commandContext.cjs","sources":["../../src/commands/commandContext.ts"],"sourcesContent":["import { type ReactNode, createContext } from 'react';\n\n/**\n * A single executable action surfaced through the command palette and,\n * eventually, agent tool-calls. Commands are presentational contracts —\n * the host owns the side-effect inside `handler`.\n */\nexport interface Command<TArgs = unknown> {\n /** Globally unique id. Convention: 'app.action' e.g. 'projects.create'. */\n id: string;\n /** Human label shown in the palette. */\n label: string;\n /** Longer description — also shown to agents as tool description. */\n description?: string;\n /** Search keywords (lowercase). */\n keywords?: string[];\n /** Icon node shown in the palette row. */\n icon?: ReactNode;\n /** UI grouping (e.g. 'Quick actions', 'Navigate'). Default: 'Other'. */\n group?: string;\n /** Keybinding using 'mod' for Cmd/Ctrl, e.g. 'mod+shift+p'. */\n shortcut?: string;\n /** When set, command is only available while this AegisApp is active. */\n scope?: string;\n /** Hide from palette UI; still callable via execute() (used by agents). */\n agentOnly?: boolean;\n /** JSON-schema-ish param description for agents. Library doesn't parse it. */\n schema?: Record<string, unknown>;\n /** The actual side-effect. */\n handler: (args?: TArgs) => void | Promise<void>;\n /** Optional undo callback for hosts that offer Undo; CommandPalette never calls it. */\n undo?: () => void | Promise<void>;\n}\n\n/**\n * Contract exposed by the CommandProvider. Unlike auth/notifications,\n * the library owns this state — the registry only makes sense as a\n * library-managed runtime.\n */\nexport interface CommandContextValue {\n /** All registered commands, scope-filtered for the current active app. */\n commands: Command[];\n /** All registered commands regardless of scope (for agents). */\n allCommands: Command[];\n /** Register a batch of commands. Returns an unregister function. */\n register: (cmds: Command[]) => () => void;\n /** Set the active scope (called by AegisShell — apps don't touch this). */\n setActiveScope: (scope: string | undefined) => void;\n /** Execute by id. Throws if no command with that id. */\n execute: (id: string, args?: unknown) => Promise<void>;\n /** Open or close the palette. */\n setPaletteOpen: (open: boolean) => void;\n paletteOpen: boolean;\n}\n\n/** Null until a `<CommandProvider>` is mounted; `useCommands` reads it. */\nexport const CommandContext = createContext<CommandContextValue | null>(null);\n"],"names":["CommandContext","createContext"],"mappings":"yGAwDaA,EAAiBC,EAAAA,cAA0C,IAAI"}
1
+ {"version":3,"file":"commandContext.cjs","sources":["../../src/commands/commandContext.ts"],"sourcesContent":["import { type ReactNode, createContext } from 'react';\n\n/**\n * A single executable action surfaced through the command palette and,\n * eventually, agent tool-calls. Commands are presentational contracts —\n * the host owns the side-effect inside `handler`.\n */\nexport interface Command<TArgs = unknown> {\n /** Globally unique id. Convention: 'app.action' e.g. 'projects.create'. */\n id: string;\n /** Human label shown in the palette. */\n label: string;\n /** Longer description — also shown to agents as tool description. */\n description?: string;\n /** Search keywords (lowercase). */\n keywords?: string[];\n /** Icon node shown in the palette row. */\n icon?: ReactNode;\n /**\n * UI grouping (e.g. 'Quick actions', 'Navigate'). Without one, the\n * palette files the command under the locale's `commandGroupOther`.\n */\n group?: string;\n /** Keybinding using 'mod' for Cmd/Ctrl, e.g. 'mod+shift+p'. */\n shortcut?: string;\n /** When set, command is only available while this AegisApp is active. */\n scope?: string;\n /** Hide from palette UI; still callable via execute() (used by agents). */\n agentOnly?: boolean;\n /** JSON-schema-ish param description for agents. Library doesn't parse it. */\n schema?: Record<string, unknown>;\n /** The actual side-effect. */\n handler: (args?: TArgs) => void | Promise<void>;\n /** Optional undo callback for hosts that offer Undo; CommandPalette never calls it. */\n undo?: () => void | Promise<void>;\n}\n\n/**\n * Contract exposed by the CommandProvider. Unlike auth/notifications,\n * the library owns this state — the registry only makes sense as a\n * library-managed runtime.\n */\nexport interface CommandContextValue {\n /** All registered commands, scope-filtered for the current active app. */\n commands: Command[];\n /** All registered commands regardless of scope (for agents). */\n allCommands: Command[];\n /** Register a batch of commands. Returns an unregister function. */\n register: (cmds: Command[]) => () => void;\n /** Set the active scope (called by AegisShell — apps don't touch this). */\n setActiveScope: (scope: string | undefined) => void;\n /** Execute by id. Throws if no command with that id. */\n execute: (id: string, args?: unknown) => Promise<void>;\n /** Open or close the palette. */\n setPaletteOpen: (open: boolean) => void;\n paletteOpen: boolean;\n}\n\n/** Null until a `<CommandProvider>` is mounted; `useCommands` reads it. */\nexport const CommandContext = createContext<CommandContextValue | null>(null);\n"],"names":["CommandContext","createContext"],"mappings":"yGA2DaA,EAAiBC,EAAAA,cAA0C,IAAI"}
@@ -15,7 +15,10 @@ export interface Command<TArgs = unknown> {
15
15
  keywords?: string[];
16
16
  /** Icon node shown in the palette row. */
17
17
  icon?: ReactNode;
18
- /** UI grouping (e.g. 'Quick actions', 'Navigate'). Default: 'Other'. */
18
+ /**
19
+ * UI grouping (e.g. 'Quick actions', 'Navigate'). Without one, the
20
+ * palette files the command under the locale's `commandGroupOther`.
21
+ */
19
22
  group?: string;
20
23
  /** Keybinding using 'mod' for Cmd/Ctrl, e.g. 'mod+shift+p'. */
21
24
  shortcut?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"commandContext.js","sources":["../../src/commands/commandContext.ts"],"sourcesContent":["import { type ReactNode, createContext } from 'react';\n\n/**\n * A single executable action surfaced through the command palette and,\n * eventually, agent tool-calls. Commands are presentational contracts —\n * the host owns the side-effect inside `handler`.\n */\nexport interface Command<TArgs = unknown> {\n /** Globally unique id. Convention: 'app.action' e.g. 'projects.create'. */\n id: string;\n /** Human label shown in the palette. */\n label: string;\n /** Longer description — also shown to agents as tool description. */\n description?: string;\n /** Search keywords (lowercase). */\n keywords?: string[];\n /** Icon node shown in the palette row. */\n icon?: ReactNode;\n /** UI grouping (e.g. 'Quick actions', 'Navigate'). Default: 'Other'. */\n group?: string;\n /** Keybinding using 'mod' for Cmd/Ctrl, e.g. 'mod+shift+p'. */\n shortcut?: string;\n /** When set, command is only available while this AegisApp is active. */\n scope?: string;\n /** Hide from palette UI; still callable via execute() (used by agents). */\n agentOnly?: boolean;\n /** JSON-schema-ish param description for agents. Library doesn't parse it. */\n schema?: Record<string, unknown>;\n /** The actual side-effect. */\n handler: (args?: TArgs) => void | Promise<void>;\n /** Optional undo callback for hosts that offer Undo; CommandPalette never calls it. */\n undo?: () => void | Promise<void>;\n}\n\n/**\n * Contract exposed by the CommandProvider. Unlike auth/notifications,\n * the library owns this state — the registry only makes sense as a\n * library-managed runtime.\n */\nexport interface CommandContextValue {\n /** All registered commands, scope-filtered for the current active app. */\n commands: Command[];\n /** All registered commands regardless of scope (for agents). */\n allCommands: Command[];\n /** Register a batch of commands. Returns an unregister function. */\n register: (cmds: Command[]) => () => void;\n /** Set the active scope (called by AegisShell — apps don't touch this). */\n setActiveScope: (scope: string | undefined) => void;\n /** Execute by id. Throws if no command with that id. */\n execute: (id: string, args?: unknown) => Promise<void>;\n /** Open or close the palette. */\n setPaletteOpen: (open: boolean) => void;\n paletteOpen: boolean;\n}\n\n/** Null until a `<CommandProvider>` is mounted; `useCommands` reads it. */\nexport const CommandContext = createContext<CommandContextValue | null>(null);\n"],"names":["CommandContext","createContext"],"mappings":";AAwDO,MAAMA,IAAiBC,EAA0C,IAAI;"}
1
+ {"version":3,"file":"commandContext.js","sources":["../../src/commands/commandContext.ts"],"sourcesContent":["import { type ReactNode, createContext } from 'react';\n\n/**\n * A single executable action surfaced through the command palette and,\n * eventually, agent tool-calls. Commands are presentational contracts —\n * the host owns the side-effect inside `handler`.\n */\nexport interface Command<TArgs = unknown> {\n /** Globally unique id. Convention: 'app.action' e.g. 'projects.create'. */\n id: string;\n /** Human label shown in the palette. */\n label: string;\n /** Longer description — also shown to agents as tool description. */\n description?: string;\n /** Search keywords (lowercase). */\n keywords?: string[];\n /** Icon node shown in the palette row. */\n icon?: ReactNode;\n /**\n * UI grouping (e.g. 'Quick actions', 'Navigate'). Without one, the\n * palette files the command under the locale's `commandGroupOther`.\n */\n group?: string;\n /** Keybinding using 'mod' for Cmd/Ctrl, e.g. 'mod+shift+p'. */\n shortcut?: string;\n /** When set, command is only available while this AegisApp is active. */\n scope?: string;\n /** Hide from palette UI; still callable via execute() (used by agents). */\n agentOnly?: boolean;\n /** JSON-schema-ish param description for agents. Library doesn't parse it. */\n schema?: Record<string, unknown>;\n /** The actual side-effect. */\n handler: (args?: TArgs) => void | Promise<void>;\n /** Optional undo callback for hosts that offer Undo; CommandPalette never calls it. */\n undo?: () => void | Promise<void>;\n}\n\n/**\n * Contract exposed by the CommandProvider. Unlike auth/notifications,\n * the library owns this state — the registry only makes sense as a\n * library-managed runtime.\n */\nexport interface CommandContextValue {\n /** All registered commands, scope-filtered for the current active app. */\n commands: Command[];\n /** All registered commands regardless of scope (for agents). */\n allCommands: Command[];\n /** Register a batch of commands. Returns an unregister function. */\n register: (cmds: Command[]) => () => void;\n /** Set the active scope (called by AegisShell — apps don't touch this). */\n setActiveScope: (scope: string | undefined) => void;\n /** Execute by id. Throws if no command with that id. */\n execute: (id: string, args?: unknown) => Promise<void>;\n /** Open or close the palette. */\n setPaletteOpen: (open: boolean) => void;\n paletteOpen: boolean;\n}\n\n/** Null until a `<CommandProvider>` is mounted; `useCommands` reads it. */\nexport const CommandContext = createContext<CommandContextValue | null>(null);\n"],"names":["CommandContext","createContext"],"mappings":";AA2DO,MAAMA,IAAiBC,EAA0C,IAAI;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),o=require("../../agent/core/usePrimitiveSurface.cjs");;/* empty css */function d({title:n,headerActions:a,children:l,footer:s,className:t,surface:r}){const i=u.useRef(null),c=o.usePrimitiveSurface(r,null,"panel",i),g=["aegis-agent-panel",t??""].filter(Boolean).join(" ");return e.jsxs("aside",{ref:i,className:g,"aria-label":"Agent panel",...c,children:[(n??a)&&e.jsxs("header",{className:"aegis-agent-panel__header",children:[e.jsx("div",{className:"aegis-agent-panel__title",children:n}),a&&e.jsx("div",{className:"aegis-agent-panel__actions",children:a})]}),e.jsx("div",{className:"aegis-agent-panel__body",children:l}),s&&e.jsx("div",{className:"aegis-agent-panel__footer",children:s})]})}exports.AgentPanel=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),d=require("../../agent/core/usePrimitiveSurface.cjs");;/* empty css */const m=require("../../locale/useStrings.cjs");function _({title:s,headerActions:a,children:t,footer:n,className:r,surface:l}){const c=m.useStrings(),i=o.useRef(null),g=d.usePrimitiveSurface(l,null,"panel",i),u=["aegis-agent-panel",r??""].filter(Boolean).join(" ");return e.jsxs("aside",{ref:i,className:u,"aria-label":c.agentPanel,...g,children:[(s??a)&&e.jsxs("header",{className:"aegis-agent-panel__header",children:[e.jsx("div",{className:"aegis-agent-panel__title",children:s}),a&&e.jsx("div",{className:"aegis-agent-panel__actions",children:a})]}),e.jsx("div",{className:"aegis-agent-panel__body",children:t}),n&&e.jsx("div",{className:"aegis-agent-panel__footer",children:n})]})}exports.AgentPanel=_;
2
2
  //# sourceMappingURL=AgentPanel.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentPanel.cjs","sources":["../../../src/components/ui/AgentPanel.tsx"],"sourcesContent":["import { type ReactNode, useRef } from 'react';\n\nimport {\n type ContainerSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport './AgentPanel.css';\n\nexport type AgentPanelSurface = ContainerSurface;\n\ninterface AgentPanelProps {\n title?: ReactNode;\n /** Header right-side slot (e.g. close button). */\n headerActions?: ReactNode;\n /** The conversation area — typically ChatMessageList. */\n children: ReactNode;\n /** Sticky footer — typically ChatComposer. */\n footer?: ReactNode;\n className?: string;\n surface?: AgentPanelSurface;\n}\n\nexport function AgentPanel({\n title,\n headerActions,\n children,\n footer,\n className,\n surface,\n}: AgentPanelProps) {\n const wrapRef = useRef<HTMLElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, null, 'panel', wrapRef);\n const cls = ['aegis-agent-panel', className ?? ''].filter(Boolean).join(' ');\n\n return (\n <aside\n ref={wrapRef}\n className={cls}\n aria-label=\"Agent panel\"\n {...agentAttrs}\n >\n {(title ?? headerActions) && (\n <header className=\"aegis-agent-panel__header\">\n <div className=\"aegis-agent-panel__title\">{title}</div>\n {headerActions && (\n <div className=\"aegis-agent-panel__actions\">{headerActions}</div>\n )}\n </header>\n )}\n <div className=\"aegis-agent-panel__body\">{children}</div>\n {footer && <div className=\"aegis-agent-panel__footer\">{footer}</div>}\n </aside>\n );\n}\n"],"names":["AgentPanel","title","headerActions","children","footer","className","surface","wrapRef","useRef","agentAttrs","usePrimitiveSurface","cls","jsxs","jsx"],"mappings":"8NAsBO,SAASA,EAAW,CACzB,MAAAC,EACA,cAAAC,EACA,SAAAC,EACA,OAAAC,EACA,UAAAC,EACA,QAAAC,CACF,EAAoB,CAClB,MAAMC,EAAUC,EAAAA,OAAoB,IAAI,EAClCC,EAAaC,EAAAA,oBAAoBJ,EAAS,KAAM,QAASC,CAAO,EAChEI,EAAM,CAAC,oBAAqBN,GAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAE3E,OACEO,EAAAA,KAAC,QAAA,CACC,IAAKL,EACL,UAAWI,EACX,aAAW,cACV,GAAGF,EAEF,SAAA,EAAAR,GAASC,IACTU,EAAAA,KAAC,SAAA,CAAO,UAAU,4BAChB,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,2BAA4B,SAAAZ,EAAM,EAChDC,GACCW,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA8B,SAAAX,CAAA,CAAc,CAAA,EAE/D,EAEFW,EAAAA,IAAC,MAAA,CAAI,UAAU,0BAA2B,SAAAV,CAAA,CAAS,EAClDC,GAAUS,EAAAA,IAAC,MAAA,CAAI,UAAU,4BAA6B,SAAAT,CAAA,CAAO,CAAA,CAAA,CAAA,CAGpE"}
1
+ {"version":3,"file":"AgentPanel.cjs","sources":["../../../src/components/ui/AgentPanel.tsx"],"sourcesContent":["import { type ReactNode, useRef } from 'react';\n\nimport {\n type ContainerSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { useStrings } from '../../locale';\nimport './AgentPanel.css';\n\nexport type AgentPanelSurface = ContainerSurface;\n\ninterface AgentPanelProps {\n title?: ReactNode;\n /** Header right-side slot (e.g. close button). */\n headerActions?: ReactNode;\n /** The conversation area — typically ChatMessageList. */\n children: ReactNode;\n /** Sticky footer — typically ChatComposer. */\n footer?: ReactNode;\n className?: string;\n surface?: AgentPanelSurface;\n}\n\nexport function AgentPanel({\n title,\n headerActions,\n children,\n footer,\n className,\n surface,\n}: AgentPanelProps) {\n const strings = useStrings();\n const wrapRef = useRef<HTMLElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, null, 'panel', wrapRef);\n const cls = ['aegis-agent-panel', className ?? ''].filter(Boolean).join(' ');\n\n return (\n <aside\n ref={wrapRef}\n className={cls}\n aria-label={strings.agentPanel}\n {...agentAttrs}\n >\n {(title ?? headerActions) && (\n <header className=\"aegis-agent-panel__header\">\n <div className=\"aegis-agent-panel__title\">{title}</div>\n {headerActions && (\n <div className=\"aegis-agent-panel__actions\">{headerActions}</div>\n )}\n </header>\n )}\n <div className=\"aegis-agent-panel__body\">{children}</div>\n {footer && <div className=\"aegis-agent-panel__footer\">{footer}</div>}\n </aside>\n );\n}\n"],"names":["AgentPanel","title","headerActions","children","footer","className","surface","strings","useStrings","wrapRef","useRef","agentAttrs","usePrimitiveSurface","cls","jsxs","jsx"],"mappings":"6QAuBO,SAASA,EAAW,CACzB,MAAAC,EACA,cAAAC,EACA,SAAAC,EACA,OAAAC,EACA,UAAAC,EACA,QAAAC,CACF,EAAoB,CAClB,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAUC,EAAAA,OAAoB,IAAI,EAClCC,EAAaC,EAAAA,oBAAoBN,EAAS,KAAM,QAASG,CAAO,EAChEI,EAAM,CAAC,oBAAqBR,GAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAE3E,OACES,EAAAA,KAAC,QAAA,CACC,IAAKL,EACL,UAAWI,EACX,aAAYN,EAAQ,WACnB,GAAGI,EAEF,SAAA,EAAAV,GAASC,IACTY,EAAAA,KAAC,SAAA,CAAO,UAAU,4BAChB,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,2BAA4B,SAAAd,EAAM,EAChDC,GACCa,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA8B,SAAAb,CAAA,CAAc,CAAA,EAE/D,EAEFa,EAAAA,IAAC,MAAA,CAAI,UAAU,0BAA2B,SAAAZ,CAAA,CAAS,EAClDC,GAAUW,EAAAA,IAAC,MAAA,CAAI,UAAU,4BAA6B,SAAAX,CAAA,CAAO,CAAA,CAAA,CAAA,CAGpE"}