@adecore/agents-react 0.0.1 → 0.17.0-beta.2

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 (513) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +61 -0
  3. package/dist/agents/AccountDot.d.ts +4 -0
  4. package/dist/agents/AccountDot.js +8 -0
  5. package/dist/agents/AgentIcon.d.ts +6 -0
  6. package/dist/agents/AgentIcon.js +20 -0
  7. package/dist/agents/ModelOptionControl.d.ts +15 -0
  8. package/dist/agents/ModelOptionControl.js +33 -0
  9. package/dist/agents/ProviderLogo.d.ts +8 -0
  10. package/dist/agents/ProviderLogo.js +8 -0
  11. package/dist/agents/account-limits.d.ts +7 -0
  12. package/dist/agents/account-limits.js +40 -0
  13. package/dist/agents/accounts.d.ts +22 -0
  14. package/dist/agents/accounts.js +113 -0
  15. package/dist/agents/model-name.d.ts +12 -0
  16. package/dist/agents/model-name.js +56 -0
  17. package/dist/agents/model-options.d.ts +5 -0
  18. package/dist/agents/model-options.js +15 -0
  19. package/dist/agents/provider-paths.d.ts +2 -0
  20. package/dist/agents/provider-paths.js +8 -0
  21. package/dist/agents/status-look.d.ts +13 -0
  22. package/dist/agents/status-look.js +24 -0
  23. package/dist/chat/account-choice.d.ts +11 -0
  24. package/dist/chat/account-choice.js +30 -0
  25. package/dist/chat/actions.d.ts +6 -0
  26. package/dist/chat/actions.js +68 -0
  27. package/dist/chat/activity.d.ts +5 -0
  28. package/dist/chat/activity.js +6 -0
  29. package/dist/chat/attachments.d.ts +23 -0
  30. package/dist/chat/attachments.js +86 -0
  31. package/dist/chat/bookmarks.d.ts +14 -0
  32. package/dist/chat/bookmarks.js +73 -0
  33. package/dist/chat/chat-client.d.ts +55 -0
  34. package/dist/chat/chat-client.js +279 -0
  35. package/dist/chat/chat-references.d.ts +5 -0
  36. package/dist/chat/chat-references.js +5 -0
  37. package/dist/chat/drafts.d.ts +29 -0
  38. package/dist/chat/drafts.js +116 -0
  39. package/dist/chat/forks.d.ts +2 -0
  40. package/dist/chat/forks.js +28 -0
  41. package/dist/chat/guards.d.ts +12 -0
  42. package/dist/chat/guards.js +69 -0
  43. package/dist/chat/logic/ansi.d.ts +13 -0
  44. package/dist/chat/logic/ansi.js +185 -0
  45. package/dist/chat/logic/answers.d.ts +1 -0
  46. package/dist/chat/logic/answers.js +8 -0
  47. package/dist/chat/logic/bookmarks.d.ts +5 -0
  48. package/dist/chat/logic/bookmarks.js +33 -0
  49. package/dist/chat/logic/context-usage.d.ts +12 -0
  50. package/dist/chat/logic/context-usage.js +21 -0
  51. package/dist/chat/logic/fork.d.ts +45 -0
  52. package/dist/chat/logic/fork.js +148 -0
  53. package/dist/chat/logic/handback.d.ts +2 -0
  54. package/dist/chat/logic/handback.js +8 -0
  55. package/dist/chat/logic/json.d.ts +1 -0
  56. package/dist/chat/logic/json.js +4 -0
  57. package/dist/chat/logic/limit.d.ts +7 -0
  58. package/dist/chat/logic/limit.js +34 -0
  59. package/dist/chat/logic/resume-compaction.d.ts +14 -0
  60. package/dist/chat/logic/resume-compaction.js +47 -0
  61. package/dist/chat/logic/scrubber.d.ts +50 -0
  62. package/dist/chat/logic/scrubber.js +220 -0
  63. package/dist/chat/logic/thread-cards.d.ts +3 -0
  64. package/dist/chat/logic/thread-cards.js +59 -0
  65. package/dist/chat/logic/timeline-copy.d.ts +4 -0
  66. package/dist/chat/logic/timeline-copy.js +59 -0
  67. package/dist/chat/logic/timeline-target.d.ts +12 -0
  68. package/dist/chat/logic/timeline-target.js +34 -0
  69. package/dist/chat/logic/timeline.d.ts +115 -0
  70. package/dist/chat/logic/timeline.js +343 -0
  71. package/dist/chat/logic/tool-catalog.d.ts +10 -0
  72. package/dist/chat/logic/tool-catalog.js +44 -0
  73. package/dist/chat/logic/tools.d.ts +15 -0
  74. package/dist/chat/logic/tools.js +82 -0
  75. package/dist/chat/logic/welcome.d.ts +2 -0
  76. package/dist/chat/logic/welcome.js +10 -0
  77. package/dist/chat/logic/workflow.d.ts +14 -0
  78. package/dist/chat/logic/workflow.js +47 -0
  79. package/dist/chat/mentions.d.ts +65 -0
  80. package/dist/chat/mentions.js +184 -0
  81. package/dist/chat/persisted-json.d.ts +5 -0
  82. package/dist/chat/persisted-json.js +58 -0
  83. package/dist/chat/preferences.d.ts +27 -0
  84. package/dist/chat/preferences.js +139 -0
  85. package/dist/chat/quote.d.ts +2 -0
  86. package/dist/chat/quote.js +25 -0
  87. package/dist/chat/recent-messages.d.ts +17 -0
  88. package/dist/chat/recent-messages.js +36 -0
  89. package/dist/chat/resume-compaction-dismissals.d.ts +3 -0
  90. package/dist/chat/resume-compaction-dismissals.js +14 -0
  91. package/dist/chat/runtime-modes.d.ts +4 -0
  92. package/dist/chat/runtime-modes.js +15 -0
  93. package/dist/chat/stash.d.ts +24 -0
  94. package/dist/chat/stash.js +91 -0
  95. package/dist/chat/subagent-conversation.d.ts +41 -0
  96. package/dist/chat/subagent-conversation.js +167 -0
  97. package/dist/chat/subagent-list.d.ts +19 -0
  98. package/dist/chat/subagent-list.js +106 -0
  99. package/dist/chat/subagent-support.d.ts +6 -0
  100. package/dist/chat/subagent-support.js +14 -0
  101. package/dist/chat/subagent-view.d.ts +35 -0
  102. package/dist/chat/subagent-view.js +96 -0
  103. package/dist/chat/thumbnails.d.ts +10 -0
  104. package/dist/chat/thumbnails.js +89 -0
  105. package/dist/chat/timeline-flash.d.ts +12 -0
  106. package/dist/chat/timeline-flash.js +16 -0
  107. package/dist/chat/timeline-scroll.d.ts +27 -0
  108. package/dist/chat/timeline-scroll.js +152 -0
  109. package/dist/chat/ui/AccountPill.d.ts +3 -0
  110. package/dist/chat/ui/AccountPill.js +23 -0
  111. package/dist/chat/ui/AnsiOutput.d.ts +5 -0
  112. package/dist/chat/ui/AnsiOutput.js +9 -0
  113. package/dist/chat/ui/BookmarkMarker.d.ts +8 -0
  114. package/dist/chat/ui/BookmarkMarker.js +57 -0
  115. package/dist/chat/ui/BookmarkSubmenu.d.ts +3 -0
  116. package/dist/chat/ui/BookmarkSubmenu.js +33 -0
  117. package/dist/chat/ui/ChatActivity.d.ts +7 -0
  118. package/dist/chat/ui/ChatActivity.js +84 -0
  119. package/dist/chat/ui/ChatReferenceChip.d.ts +4 -0
  120. package/dist/chat/ui/ChatReferenceChip.js +16 -0
  121. package/dist/chat/ui/CodeBlock.d.ts +4 -0
  122. package/dist/chat/ui/CodeBlock.js +132 -0
  123. package/dist/chat/ui/Composer.d.ts +15 -0
  124. package/dist/chat/ui/Composer.js +856 -0
  125. package/dist/chat/ui/ComposerInput.d.ts +29 -0
  126. package/dist/chat/ui/ComposerInput.js +127 -0
  127. package/dist/chat/ui/DiffPool.d.ts +5 -0
  128. package/dist/chat/ui/DiffPool.js +26 -0
  129. package/dist/chat/ui/EditDiff.d.ts +4 -0
  130. package/dist/chat/ui/EditDiff.js +21 -0
  131. package/dist/chat/ui/FadingWords.d.ts +3 -0
  132. package/dist/chat/ui/FadingWords.js +5 -0
  133. package/dist/chat/ui/ImageView.d.ts +6 -0
  134. package/dist/chat/ui/ImageView.js +81 -0
  135. package/dist/chat/ui/LimitState.d.ts +8 -0
  136. package/dist/chat/ui/LimitState.js +112 -0
  137. package/dist/chat/ui/Markdown.d.ts +18 -0
  138. package/dist/chat/ui/Markdown.js +159 -0
  139. package/dist/chat/ui/MessageActions.d.ts +9 -0
  140. package/dist/chat/ui/MessageActions.js +53 -0
  141. package/dist/chat/ui/Pickers.d.ts +21 -0
  142. package/dist/chat/ui/Pickers.js +111 -0
  143. package/dist/chat/ui/PromptComposer.d.ts +13 -0
  144. package/dist/chat/ui/PromptComposer.js +56 -0
  145. package/dist/chat/ui/QuoteButton.d.ts +7 -0
  146. package/dist/chat/ui/QuoteButton.js +74 -0
  147. package/dist/chat/ui/ResumeCompactionDock.d.ts +5 -0
  148. package/dist/chat/ui/ResumeCompactionDock.js +14 -0
  149. package/dist/chat/ui/RunSettings.d.ts +28 -0
  150. package/dist/chat/ui/RunSettings.js +153 -0
  151. package/dist/chat/ui/Scrubber.d.ts +17 -0
  152. package/dist/chat/ui/Scrubber.js +118 -0
  153. package/dist/chat/ui/SubagentControls.d.ts +11 -0
  154. package/dist/chat/ui/SubagentControls.js +36 -0
  155. package/dist/chat/ui/SubagentInfo.d.ts +4 -0
  156. package/dist/chat/ui/SubagentInfo.js +34 -0
  157. package/dist/chat/ui/SubagentStopButton.d.ts +7 -0
  158. package/dist/chat/ui/SubagentStopButton.js +34 -0
  159. package/dist/chat/ui/SubagentTimeline.d.ts +4 -0
  160. package/dist/chat/ui/SubagentTimeline.js +107 -0
  161. package/dist/chat/ui/Timeline.d.ts +6 -0
  162. package/dist/chat/ui/Timeline.js +424 -0
  163. package/dist/chat/ui/TimelineMenu.d.ts +12 -0
  164. package/dist/chat/ui/TimelineMenu.js +54 -0
  165. package/dist/chat/ui/UnifiedDiff.d.ts +11 -0
  166. package/dist/chat/ui/UnifiedDiff.js +66 -0
  167. package/dist/chat/ui/UploadThumb.d.ts +4 -0
  168. package/dist/chat/ui/UploadThumb.js +11 -0
  169. package/dist/chat/ui/Welcome.d.ts +4 -0
  170. package/dist/chat/ui/Welcome.js +16 -0
  171. package/dist/chat/ui/chips.d.ts +4 -0
  172. package/dist/chat/ui/chips.js +11 -0
  173. package/dist/chat/ui/code-lines.d.ts +18 -0
  174. package/dist/chat/ui/code-lines.js +46 -0
  175. package/dist/chat/ui/code-streaming.d.ts +1 -0
  176. package/dist/chat/ui/code-streaming.js +3 -0
  177. package/dist/chat/ui/code-theme.d.ts +3 -0
  178. package/dist/chat/ui/code-theme.js +12 -0
  179. package/dist/chat/ui/composer/chips.d.ts +6 -0
  180. package/dist/chat/ui/composer/chips.js +31 -0
  181. package/dist/chat/ui/composer/editor.d.ts +11 -0
  182. package/dist/chat/ui/composer/editor.js +98 -0
  183. package/dist/chat/ui/composer/insert.d.ts +2 -0
  184. package/dist/chat/ui/composer/insert.js +19 -0
  185. package/dist/chat/ui/composer/keys.d.ts +30 -0
  186. package/dist/chat/ui/composer/keys.js +100 -0
  187. package/dist/chat/ui/diff-theme.d.ts +2 -0
  188. package/dist/chat/ui/diff-theme.js +20 -0
  189. package/dist/chat/ui/file-links.d.ts +5 -0
  190. package/dist/chat/ui/file-links.js +20 -0
  191. package/dist/chat/ui/find-reveal.d.ts +7 -0
  192. package/dist/chat/ui/find-reveal.js +13 -0
  193. package/dist/chat/ui/full-diff.d.ts +6 -0
  194. package/dist/chat/ui/full-diff.js +19 -0
  195. package/dist/chat/ui/icons.d.ts +4 -0
  196. package/dist/chat/ui/icons.js +20 -0
  197. package/dist/chat/ui/markdown-blocks.d.ts +6 -0
  198. package/dist/chat/ui/markdown-blocks.js +103 -0
  199. package/dist/chat/ui/quote-selection.d.ts +3 -0
  200. package/dist/chat/ui/quote-selection.js +46 -0
  201. package/dist/chat/ui/rehype-chips.d.ts +23 -0
  202. package/dist/chat/ui/rehype-chips.js +32 -0
  203. package/dist/chat/ui/rehype-fade.d.ts +23 -0
  204. package/dist/chat/ui/rehype-fade.js +36 -0
  205. package/dist/chat/ui/remark-html-as-text.d.ts +8 -0
  206. package/dist/chat/ui/remark-html-as-text.js +26 -0
  207. package/dist/chat/ui/reply-context.d.ts +5 -0
  208. package/dist/chat/ui/reply-context.js +2 -0
  209. package/dist/chat/ui/reveal.d.ts +13 -0
  210. package/dist/chat/ui/reveal.js +114 -0
  211. package/dist/chat/ui/rows/ForksRow.d.ts +4 -0
  212. package/dist/chat/ui/rows/ForksRow.js +38 -0
  213. package/dist/chat/ui/rows/MessageRows.d.ts +40 -0
  214. package/dist/chat/ui/rows/MessageRows.js +204 -0
  215. package/dist/chat/ui/rows/Rows.d.ts +12 -0
  216. package/dist/chat/ui/rows/Rows.js +61 -0
  217. package/dist/chat/ui/rows/SubagentRow.d.ts +17 -0
  218. package/dist/chat/ui/rows/SubagentRow.js +101 -0
  219. package/dist/chat/ui/rows/TaskRow.d.ts +8 -0
  220. package/dist/chat/ui/rows/TaskRow.js +63 -0
  221. package/dist/chat/ui/rows/WorkRows.d.ts +47 -0
  222. package/dist/chat/ui/rows/WorkRows.js +168 -0
  223. package/dist/chat/ui/rows/WorkflowRow.d.ts +8 -0
  224. package/dist/chat/ui/rows/WorkflowRow.js +48 -0
  225. package/dist/chat/ui/rows/row-rhythm.d.ts +6 -0
  226. package/dist/chat/ui/rows/row-rhythm.js +34 -0
  227. package/dist/chat/ui/useToggleSet.d.ts +6 -0
  228. package/dist/chat/ui/useToggleSet.js +25 -0
  229. package/dist/host.d.ts +195 -0
  230. package/dist/host.js +55 -0
  231. package/dist/lazy.d.ts +6 -0
  232. package/dist/lazy.js +57 -0
  233. package/dist/locales/en/agent-chat.json +446 -0
  234. package/dist/locales/en/agent-prompts.json +42 -0
  235. package/dist/locales/en/agent-providers.json +131 -0
  236. package/dist/locales/en/agent-usage.json +131 -0
  237. package/dist/locales/nl/agent-chat.json +446 -0
  238. package/dist/locales/nl/agent-prompts.json +42 -0
  239. package/dist/locales/nl/agent-providers.json +131 -0
  240. package/dist/locales/nl/agent-usage.json +131 -0
  241. package/dist/locales.d.ts +5 -0
  242. package/dist/locales.js +20 -0
  243. package/dist/mounted-registry.d.ts +7 -0
  244. package/dist/mounted-registry.js +39 -0
  245. package/dist/port-transport.d.ts +6 -0
  246. package/dist/port-transport.js +129 -0
  247. package/dist/prompts/logic/focus.d.ts +2 -0
  248. package/dist/prompts/logic/focus.js +23 -0
  249. package/dist/prompts/logic/keys.d.ts +42 -0
  250. package/dist/prompts/logic/keys.js +94 -0
  251. package/dist/prompts/logic/prompts.d.ts +34 -0
  252. package/dist/prompts/logic/prompts.fixtures.d.ts +5 -0
  253. package/dist/prompts/logic/prompts.fixtures.js +79 -0
  254. package/dist/prompts/logic/prompts.js +32 -0
  255. package/dist/prompts/logic/subjects.d.ts +50 -0
  256. package/dist/prompts/logic/subjects.js +63 -0
  257. package/dist/prompts/logic/useFocusAfterAnswer.d.ts +6 -0
  258. package/dist/prompts/logic/useFocusAfterAnswer.js +28 -0
  259. package/dist/prompts/logic/usePromptSession.d.ts +24 -0
  260. package/dist/prompts/logic/usePromptSession.js +87 -0
  261. package/dist/prompts/ui/ApprovalBody.d.ts +13 -0
  262. package/dist/prompts/ui/ApprovalBody.js +34 -0
  263. package/dist/prompts/ui/PromptActions.d.ts +27 -0
  264. package/dist/prompts/ui/PromptActions.js +18 -0
  265. package/dist/prompts/ui/PromptCard.d.ts +16 -0
  266. package/dist/prompts/ui/PromptCard.js +50 -0
  267. package/dist/prompts/ui/PromptView.d.ts +2 -0
  268. package/dist/prompts/ui/PromptView.js +47 -0
  269. package/dist/prompts/ui/QuestionBody.d.ts +9 -0
  270. package/dist/prompts/ui/QuestionBody.js +87 -0
  271. package/dist/providers/AccountColors.d.ts +5 -0
  272. package/dist/providers/AccountColors.js +8 -0
  273. package/dist/providers/AccountDetail.d.ts +12 -0
  274. package/dist/providers/AccountDetail.js +69 -0
  275. package/dist/providers/AccountVariables.d.ts +8 -0
  276. package/dist/providers/AccountVariables.js +43 -0
  277. package/dist/providers/AddAccountForm.d.ts +10 -0
  278. package/dist/providers/AddAccountForm.js +54 -0
  279. package/dist/providers/CliDetail.d.ts +12 -0
  280. package/dist/providers/CliDetail.js +54 -0
  281. package/dist/providers/ProvidersPane.d.ts +9 -0
  282. package/dist/providers/ProvidersPane.js +86 -0
  283. package/dist/providers/account-actions.d.ts +7 -0
  284. package/dist/providers/account-actions.js +57 -0
  285. package/dist/providers/parts.d.ts +9 -0
  286. package/dist/providers/parts.js +18 -0
  287. package/dist/providers/provider-abilities.d.ts +2 -0
  288. package/dist/providers/provider-abilities.js +7 -0
  289. package/dist/providers/variables.d.ts +13 -0
  290. package/dist/providers/variables.js +63 -0
  291. package/dist/scope.d.ts +11 -0
  292. package/dist/scope.js +10 -0
  293. package/dist/settings/sections.d.ts +13 -0
  294. package/dist/settings/sections.js +32 -0
  295. package/dist/state/chats.d.ts +44 -0
  296. package/dist/state/chats.js +199 -0
  297. package/dist/state/provider-accounts.d.ts +17 -0
  298. package/dist/state/provider-accounts.js +67 -0
  299. package/dist/state/providers.d.ts +17 -0
  300. package/dist/state/providers.js +33 -0
  301. package/dist/state/usage.d.ts +44 -0
  302. package/dist/state/usage.js +121 -0
  303. package/dist/storage.d.ts +20 -0
  304. package/dist/storage.js +89 -0
  305. package/dist/theme.css +212 -0
  306. package/dist/transport.d.ts +24 -0
  307. package/dist/transport.js +18 -0
  308. package/dist/ui/PlainTextarea.d.ts +2 -0
  309. package/dist/ui/PlainTextarea.js +5 -0
  310. package/dist/usage/LimitsList.d.ts +18 -0
  311. package/dist/usage/LimitsList.js +73 -0
  312. package/dist/usage/UsageBreakdown.d.ts +9 -0
  313. package/dist/usage/UsageBreakdown.js +67 -0
  314. package/dist/usage/UsageChart.d.ts +10 -0
  315. package/dist/usage/UsageChart.js +47 -0
  316. package/dist/usage/UsageDialog.d.ts +6 -0
  317. package/dist/usage/UsageDialog.js +12 -0
  318. package/dist/usage/UsageLimits.d.ts +1 -0
  319. package/dist/usage/UsageLimits.js +57 -0
  320. package/dist/usage/UsageLimitsCard.d.ts +4 -0
  321. package/dist/usage/UsageLimitsCard.js +26 -0
  322. package/dist/usage/UsagePage.d.ts +7 -0
  323. package/dist/usage/UsagePage.js +154 -0
  324. package/dist/usage/UsagePane.d.ts +3 -0
  325. package/dist/usage/UsagePane.js +21 -0
  326. package/dist/usage/UsageSummary.d.ts +12 -0
  327. package/dist/usage/UsageSummary.js +15 -0
  328. package/dist/usage/UsageTiles.d.ts +7 -0
  329. package/dist/usage/UsageTiles.js +19 -0
  330. package/dist/usage/format.d.ts +13 -0
  331. package/dist/usage/format.js +55 -0
  332. package/dist/usage/limit-groups.d.ts +22 -0
  333. package/dist/usage/limit-groups.js +86 -0
  334. package/dist/usage/limits.d.ts +4 -0
  335. package/dist/usage/limits.js +58 -0
  336. package/dist/usage/money.d.ts +1 -0
  337. package/dist/usage/money.js +13 -0
  338. package/dist/usage/summary.d.ts +34 -0
  339. package/dist/usage/summary.js +94 -0
  340. package/package.json +895 -3
  341. package/src/agents/AccountDot.tsx +14 -0
  342. package/src/agents/AgentIcon.tsx +26 -0
  343. package/src/agents/ModelOptionControl.tsx +68 -0
  344. package/src/agents/ProviderLogo.tsx +20 -0
  345. package/src/agents/account-limits.ts +61 -0
  346. package/src/agents/accounts.ts +137 -0
  347. package/src/agents/model-name.ts +70 -0
  348. package/src/agents/model-options.ts +21 -0
  349. package/src/agents/provider-paths.ts +10 -0
  350. package/src/agents/status-look.ts +43 -0
  351. package/src/chat/account-choice.ts +44 -0
  352. package/src/chat/actions.ts +72 -0
  353. package/src/chat/activity.ts +8 -0
  354. package/src/chat/attachments.ts +118 -0
  355. package/src/chat/bookmarks.ts +87 -0
  356. package/src/chat/chat-client.ts +345 -0
  357. package/src/chat/chat-references.ts +11 -0
  358. package/src/chat/drafts.ts +165 -0
  359. package/src/chat/forks.ts +33 -0
  360. package/src/chat/guards.ts +84 -0
  361. package/src/chat/logic/ansi.ts +206 -0
  362. package/src/chat/logic/answers.ts +8 -0
  363. package/src/chat/logic/bookmarks.ts +42 -0
  364. package/src/chat/logic/context-usage.ts +36 -0
  365. package/src/chat/logic/fork.ts +200 -0
  366. package/src/chat/logic/handback.ts +10 -0
  367. package/src/chat/logic/json.ts +4 -0
  368. package/src/chat/logic/limit.ts +46 -0
  369. package/src/chat/logic/resume-compaction.ts +71 -0
  370. package/src/chat/logic/scrubber.ts +289 -0
  371. package/src/chat/logic/thread-cards.ts +64 -0
  372. package/src/chat/logic/timeline-copy.ts +65 -0
  373. package/src/chat/logic/timeline-target.ts +52 -0
  374. package/src/chat/logic/timeline.ts +419 -0
  375. package/src/chat/logic/tool-catalog.ts +62 -0
  376. package/src/chat/logic/tools.ts +102 -0
  377. package/src/chat/logic/welcome.ts +13 -0
  378. package/src/chat/logic/workflow.ts +66 -0
  379. package/src/chat/mentions.ts +232 -0
  380. package/src/chat/persisted-json.ts +67 -0
  381. package/src/chat/preferences.ts +179 -0
  382. package/src/chat/quote.ts +26 -0
  383. package/src/chat/recent-messages.ts +59 -0
  384. package/src/chat/resume-compaction-dismissals.ts +17 -0
  385. package/src/chat/runtime-modes.ts +18 -0
  386. package/src/chat/stash.ts +122 -0
  387. package/src/chat/subagent-conversation.ts +203 -0
  388. package/src/chat/subagent-list.ts +141 -0
  389. package/src/chat/subagent-support.ts +21 -0
  390. package/src/chat/subagent-view.ts +137 -0
  391. package/src/chat/thumbnails.ts +108 -0
  392. package/src/chat/timeline-flash.ts +33 -0
  393. package/src/chat/timeline-scroll.ts +199 -0
  394. package/src/chat/ui/AccountPill.tsx +31 -0
  395. package/src/chat/ui/AnsiOutput.tsx +18 -0
  396. package/src/chat/ui/BookmarkMarker.tsx +108 -0
  397. package/src/chat/ui/BookmarkSubmenu.tsx +53 -0
  398. package/src/chat/ui/ChatActivity.tsx +198 -0
  399. package/src/chat/ui/ChatReferenceChip.tsx +28 -0
  400. package/src/chat/ui/CodeBlock.tsx +175 -0
  401. package/src/chat/ui/Composer.tsx +1326 -0
  402. package/src/chat/ui/ComposerInput.tsx +187 -0
  403. package/src/chat/ui/DiffPool.tsx +36 -0
  404. package/src/chat/ui/EditDiff.tsx +30 -0
  405. package/src/chat/ui/FadingWords.tsx +18 -0
  406. package/src/chat/ui/ImageView.tsx +159 -0
  407. package/src/chat/ui/LimitState.tsx +165 -0
  408. package/src/chat/ui/Markdown.tsx +258 -0
  409. package/src/chat/ui/MessageActions.tsx +88 -0
  410. package/src/chat/ui/Pickers.tsx +272 -0
  411. package/src/chat/ui/PromptComposer.tsx +119 -0
  412. package/src/chat/ui/QuoteButton.tsx +103 -0
  413. package/src/chat/ui/ResumeCompactionDock.tsx +28 -0
  414. package/src/chat/ui/RunSettings.tsx +546 -0
  415. package/src/chat/ui/Scrubber.tsx +262 -0
  416. package/src/chat/ui/SubagentControls.tsx +66 -0
  417. package/src/chat/ui/SubagentInfo.tsx +67 -0
  418. package/src/chat/ui/SubagentStopButton.tsx +45 -0
  419. package/src/chat/ui/SubagentTimeline.tsx +170 -0
  420. package/src/chat/ui/Timeline.tsx +628 -0
  421. package/src/chat/ui/TimelineMenu.tsx +124 -0
  422. package/src/chat/ui/UnifiedDiff.tsx +99 -0
  423. package/src/chat/ui/UploadThumb.tsx +13 -0
  424. package/src/chat/ui/Welcome.tsx +22 -0
  425. package/src/chat/ui/chips.ts +15 -0
  426. package/src/chat/ui/code-lines.ts +60 -0
  427. package/src/chat/ui/code-streaming.ts +4 -0
  428. package/src/chat/ui/code-theme.ts +15 -0
  429. package/src/chat/ui/composer/chips.ts +43 -0
  430. package/src/chat/ui/composer/editor.ts +118 -0
  431. package/src/chat/ui/composer/insert.ts +22 -0
  432. package/src/chat/ui/composer/keys.ts +144 -0
  433. package/src/chat/ui/diff-theme.ts +23 -0
  434. package/src/chat/ui/file-links.ts +24 -0
  435. package/src/chat/ui/find-reveal.ts +23 -0
  436. package/src/chat/ui/full-diff.ts +25 -0
  437. package/src/chat/ui/icons.tsx +24 -0
  438. package/src/chat/ui/markdown-blocks.ts +123 -0
  439. package/src/chat/ui/quote-selection.ts +53 -0
  440. package/src/chat/ui/rehype-chips.ts +62 -0
  441. package/src/chat/ui/rehype-fade.ts +64 -0
  442. package/src/chat/ui/remark-html-as-text.ts +36 -0
  443. package/src/chat/ui/reply-context.ts +4 -0
  444. package/src/chat/ui/reveal.ts +135 -0
  445. package/src/chat/ui/rows/ForksRow.tsx +79 -0
  446. package/src/chat/ui/rows/MessageRows.tsx +415 -0
  447. package/src/chat/ui/rows/Rows.tsx +81 -0
  448. package/src/chat/ui/rows/SubagentRow.tsx +209 -0
  449. package/src/chat/ui/rows/TaskRow.tsx +91 -0
  450. package/src/chat/ui/rows/WorkRows.tsx +445 -0
  451. package/src/chat/ui/rows/WorkflowRow.tsx +120 -0
  452. package/src/chat/ui/rows/row-rhythm.ts +37 -0
  453. package/src/chat/ui/useToggleSet.ts +39 -0
  454. package/src/host.ts +324 -0
  455. package/src/lazy.tsx +64 -0
  456. package/src/locales/en/agent-chat.json +446 -0
  457. package/src/locales/en/agent-prompts.json +42 -0
  458. package/src/locales/en/agent-providers.json +131 -0
  459. package/src/locales/en/agent-usage.json +131 -0
  460. package/src/locales/nl/agent-chat.json +446 -0
  461. package/src/locales/nl/agent-prompts.json +42 -0
  462. package/src/locales/nl/agent-providers.json +131 -0
  463. package/src/locales/nl/agent-usage.json +131 -0
  464. package/src/locales.ts +33 -0
  465. package/src/mounted-registry.ts +45 -0
  466. package/src/port-transport.ts +146 -0
  467. package/src/prompts/logic/focus.ts +25 -0
  468. package/src/prompts/logic/keys.ts +116 -0
  469. package/src/prompts/logic/prompts.fixtures.ts +84 -0
  470. package/src/prompts/logic/prompts.ts +58 -0
  471. package/src/prompts/logic/subjects.ts +122 -0
  472. package/src/prompts/logic/useFocusAfterAnswer.ts +38 -0
  473. package/src/prompts/logic/usePromptSession.ts +114 -0
  474. package/src/prompts/ui/ApprovalBody.tsx +109 -0
  475. package/src/prompts/ui/PromptActions.tsx +109 -0
  476. package/src/prompts/ui/PromptCard.tsx +101 -0
  477. package/src/prompts/ui/PromptView.tsx +111 -0
  478. package/src/prompts/ui/QuestionBody.tsx +174 -0
  479. package/src/providers/AccountColors.tsx +8 -0
  480. package/src/providers/AccountDetail.tsx +209 -0
  481. package/src/providers/AccountVariables.tsx +126 -0
  482. package/src/providers/AddAccountForm.tsx +121 -0
  483. package/src/providers/CliDetail.tsx +157 -0
  484. package/src/providers/ProvidersPane.tsx +236 -0
  485. package/src/providers/account-actions.ts +67 -0
  486. package/src/providers/parts.tsx +25 -0
  487. package/src/providers/provider-abilities.ts +9 -0
  488. package/src/providers/variables.ts +87 -0
  489. package/src/scope.ts +30 -0
  490. package/src/settings/sections.ts +47 -0
  491. package/src/state/chats.ts +279 -0
  492. package/src/state/provider-accounts.ts +87 -0
  493. package/src/state/providers.ts +50 -0
  494. package/src/state/usage.ts +196 -0
  495. package/src/storage.ts +113 -0
  496. package/src/theme.css +212 -0
  497. package/src/transport.ts +50 -0
  498. package/src/ui/PlainTextarea.tsx +6 -0
  499. package/src/usage/LimitsList.tsx +232 -0
  500. package/src/usage/UsageBreakdown.tsx +210 -0
  501. package/src/usage/UsageChart.tsx +113 -0
  502. package/src/usage/UsageDialog.tsx +20 -0
  503. package/src/usage/UsageLimits.tsx +145 -0
  504. package/src/usage/UsageLimitsCard.tsx +36 -0
  505. package/src/usage/UsagePage.tsx +276 -0
  506. package/src/usage/UsagePane.tsx +52 -0
  507. package/src/usage/UsageSummary.tsx +50 -0
  508. package/src/usage/UsageTiles.tsx +34 -0
  509. package/src/usage/format.ts +71 -0
  510. package/src/usage/limit-groups.ts +119 -0
  511. package/src/usage/limits.ts +71 -0
  512. package/src/usage/money.ts +14 -0
  513. package/src/usage/summary.ts +137 -0
