@adecore/agents-react 0.31.12 → 0.32.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 (402) hide show
  1. package/dist/agents/AccountDot.js +57 -6
  2. package/dist/agents/AgentIcon.js +88 -12
  3. package/dist/agents/ModelOptionControl.js +153 -18
  4. package/dist/agents/ProviderLogo.js +49 -4
  5. package/dist/agents/account-limits.js +17 -14
  6. package/dist/agents/accounts.js +99 -67
  7. package/dist/agents/agent-marks.js +5 -3
  8. package/dist/agents/model-name.js +42 -31
  9. package/dist/agents/model-options.js +8 -8
  10. package/dist/agents/model-requirement.js +17 -14
  11. package/dist/agents/option-words.d.ts +7 -0
  12. package/dist/agents/option-words.js +35 -0
  13. package/dist/agents/provider-paths.js +6 -6
  14. package/dist/agents/status-look.js +32 -12
  15. package/dist/chat/account-choice.d.ts +13 -0
  16. package/dist/chat/account-choice.js +90 -20
  17. package/dist/chat/actions.js +126 -59
  18. package/dist/chat/activity.js +5 -5
  19. package/dist/chat/attachments.js +74 -53
  20. package/dist/chat/bookmarks.js +58 -48
  21. package/dist/chat/chat-client.js +344 -263
  22. package/dist/chat/chat-references.js +3 -3
  23. package/dist/chat/composer-effort.d.ts +5 -0
  24. package/dist/chat/composer-effort.js +26 -0
  25. package/dist/chat/composer-send.js +13 -13
  26. package/dist/chat/drafts.js +115 -79
  27. package/dist/chat/forks.js +81 -24
  28. package/dist/chat/guards.js +15 -43
  29. package/dist/chat/index.d.ts +3 -1
  30. package/dist/chat/index.js +3 -2
  31. package/dist/chat/logic/ansi.js +170 -167
  32. package/dist/chat/logic/answers.js +2 -2
  33. package/dist/chat/logic/bookmarks.js +19 -19
  34. package/dist/chat/logic/command-looks.js +138 -96
  35. package/dist/chat/logic/context-usage.js +13 -9
  36. package/dist/chat/logic/continue-after-stop.js +15 -19
  37. package/dist/chat/logic/effort.d.ts +14 -0
  38. package/dist/chat/logic/effort.js +34 -0
  39. package/dist/chat/logic/embedded-code.js +387 -326
  40. package/dist/chat/logic/fork.js +134 -110
  41. package/dist/chat/logic/generated-image.js +54 -23
  42. package/dist/chat/logic/goal.js +28 -20
  43. package/dist/chat/logic/handback.js +6 -6
  44. package/dist/chat/logic/json.js +2 -2
  45. package/dist/chat/logic/limit.js +46 -30
  46. package/dist/chat/logic/picker-entries.d.ts +5 -3
  47. package/dist/chat/logic/picker-entries.js +83 -43
  48. package/dist/chat/logic/resume-compaction.d.ts +14 -1
  49. package/dist/chat/logic/resume-compaction.js +93 -24
  50. package/dist/chat/logic/scrubber.js +188 -136
  51. package/dist/chat/logic/thought.js +13 -16
  52. package/dist/chat/logic/thread-cards.js +60 -48
  53. package/dist/chat/logic/timeline-copy.js +30 -38
  54. package/dist/chat/logic/timeline-target.js +92 -63
  55. package/dist/chat/logic/timeline.js +499 -355
  56. package/dist/chat/logic/tool-catalog.js +54 -34
  57. package/dist/chat/logic/tools.js +106 -82
  58. package/dist/chat/logic/visual-height.js +18 -18
  59. package/dist/chat/logic/visual-viewport.js +6 -3
  60. package/dist/chat/logic/welcome.js +9 -9
  61. package/dist/chat/logic/workflow.js +45 -34
  62. package/dist/chat/mentions.js +149 -109
  63. package/dist/chat/persisted-json.js +51 -54
  64. package/dist/chat/preferences.d.ts +4 -0
  65. package/dist/chat/preferences.js +162 -84
  66. package/dist/chat/prompt-hold.js +9 -9
  67. package/dist/chat/quote.js +21 -30
  68. package/dist/chat/reading-width.js +12 -10
  69. package/dist/chat/recent-messages.js +34 -21
  70. package/dist/chat/resume-compaction-dismissals.js +25 -5
  71. package/dist/chat/runtime-modes.js +3 -3
  72. package/dist/chat/send-key.js +11 -7
  73. package/dist/chat/stash.js +89 -69
  74. package/dist/chat/subagent-conversation.js +181 -139
  75. package/dist/chat/subagent-list.js +65 -67
  76. package/dist/chat/subagent-support.js +12 -7
  77. package/dist/chat/subagent-view.js +132 -44
  78. package/dist/chat/thumbnails.js +88 -60
  79. package/dist/chat/timeline-flash.js +24 -12
  80. package/dist/chat/timeline-scroll.js +116 -86
  81. package/dist/chat/ui/AccountPill.js +126 -15
  82. package/dist/chat/ui/AnsiOutput.js +62 -6
  83. package/dist/chat/ui/BookmarkMarker.js +231 -41
  84. package/dist/chat/ui/BookmarkSubmenu.js +165 -18
  85. package/dist/chat/ui/ChatActivity.js +649 -70
  86. package/dist/chat/ui/ChatReferenceChip.js +104 -9
  87. package/dist/chat/ui/CodeBlock.js +132 -58
  88. package/dist/chat/ui/Composer.js +866 -132
  89. package/dist/chat/ui/ComposerInput.js +309 -120
  90. package/dist/chat/ui/DiffPool.js +75 -14
  91. package/dist/chat/ui/EditDiff.js +160 -21
  92. package/dist/chat/ui/FadingWords.js +32 -3
  93. package/dist/chat/ui/GoalDock.js +235 -42
  94. package/dist/chat/ui/ImageView.js +617 -61
  95. package/dist/chat/ui/LimitState.js +446 -72
  96. package/dist/chat/ui/Markdown.js +991 -173
  97. package/dist/chat/ui/MermaidBlock.js +238 -68
  98. package/dist/chat/ui/MessageActions.js +251 -39
  99. package/dist/chat/ui/ModelMarks.js +55 -5
  100. package/dist/chat/ui/Pickers.js +664 -113
  101. package/dist/chat/ui/PromptComposer.js +281 -51
  102. package/dist/chat/ui/QuoteButton.js +151 -57
  103. package/dist/chat/ui/ResumeCompactionDock.d.ts +6 -2
  104. package/dist/chat/ui/ResumeCompactionDock.js +141 -6
  105. package/dist/chat/ui/RowTime.js +59 -5
  106. package/dist/chat/ui/RunSettings.js +1744 -154
  107. package/dist/chat/ui/Scrubber.js +517 -88
  108. package/dist/chat/ui/ShellCommand.js +183 -107
  109. package/dist/chat/ui/SubagentControls.js +212 -24
  110. package/dist/chat/ui/SubagentInfo.js +170 -13
  111. package/dist/chat/ui/SubagentStopButton.js +115 -24
  112. package/dist/chat/ui/SubagentTimeline.js +357 -91
  113. package/dist/chat/ui/Timeline.js +988 -476
  114. package/dist/chat/ui/TimelineMenu.js +552 -37
  115. package/dist/chat/ui/UnifiedDiff.js +234 -27
  116. package/dist/chat/ui/UploadThumb.js +37 -7
  117. package/dist/chat/ui/VisualDialogs.js +251 -20
  118. package/dist/chat/ui/VisualFrame.js +321 -95
  119. package/dist/chat/ui/Welcome.js +72 -7
  120. package/dist/chat/ui/chips.js +1 -1
  121. package/dist/chat/ui/code-lines.js +36 -36
  122. package/dist/chat/ui/code-streaming.js +1 -1
  123. package/dist/chat/ui/code-theme.js +7 -7
  124. package/dist/chat/ui/composer/ComposerControls.js +329 -21
  125. package/dist/chat/ui/composer/ComposerMenu.js +358 -30
  126. package/dist/chat/ui/composer/DraftParts.js +185 -11
  127. package/dist/chat/ui/composer/QueuedMessages.js +138 -13
  128. package/dist/chat/ui/composer/chips.js +29 -19
  129. package/dist/chat/ui/composer/editor.js +79 -63
  130. package/dist/chat/ui/composer/insert.js +26 -12
  131. package/dist/chat/ui/composer/key-handler.js +180 -127
  132. package/dist/chat/ui/composer/keys.js +90 -73
  133. package/dist/chat/ui/composer/menu-aria.js +18 -9
  134. package/dist/chat/ui/composer/placeholder.js +78 -31
  135. package/dist/chat/ui/composer/surface.js +13 -37
  136. package/dist/chat/ui/composer/use-chat-controls.js +230 -90
  137. package/dist/chat/ui/composer/use-compaction-offer.js +50 -18
  138. package/dist/chat/ui/composer/use-composer-draft.js +65 -34
  139. package/dist/chat/ui/composer/use-composer-menus.js +478 -193
  140. package/dist/chat/ui/composer/use-composer-submit.js +251 -109
  141. package/dist/chat/ui/composer/use-continuable-turn.js +33 -6
  142. package/dist/chat/ui/composer/use-draft-files.js +245 -93
  143. package/dist/chat/ui/composer/use-effort-stepper.d.ts +13 -0
  144. package/dist/chat/ui/composer/use-effort-stepper.js +88 -0
  145. package/dist/chat/ui/composer/use-notice.js +61 -16
  146. package/dist/chat/ui/composer/use-pending-requests.js +38 -17
  147. package/dist/chat/ui/composer/use-prompt-history.js +117 -45
  148. package/dist/chat/ui/composer/use-prompt-hold.js +119 -35
  149. package/dist/chat/ui/composer/use-take-back.js +94 -72
  150. package/dist/chat/ui/diff/ApprovalReview.js +101 -23
  151. package/dist/chat/ui/diff/DiffFallbackBoundary.js +21 -13
  152. package/dist/chat/ui/diff/DiffOmitted.js +56 -6
  153. package/dist/chat/ui/diff/DiffStack.js +92 -8
  154. package/dist/chat/ui/diff/DiffUnavailable.js +56 -6
  155. package/dist/chat/ui/diff/EditorEditDiff.js +263 -51
  156. package/dist/chat/ui/diff/EditorPatchDiff.js +39 -14
  157. package/dist/chat/ui/diff/LegacyDiffPool.js +27 -10
  158. package/dist/chat/ui/diff/LegacyEditDiff.js +97 -20
  159. package/dist/chat/ui/diff/LegacyUnifiedDiff.js +172 -42
  160. package/dist/chat/ui/diff/RawDiff.js +65 -5
  161. package/dist/chat/ui/diff/ReviewDiff.js +77 -5
  162. package/dist/chat/ui/diff/diff-props.js +1 -1
  163. package/dist/chat/ui/diff/diff-source-budget.js +46 -35
  164. package/dist/chat/ui/diff/editor-edit-model.js +18 -14
  165. package/dist/chat/ui/diff/review-plan.js +63 -40
  166. package/dist/chat/ui/diff/review-settle.js +24 -9
  167. package/dist/chat/ui/diff/syntax-runtime.js +236 -201
  168. package/dist/chat/ui/diff/use-review-stack.js +146 -25
  169. package/dist/chat/ui/diff-syntax.js +70 -58
  170. package/dist/chat/ui/diff-theme.js +31 -12
  171. package/dist/chat/ui/file-links.js +39 -10
  172. package/dist/chat/ui/find-reveal.js +29 -8
  173. package/dist/chat/ui/full-diff.js +17 -12
  174. package/dist/chat/ui/highlighter.js +143 -113
  175. package/dist/chat/ui/icons.js +16 -7
  176. package/dist/chat/ui/index.js +1 -1
  177. package/dist/chat/ui/intelligent-ui/UiBlockFrame.js +556 -82
  178. package/dist/chat/ui/intelligent-ui/UiFallbackPart.js +73 -5
  179. package/dist/chat/ui/intelligent-ui/UiReply.js +666 -262
  180. package/dist/chat/ui/intelligent-ui/block-local.js +59 -31
  181. package/dist/chat/ui/intelligent-ui/chart-data.js +77 -67
  182. package/dist/chat/ui/intelligent-ui/node-text.js +77 -91
  183. package/dist/chat/ui/intelligent-ui/registry.js +46 -46
  184. package/dist/chat/ui/intelligent-ui/render-context.js +1 -1
  185. package/dist/chat/ui/intelligent-ui/renderers/base-land.js +1 -1
  186. package/dist/chat/ui/intelligent-ui/renderers/binding.js +3 -3
  187. package/dist/chat/ui/intelligent-ui/renderers/chart.js +1223 -123
  188. package/dist/chat/ui/intelligent-ui/renderers/choices.js +312 -34
  189. package/dist/chat/ui/intelligent-ui/renderers/content.js +1241 -86
  190. package/dist/chat/ui/intelligent-ui/renderers/data.js +619 -54
  191. package/dist/chat/ui/intelligent-ui/renderers/inputs.js +868 -67
  192. package/dist/chat/ui/intelligent-ui/renderers/links.js +366 -62
  193. package/dist/chat/ui/intelligent-ui/renderers/map-slots.js +118 -60
  194. package/dist/chat/ui/intelligent-ui/renderers/map-style.js +85 -78
  195. package/dist/chat/ui/intelligent-ui/renderers/map-view.js +282 -217
  196. package/dist/chat/ui/intelligent-ui/renderers/map.js +621 -69
  197. package/dist/chat/ui/intelligent-ui/renderers/place-point.js +15 -8
  198. package/dist/chat/ui/intelligent-ui/renderers/structure.js +262 -20
  199. package/dist/chat/ui/intelligent-ui/renderers/text.js +674 -49
  200. package/dist/chat/ui/intelligent-ui/reply-parts.js +24 -15
  201. package/dist/chat/ui/intelligent-ui/table-data.js +97 -57
  202. package/dist/chat/ui/intelligent-ui/tones.js +31 -31
  203. package/dist/chat/ui/intelligent-ui/use-in-view.js +30 -12
  204. package/dist/chat/ui/intelligent-ui/use-later.js +28 -13
  205. package/dist/chat/ui/intelligent-ui/use-truncated.js +45 -21
  206. package/dist/chat/ui/intelligent-ui/use-ui-links.js +296 -109
  207. package/dist/chat/ui/intelligent-ui/use-ui-queries.js +256 -246
  208. package/dist/chat/ui/markdown-blocks.js +296 -262
  209. package/dist/chat/ui/mermaid.js +60 -72
  210. package/dist/chat/ui/quote-selection.js +32 -29
  211. package/dist/chat/ui/rehype-chips.js +35 -23
  212. package/dist/chat/ui/rehype-fade.js +28 -17
  213. package/dist/chat/ui/remark-html-as-text.js +22 -15
  214. package/dist/chat/ui/reply-context.js +1 -1
  215. package/dist/chat/ui/reveal.js +161 -72
  216. package/dist/chat/ui/rows/ForksRow.js +226 -24
  217. package/dist/chat/ui/rows/GeneratedImageRow.js +541 -87
  218. package/dist/chat/ui/rows/MessageRows.js +1706 -159
  219. package/dist/chat/ui/rows/RowContainer.js +57 -7
  220. package/dist/chat/ui/rows/Rows.js +463 -54
  221. package/dist/chat/ui/rows/SubagentRow.js +577 -60
  222. package/dist/chat/ui/rows/TaskRow.js +359 -40
  223. package/dist/chat/ui/rows/VisualRow.js +233 -11
  224. package/dist/chat/ui/rows/WorkRows.js +1945 -164
  225. package/dist/chat/ui/rows/WorkflowRow.js +293 -34
  226. package/dist/chat/ui/rows/row-rhythm.js +27 -17
  227. package/dist/chat/ui/theme-watch.js +26 -23
  228. package/dist/chat/ui/timestamp-format.js +4 -1
  229. package/dist/chat/ui/use-diff-source-tokens.js +70 -34
  230. package/dist/chat/ui/useToggleSet.js +51 -19
  231. package/dist/chat/ui/visual-theme.js +153 -128
  232. package/dist/chat/visual-bridge.js +123 -123
  233. package/dist/chat/visual-viewport.js +94 -83
  234. package/dist/chat/visuals.js +13 -5
  235. package/dist/host-hooks.d.ts +29 -0
  236. package/dist/host-hooks.js +78 -0
  237. package/dist/host.js +120 -48
  238. package/dist/index.js +1 -1
  239. package/dist/lazy.js +38 -32
  240. package/dist/locales/en/agent-chat.d.ts +34 -0
  241. package/dist/locales/en/agent-chat.js +747 -713
  242. package/dist/locales/en/agent-prompts.js +42 -42
  243. package/dist/locales/en/agent-providers.d.ts +1 -0
  244. package/dist/locales/en/agent-providers.js +166 -165
  245. package/dist/locales/en/agent-usage.d.ts +6 -0
  246. package/dist/locales/en/agent-usage.js +129 -123
  247. package/dist/locales/nl/agent-chat.d.ts +34 -0
  248. package/dist/locales/nl/agent-chat.js +747 -713
  249. package/dist/locales/nl/agent-prompts.js +42 -42
  250. package/dist/locales/nl/agent-providers.d.ts +1 -0
  251. package/dist/locales/nl/agent-providers.js +166 -165
  252. package/dist/locales/nl/agent-usage.d.ts +6 -0
  253. package/dist/locales/nl/agent-usage.js +129 -123
  254. package/dist/locales.js +14 -14
  255. package/dist/mounted-registry.js +31 -30
  256. package/dist/port-transport.js +122 -111
  257. package/dist/prompts/index.js +1 -1
  258. package/dist/prompts/logic/focus.js +15 -14
  259. package/dist/prompts/logic/keys.js +93 -59
  260. package/dist/prompts/logic/prompts.js +27 -14
  261. package/dist/prompts/logic/subjects.js +60 -46
  262. package/dist/prompts/logic/useFocusAfterAnswer.js +60 -20
  263. package/dist/prompts/logic/usePromptSession.js +88 -77
  264. package/dist/prompts/ui/ApprovalBody.js +246 -27
  265. package/dist/prompts/ui/PromptActions.js +215 -9
  266. package/dist/prompts/ui/PromptCard.js +215 -36
  267. package/dist/prompts/ui/PromptView.js +372 -34
  268. package/dist/prompts/ui/QuestionBody.js +269 -73
  269. package/dist/providers/AccountColors.js +36 -5
  270. package/dist/providers/AccountDetail.js +683 -50
  271. package/dist/providers/AccountVariables.js +139 -32
  272. package/dist/providers/AddAccountForm.js +125 -38
  273. package/dist/providers/CliDetail.js +343 -36
  274. package/dist/providers/InstallPage.js +644 -59
  275. package/dist/providers/ProviderList.d.ts +2 -1
  276. package/dist/providers/ProviderList.js +215 -23
  277. package/dist/providers/ProvidersPane.d.ts +4 -2
  278. package/dist/providers/ProvidersPane.js +244 -64
  279. package/dist/providers/account-actions.js +54 -30
  280. package/dist/providers/index.js +1 -1
  281. package/dist/providers/install-steps.js +12 -9
  282. package/dist/providers/pane-target.d.ts +3 -0
  283. package/dist/providers/pane-target.js +34 -13
  284. package/dist/providers/parts.js +62 -12
  285. package/dist/providers/provider-abilities.js +5 -5
  286. package/dist/providers/provider-groups.js +75 -40
  287. package/dist/providers/variables.js +73 -39
  288. package/dist/scope.js +6 -6
  289. package/dist/settings/sections.js +18 -18
  290. package/dist/state/chats.js +404 -192
  291. package/dist/state/index.js +1 -1
  292. package/dist/state/provider-accounts.js +70 -47
  293. package/dist/state/providers.js +45 -16
  294. package/dist/state/usage.js +154 -77
  295. package/dist/storage.js +69 -68
  296. package/dist/testing/index.js +1 -1
  297. package/dist/testing/prompts.js +105 -67
  298. package/dist/transport.js +10 -10
  299. package/dist/ui/PlainTextarea.js +27 -3
  300. package/dist/usage/LimitsList.js +646 -40
  301. package/dist/usage/UsageBreakdown.js +879 -38
  302. package/dist/usage/UsageChart.js +311 -32
  303. package/dist/usage/UsageDialog.js +46 -4
  304. package/dist/usage/UsageLimits.js +467 -34
  305. package/dist/usage/UsageLimitsCard.js +95 -11
  306. package/dist/usage/UsagePage.js +817 -96
  307. package/dist/usage/UsagePane.js +164 -10
  308. package/dist/usage/UsageSummary.js +151 -6
  309. package/dist/usage/UsageTiles.js +164 -14
  310. package/dist/usage/format.js +32 -32
  311. package/dist/usage/index.d.ts +1 -1
  312. package/dist/usage/index.js +2 -1
  313. package/dist/usage/limit-groups.d.ts +2 -0
  314. package/dist/usage/limit-groups.js +77 -59
  315. package/dist/usage/limits.js +78 -43
  316. package/dist/usage/money.js +20 -4
  317. package/dist/usage/summary.js +85 -64
  318. package/package.json +8 -8
  319. package/src/agents/ModelOptionControl.tsx +3 -1
  320. package/src/agents/option-words.ts +27 -0
  321. package/src/chat/account-choice.ts +41 -1
  322. package/src/chat/composer-effort.ts +32 -0
  323. package/src/chat/forks.ts +4 -5
  324. package/src/chat/index.ts +3 -1
  325. package/src/chat/logic/effort.ts +32 -0
  326. package/src/chat/logic/picker-entries.ts +45 -10
  327. package/src/chat/logic/resume-compaction.ts +95 -17
  328. package/src/chat/logic/timeline.ts +11 -3
  329. package/src/chat/preferences.ts +35 -0
  330. package/src/chat/subagent-view.ts +2 -3
  331. package/src/chat/ui/AnsiOutput.tsx +1 -2
  332. package/src/chat/ui/BookmarkSubmenu.tsx +3 -3
  333. package/src/chat/ui/ChatActivity.tsx +14 -22
  334. package/src/chat/ui/ChatReferenceChip.tsx +2 -3
  335. package/src/chat/ui/Composer.tsx +15 -7
  336. package/src/chat/ui/EditDiff.tsx +2 -3
  337. package/src/chat/ui/LimitState.tsx +2 -2
  338. package/src/chat/ui/Markdown.tsx +10 -8
  339. package/src/chat/ui/MermaidBlock.tsx +2 -3
  340. package/src/chat/ui/Pickers.tsx +49 -29
  341. package/src/chat/ui/PromptComposer.tsx +7 -9
  342. package/src/chat/ui/ResumeCompactionDock.tsx +16 -4
  343. package/src/chat/ui/RunSettings.tsx +67 -28
  344. package/src/chat/ui/Scrubber.tsx +3 -3
  345. package/src/chat/ui/ShellCommand.tsx +2 -0
  346. package/src/chat/ui/SubagentInfo.tsx +2 -3
  347. package/src/chat/ui/SubagentTimeline.tsx +12 -16
  348. package/src/chat/ui/Timeline.tsx +6 -6
  349. package/src/chat/ui/UnifiedDiff.tsx +3 -4
  350. package/src/chat/ui/VisualFrame.tsx +5 -8
  351. package/src/chat/ui/code-theme.ts +4 -4
  352. package/src/chat/ui/composer/placeholder.ts +2 -2
  353. package/src/chat/ui/composer/use-compaction-offer.ts +36 -16
  354. package/src/chat/ui/composer/use-composer-menus.ts +4 -9
  355. package/src/chat/ui/composer/use-composer-submit.ts +2 -1
  356. package/src/chat/ui/composer/use-effort-stepper.ts +56 -0
  357. package/src/chat/ui/composer/use-notice.ts +2 -2
  358. package/src/chat/ui/diff/EditorEditDiff.tsx +9 -13
  359. package/src/chat/ui/diff/LegacyEditDiff.tsx +12 -17
  360. package/src/chat/ui/diff/LegacyUnifiedDiff.tsx +13 -21
  361. package/src/chat/ui/diff/use-review-stack.ts +4 -4
  362. package/src/chat/ui/diff-theme.ts +3 -3
  363. package/src/chat/ui/file-links.ts +2 -2
  364. package/src/chat/ui/intelligent-ui/UiReply.tsx +2 -0
  365. package/src/chat/ui/intelligent-ui/renderers/chart.tsx +3 -3
  366. package/src/chat/ui/intelligent-ui/renderers/content.tsx +5 -6
  367. package/src/chat/ui/intelligent-ui/renderers/map-view.tsx +2 -1
  368. package/src/chat/ui/intelligent-ui/renderers/map.tsx +2 -1
  369. package/src/chat/ui/intelligent-ui/use-truncated.ts +16 -19
  370. package/src/chat/ui/intelligent-ui/use-ui-links.ts +3 -3
  371. package/src/chat/ui/rows/ForksRow.tsx +3 -5
  372. package/src/chat/ui/rows/GeneratedImageRow.tsx +2 -1
  373. package/src/chat/ui/rows/MessageRows.tsx +12 -21
  374. package/src/chat/ui/rows/SubagentRow.tsx +3 -3
  375. package/src/chat/ui/rows/TaskRow.tsx +1 -1
  376. package/src/chat/ui/rows/WorkRows.tsx +10 -5
  377. package/src/chat/ui/useToggleSet.ts +15 -18
  378. package/src/chat/ui/visual-theme.ts +2 -3
  379. package/src/host-hooks.ts +113 -0
  380. package/src/lazy.tsx +2 -0
  381. package/src/locales/en/agent-chat.ts +134 -108
  382. package/src/locales/en/agent-prompts.ts +7 -7
  383. package/src/locales/en/agent-providers.ts +35 -34
  384. package/src/locales/en/agent-usage.ts +26 -20
  385. package/src/locales/nl/agent-chat.ts +126 -100
  386. package/src/locales/nl/agent-prompts.ts +5 -5
  387. package/src/locales/nl/agent-providers.ts +33 -32
  388. package/src/locales/nl/agent-usage.ts +25 -20
  389. package/src/providers/CliDetail.tsx +2 -1
  390. package/src/providers/InstallPage.tsx +2 -4
  391. package/src/providers/ProviderList.tsx +12 -2
  392. package/src/providers/ProvidersPane.tsx +45 -15
  393. package/src/providers/pane-target.ts +20 -4
  394. package/src/state/chats.ts +2 -2
  395. package/src/usage/LimitsList.tsx +12 -13
  396. package/src/usage/UsageBreakdown.tsx +17 -6
  397. package/src/usage/UsageLimits.tsx +2 -1
  398. package/src/usage/UsagePage.tsx +3 -3
  399. package/src/usage/index.ts +1 -1
  400. package/src/usage/limit-groups.ts +12 -0
  401. package/src/usage/limits.ts +2 -2
  402. package/src/usage/money.ts +1 -2