@@ -0,0 +1,29 @@
1
+ import type { ChatAttachmentUpload } from '@adecore/agent-contracts';
2
+ export interface ChatDraft {
3
+ text: string;
4
+ mentions: string[];
5
+ skills: string[];
6
+ chats: string[];
7
+ attachments: ChatAttachmentUpload[];
8
+ quote: string;
9
+ }
10
+ export declare const EMPTY_DRAFT: ChatDraft;
11
+ export declare function isEmptyDraft(draft: ChatDraft): boolean;
12
+ export declare const useDrafts: import("zustand").UseBoundStore<import("zustand").StoreApi<{
13
+ ids: string[];
14
+ }>>;
15
+ export declare function useHasDraft(chatId: string): boolean;
16
+ export declare function readDraft(chatId: string): ChatDraft;
17
+ export declare function writeDraft(chatId: string, draft: ChatDraft): void;
18
+ export declare function joinDraftText(current: string, added: string): string;
19
+ export declare function takeBackIntoDraft(current: ChatDraft, taken: Omit<ChatDraft, 'quote'>): {
20
+ draft: ChatDraft;
21
+ rejected: Array<{
22
+ name: string;
23
+ reason: string;
24
+ }>;
25
+ };
26
+ type DraftTaker = (text: string) => void;
27
+ export declare function takeDraftOffers(chatId: string, take: DraftTaker): () => void;
28
+ export declare function offerDraft(chatId: string, text: string): void;
29
+ export {};
@@ -0,0 +1,116 @@
1
+ import { chatStorageKey, chatStorageLegacyKeys, createChatStore } from '../storage.js';
2
+ import { checkAttachmentLimits, uploadBytes } from './attachments.js';
3
+ import { persistedJson } from './persisted-json.js';
4
+ const storageKey = () => chatStorageKey('drafts');
5
+ export const EMPTY_DRAFT = { text: '', mentions: [], skills: [], chats: [], attachments: [], quote: '' };
6
+ const storage = persistedJson(storageKey, (raw) => (raw ? JSON.parse(raw) : {}), {}, () => chatStorageLegacyKeys('drafts'));
7
+ function readAll() {
8
+ return storage.read();
9
+ }
10
+ function store(drafts) {
11
+ return storage.write(drafts);
12
+ }
13
+ export function isEmptyDraft(draft) {
14
+ return draft.text.trim() === '' && draft.attachments.length === 0 && draft.quote === '';
15
+ }
16
+ /*
17
+ * Which chats hold an unsent prompt, for a dot beside them in a list of chats. The drafts themselves
18
+ * stay in storage: a node that is not on screen has no composer, and this is all anyone else needs.
19
+ */
20
+ export const useDrafts = createChatStore(() => ({ ids: [] }), (store) => store.setState({ ids: Object.keys(readAll()) }));
21
+ export function useHasDraft(chatId) {
22
+ return useDrafts((s) => s.ids.includes(chatId));
23
+ }
24
+ function trackDraft(chatId, held) {
25
+ const { ids } = useDrafts.getState();
26
+ if (ids.includes(chatId) === held) {
27
+ return;
28
+ }
29
+ useDrafts.setState({ ids: held ? [...ids, chatId] : ids.filter((id) => id !== chatId) });
30
+ }
31
+ /* An unsent prompt per chat node, kept across reloads so a half-written message is never lost. */
32
+ export function readDraft(chatId) {
33
+ const record = readAll()[chatId];
34
+ return record
35
+ ? {
36
+ text: record.text,
37
+ mentions: record.mentions ?? [],
38
+ skills: record.skills ?? [],
39
+ chats: record.chats ?? [],
40
+ attachments: record.attachments ?? [],
41
+ quote: record.quote ?? ''
42
+ }
43
+ : EMPTY_DRAFT;
44
+ }
45
+ export function writeDraft(chatId, draft) {
46
+ const drafts = readAll();
47
+ trackDraft(chatId, !isEmptyDraft(draft));
48
+ if (isEmptyDraft(draft)) {
49
+ delete drafts[chatId];
50
+ store(drafts);
51
+ return;
52
+ }
53
+ drafts[chatId] = {
54
+ text: draft.text,
55
+ mentions: draft.mentions,
56
+ skills: draft.skills,
57
+ chats: draft.chats,
58
+ attachments: draft.attachments,
59
+ quote: draft.quote
60
+ };
61
+ if (store(drafts)) {
62
+ return;
63
+ }
64
+ // A file can outgrow the storage quota; the text is the part worth keeping then.
65
+ drafts[chatId] = { text: draft.text, mentions: draft.mentions, skills: draft.skills, chats: draft.chats, quote: draft.quote };
66
+ store(drafts);
67
+ }
68
+ /* Text handed to a draft from outside the composer goes under what was already typed, never over it. */
69
+ export function joinDraftText(current, added) {
70
+ return current.trim() === '' ? added : `${current.replace(/\s+$/, '')}\n\n${added}`;
71
+ }
72
+ function union(first, second) {
73
+ return [...first, ...second.filter((entry) => !first.includes(entry))];
74
+ }
75
+ /*
76
+ * A queued message taken back to edit goes above what was typed since. Its files join the draft's as
77
+ * far as the limits let them, and the rest come back rejected, the way a dropped file would. A quote
78
+ * it was sent with is part of its text; the draft keeps the one it holds.
79
+ */
80
+ export function takeBackIntoDraft(current, taken) {
81
+ const checked = checkAttachmentLimits(current.attachments.length, taken.attachments.map((upload) => ({ name: upload.name, mime: upload.mime, bytes: uploadBytes(upload), upload })), current.attachments.reduce((bytes, upload) => bytes + uploadBytes(upload), 0));
82
+ return {
83
+ draft: {
84
+ text: current.text.trim() === '' ? taken.text : joinDraftText(taken.text, current.text),
85
+ mentions: union(taken.mentions, current.mentions),
86
+ skills: union(taken.skills, current.skills),
87
+ chats: union(taken.chats, current.chats),
88
+ attachments: [...checked.accepted.map((entry) => entry.upload), ...current.attachments],
89
+ quote: current.quote
90
+ },
91
+ rejected: checked.rejected
92
+ };
93
+ }
94
+ /* The composers on screen, by chat. One that is not mounted reads what was offered from storage when it is. */
95
+ const takers = new Map();
96
+ export function takeDraftOffers(chatId, take) {
97
+ takers.set(chatId, take);
98
+ return () => {
99
+ if (takers.get(chatId) === take) {
100
+ takers.delete(chatId);
101
+ }
102
+ };
103
+ }
104
+ /*
105
+ * Puts text in a chat's prompt without sending it: the person reads it and presses Enter. A mounted
106
+ * composer owns its draft and writes it back to storage itself, so it has to be the one to take it.
107
+ */
108
+ export function offerDraft(chatId, text) {
109
+ const take = takers.get(chatId);
110
+ if (take) {
111
+ take(text);
112
+ return;
113
+ }
114
+ const current = readDraft(chatId);
115
+ writeDraft(chatId, { ...current, text: joinDraftText(current.text, text) });
116
+ }
@@ -0,0 +1,2 @@
1
+ export declare function useForkedTurns(chatId: string): ReadonlySet<string>;
2
+ export declare function useForkIdsAfter(chatId: string, turnId: string): string[];
@@ -0,0 +1,28 @@
1
+ import { useMemo } from 'react';
2
+ import { forkIdsAfter, forkedTurnIds } from './logic/fork.js';
3
+ import { useChatScope } from '../scope.js';
4
+ import { useChats } from '../state/chats.js';
5
+ /* The chats this client holds of one host, which is where the forks it knows of are. */
6
+ function* forkInfosOn(byKey, owns) {
7
+ for (const [key, state] of Object.entries(byKey)) {
8
+ if (state.info.forkOf !== undefined && owns(key)) {
9
+ yield state.info;
10
+ }
11
+ }
12
+ }
13
+ /* Selectors answer a joined string, never a new array or set, and split it again in a memo. */
14
+ function splitIds(joined) {
15
+ return joined === '' ? [] : joined.split('\n');
16
+ }
17
+ /* The turns of this chat a fork went on after, for the thread to put a line under. */
18
+ export function useForkedTurns(chatId) {
19
+ const { owns } = useChatScope();
20
+ const joined = useChats((s) => [...forkedTurnIds(forkInfosOn(s.byKey, owns), chatId)].join('\n'));
21
+ return useMemo(() => new Set(splitIds(joined)), [joined]);
22
+ }
23
+ /* The forks that went on after this turn of this chat. */
24
+ export function useForkIdsAfter(chatId, turnId) {
25
+ const { owns } = useChatScope();
26
+ const joined = useChats((s) => forkIdsAfter(forkInfosOn(s.byKey, owns), chatId, turnId).join('\n'));
27
+ return useMemo(() => splitIds(joined), [joined]);
28
+ }
@@ -0,0 +1,12 @@
1
+ export declare const PROMPT_MAX_CHARS = 120000;
2
+ export declare const PROMPT_COUNTER_FROM = 100000;
3
+ export declare const PASTE_ATTACHMENT_FROM_BYTES: number;
4
+ export declare function pasteBecomesAttachment(text: string): boolean;
5
+ export declare function pastedTextName(taken: string[]): string;
6
+ export interface PromptGuard {
7
+ count: number;
8
+ visible: boolean;
9
+ tooLong: boolean;
10
+ }
11
+ export declare function promptGuard(text: string): PromptGuard;
12
+ export declare function usableSlashCommands(names: string[]): string[];
@@ -0,0 +1,69 @@
1
+ // What a CLI still accepts without the turn becoming slower than the answer is worth; a Claude user
2
+ // frame this large is legal but sluggish.
3
+ export const PROMPT_MAX_CHARS = 120000;
4
+ // Below this the counter would only be noise; a prompt this long is already unusual.
5
+ export const PROMPT_COUNTER_FROM = 100000;
6
+ /*
7
+ * From this many bytes a paste of text becomes a file beside the prompt instead of text in it. A log
8
+ * or a file that large is something to read with a tool, not words for the model to take in on
9
+ * every turn, and in the textarea it buries what the person actually wants to say.
10
+ */
11
+ export const PASTE_ATTACHMENT_FROM_BYTES = 32 * 1024;
12
+ const encoder = new TextEncoder();
13
+ /* Whether pasted text is large enough to go in as an attachment. Bytes, since that is what the file weighs. */
14
+ export function pasteBecomesAttachment(text) {
15
+ return text.length * 3 >= PASTE_ATTACHMENT_FROM_BYTES && encoder.encode(text).length >= PASTE_ATTACHMENT_FROM_BYTES;
16
+ }
17
+ /* A name for pasted text that no attachment of the draft has yet: paste-1.txt, paste-2.txt, ... */
18
+ export function pastedTextName(taken) {
19
+ const names = new Set(taken);
20
+ let index = 1;
21
+ while (names.has(`paste-${index}.txt`)) {
22
+ index += 1;
23
+ }
24
+ return `paste-${index}.txt`;
25
+ }
26
+ export function promptGuard(text) {
27
+ return {
28
+ count: text.length,
29
+ visible: text.length >= PROMPT_COUNTER_FROM,
30
+ tooLong: text.length > PROMPT_MAX_CHARS
31
+ };
32
+ }
33
+ /*
34
+ * Commands the CLI lists because its own terminal has them: they change the terminal, the login or
35
+ * the config, or they end a session the chat node does not own.
36
+ */
37
+ const TUI_ONLY = new Set([
38
+ 'bug',
39
+ 'color',
40
+ 'config',
41
+ 'doctor',
42
+ 'exit',
43
+ 'heapdump',
44
+ 'help',
45
+ 'hooks',
46
+ 'ide',
47
+ 'install-github-app',
48
+ 'keybindings',
49
+ 'login',
50
+ 'logout',
51
+ 'migrate-installer',
52
+ 'privacy-settings',
53
+ 'quit',
54
+ 'release-notes',
55
+ 'reload-plugins',
56
+ 'reload-skills',
57
+ 'rename',
58
+ 'resume',
59
+ 'status',
60
+ 'statusline',
61
+ 'terminal-setup',
62
+ 'theme',
63
+ 'upgrade',
64
+ 'vim'
65
+ ]);
66
+ /* The commands of the CLI's list that mean something in a chat node. */
67
+ export function usableSlashCommands(names) {
68
+ return names.filter((name) => !TUI_ONLY.has(name));
69
+ }
@@ -0,0 +1,13 @@
1
+ import type { CSSProperties } from 'react';
2
+ export interface AnsiToken {
3
+ content: string;
4
+ style: CSSProperties;
5
+ }
6
+ export declare function stripAnsi(text: string): string;
7
+ export declare function parseAnsi(text: string, options?: {
8
+ limit?: number;
9
+ tailLines?: number;
10
+ }): {
11
+ tokens: AnsiToken[];
12
+ omitted: number;
13
+ };
@@ -0,0 +1,185 @@
1
+ const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
2
+ const COLOR_LEVELS = [0, 95, 135, 175, 215, 255];
3
+ // Consume non-color controls too, so cursor commands and OSC links never become visible text or HTML.
4
+ /* oxlint-disable no-control-regex */
5
+ const ESCAPES = /(?:\x1b\[|\x9b)([0-?]*[ -/]*)([@-~]|$)|(?:\x1b\]|\x9d)[^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c|$)|\x1b[PX^_][^\x1b\x9c]*(?:\x1b\\|\x9c|$)|\x1b[ -/]*[@-~]|\x1b$|[\x00-\x08\x0b\x0c\x0e-\x1a\x1c-\x1f\x7f-\x9f]/g;
6
+ /* oxlint-enable no-control-regex */
7
+ export function stripAnsi(text) {
8
+ return text.replace(ESCAPES, '');
9
+ }
10
+ function rgb(channels) {
11
+ if (channels.length !== 3 || channels.some((channel) => !Number.isInteger(channel) || channel < 0 || channel > 255)) {
12
+ return undefined;
13
+ }
14
+ return `rgb(${channels.join(' ')})`;
15
+ }
16
+ function paletteColor(index) {
17
+ if (!Number.isInteger(index) || index < 0 || index > 255) {
18
+ return undefined;
19
+ }
20
+ if (index < 16) {
21
+ return `var(--term-ansi-${index >= 8 ? 'bright-' : ''}${COLORS[index % 8]})`;
22
+ }
23
+ if (index < 232) {
24
+ const cube = index - 16;
25
+ return rgb([COLOR_LEVELS[Math.floor(cube / 36)], COLOR_LEVELS[Math.floor(cube / 6) % 6], COLOR_LEVELS[cube % 6]]);
26
+ }
27
+ const gray = 8 + (index - 232) * 10;
28
+ return rgb([gray, gray, gray]);
29
+ }
30
+ function extendedColor(parameters) {
31
+ const mode = parameters[0];
32
+ if (mode === '5' && parameters.length === 2 && parameters[1] !== '') {
33
+ return paletteColor(Number(parameters[1]));
34
+ }
35
+ if (mode === '2') {
36
+ // Colon-form RGB may include an empty color-space parameter before its three channels.
37
+ const channels = parameters.length === 5 ? parameters.slice(2) : parameters.slice(1);
38
+ return rgb(channels.map((channel) => (channel === '' ? NaN : Number(channel))));
39
+ }
40
+ return undefined;
41
+ }
42
+ function applyRendition(state, parameters) {
43
+ if (!/^[\d;:]*$/.test(parameters)) {
44
+ return state;
45
+ }
46
+ const values = parameters.split(';');
47
+ for (let i = 0; i < values.length; i++) {
48
+ const parts = values[i].split(':');
49
+ const code = Number(parts[0]);
50
+ if (code === 38 || code === 48) {
51
+ let color;
52
+ if (parts.length > 1) {
53
+ color = extendedColor(parts.slice(1));
54
+ }
55
+ else {
56
+ const count = values[i + 1] === '2' ? 4 : values[i + 1] === '5' ? 2 : 1;
57
+ color = extendedColor(values.slice(i + 1, i + 1 + count));
58
+ i += count;
59
+ }
60
+ if (color !== undefined) {
61
+ state[code === 38 ? 'foreground' : 'background'] = color;
62
+ }
63
+ }
64
+ else if (code >= 30 && code <= 37) {
65
+ state.foreground = paletteColor(code - 30);
66
+ }
67
+ else if (code >= 40 && code <= 47) {
68
+ state.background = paletteColor(code - 40);
69
+ }
70
+ else if (code >= 90 && code <= 97) {
71
+ state.foreground = paletteColor(code - 90 + 8);
72
+ }
73
+ else if (code >= 100 && code <= 107) {
74
+ state.background = paletteColor(code - 100 + 8);
75
+ }
76
+ else {
77
+ switch (code) {
78
+ case 0:
79
+ state = {};
80
+ break;
81
+ case 1:
82
+ state.bold = true;
83
+ break;
84
+ case 2:
85
+ state.dim = true;
86
+ break;
87
+ case 3:
88
+ state.italic = true;
89
+ break;
90
+ case 4:
91
+ state.underline = parts[1] !== '0';
92
+ break;
93
+ case 7:
94
+ state.inverse = true;
95
+ break;
96
+ case 9:
97
+ state.strike = true;
98
+ break;
99
+ case 22:
100
+ state.bold = false;
101
+ state.dim = false;
102
+ break;
103
+ case 23:
104
+ state.italic = false;
105
+ break;
106
+ case 24:
107
+ state.underline = false;
108
+ break;
109
+ case 27:
110
+ state.inverse = false;
111
+ break;
112
+ case 29:
113
+ state.strike = false;
114
+ break;
115
+ case 39:
116
+ state.foreground = undefined;
117
+ break;
118
+ case 49:
119
+ state.background = undefined;
120
+ break;
121
+ }
122
+ }
123
+ }
124
+ return state;
125
+ }
126
+ function styleOf(state) {
127
+ const style = {};
128
+ const color = state.inverse ? (state.background ?? 'var(--chat-code-bg)') : state.foreground;
129
+ const background = state.inverse ? (state.foreground ?? 'var(--chat-output)') : state.background;
130
+ if (color !== undefined || state.dim) {
131
+ style.color = state.dim ? `color-mix(in srgb, ${color ?? 'currentColor'} 65%, transparent)` : color;
132
+ }
133
+ if (background !== undefined) {
134
+ style.backgroundColor = background;
135
+ }
136
+ if (state.bold) {
137
+ style.fontWeight = 'bold';
138
+ }
139
+ if (state.italic) {
140
+ style.fontStyle = 'italic';
141
+ }
142
+ if (state.underline || state.strike) {
143
+ style.textDecorationLine = [state.underline && 'underline', state.strike && 'line-through'].filter(Boolean).join(' ');
144
+ }
145
+ return style;
146
+ }
147
+ export function parseAnsi(text, options = {}) {
148
+ const tokens = [];
149
+ let state = {};
150
+ let position = 0;
151
+ for (const match of text.matchAll(ESCAPES)) {
152
+ if (match.index > position) {
153
+ tokens.push({ content: text.slice(position, match.index), style: styleOf(state) });
154
+ }
155
+ if (match[2] === 'm') {
156
+ state = applyRendition(state, match[1]);
157
+ }
158
+ position = match.index + match[0].length;
159
+ }
160
+ if (position < text.length) {
161
+ tokens.push({ content: text.slice(position), style: styleOf(state) });
162
+ }
163
+ const plain = tokens.map((token) => token.content).join('');
164
+ let start = 0;
165
+ let end = plain.length;
166
+ if (options.tailLines !== undefined) {
167
+ if (plain.endsWith('\n')) {
168
+ end--;
169
+ }
170
+ const tail = plain.slice(0, end).split('\n').slice(-options.tailLines).join('\n');
171
+ start = end - tail.length;
172
+ }
173
+ const omitted = options.limit === undefined ? 0 : Math.max(0, end - start - options.limit);
174
+ end -= omitted;
175
+ let offset = 0;
176
+ return {
177
+ tokens: tokens.flatMap((token) => {
178
+ const from = Math.max(0, start - offset);
179
+ const to = Math.min(token.content.length, end - offset);
180
+ offset += token.content.length;
181
+ return to > from ? [{ ...token, content: token.content.slice(from, to) }] : [];
182
+ }),
183
+ omitted
184
+ };
185
+ }
@@ -0,0 +1 @@
1
+ export declare function toggleChoice(picked: string[], label: string): string[];
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Add or remove one choice of a multi select question. The picks stay a list here because a label
3
+ * may hold the separator itself: joined too early, such a label no longer matches itself and the
4
+ * choice would read as unpicked on screen.
5
+ */
6
+ export function toggleChoice(picked, label) {
7
+ return picked.includes(label) ? picked.filter((choice) => choice !== label) : [...picked, label];
8
+ }
@@ -0,0 +1,5 @@
1
+ import type { ChatBookmark, ChatItem } from '@adecore/agent-contracts';
2
+ import type { TimelineRow } from './timeline.js';
3
+ export declare function bookmarkLabel(bookmark: ChatBookmark): string;
4
+ export declare function bookmarksInThreadOrder(bookmarks: readonly ChatBookmark[], order: readonly string[]): ChatBookmark[];
5
+ export declare function bookmarkRows(rows: readonly TimelineRow[], bookmarks: readonly ChatBookmark[], items: Readonly<Record<string, ChatItem>>): Map<string, ChatBookmark>;
@@ -0,0 +1,33 @@
1
+ /* What a list calls a bookmark: its name, else the start of the message. */
2
+ export function bookmarkLabel(bookmark) {
3
+ return bookmark.name ?? bookmark.excerpt;
4
+ }
5
+ /* The bookmarks in the order of the thread; one whose message this client does not hold goes last. */
6
+ export function bookmarksInThreadOrder(bookmarks, order) {
7
+ const places = new Map(order.map((id, index) => [id, index]));
8
+ const place = (bookmark) => places.get(bookmark.itemId) ?? order.length;
9
+ return [...bookmarks].sort((left, right) => place(left) - place(right) || left.createdAt - right.createdAt);
10
+ }
11
+ /*
12
+ * Which row each bookmark is drawn at, by row id: the message's own row, or the fold of a settled
13
+ * turn that hides a reply before its last one. A bookmark on a message this client does not hold
14
+ * has no row.
15
+ */
16
+ export function bookmarkRows(rows, bookmarks, items) {
17
+ const rowIds = new Set(rows.map((row) => row.id));
18
+ const folds = new Map();
19
+ for (const row of rows) {
20
+ if (row.kind === 'turn-fold') {
21
+ folds.set(row.turn.id, row.id);
22
+ }
23
+ }
24
+ const marked = new Map();
25
+ for (const bookmark of bookmarks) {
26
+ const turnId = items[bookmark.itemId]?.turnId ?? null;
27
+ const rowId = rowIds.has(bookmark.itemId) ? bookmark.itemId : turnId === null ? undefined : folds.get(turnId);
28
+ if (rowId !== undefined && !marked.has(rowId)) {
29
+ marked.set(rowId, bookmark);
30
+ }
31
+ }
32
+ return marked;
33
+ }
@@ -0,0 +1,12 @@
1
+ import type { ChatContextBreakdown, ChatUsage, ModelOptionDescriptor } from '@adecore/agent-contracts';
2
+ export declare const CONTEXT_OPTION = "contextWindow";
3
+ export type ContextPart = keyof ChatContextBreakdown;
4
+ export declare const CONTEXT_PARTS: readonly ContextPart[];
5
+ export interface ContextSegment {
6
+ part: ContextPart;
7
+ tokens: number;
8
+ fraction: number;
9
+ }
10
+ export declare function contextFraction(usage: ChatUsage): number;
11
+ export declare function contextSegments(usage: ChatUsage): ContextSegment[] | null;
12
+ export declare function orderOptions(options: readonly ModelOptionDescriptor[]): ModelOptionDescriptor[];
@@ -0,0 +1,21 @@
1
+ export const CONTEXT_OPTION = 'contextWindow';
2
+ export const CONTEXT_PARTS = ['toolOutput', 'filesRead', 'conversation', 'system'];
3
+ export function contextFraction(usage) {
4
+ return usage.contextWindow ? Math.min(1, usage.contextTokens / usage.contextWindow) : 0;
5
+ }
6
+ /* The stretches of the bar, in the legend's order; null from a host that does not estimate, which draws the plain bar. */
7
+ export function contextSegments(usage) {
8
+ const breakdown = usage.breakdown;
9
+ if (!breakdown || usage.contextTokens === 0) {
10
+ return null;
11
+ }
12
+ const whole = Math.max(usage.contextWindow ?? 0, usage.contextTokens);
13
+ return CONTEXT_PARTS.map((part) => ({ part, tokens: breakdown[part], fraction: breakdown[part] / whole }));
14
+ }
15
+ /*
16
+ * The model's own knobs with the context window last: its details sit in the group right under it,
17
+ * and a switch like Fast mode belongs with the reasoning choice above rather than below the size.
18
+ */
19
+ export function orderOptions(options) {
20
+ return [...options.filter((option) => option.id !== CONTEXT_OPTION), ...options.filter((option) => option.id === CONTEXT_OPTION)];
21
+ }
@@ -0,0 +1,45 @@
1
+ import type { AgentKind, ChatForkPayload, ChatInfo, ChatItem, ModelSelection } from '@adecore/agent-contracts';
2
+ import type { TimelineRow } from './timeline.js';
3
+ export declare const FORKABLE_PROVIDERS: ReadonlySet<string>;
4
+ export interface ForkPoint {
5
+ turnId: string;
6
+ number: number;
7
+ total: number;
8
+ counted: boolean;
9
+ last: boolean;
10
+ prompt: string | null;
11
+ }
12
+ export declare function forkRefusal(info: ChatInfo | null, turn: ChatItem | undefined): string | null;
13
+ export declare function summaryRefusal(state: {
14
+ busy: boolean;
15
+ originalPresent: boolean;
16
+ }): string | null;
17
+ export declare function forkIdsAfter(infos: Iterable<ChatInfo>, chatId: string, turnId: string): string[];
18
+ export declare function forkedTurnIds(infos: Iterable<ChatInfo>, chatId: string): Set<string>;
19
+ export declare function lastSettledTurn(items: Record<string, ChatItem>, order: readonly string[]): string | null;
20
+ export declare function forkPointOf(items: Record<string, ChatItem>, order: readonly string[], turnId: string, whole: boolean): ForkPoint | null;
21
+ export declare function forkPointLabel(point: ForkPoint, maxPrompt?: number): string;
22
+ export declare function turnIdOfRow(row: TimelineRow): string | null;
23
+ export type ForkShape = 'node' | 'view';
24
+ export declare function forkShapes(origin: ForkShape): ForkShape[];
25
+ export interface ForkWorktreeChoice {
26
+ branch: string;
27
+ filesAfterTurn: boolean;
28
+ }
29
+ export interface ForkCliChoice {
30
+ provider: AgentKind;
31
+ selection: ModelSelection;
32
+ account?: string;
33
+ }
34
+ export declare function forkPayload(input: {
35
+ chatId: string;
36
+ turnId: string;
37
+ title: string;
38
+ shape: ForkShape;
39
+ worktree?: ForkWorktreeChoice | null;
40
+ cli?: {
41
+ original: ForkCliChoice;
42
+ chosen: ForkCliChoice;
43
+ };
44
+ }): ChatForkPayload;
45
+ export declare function branchRefusal(branch: string, taken: readonly string[]): string | null;