@@ -1,6 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { Component, createContext, Fragment, memo, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
3
- import ReactMarkdown, {} from 'react-markdown';
3
+ import ReactMarkdown from 'react-markdown';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { evaluateUiBlock, uiInputValues, isUiComponent, UI_CATALOG_VERSION, UiState } from '@adecore/intelligent-ui';
6
6
  import { ErrorBoundary, Tooltip } from '@adecore/ui';
@@ -17,19 +17,20 @@ import { useUiQueries, useUiLiveValues } from './use-ui-queries.js';
17
17
  import { UiSourceCitation } from './renderers/content.js';
18
18
  import { uiChildrenOf, revealUiSource, uiLiveChoiceReason, uiUrlDomain } from './node-text.js';
19
19
  import { uiReplyParts } from './reply-parts.js';
20
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
21
  const localStates = new UiPageMemory(64);
21
22
  function localState(key, block, answered) {
22
- let state = localStates.get(key);
23
- if (!state) {
24
- state = new UiState(block);
25
- if (answered && answered.revision === block.revision) {
26
- for (const [name, value] of Object.entries(answered.values ?? {})) {
27
- state.set(name, value);
28
- }
29
- }
30
- localStates.set(key, state);
23
+ let state = localStates.get(key);
24
+ if (!state) {
25
+ state = new UiState(block);
26
+ if (answered && answered.revision === block.revision) {
27
+ for (const [name, value] of Object.entries(answered.values ?? {})) {
28
+ state.set(name, value);
29
+ }
31
30
  }
32
- return state;
31
+ localStates.set(key, state);
32
+ }
33
+ return state;
33
34
  }
34
35
  /* The block itself, as the parent of its top-level nodes. */
35
36
  const BLOCK = '$block';
@@ -40,88 +41,134 @@ const BLOCK = '$block';
40
41
  const LITERAL_PARENTS = new Set(['CodeBlock', 'Tag', 'Choice', 'Item', 'Switch', 'Slider', 'Segmented', 'Option', 'Button', 'Column']);
41
42
  /* Parents that stack their children, where a run of text and inline nodes is one paragraph. */
42
43
  const PARAGRAPHS = {
43
- [BLOCK]: 'text-xs text-text',
44
- Tab: 'text-xs text-text',
45
- Section: 'text-xs text-text-muted'
44
+ [BLOCK]: 'text-xs text-text',
45
+ Tab: 'text-xs text-text',
46
+ Section: 'text-xs text-text-muted'
46
47
  };
47
48
  const LINKS = new Set(['File', 'Diff', 'Commit', 'Node']);
48
49
  /* Constructs that would start a block or load an image stay text; without GFM a table never forms. */
49
- const BLOCK_CONSTRUCTS = [
50
- 'blockQuote',
51
- 'codeFenced',
52
- 'codeIndented',
53
- 'definition',
54
- 'headingAtx',
55
- 'htmlFlow',
56
- 'htmlText',
57
- 'labelStartImage',
58
- 'list',
59
- 'setextUnderline',
60
- 'thematicBreak'
61
- ];
50
+ const BLOCK_CONSTRUCTS = ['blockQuote', 'codeFenced', 'codeIndented', 'definition', 'headingAtx', 'htmlFlow', 'htmlText', 'labelStartImage', 'list', 'setextUnderline', 'thematicBreak'];
62
51
  /* Prose between the tags of a block is inline: only emphasis, code and links are Markdown, and a blank line is a line break. */
63
52
  function remarkInlineProse() {
64
- // The field remark-parse reads its syntax extensions from, as remark-gfm adds its own.
65
- const data = this.data();
66
- data.micromarkExtensions = [...(data.micromarkExtensions ?? []), { disable: { null: BLOCK_CONSTRUCTS } }];
67
- return (tree) => {
68
- tree.children = [
69
- {
70
- type: 'paragraph',
71
- children: (tree.children ?? []).flatMap((paragraph, index) => [...(index > 0 ? [{ type: 'break' }] : []), ...(paragraph.children ?? [])])
72
- }
73
- ];
74
- };
53
+ // The field remark-parse reads its syntax extensions from, as remark-gfm adds its own.
54
+ const data = this.data();
55
+ data.micromarkExtensions = [...(data.micromarkExtensions ?? []), {
56
+ disable: {
57
+ null: BLOCK_CONSTRUCTS
58
+ }
59
+ }];
60
+ return tree => {
61
+ tree.children = [{
62
+ type: 'paragraph',
63
+ children: (tree.children ?? []).flatMap((paragraph, index) => [...(index > 0 ? [{
64
+ type: 'break'
65
+ }] : []), ...(paragraph.children ?? [])])
66
+ }];
67
+ };
75
68
  }
76
69
  function remarkCitations() {
77
- return (tree) => {
78
- const visit = (parent) => {
79
- if (['link', 'inlineCode', 'code'].includes(parent.type)) {
80
- return;
81
- }
82
- parent.children = parent.children?.flatMap((child) => {
83
- if (child.type !== 'text' || !child.value) {
84
- visit(child);
85
- return [child];
86
- }
87
- const parts = [];
88
- let start = 0;
89
- for (const match of child.value.matchAll(/\[(\d{1,3})\]/g)) {
90
- parts.push({ type: 'text', value: child.value.slice(start, match.index) });
91
- parts.push({
92
- type: 'citation',
93
- data: { hName: 'span', hProperties: { 'data-ui-citation': match[1] } },
94
- children: [{ type: 'text', value: match[0] }]
95
- });
96
- start = match.index + match[0].length;
97
- }
98
- parts.push({ type: 'text', value: child.value.slice(start) });
99
- return parts;
100
- });
101
- };
102
- visit(tree);
70
+ return tree => {
71
+ const visit = parent => {
72
+ if (['link', 'inlineCode', 'code'].includes(parent.type)) {
73
+ return;
74
+ }
75
+ parent.children = parent.children?.flatMap(child => {
76
+ if (child.type !== 'text' || !child.value) {
77
+ visit(child);
78
+ return [child];
79
+ }
80
+ const parts = [];
81
+ let start = 0;
82
+ for (const match of child.value.matchAll(/\[(\d{1,3})\]/g)) {
83
+ parts.push({
84
+ type: 'text',
85
+ value: child.value.slice(start, match.index)
86
+ });
87
+ parts.push({
88
+ type: 'citation',
89
+ data: {
90
+ hName: 'span',
91
+ hProperties: {
92
+ 'data-ui-citation': match[1]
93
+ }
94
+ },
95
+ children: [{
96
+ type: 'text',
97
+ value: match[0]
98
+ }]
99
+ });
100
+ start = match.index + match[0].length;
101
+ }
102
+ parts.push({
103
+ type: 'text',
104
+ value: child.value.slice(start)
105
+ });
106
+ return parts;
107
+ });
103
108
  };
109
+ visit(tree);
110
+ };
104
111
  }
105
- const CitationContext = createContext({ sources: new Map() });
106
- function ProseCitation({ number, children }) {
107
- const { sources, reveal } = useContext(CitationContext);
108
- const source = sources.get(number);
109
- return source ? _jsx(UiSourceCitation, { number: number, title: source.title, url: source.url, onReveal: reveal ? () => reveal(source) : undefined }) : children;
112
+ const CitationContext = createContext({
113
+ sources: new Map()
114
+ });
115
+ function ProseCitation(t0) {
116
+ const $ = _c(8);
117
+ const {
118
+ number,
119
+ children
120
+ } = t0;
121
+ const {
122
+ sources,
123
+ reveal
124
+ } = useContext(CitationContext);
125
+ let t1;
126
+ if ($[0] !== number || $[1] !== sources) {
127
+ t1 = sources.get(number);
128
+ $[0] = number;
129
+ $[1] = sources;
130
+ $[2] = t1;
131
+ } else {
132
+ t1 = $[2];
133
+ }
134
+ const source = t1;
135
+ let t2;
136
+ if ($[3] !== children || $[4] !== number || $[5] !== reveal || $[6] !== source) {
137
+ t2 = source ? /*#__PURE__*/_jsx(UiSourceCitation, {
138
+ number: number,
139
+ title: source.title,
140
+ url: source.url,
141
+ onReveal: reveal ? () => reveal(source) : undefined
142
+ }) : children;
143
+ $[3] = children;
144
+ $[4] = number;
145
+ $[5] = reveal;
146
+ $[6] = source;
147
+ $[7] = t2;
148
+ } else {
149
+ t2 = $[7];
150
+ }
151
+ return t2;
110
152
  }
111
153
  function sourceTargets(nodes) {
112
- const lists = [];
113
- const visit = (nodes, ancestors = []) => {
114
- for (const node of nodes) {
115
- const path = ['Tab', 'Section'].includes(node.type) ? [...ancestors, node.id] : ancestors;
116
- if (node.type === 'Sources') {
117
- lists.push(uiChildrenOf(node, 'Source').map((source) => ({ id: source.id, title: source.props.title, url: source.props.url, ancestors: path })));
118
- }
119
- visit(node.children, path);
120
- }
121
- };
122
- visit(nodes);
123
- // Numbers restart in each Sources list, so multiple lists have no unambiguous prose target.
124
- return new Map(lists.length === 1 ? lists[0].map((source, index) => [index + 1, source]) : []);
154
+ const lists = [];
155
+ const visit = (nodes, ancestors = []) => {
156
+ for (const node of nodes) {
157
+ const path = ['Tab', 'Section'].includes(node.type) ? [...ancestors, node.id] : ancestors;
158
+ if (node.type === 'Sources') {
159
+ lists.push(uiChildrenOf(node, 'Source').map(source => ({
160
+ id: source.id,
161
+ title: source.props.title,
162
+ url: source.props.url,
163
+ ancestors: path
164
+ })));
165
+ }
166
+ visit(node.children, path);
167
+ }
168
+ };
169
+ visit(nodes);
170
+ // Numbers restart in each Sources list, so multiple lists have no unambiguous prose target.
171
+ return new Map(lists.length === 1 ? lists[0].map((source, index) => [index + 1, source]) : []);
125
172
  }
126
173
  const PROSE_PLUGINS = [remarkInlineProse, remarkCitations];
127
174
  const PROSE_ELEMENTS = ['p', 'br', 'strong', 'em', 'code', 'a', 'span'];
@@ -129,108 +176,354 @@ const FADE_PLUGINS = [rehypeFadeWords];
129
176
  const NO_PLUGINS = [];
130
177
  const ProseUrlContext = createContext(undefined);
131
178
  /* Through the host only, like a Source: the address is the model's, so nothing here navigates by itself. */
132
- function ProseLink({ href, children }) {
133
- const openUrl = useContext(ProseUrlContext);
134
- if (openUrl === undefined || href === undefined || !/^https?:\/\//i.test(href)) {
135
- return children;
136
- }
137
- return (_jsx(Tooltip, { label: uiUrlDomain(href), children: _jsx("button", { type: "button", className: "cursor-pointer text-accent underline underline-offset-2 select-text", onClick: () => openUrl(href), children: children }) }));
179
+ function ProseLink(t0) {
180
+ const $ = _c(11);
181
+ const {
182
+ href,
183
+ children
184
+ } = t0;
185
+ const openUrl = useContext(ProseUrlContext);
186
+ if (openUrl === undefined || href === undefined || !/^https?:\/\//i.test(href)) {
187
+ return children;
188
+ }
189
+ let t1;
190
+ if ($[0] !== href) {
191
+ t1 = uiUrlDomain(href);
192
+ $[0] = href;
193
+ $[1] = t1;
194
+ } else {
195
+ t1 = $[1];
196
+ }
197
+ let t2;
198
+ if ($[2] !== href || $[3] !== openUrl) {
199
+ t2 = () => openUrl(href);
200
+ $[2] = href;
201
+ $[3] = openUrl;
202
+ $[4] = t2;
203
+ } else {
204
+ t2 = $[4];
205
+ }
206
+ let t3;
207
+ if ($[5] !== children || $[6] !== t2) {
208
+ t3 = /*#__PURE__*/_jsx("button", {
209
+ type: "button",
210
+ className: "cursor-pointer text-accent underline underline-offset-2 select-text",
211
+ onClick: t2,
212
+ children: children
213
+ });
214
+ $[5] = children;
215
+ $[6] = t2;
216
+ $[7] = t3;
217
+ } else {
218
+ t3 = $[7];
219
+ }
220
+ let t4;
221
+ if ($[8] !== t1 || $[9] !== t3) {
222
+ t4 = /*#__PURE__*/_jsx(Tooltip, {
223
+ label: t1,
224
+ children: t3
225
+ });
226
+ $[8] = t1;
227
+ $[9] = t3;
228
+ $[10] = t4;
229
+ } else {
230
+ t4 = $[10];
231
+ }
232
+ return t4;
138
233
  }
139
234
  const PROSE_COMPONENTS = {
140
- p: ({ children }) => children,
141
- code: ({ children }) => _jsx("code", { className: "rounded-sm bg-ui-tile px-1 py-px font-mono text-code", children: children }),
142
- a: ({ href, children }) => _jsx(ProseLink, { href: href, children: children }),
143
- span: ({ node, children, className }) => node?.properties['data-ui-citation'] !== undefined ? (_jsx(ProseCitation, { number: Number(node.properties['data-ui-citation']), children: children })) : (_jsx("span", { className: className, children: children }))
235
+ p: ({
236
+ children
237
+ }) => children,
238
+ code: ({
239
+ children
240
+ }) => /*#__PURE__*/_jsx("code", {
241
+ className: "rounded-sm bg-ui-tile px-1 py-px font-mono text-code",
242
+ children: children
243
+ }),
244
+ a: ({
245
+ href,
246
+ children
247
+ }) => /*#__PURE__*/_jsx(ProseLink, {
248
+ href: href,
249
+ children: children
250
+ }),
251
+ span: ({
252
+ node,
253
+ children,
254
+ className
255
+ }) => node?.properties['data-ui-citation'] !== undefined ? /*#__PURE__*/_jsx(ProseCitation, {
256
+ number: Number(node.properties['data-ui-citation']),
257
+ children: children
258
+ }) : /*#__PURE__*/_jsx("span", {
259
+ className: className,
260
+ children: children
261
+ })
144
262
  };
145
263
  /*
146
264
  * Text an agent wrote in a block, as inline Markdown without raw HTML. Markdown trims a paragraph,
147
265
  * so the whitespace at either end stays text: it is the space between a word and the tag beside it.
148
266
  * While the block streams every new word fades in, as in the prose of the reply around it.
149
267
  */
150
- const UiProse = memo(function UiProse({ text, fade, openUrl }) {
151
- const [, lead = '', body = '', trail = ''] = /^(\s*)([\s\S]*?)(\s*)$/.exec(text) ?? [];
152
- if (body === '') {
153
- return text;
154
- }
155
- return (_jsxs(ProseUrlContext, { value: openUrl, children: [lead, _jsx(ReactMarkdown, { remarkPlugins: PROSE_PLUGINS, rehypePlugins: fade ? FADE_PLUGINS : NO_PLUGINS, allowedElements: PROSE_ELEMENTS, unwrapDisallowed: true, components: PROSE_COMPONENTS, children: body }), trail] }));
268
+ const UiProse = memo(function UiProse(t0) {
269
+ const $ = _c(10);
270
+ const {
271
+ text,
272
+ fade,
273
+ openUrl
274
+ } = t0;
275
+ let t1;
276
+ if ($[0] !== text) {
277
+ t1 = /^(\s*)([\s\S]*?)(\s*)$/.exec(text) ?? [];
278
+ $[0] = text;
279
+ $[1] = t1;
280
+ } else {
281
+ t1 = $[1];
282
+ }
283
+ const [, t2, t3, t4] = t1;
284
+ const lead = t2 === undefined ? "" : t2;
285
+ const body = t3 === undefined ? "" : t3;
286
+ const trail = t4 === undefined ? "" : t4;
287
+ if (body === "") {
288
+ return text;
289
+ }
290
+ const t5 = fade ? FADE_PLUGINS : NO_PLUGINS;
291
+ let t6;
292
+ if ($[2] !== body || $[3] !== t5) {
293
+ t6 = /*#__PURE__*/_jsx(ReactMarkdown, {
294
+ remarkPlugins: PROSE_PLUGINS,
295
+ rehypePlugins: t5,
296
+ allowedElements: PROSE_ELEMENTS,
297
+ unwrapDisallowed: true,
298
+ components: PROSE_COMPONENTS,
299
+ children: body
300
+ });
301
+ $[2] = body;
302
+ $[3] = t5;
303
+ $[4] = t6;
304
+ } else {
305
+ t6 = $[4];
306
+ }
307
+ let t7;
308
+ if ($[5] !== lead || $[6] !== openUrl || $[7] !== t6 || $[8] !== trail) {
309
+ t7 = /*#__PURE__*/_jsxs(ProseUrlContext, {
310
+ value: openUrl,
311
+ children: [lead, t6, trail]
312
+ });
313
+ $[5] = lead;
314
+ $[6] = openUrl;
315
+ $[7] = t6;
316
+ $[8] = trail;
317
+ $[9] = t7;
318
+ } else {
319
+ t7 = $[9];
320
+ }
321
+ return t7;
156
322
  });
157
323
  /* Which text nodes of a block the agent wrote out, by id; the value of an expression is data and stays as it is. */
158
324
  function writtenTexts(nodes, into = new Map()) {
159
- for (const node of nodes) {
160
- if (node.type === '$text') {
161
- into.set(node.id, node.expressions.text === undefined);
162
- }
163
- writtenTexts(node.children, into);
325
+ for (const node of nodes) {
326
+ if (node.type === '$text') {
327
+ into.set(node.id, node.expressions.text === undefined);
164
328
  }
165
- return into;
329
+ writtenTexts(node.children, into);
330
+ }
331
+ return into;
166
332
  }
167
333
  function isInline(node) {
168
- if (node.type === '$text') {
169
- return true;
170
- }
171
- return node.error === undefined && (node.type === 'Tag' || (LINKS.has(node.type) && node.children.length === 0));
334
+ if (node.type === '$text') {
335
+ return true;
336
+ }
337
+ return node.error === undefined && (node.type === 'Tag' || LINKS.has(node.type) && node.children.length === 0);
172
338
  }
173
339
  function isBlank(node) {
174
- return node.type === '$text' && String(node.props.text ?? '').trim() === '';
340
+ return node.type === '$text' && String(node.props.text ?? '').trim() === '';
175
341
  }
176
342
  /* The children of one parent, each in its own boundary. Where the parent stacks them, a run of text and inline nodes becomes a paragraph. */
177
- function UiNodes({ nodes, parent, texts, context }) {
178
- const drawn = (node) => (_jsx(UiNodeBoundary, { node: node, children: _jsx(UiNodeBody, { node: node, parent: parent, texts: texts, context: context }) }, node.id));
179
- const paragraph = PARAGRAPHS[parent];
180
- if (parent === 'Choices') {
181
- // A primary choice stands first in the order a keyboard and a screen reader meet it too, not only on screen.
182
- return [...nodes].sort((a, b) => Number(b.props.primary === true) - Number(a.props.primary === true)).map(drawn);
343
+ function UiNodes({
344
+ nodes,
345
+ parent,
346
+ texts,
347
+ context
348
+ }) {
349
+ const drawn = node => /*#__PURE__*/_jsx(UiNodeBoundary, {
350
+ node: node,
351
+ children: /*#__PURE__*/_jsx(UiNodeBody, {
352
+ node: node,
353
+ parent: parent,
354
+ texts: texts,
355
+ context: context
356
+ })
357
+ }, node.id);
358
+ const paragraph = PARAGRAPHS[parent];
359
+ if (parent === 'Choices') {
360
+ // A primary choice stands first in the order a keyboard and a screen reader meet it too, not only on screen.
361
+ return [...nodes].sort((a, b) => Number(b.props.primary === true) - Number(a.props.primary === true)).map(drawn);
362
+ }
363
+ if (paragraph === undefined) {
364
+ return nodes.map(drawn);
365
+ }
366
+ const output = [];
367
+ let run = [];
368
+ const close = () => {
369
+ if (run.some(node => !isBlank(node))) {
370
+ output.push(/*#__PURE__*/_jsx("div", {
371
+ className: paragraph,
372
+ children: run.map(drawn)
373
+ }, `run:${run[0].id}`));
183
374
  }
184
- if (paragraph === undefined) {
185
- return nodes.map(drawn);
186
- }
187
- const output = [];
188
- let run = [];
189
- const close = () => {
190
- if (run.some((node) => !isBlank(node))) {
191
- output.push(_jsx("div", { className: paragraph, children: run.map(drawn) }, `run:${run[0].id}`));
192
- }
193
- run = [];
194
- };
195
- for (const node of nodes) {
196
- if (isInline(node)) {
197
- run.push(node);
198
- continue;
199
- }
200
- close();
201
- output.push(drawn(node));
375
+ run = [];
376
+ };
377
+ for (const node of nodes) {
378
+ if (isInline(node)) {
379
+ run.push(node);
380
+ continue;
202
381
  }
203
382
  close();
204
- return output;
383
+ output.push(drawn(node));
384
+ }
385
+ close();
386
+ return output;
205
387
  }
206
388
  class UiNodeBoundary extends Component {
207
- state = { failed: false, node: this.props.node };
208
- static getDerivedStateFromError() {
209
- return { failed: true };
210
- }
211
- static getDerivedStateFromProps(props, state) {
212
- return props.node === state.node ? null : { failed: false, node: props.node };
213
- }
214
- render() {
215
- return this.state.failed ? _jsx(UiFallbackPart, { fallback: this.props.node.fallback, problem: { kind: 'failed' } }) : this.props.children;
216
- }
389
+ state = {
390
+ failed: false,
391
+ node: this.props.node
392
+ };
393
+ static getDerivedStateFromError() {
394
+ return {
395
+ failed: true
396
+ };
397
+ }
398
+ static getDerivedStateFromProps(props, state) {
399
+ return props.node === state.node ? null : {
400
+ failed: false,
401
+ node: props.node
402
+ };
403
+ }
404
+ render() {
405
+ return this.state.failed ? /*#__PURE__*/_jsx(UiFallbackPart, {
406
+ fallback: this.props.node.fallback,
407
+ problem: {
408
+ kind: 'failed'
409
+ }
410
+ }) : this.props.children;
411
+ }
217
412
  }
218
- function UiNodeBody({ node, parent, texts, context }) {
219
- if (node.type === '$text') {
220
- const text = String(node.props.text ?? '');
221
- return LITERAL_PARENTS.has(parent) || texts.get(node.sourceId ?? node.id) !== true ? (text) : (_jsx(UiProse, { text: text, fade: context.phase === 'streaming', openUrl: context.openUrl }));
413
+ function UiNodeBody(t0) {
414
+ const $ = _c(25);
415
+ const {
416
+ node,
417
+ parent,
418
+ texts,
419
+ context
420
+ } = t0;
421
+ if (node.type === "$text") {
422
+ const text = String(node.props.text ?? "");
423
+ let t1;
424
+ if ($[0] !== context || $[1] !== node.id || $[2] !== node.sourceId || $[3] !== parent || $[4] !== text || $[5] !== texts) {
425
+ t1 = LITERAL_PARENTS.has(parent) || texts.get(node.sourceId ?? node.id) !== true ? text : /*#__PURE__*/_jsx(UiProse, {
426
+ text: text,
427
+ fade: context.phase === "streaming",
428
+ openUrl: context.openUrl
429
+ });
430
+ $[0] = context;
431
+ $[1] = node.id;
432
+ $[2] = node.sourceId;
433
+ $[3] = parent;
434
+ $[4] = text;
435
+ $[5] = texts;
436
+ $[6] = t1;
437
+ } else {
438
+ t1 = $[6];
439
+ }
440
+ return t1;
441
+ }
442
+ if (node.error !== undefined) {
443
+ let t1;
444
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
445
+ t1 = {
446
+ kind: "failed"
447
+ };
448
+ $[7] = t1;
449
+ } else {
450
+ t1 = $[7];
222
451
  }
223
- if (node.error !== undefined) {
224
- return _jsx(UiFallbackPart, { fallback: node.fallback, problem: { kind: 'failed' } });
452
+ let t2;
453
+ if ($[8] !== node.fallback) {
454
+ t2 = /*#__PURE__*/_jsx(UiFallbackPart, {
455
+ fallback: node.fallback,
456
+ problem: t1
457
+ });
458
+ $[8] = node.fallback;
459
+ $[9] = t2;
460
+ } else {
461
+ t2 = $[9];
225
462
  }
226
- if (!isUiComponent(node.type)) {
227
- return _jsx(UiFallbackPart, { fallback: node.fallback, problem: { kind: 'unknown', component: node.type } });
463
+ return t2;
464
+ }
465
+ if (!isUiComponent(node.type)) {
466
+ let t1;
467
+ if ($[10] !== node.type) {
468
+ t1 = {
469
+ kind: "unknown",
470
+ component: node.type
471
+ };
472
+ $[10] = node.type;
473
+ $[11] = t1;
474
+ } else {
475
+ t1 = $[11];
228
476
  }
229
- const Renderer = UI_RENDERERS[node.type];
230
- if (Renderer === null) {
231
- return null;
477
+ let t2;
478
+ if ($[12] !== node.fallback || $[13] !== t1) {
479
+ t2 = /*#__PURE__*/_jsx(UiFallbackPart, {
480
+ fallback: node.fallback,
481
+ problem: t1
482
+ });
483
+ $[12] = node.fallback;
484
+ $[13] = t1;
485
+ $[14] = t2;
486
+ } else {
487
+ t2 = $[14];
232
488
  }
233
- return (_jsx(Renderer, { node: node, context: context, children: _jsx(UiNodes, { nodes: node.children, parent: node.type, texts: texts, context: context }) }));
489
+ return t2;
490
+ }
491
+ const Renderer = UI_RENDERERS[node.type];
492
+ if (Renderer === null) {
493
+ return null;
494
+ }
495
+ let t1;
496
+ if ($[15] !== context || $[16] !== node.children || $[17] !== node.type || $[18] !== texts) {
497
+ t1 = /*#__PURE__*/_jsx(UiNodes, {
498
+ nodes: node.children,
499
+ parent: node.type,
500
+ texts: texts,
501
+ context: context
502
+ });
503
+ $[15] = context;
504
+ $[16] = node.children;
505
+ $[17] = node.type;
506
+ $[18] = texts;
507
+ $[19] = t1;
508
+ } else {
509
+ t1 = $[19];
510
+ }
511
+ let t2;
512
+ if ($[20] !== Renderer || $[21] !== context || $[22] !== node || $[23] !== t1) {
513
+ t2 = /*#__PURE__*/_jsx(Renderer, {
514
+ node: node,
515
+ context: context,
516
+ children: t1
517
+ });
518
+ $[20] = Renderer;
519
+ $[21] = context;
520
+ $[22] = node;
521
+ $[23] = t1;
522
+ $[24] = t2;
523
+ } else {
524
+ t2 = $[24];
525
+ }
526
+ return t2;
234
527
  }
235
528
  /*
236
529
  * The points the machine froze beside a block, as a renderer asks for them. Until the block is frozen
@@ -238,111 +531,222 @@ function UiNodeBody({ node, parent, texts, context }) {
238
531
  * with no reading for its current address is one the machine did not look up.
239
532
  */
240
533
  function placeReader(frozen, revision, unrecorded) {
241
- if (frozen === undefined || frozen.revision !== revision) {
242
- return () => (unrecorded ? null : undefined);
243
- }
244
- return (nodeId, address) => {
245
- const reading = Object.hasOwn(frozen.places ?? {}, nodeId) ? frozen.places[nodeId] : undefined;
246
- return reading?.address === address.trim() && reading.state === 'found' && reading.lat !== undefined && reading.lon !== undefined
247
- ? { lat: reading.lat, lon: reading.lon, label: reading.label }
248
- : null;
249
- };
534
+ if (frozen === undefined || frozen.revision !== revision) {
535
+ return () => unrecorded ? null : undefined;
536
+ }
537
+ return (nodeId, address) => {
538
+ const reading = Object.hasOwn(frozen.places ?? {}, nodeId) ? frozen.places[nodeId] : undefined;
539
+ return reading?.address === address.trim() && reading.state === 'found' && reading.lat !== undefined && reading.lon !== undefined ? {
540
+ lat: reading.lat,
541
+ lon: reading.lon,
542
+ label: reading.label
543
+ } : null;
544
+ };
250
545
  }
251
- function UiBlockBody({ block, context, answered, frozen, unrecorded }) {
252
- const host = useChatHost();
253
- const { t } = useTranslation('agent-chat');
254
- const key = JSON.stringify([context.scopeId, context.chatId, context.itemId, block.id]);
255
- const [state] = useState(() => localState(key, block, answered));
256
- state.sync(block);
257
- const stateRevision = useSyncExternalStore((listener) => state.subscribe(listener), () => state.snapshot(), () => state.snapshot());
258
- const [optimistic, setOptimistic] = useState(null);
259
- const [failedChoiceId, setFailedChoiceId] = useState(null);
260
- const pending = useRef(false);
261
- useEffect(() => {
262
- if (answered && answered.revision === block.revision && answered.values) {
263
- for (const [name, value] of Object.entries(answered.values)) {
264
- state.set(name, value);
265
- }
266
- }
267
- }, [state, answered, block.revision]);
268
- const answer = answered && answered.revision === block.revision
269
- ? { choiceId: answered.choiceId, state: answered.queued ? 'queued' : 'sent' }
270
- : optimistic?.revision === block.revision
271
- ? optimistic
272
- : null;
273
- const [element, setElement] = useState(null);
274
- const navigation = useContext(UiReplyNavigationContext);
275
- const flash = navigation?.flash;
276
- const flashing = navigation?.chatId === context.chatId && flash?.itemId === context.itemId && flash.blockId === block.id && flash.revision === block.revision;
277
- const queries = useUiQueries(block, state, context, element, frozen);
278
- const links = useUiLinks(block, state, context, queries.reads, frozen);
279
- // The state changes in place, so its revision is what tells this evaluation it went stale.
280
- // oxlint-disable-next-line react-hooks/exhaustive-deps
281
- const evaluation = useMemo(() => evaluateUiBlock(block, state), [block, state, stateRevision]);
282
- const texts = useMemo(() => writtenTexts(block.nodes), [block]);
283
- const sources = useMemo(() => sourceTargets(evaluation.nodes), [evaluation]);
284
- const citations = useMemo(() => ({
285
- sources,
286
- reveal: element
287
- ? (source) => {
288
- void revealUiSource(element, source.id, source.ancestors);
289
- }
290
- : undefined
291
- }), [sources, element]);
292
- const liveValue = useUiLiveValues(block, evaluation.nodes, queries.currentReadings);
293
- const sendChoice = host.intelligentUi?.sendChoice;
294
- const place = useMemo(() => placeReader(frozen, block.revision, unrecorded), [frozen, block.revision, unrecorded]);
295
- const rendering = {
296
- ...context,
297
- ...links,
298
- place,
299
- answer,
300
- failedChoiceId,
301
- live: queries.live,
302
- liveValue,
303
- choiceReason: uiLiveChoiceReason(t, queries.live),
304
- onChoose: !queries.ready || queries.reading
305
- ? undefined
306
- : sendChoice && block.revision && block.complete && context.phase === 'final'
307
- ? (choiceId) => {
308
- if (pending.current || answer || queries.reading) {
309
- return;
310
- }
311
- const values = uiInputValues(block, state);
312
- const reads = queries.readsFor(values);
313
- if (reads === null) {
314
- return;
315
- }
316
- pending.current = true;
317
- setFailedChoiceId(null);
318
- const revision = block.revision;
319
- setOptimistic({ revision, choiceId, state: 'sending' });
320
- void sendChoice(context.scopeId, {
321
- chatId: context.chatId,
322
- itemId: context.itemId,
323
- blockId: block.id,
324
- revision,
325
- choiceId,
326
- reads,
327
- values
328
- })
329
- .then((state) => setOptimistic({ revision, choiceId, state }))
330
- .catch(() => {
331
- setOptimistic(null);
332
- setFailedChoiceId(choiceId);
333
- })
334
- .finally(() => {
335
- pending.current = false;
336
- });
337
- }
338
- : undefined
339
- };
340
- const unknown = block.catalogVersion !== UI_CATALOG_VERSION;
341
- const failed = !unknown && !block.nodes.length && block.diagnostics.length > 0;
342
- const shownAsText = unknown ? t('blocks.unreadable') : failed ? block.diagnostics[0].message : undefined;
343
- return (_jsxs("div", { ref: setElement, className: "relative", "data-ui-block": block.id, "data-ui-revision": block.revision, tabIndex: -1, children: [flashing && _jsx("span", { className: "chat-flash pointer-events-none absolute inset-0 rounded-lg", "aria-hidden": true }, flash.nonce), _jsx(UiBlockFrame, { live: queries.live, nodes: evaluation.nodes, phase: context.phase, fixes: [...block.diagnostics, ...evaluation.diagnostics].filter((diagnostic) => diagnostic.severity !== 'warning'), shownAsText: shownAsText, answered: answered, children: unknown || failed ? (_jsx(ReplyMarkdown, { text: block.fallback, streaming: false })) : (_jsx(CitationContext, { value: citations, children: _jsx(UiNodes, { nodes: evaluation.nodes, parent: BLOCK, texts: texts, context: rendering }) })) })] }));
546
+ function UiBlockBody({
547
+ block,
548
+ context,
549
+ answered,
550
+ frozen,
551
+ unrecorded
552
+ }) {
553
+ // The block's state changes in place and only its revision says so; compiled, the evaluation of the first revision would stay.
554
+ 'use no memo';
555
+
556
+ const host = useChatHost();
557
+ const {
558
+ t
559
+ } = useTranslation('agent-chat');
560
+ const key = JSON.stringify([context.scopeId, context.chatId, context.itemId, block.id]);
561
+ const [state] = useState(() => localState(key, block, answered));
562
+ state.sync(block);
563
+ const stateRevision = useSyncExternalStore(listener => state.subscribe(listener), () => state.snapshot(), () => state.snapshot());
564
+ const [optimistic, setOptimistic] = useState(null);
565
+ const [failedChoiceId, setFailedChoiceId] = useState(null);
566
+ const pending = useRef(false);
567
+ useEffect(() => {
568
+ if (answered && answered.revision === block.revision && answered.values) {
569
+ for (const [name, value] of Object.entries(answered.values)) {
570
+ state.set(name, value);
571
+ }
572
+ }
573
+ }, [state, answered, block.revision]);
574
+ const answer = answered && answered.revision === block.revision ? {
575
+ choiceId: answered.choiceId,
576
+ state: answered.queued ? 'queued' : 'sent'
577
+ } : optimistic?.revision === block.revision ? optimistic : null;
578
+ const [element, setElement] = useState(null);
579
+ const navigation = useContext(UiReplyNavigationContext);
580
+ const flash = navigation?.flash;
581
+ const flashing = navigation?.chatId === context.chatId && flash?.itemId === context.itemId && flash.blockId === block.id && flash.revision === block.revision;
582
+ const queries = useUiQueries(block, state, context, element, frozen);
583
+ const links = useUiLinks(block, state, context, queries.reads, frozen);
584
+ // The state changes in place, so its revision is what tells this evaluation it went stale.
585
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
586
+ const evaluation = useMemo(() => evaluateUiBlock(block, state), [block, state, stateRevision]);
587
+ const texts = useMemo(() => writtenTexts(block.nodes), [block]);
588
+ const sources = useMemo(() => sourceTargets(evaluation.nodes), [evaluation]);
589
+ const citations = useMemo(() => ({
590
+ sources,
591
+ reveal: element ? source => {
592
+ void revealUiSource(element, source.id, source.ancestors);
593
+ } : undefined
594
+ }), [sources, element]);
595
+ const liveValue = useUiLiveValues(block, evaluation.nodes, queries.currentReadings);
596
+ const sendChoice = host.intelligentUi?.sendChoice;
597
+ const place = useMemo(() => placeReader(frozen, block.revision, unrecorded), [frozen, block.revision, unrecorded]);
598
+ const rendering = {
599
+ ...context,
600
+ ...links,
601
+ place,
602
+ answer,
603
+ failedChoiceId,
604
+ live: queries.live,
605
+ liveValue,
606
+ choiceReason: uiLiveChoiceReason(t, queries.live),
607
+ onChoose: !queries.ready || queries.reading ? undefined : sendChoice && block.revision && block.complete && context.phase === 'final' ? choiceId => {
608
+ if (pending.current || answer || queries.reading) {
609
+ return;
610
+ }
611
+ const values = uiInputValues(block, state);
612
+ const reads = queries.readsFor(values);
613
+ if (reads === null) {
614
+ return;
615
+ }
616
+ pending.current = true;
617
+ setFailedChoiceId(null);
618
+ const revision = block.revision;
619
+ setOptimistic({
620
+ revision,
621
+ choiceId,
622
+ state: 'sending'
623
+ });
624
+ void sendChoice(context.scopeId, {
625
+ chatId: context.chatId,
626
+ itemId: context.itemId,
627
+ blockId: block.id,
628
+ revision,
629
+ choiceId,
630
+ reads,
631
+ values
632
+ }).then(state_0 => setOptimistic({
633
+ revision,
634
+ choiceId,
635
+ state: state_0
636
+ })).catch(() => {
637
+ setOptimistic(null);
638
+ setFailedChoiceId(choiceId);
639
+ }).finally(() => {
640
+ pending.current = false;
641
+ });
642
+ } : undefined
643
+ };
644
+ const unknown = block.catalogVersion !== UI_CATALOG_VERSION;
645
+ const failed = !unknown && !block.nodes.length && block.diagnostics.length > 0;
646
+ const shownAsText = unknown ? t('blocks.unreadable') : failed ? block.diagnostics[0].message : undefined;
647
+ return /*#__PURE__*/_jsxs("div", {
648
+ ref: setElement,
649
+ className: "relative",
650
+ "data-ui-block": block.id,
651
+ "data-ui-revision": block.revision,
652
+ tabIndex: -1,
653
+ children: [flashing && /*#__PURE__*/_jsx("span", {
654
+ className: "chat-flash pointer-events-none absolute inset-0 rounded-lg",
655
+ "aria-hidden": true
656
+ }, flash.nonce), /*#__PURE__*/_jsx(UiBlockFrame, {
657
+ live: queries.live,
658
+ nodes: evaluation.nodes,
659
+ phase: context.phase,
660
+ fixes: [...block.diagnostics, ...evaluation.diagnostics].filter(diagnostic => diagnostic.severity !== 'warning'),
661
+ shownAsText: shownAsText,
662
+ answered: answered,
663
+ children: unknown || failed ? /*#__PURE__*/_jsx(ReplyMarkdown, {
664
+ text: block.fallback,
665
+ streaming: false
666
+ }) : /*#__PURE__*/_jsx(CitationContext, {
667
+ value: citations,
668
+ children: /*#__PURE__*/_jsx(UiNodes, {
669
+ nodes: evaluation.nodes,
670
+ parent: BLOCK,
671
+ texts: texts,
672
+ context: rendering
673
+ })
674
+ })
675
+ })]
676
+ });
344
677
  }
345
678
  /* Prose and cards a block gap apart, as the rows of a turn are; text that is only the newline between two fences draws nothing. */
346
- export function UiReply({ text, blocks, context, answers, queries, reply }) {
347
- return (_jsx("div", { className: "flex flex-col gap-(--chat-block-gap)", children: uiReplyParts(text, blocks, context.phase === 'streaming').map((part, index) => part.kind === 'text' ? (part.text.trim() !== '' && (_jsx(Fragment, { children: _jsx(ReplyMarkdown, { text: part.text, streaming: context.phase === 'streaming', reply: reply }) }, `text:${index}`))) : (_jsx(ErrorBoundary, { label: "UI block", children: _jsx(UiBlockBody, { block: part.block, frozen: queries?.blocks[part.block.id], unrecorded: context.phase === 'final' && queries === undefined, answered: answers?.[part.block.id], context: { scopeId: context.scopeId, chatId: context.chatId, itemId: context.itemId, phase: context.phase, blockId: part.block.id } }) }, JSON.stringify([context.scopeId, context.chatId, context.itemId, part.block.id])))) }));
348
- }
679
+ export function UiReply(t0) {
680
+ const $ = _c(20);
681
+ const {
682
+ text,
683
+ blocks,
684
+ context,
685
+ answers,
686
+ queries,
687
+ reply
688
+ } = t0;
689
+ let t1;
690
+ if ($[0] !== answers || $[1] !== blocks || $[2] !== context.chatId || $[3] !== context.itemId || $[4] !== context.phase || $[5] !== context.scopeId || $[6] !== queries || $[7] !== reply || $[8] !== text) {
691
+ let t2;
692
+ if ($[10] !== answers || $[11] !== context.chatId || $[12] !== context.itemId || $[13] !== context.phase || $[14] !== context.scopeId || $[15] !== queries || $[16] !== reply) {
693
+ t2 = (part, index) => part.kind === "text" ? part.text.trim() !== "" && /*#__PURE__*/_jsx(Fragment, {
694
+ children: /*#__PURE__*/_jsx(ReplyMarkdown, {
695
+ text: part.text,
696
+ streaming: context.phase === "streaming",
697
+ reply: reply
698
+ })
699
+ }, `text:${index}`) : /*#__PURE__*/_jsx(ErrorBoundary, {
700
+ label: "UI block",
701
+ children: /*#__PURE__*/_jsx(UiBlockBody, {
702
+ block: part.block,
703
+ frozen: queries?.blocks[part.block.id],
704
+ unrecorded: context.phase === "final" && queries === undefined,
705
+ answered: answers?.[part.block.id],
706
+ context: {
707
+ scopeId: context.scopeId,
708
+ chatId: context.chatId,
709
+ itemId: context.itemId,
710
+ phase: context.phase,
711
+ blockId: part.block.id
712
+ }
713
+ })
714
+ }, JSON.stringify([context.scopeId, context.chatId, context.itemId, part.block.id]));
715
+ $[10] = answers;
716
+ $[11] = context.chatId;
717
+ $[12] = context.itemId;
718
+ $[13] = context.phase;
719
+ $[14] = context.scopeId;
720
+ $[15] = queries;
721
+ $[16] = reply;
722
+ $[17] = t2;
723
+ } else {
724
+ t2 = $[17];
725
+ }
726
+ t1 = uiReplyParts(text, blocks, context.phase === "streaming").map(t2);
727
+ $[0] = answers;
728
+ $[1] = blocks;
729
+ $[2] = context.chatId;
730
+ $[3] = context.itemId;
731
+ $[4] = context.phase;
732
+ $[5] = context.scopeId;
733
+ $[6] = queries;
734
+ $[7] = reply;
735
+ $[8] = text;
736
+ $[9] = t1;
737
+ } else {
738
+ t1 = $[9];
739
+ }
740
+ let t2;
741
+ if ($[18] !== t1) {
742
+ t2 = /*#__PURE__*/_jsx("div", {
743
+ className: "flex flex-col gap-(--chat-block-gap)",
744
+ children: t1
745
+ });
746
+ $[18] = t1;
747
+ $[19] = t2;
748
+ } else {
749
+ t2 = $[19];
750
+ }
751
+ return t2;
752
+ }