@adecore/agents-react 0.38.0 → 0.40.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 (351) hide show
  1. package/dist/agents/AgentModelLabel.d.ts +10 -0
  2. package/dist/agents/AgentModelLabel.js +98 -0
  3. package/dist/agents/model-name.js +2 -1
  4. package/dist/agents/provider-paths.d.ts +2 -1
  5. package/dist/agents/provider-paths.js +7 -3
  6. package/dist/chat/account-choice.js +57 -28
  7. package/dist/chat/bookmarks.js +2 -1
  8. package/dist/chat/drafts.d.ts +0 -1
  9. package/dist/chat/drafts.js +9 -28
  10. package/dist/chat/logic/picker-entries.js +2 -8
  11. package/dist/chat/logic/resume-compaction.js +2 -5
  12. package/dist/chat/logic/timeline-copy.js +2 -8
  13. package/dist/chat/logic/timeline.js +9 -10
  14. package/dist/chat/logic/workflow.js +2 -4
  15. package/dist/chat/subagent-conversation.js +2 -1
  16. package/dist/chat/ui/Composer.js +385 -360
  17. package/dist/chat/ui/GoalDock.js +2 -1
  18. package/dist/chat/ui/LimitState.js +4 -6
  19. package/dist/chat/ui/Pickers.d.ts +2 -1
  20. package/dist/chat/ui/Pickers.js +126 -123
  21. package/dist/chat/ui/PromptEditor.d.ts +19 -0
  22. package/dist/chat/ui/PromptEditor.js +115 -0
  23. package/dist/chat/ui/Timeline.d.ts +2 -1
  24. package/dist/chat/ui/Timeline.js +13 -1
  25. package/dist/chat/ui/composer/ComposerControls.d.ts +3 -0
  26. package/dist/chat/ui/composer/ComposerControls.js +235 -38
  27. package/dist/chat/ui/composer/key-handler.d.ts +1 -1
  28. package/dist/chat/ui/composer/key-handler.js +3 -11
  29. package/dist/chat/ui/composer/prompt-picks.d.ts +4 -0
  30. package/dist/chat/ui/composer/prompt-picks.js +14 -0
  31. package/dist/chat/ui/composer/use-composer-menus.d.ts +4 -49
  32. package/dist/chat/ui/composer/use-composer-menus.js +65 -519
  33. package/dist/chat/ui/composer/use-continuable-turn.js +0 -1
  34. package/dist/chat/ui/composer/use-notice.js +2 -1
  35. package/dist/chat/ui/composer/use-prompt-history.js +1 -1
  36. package/dist/chat/ui/composer/use-prompt-menus.d.ts +73 -0
  37. package/dist/chat/ui/composer/use-prompt-menus.js +499 -0
  38. package/dist/chat/ui/composer/use-take-back.js +2 -2
  39. package/dist/chat/ui/diff/ApprovalReview.js +1 -1
  40. package/dist/chat/ui/highlighter.d.ts +0 -6
  41. package/dist/chat/ui/highlighter.js +0 -12
  42. package/dist/chat/ui/icons.d.ts +0 -1
  43. package/dist/chat/ui/icons.js +0 -3
  44. package/dist/chat/ui/index.d.ts +3 -0
  45. package/dist/chat/ui/index.js +2 -0
  46. package/dist/chat/ui/rows/MessageRows.js +2 -5
  47. package/dist/chat/ui/rows/row-rhythm.js +2 -5
  48. package/dist/chat/ui/theme-watch.js +3 -7
  49. package/dist/host-hooks.d.ts +2 -1
  50. package/dist/host-hooks.js +6 -0
  51. package/dist/host.d.ts +17 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/locales/en/agent-chat.d.ts +1 -0
  54. package/dist/locales/en/agent-chat.js +1 -0
  55. package/dist/locales/nl/agent-chat.d.ts +1 -0
  56. package/dist/locales/nl/agent-chat.js +1 -0
  57. package/dist/prompts/logic/usePromptSession.js +2 -1
  58. package/dist/providers/AddAccountForm.js +2 -1
  59. package/dist/providers/CliDetail.js +104 -130
  60. package/dist/providers/account-actions.js +6 -9
  61. package/dist/providers/index.d.ts +1 -0
  62. package/dist/providers/index.js +1 -0
  63. package/dist/state/chats.d.ts +1 -0
  64. package/dist/state/chats.js +6 -11
  65. package/dist/state/provider-accounts.d.ts +1 -1
  66. package/dist/state/provider-accounts.js +2 -8
  67. package/dist/theme.css +3 -0
  68. package/dist/transport.d.ts +2 -0
  69. package/dist/transport.js +14 -0
  70. package/dist/usage/ChartLogo.d.ts +5 -0
  71. package/dist/usage/ChartLogo.js +48 -0
  72. package/dist/usage/LimitsList.js +6 -16
  73. package/dist/usage/UsageBreakdown.js +17 -40
  74. package/dist/usage/UsageLimits.js +183 -211
  75. package/dist/usage/UsagePage.js +3 -17
  76. package/dist/usage/UsageSummary.js +4 -9
  77. package/dist/usage/limits.js +16 -31
  78. package/dist/usage/summary.d.ts +1 -1
  79. package/dist/usage/summary.js +3 -5
  80. package/package.json +26 -26
  81. package/src/agents/AccountDot.tsx +1 -0
  82. package/src/agents/AgentIcon.tsx +2 -0
  83. package/src/agents/AgentModelLabel.tsx +38 -0
  84. package/src/agents/ModelOptionControl.tsx +8 -0
  85. package/src/agents/account-limits.ts +3 -0
  86. package/src/agents/accounts.ts +12 -0
  87. package/src/agents/model-name.ts +13 -1
  88. package/src/agents/model-options.ts +2 -0
  89. package/src/agents/model-requirement.ts +4 -0
  90. package/src/agents/option-words.ts +2 -0
  91. package/src/agents/provider-paths.ts +8 -3
  92. package/src/agents/status-look.ts +1 -0
  93. package/src/chat/account-choice.ts +25 -19
  94. package/src/chat/actions.ts +5 -0
  95. package/src/chat/attachments.ts +8 -0
  96. package/src/chat/bookmarks.ts +13 -1
  97. package/src/chat/chat-client.ts +63 -0
  98. package/src/chat/chat-references.ts +3 -0
  99. package/src/chat/composer-effort.ts +5 -0
  100. package/src/chat/composer-send.ts +4 -0
  101. package/src/chat/drafts.ts +21 -17
  102. package/src/chat/forks.ts +4 -0
  103. package/src/chat/guards.ts +2 -0
  104. package/src/chat/index.ts +7 -0
  105. package/src/chat/logic/ansi.ts +47 -0
  106. package/src/chat/logic/bookmarks.ts +7 -0
  107. package/src/chat/logic/command-looks.ts +29 -0
  108. package/src/chat/logic/context-usage.ts +3 -0
  109. package/src/chat/logic/continue-after-stop.ts +5 -0
  110. package/src/chat/logic/effort.ts +4 -0
  111. package/src/chat/logic/embedded-code.ts +63 -0
  112. package/src/chat/logic/fork.ts +22 -0
  113. package/src/chat/logic/generated-image.ts +7 -0
  114. package/src/chat/logic/goal.ts +7 -0
  115. package/src/chat/logic/handback.ts +2 -0
  116. package/src/chat/logic/limit.ts +8 -0
  117. package/src/chat/logic/picker-entries.ts +16 -4
  118. package/src/chat/logic/resume-compaction.ts +22 -5
  119. package/src/chat/logic/scrubber.ts +38 -5
  120. package/src/chat/logic/thought.ts +5 -0
  121. package/src/chat/logic/thread-cards.ts +6 -0
  122. package/src/chat/logic/timeline-copy.ts +4 -9
  123. package/src/chat/logic/timeline-target.ts +15 -0
  124. package/src/chat/logic/timeline.ts +113 -10
  125. package/src/chat/logic/tools.ts +30 -0
  126. package/src/chat/logic/visual-height.ts +5 -0
  127. package/src/chat/logic/visual-viewport.ts +1 -0
  128. package/src/chat/logic/welcome.ts +3 -0
  129. package/src/chat/logic/workflow.ts +26 -7
  130. package/src/chat/mentions.ts +56 -0
  131. package/src/chat/pending-prompts.ts +16 -0
  132. package/src/chat/persisted-json.ts +15 -0
  133. package/src/chat/preferences.ts +16 -0
  134. package/src/chat/prompt-hold.ts +2 -0
  135. package/src/chat/quote.ts +7 -0
  136. package/src/chat/reading-width.ts +1 -0
  137. package/src/chat/recent-messages.ts +5 -0
  138. package/src/chat/resume-compaction-dismissals.ts +1 -0
  139. package/src/chat/stash.ts +12 -0
  140. package/src/chat/subagent-conversation.ts +24 -4
  141. package/src/chat/subagent-list.ts +14 -0
  142. package/src/chat/subagent-support.ts +1 -0
  143. package/src/chat/subagent-view.ts +9 -0
  144. package/src/chat/thumbnails.ts +14 -0
  145. package/src/chat/timeline-flash.ts +2 -0
  146. package/src/chat/timeline-scroll.ts +23 -0
  147. package/src/chat/ui/AccountPill.tsx +4 -0
  148. package/src/chat/ui/AnsiOutput.tsx +1 -0
  149. package/src/chat/ui/BookmarkMarker.tsx +5 -0
  150. package/src/chat/ui/BookmarkSubmenu.tsx +1 -0
  151. package/src/chat/ui/ChatActivity.tsx +13 -0
  152. package/src/chat/ui/CodeBlock.tsx +8 -0
  153. package/src/chat/ui/Composer.tsx +27 -3
  154. package/src/chat/ui/ComposerInput.tsx +22 -0
  155. package/src/chat/ui/DiffPool.tsx +3 -0
  156. package/src/chat/ui/EditDiff.tsx +5 -0
  157. package/src/chat/ui/GoalDock.tsx +13 -1
  158. package/src/chat/ui/ImageView.tsx +11 -0
  159. package/src/chat/ui/LimitState.tsx +23 -6
  160. package/src/chat/ui/Markdown.tsx +41 -0
  161. package/src/chat/ui/MermaidBlock.tsx +16 -0
  162. package/src/chat/ui/MessageActions.tsx +8 -0
  163. package/src/chat/ui/ModelMarks.tsx +1 -0
  164. package/src/chat/ui/Pickers.tsx +30 -1
  165. package/src/chat/ui/PromptComposer.tsx +2 -0
  166. package/src/chat/ui/PromptEditor.tsx +136 -0
  167. package/src/chat/ui/QuoteButton.tsx +12 -0
  168. package/src/chat/ui/ReferenceChip.tsx +3 -0
  169. package/src/chat/ui/ResumeCompactionDock.tsx +1 -0
  170. package/src/chat/ui/RowTime.tsx +1 -0
  171. package/src/chat/ui/RunSettings.tsx +38 -0
  172. package/src/chat/ui/Scrubber.tsx +14 -0
  173. package/src/chat/ui/SessionLine.tsx +1 -0
  174. package/src/chat/ui/ShellCommand.tsx +32 -0
  175. package/src/chat/ui/SubagentControls.tsx +7 -0
  176. package/src/chat/ui/SubagentInfo.tsx +1 -0
  177. package/src/chat/ui/SubagentStopButton.tsx +6 -0
  178. package/src/chat/ui/SubagentTimeline.tsx +10 -0
  179. package/src/chat/ui/Timeline.tsx +141 -1
  180. package/src/chat/ui/TimelineMenu.tsx +5 -0
  181. package/src/chat/ui/UnifiedDiff.tsx +6 -0
  182. package/src/chat/ui/UploadThumb.tsx +2 -0
  183. package/src/chat/ui/VisualDialogs.tsx +3 -0
  184. package/src/chat/ui/VisualFrame.tsx +15 -0
  185. package/src/chat/ui/Welcome.tsx +1 -0
  186. package/src/chat/ui/chip-clipboard.ts +20 -0
  187. package/src/chat/ui/code-lines.ts +14 -0
  188. package/src/chat/ui/code-theme.ts +1 -0
  189. package/src/chat/ui/composer/ComposerControls.tsx +70 -15
  190. package/src/chat/ui/composer/ComposerMenu.tsx +12 -0
  191. package/src/chat/ui/composer/DraftParts.tsx +2 -0
  192. package/src/chat/ui/composer/QueuedMessages.tsx +4 -0
  193. package/src/chat/ui/composer/chip-paste.ts +16 -0
  194. package/src/chat/ui/composer/chips.ts +6 -0
  195. package/src/chat/ui/composer/editor.ts +9 -0
  196. package/src/chat/ui/composer/insert.ts +2 -0
  197. package/src/chat/ui/composer/key-handler.ts +42 -9
  198. package/src/chat/ui/composer/keys.ts +23 -0
  199. package/src/chat/ui/composer/placeholder.ts +6 -0
  200. package/src/chat/ui/composer/prompt-picks.ts +18 -0
  201. package/src/chat/ui/composer/surface.ts +5 -0
  202. package/src/chat/ui/composer/use-chat-controls.ts +13 -0
  203. package/src/chat/ui/composer/use-compaction-offer.ts +3 -0
  204. package/src/chat/ui/composer/use-composer-menus.ts +20 -275
  205. package/src/chat/ui/composer/use-composer-submit.ts +27 -0
  206. package/src/chat/ui/composer/use-continuable-turn.ts +3 -5
  207. package/src/chat/ui/composer/use-draft-files.ts +24 -0
  208. package/src/chat/ui/composer/use-effort-stepper.ts +8 -0
  209. package/src/chat/ui/composer/use-notice.ts +4 -1
  210. package/src/chat/ui/composer/use-pending-requests.ts +3 -0
  211. package/src/chat/ui/composer/use-prompt-history.ts +20 -11
  212. package/src/chat/ui/composer/use-prompt-hold.ts +3 -0
  213. package/src/chat/ui/composer/use-prompt-menus.ts +361 -0
  214. package/src/chat/ui/composer/use-take-back.ts +20 -2
  215. package/src/chat/ui/diff/ApprovalReview.tsx +18 -15
  216. package/src/chat/ui/diff/DiffFallbackBoundary.tsx +1 -0
  217. package/src/chat/ui/diff/DiffOmitted.tsx +1 -0
  218. package/src/chat/ui/diff/DiffStack.tsx +2 -0
  219. package/src/chat/ui/diff/DiffUnavailable.tsx +1 -0
  220. package/src/chat/ui/diff/EditorEditDiff.tsx +13 -0
  221. package/src/chat/ui/diff/EditorPatchDiff.tsx +4 -0
  222. package/src/chat/ui/diff/LegacyDiffPool.tsx +2 -0
  223. package/src/chat/ui/diff/LegacyEditDiff.tsx +2 -0
  224. package/src/chat/ui/diff/LegacyUnifiedDiff.tsx +8 -0
  225. package/src/chat/ui/diff/RawDiff.tsx +1 -0
  226. package/src/chat/ui/diff/ReviewDiff.tsx +1 -0
  227. package/src/chat/ui/diff/diff-source-budget.ts +8 -0
  228. package/src/chat/ui/diff/editor-edit-model.ts +4 -0
  229. package/src/chat/ui/diff/review-plan.ts +9 -0
  230. package/src/chat/ui/diff/review-settle.ts +1 -0
  231. package/src/chat/ui/diff/syntax-runtime.ts +52 -0
  232. package/src/chat/ui/diff/use-review-stack.ts +9 -0
  233. package/src/chat/ui/diff-syntax.ts +12 -0
  234. package/src/chat/ui/diff-theme.ts +2 -0
  235. package/src/chat/ui/file-links.ts +2 -0
  236. package/src/chat/ui/find-reveal.ts +1 -0
  237. package/src/chat/ui/full-diff.ts +1 -0
  238. package/src/chat/ui/highlighter.ts +29 -15
  239. package/src/chat/ui/icons.tsx +2 -4
  240. package/src/chat/ui/index.ts +7 -0
  241. package/src/chat/ui/intelligent-ui/UiBlockFrame.tsx +25 -0
  242. package/src/chat/ui/intelligent-ui/UiFallbackPart.tsx +1 -0
  243. package/src/chat/ui/intelligent-ui/UiReply.tsx +63 -0
  244. package/src/chat/ui/intelligent-ui/block-local.ts +5 -0
  245. package/src/chat/ui/intelligent-ui/chart-data.ts +15 -0
  246. package/src/chat/ui/intelligent-ui/node-text.ts +17 -0
  247. package/src/chat/ui/intelligent-ui/renderers/binding.ts +1 -0
  248. package/src/chat/ui/intelligent-ui/renderers/chart.tsx +31 -0
  249. package/src/chat/ui/intelligent-ui/renderers/choices.tsx +4 -0
  250. package/src/chat/ui/intelligent-ui/renderers/content.tsx +18 -0
  251. package/src/chat/ui/intelligent-ui/renderers/data.tsx +11 -0
  252. package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +13 -0
  253. package/src/chat/ui/intelligent-ui/renderers/links.tsx +9 -0
  254. package/src/chat/ui/intelligent-ui/renderers/map-slots.ts +15 -0
  255. package/src/chat/ui/intelligent-ui/renderers/map-style.ts +15 -0
  256. package/src/chat/ui/intelligent-ui/renderers/map-view.tsx +48 -0
  257. package/src/chat/ui/intelligent-ui/renderers/map.tsx +20 -0
  258. package/src/chat/ui/intelligent-ui/renderers/place-point.ts +3 -0
  259. package/src/chat/ui/intelligent-ui/renderers/structure.tsx +3 -0
  260. package/src/chat/ui/intelligent-ui/renderers/text.tsx +8 -0
  261. package/src/chat/ui/intelligent-ui/reply-parts.ts +5 -0
  262. package/src/chat/ui/intelligent-ui/table-data.ts +17 -0
  263. package/src/chat/ui/intelligent-ui/use-in-view.ts +4 -0
  264. package/src/chat/ui/intelligent-ui/use-later.ts +4 -0
  265. package/src/chat/ui/intelligent-ui/use-truncated.ts +5 -0
  266. package/src/chat/ui/intelligent-ui/use-ui-links.ts +29 -0
  267. package/src/chat/ui/intelligent-ui/use-ui-queries.ts +60 -0
  268. package/src/chat/ui/markdown-blocks.ts +64 -0
  269. package/src/chat/ui/mermaid.ts +4 -0
  270. package/src/chat/ui/quote-selection.ts +10 -0
  271. package/src/chat/ui/rehype-chips.ts +5 -0
  272. package/src/chat/ui/rehype-fade.ts +2 -0
  273. package/src/chat/ui/remark-html-as-text.ts +5 -0
  274. package/src/chat/ui/reveal.ts +18 -0
  275. package/src/chat/ui/rows/ForksRow.tsx +5 -0
  276. package/src/chat/ui/rows/GeneratedImageRow.tsx +10 -0
  277. package/src/chat/ui/rows/MessageRows.tsx +29 -5
  278. package/src/chat/ui/rows/RowContainer.tsx +1 -0
  279. package/src/chat/ui/rows/Rows.tsx +2 -0
  280. package/src/chat/ui/rows/SubagentRow.tsx +13 -0
  281. package/src/chat/ui/rows/TaskRow.tsx +7 -0
  282. package/src/chat/ui/rows/VisualRow.tsx +4 -0
  283. package/src/chat/ui/rows/WorkRows.tsx +46 -0
  284. package/src/chat/ui/rows/WorkflowRow.tsx +10 -0
  285. package/src/chat/ui/rows/row-rhythm.ts +7 -5
  286. package/src/chat/ui/theme-watch.ts +8 -7
  287. package/src/chat/ui/thread-references.ts +7 -0
  288. package/src/chat/ui/use-diff-source-tokens.ts +8 -0
  289. package/src/chat/ui/useToggleSet.ts +3 -0
  290. package/src/chat/ui/visual-theme.ts +30 -0
  291. package/src/chat/visual-bridge.ts +23 -0
  292. package/src/chat/visual-viewport.ts +12 -0
  293. package/src/host-hooks.ts +15 -5
  294. package/src/host.ts +29 -1
  295. package/src/index.ts +5 -0
  296. package/src/lazy.tsx +9 -0
  297. package/src/locales/en/agent-chat.ts +1 -0
  298. package/src/locales/nl/agent-chat.ts +1 -0
  299. package/src/mounted-registry.ts +4 -0
  300. package/src/port-transport.ts +32 -0
  301. package/src/prompts/index.ts +2 -0
  302. package/src/prompts/logic/focus.ts +5 -0
  303. package/src/prompts/logic/keys.ts +12 -0
  304. package/src/prompts/logic/prompts.ts +8 -0
  305. package/src/prompts/logic/subjects.ts +8 -0
  306. package/src/prompts/logic/useFocusAfterAnswer.ts +2 -0
  307. package/src/prompts/logic/usePromptSession.ts +13 -1
  308. package/src/prompts/ui/ApprovalBody.tsx +2 -0
  309. package/src/prompts/ui/PromptActions.tsx +2 -0
  310. package/src/prompts/ui/PromptCard.tsx +6 -0
  311. package/src/prompts/ui/PromptView.tsx +6 -0
  312. package/src/prompts/ui/QuestionBody.tsx +11 -0
  313. package/src/providers/AccountColors.tsx +1 -0
  314. package/src/providers/AccountDetail.tsx +7 -0
  315. package/src/providers/AccountVariables.tsx +2 -0
  316. package/src/providers/AddAccountForm.tsx +5 -1
  317. package/src/providers/CliDetail.tsx +6 -5
  318. package/src/providers/InstallPage.tsx +11 -0
  319. package/src/providers/ProviderList.tsx +3 -0
  320. package/src/providers/ProvidersPane.tsx +18 -0
  321. package/src/providers/account-actions.ts +10 -8
  322. package/src/providers/index.ts +1 -0
  323. package/src/providers/install-steps.ts +3 -0
  324. package/src/providers/pane-target.ts +5 -0
  325. package/src/providers/provider-abilities.ts +1 -0
  326. package/src/providers/provider-groups.ts +6 -0
  327. package/src/providers/variables.ts +12 -0
  328. package/src/scope.ts +2 -0
  329. package/src/state/chats.ts +61 -14
  330. package/src/state/index.ts +2 -0
  331. package/src/state/provider-accounts.ts +7 -9
  332. package/src/state/providers.ts +1 -0
  333. package/src/state/usage.ts +6 -0
  334. package/src/storage.ts +18 -0
  335. package/src/testing/prompts.ts +5 -0
  336. package/src/theme.css +3 -0
  337. package/src/transport.ts +18 -0
  338. package/src/usage/ChartLogo.tsx +12 -0
  339. package/src/usage/LimitsList.tsx +7 -8
  340. package/src/usage/UsageBreakdown.tsx +11 -4
  341. package/src/usage/UsageChart.tsx +5 -0
  342. package/src/usage/UsageLimits.tsx +10 -7
  343. package/src/usage/UsageLimitsCard.tsx +2 -0
  344. package/src/usage/UsagePage.tsx +16 -19
  345. package/src/usage/UsageSummary.tsx +4 -5
  346. package/src/usage/UsageTiles.tsx +2 -0
  347. package/src/usage/format.ts +7 -0
  348. package/src/usage/limit-groups.ts +14 -0
  349. package/src/usage/limits.ts +11 -13
  350. package/src/usage/money.ts +1 -0
  351. package/src/usage/summary.ts +15 -7
@@ -1,560 +1,106 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { useEffect, useId, useMemo, useState } from 'react';
2
+ import { useEffect, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { ensureSyntaxTree, syntaxTree } from '@codemirror/language';
5
- import { useChatHost } from '../../../host.js';
6
4
  import { useChatScope } from '../../../scope.js';
7
- import { referenceSuggestions, referenceTokens } from '../../chat-references.js';
8
- import { usableSlashCommands } from '../../guards.js';
9
- import { chipRanges, findMentionQuery, findReferenceQuery, findSkillQuery, insertMention, insertReference, insertSkill, mentionPick, NO_MENTION_SEARCH, queryOutsideChips } from '../../mentions.js';
10
- import { inCode } from './keys.js';
11
- import { clampMenuIndex, composerMenuAria } from './menu-aria.js';
5
+ import { usePromptMenus } from './use-prompt-menus.js';
12
6
  import { useHostReferables } from '../../../host-hooks.js';
13
- const SEARCH_DEBOUNCE_MS = 80;
14
- // What fits above the composer without turning the picker into a file tree.
15
- const MENTION_RESULTS = 8;
16
- const REFERENCE_RESULTS = 8;
17
7
  // Commands the composer handles itself; the CLI's own ones are sent through as text.
18
8
  export const LOCAL_COMMANDS = ['model', 'compact', 'clear'];
19
- function sameQuery(left, right) {
20
- return left?.start === right?.start && left?.query === right?.query;
21
- }
22
- /*
23
- * The pickers over the box: `/` for a command, `$` for a skill, `@` for a file and `#` for a view,
24
- * a node or another chat. One is open at a time, and the arrow keys and the editor's ARIA attributes
25
- * follow that one.
26
- */
9
+ /* The pickers over a chat's composer, fed by what the chat's CLI has: its skills, its commands and its folder. */
27
10
  export function useComposerMenus(t0) {
28
- const $ = _c(110);
11
+ const $ = _c(22);
29
12
  const {
30
13
  chatId,
31
14
  info,
32
15
  capabilities,
33
16
  providerName,
34
- draft: t1,
17
+ draft,
35
18
  inputRef
36
19
  } = t0;
37
- const {
38
- draft,
39
- setDraft,
40
- setText
41
- } = t1;
42
20
  const {
43
21
  t
44
22
  } = useTranslation("agent-chat");
45
23
  const scope = useChatScope();
46
- const host = useChatHost();
47
- const {
48
- searchFiles
49
- } = host;
50
24
  const referables = useHostReferables(scope.id, chatId);
51
- const [menuIndex, setMenuIndex] = useState(0);
52
- const [mention, setMention] = useState(null);
53
- const [referenceQuery, setReferenceQuery] = useState(null);
54
- const [skillQuery, setSkillQuery] = useState(null);
55
- let t2;
25
+ let t1;
56
26
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
57
- t2 = [];
58
- $[0] = t2;
27
+ t1 = [];
28
+ $[0] = t1;
59
29
  } else {
60
- t2 = $[0];
30
+ t1 = $[0];
61
31
  }
62
- const [skills, setSkills] = useState(t2);
63
- const [searched, setSearched] = useState(NO_MENTION_SEARCH);
64
- const text = draft.text;
65
- const goals = capabilities?.goals;
66
- let t3;
67
- if ($[1] !== info.cwd || $[2] !== mention || $[3] !== scope.id || $[4] !== searchFiles) {
68
- t3 = () => {
69
- if (mention === null) {
70
- return;
71
- }
32
+ const [skills, setSkills] = useState(t1);
33
+ let t2;
34
+ if ($[1] !== chatId || $[2] !== scope.chats) {
35
+ t2 = () => {
72
36
  let stale = false;
73
- const search = () => {
74
- if (searchFiles === null) {
75
- return;
76
- }
77
- searchFiles(scope.id, info.cwd, mention.query, MENTION_RESULTS).then(files => {
78
- if (!stale) {
79
- setSearched({
80
- query: mention.query,
81
- files
82
- });
83
- setMenuIndex(0);
84
- }
85
- }).catch(_temp);
86
- };
87
- if (mention.query === "") {
88
- search();
89
- return () => {
90
- stale = true;
91
- };
92
- }
93
- const timer = setTimeout(search, SEARCH_DEBOUNCE_MS);
94
- return () => {
95
- stale = true;
96
- clearTimeout(timer);
97
- };
98
- };
99
- $[1] = info.cwd;
100
- $[2] = mention;
101
- $[3] = scope.id;
102
- $[4] = searchFiles;
103
- $[5] = t3;
104
- } else {
105
- t3 = $[5];
106
- }
107
- let t4;
108
- if ($[6] !== info.cwd || $[7] !== mention || $[8] !== scope || $[9] !== searchFiles) {
109
- t4 = [scope, info.cwd, mention, searchFiles];
110
- $[6] = info.cwd;
111
- $[7] = mention;
112
- $[8] = scope;
113
- $[9] = searchFiles;
114
- $[10] = t4;
115
- } else {
116
- t4 = $[10];
117
- }
118
- useEffect(t3, t4);
119
- let t5;
120
- if ($[11] !== chatId || $[12] !== scope.chats) {
121
- t5 = () => {
122
- let stale_0 = false;
123
37
  scope.chats.listSkills(chatId).then(found => {
124
- if (!stale_0) {
38
+ if (!stale) {
125
39
  setSkills(found);
126
40
  }
127
- }).catch(_temp2);
41
+ }).catch(_temp);
128
42
  return () => {
129
- stale_0 = true;
43
+ stale = true;
130
44
  };
131
45
  };
132
- $[11] = chatId;
133
- $[12] = scope.chats;
134
- $[13] = t5;
135
- } else {
136
- t5 = $[13];
137
- }
138
- let t6;
139
- if ($[14] !== chatId || $[15] !== info.running || $[16] !== info.skills || $[17] !== scope) {
140
- t6 = [scope, chatId, info.skills, info.running];
141
- $[14] = chatId;
142
- $[15] = info.running;
143
- $[16] = info.skills;
144
- $[17] = scope;
145
- $[18] = t6;
46
+ $[1] = chatId;
47
+ $[2] = scope.chats;
48
+ $[3] = t2;
146
49
  } else {
147
- t6 = $[18];
50
+ t2 = $[3];
148
51
  }
149
- useEffect(t5, t6);
52
+ let t3;
53
+ if ($[4] !== chatId || $[5] !== info.running || $[6] !== info.skills || $[7] !== scope) {
54
+ t3 = [scope, chatId, info.skills, info.running];
55
+ $[4] = chatId;
56
+ $[5] = info.running;
57
+ $[6] = info.skills;
58
+ $[7] = scope;
59
+ $[8] = t3;
60
+ } else {
61
+ t3 = $[8];
62
+ }
63
+ useEffect(t2, t3);
64
+ const t4 = capabilities?.mentions === false ? null : info.cwd;
65
+ const t5 = info.slashCommands;
66
+ const t6 = capabilities?.goals !== undefined;
150
67
  let t7;
151
- if ($[19] !== text) {
152
- t7 = text.startsWith("/") && !text.includes("\n") ? text.slice(1).trim().toLowerCase() : null;
153
- $[19] = text;
154
- $[20] = t7;
68
+ if ($[9] !== t) {
69
+ t7 = t("composer.inputLabel");
70
+ $[9] = t;
71
+ $[10] = t7;
155
72
  } else {
156
- t7 = $[20];
73
+ t7 = $[10];
157
74
  }
158
- const commandQuery = t7;
159
75
  let t8;
160
- bb0: {
161
- if (commandQuery === null) {
162
- let t9;
163
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
164
- t9 = [];
165
- $[21] = t9;
166
- } else {
167
- t9 = $[21];
168
- }
169
- t8 = t9;
170
- break bb0;
171
- }
172
- let t9;
173
- if ($[22] !== skills) {
174
- t9 = new Set(skills.map(_temp3));
175
- $[22] = skills;
176
- $[23] = t9;
177
- } else {
178
- t9 = $[23];
179
- }
180
- const known = t9;
181
- let t10;
182
- if ($[24] !== commandQuery || $[25] !== goals || $[26] !== info.slashCommands || $[27] !== known || $[28] !== providerName || $[29] !== t) {
183
- const own = LOCAL_COMMANDS.map(name => ({
184
- name,
185
- hint: t(`composer.commands.${name}`),
186
- local: true,
187
- skill: false
188
- }));
189
- const goal = goals === undefined ? [] : [{
190
- name: "goal",
191
- hint: t("composer.commands.goal"),
192
- local: false,
193
- skill: false
194
- }];
195
- const cli = usableSlashCommands(info.slashCommands).filter(name_0 => !LOCAL_COMMANDS.includes(name_0) && (goals === undefined || name_0 !== "goal")).map(name_1 => ({
196
- name: name_1,
197
- hint: known.has(name_1) ? t("composer.commands.skill") : t("composer.commands.cli", {
198
- cli: providerName ?? t("composer.commands.anyCli")
199
- }),
200
- local: false,
201
- skill: known.has(name_1)
202
- }));
203
- t10 = [...own, ...goal, ...cli].filter(command => command.name.startsWith(commandQuery)).slice(0, 8);
204
- $[24] = commandQuery;
205
- $[25] = goals;
206
- $[26] = info.slashCommands;
207
- $[27] = known;
208
- $[28] = providerName;
209
- $[29] = t;
210
- $[30] = t10;
211
- } else {
212
- t10 = $[30];
213
- }
214
- t8 = t10;
215
- }
216
- const commands = t8;
217
- let t9;
218
- bb1: {
219
- if (skillQuery === null) {
220
- let t10;
221
- if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
222
- t10 = [];
223
- $[31] = t10;
224
- } else {
225
- t10 = $[31];
226
- }
227
- t9 = t10;
228
- break bb1;
229
- }
230
- let t10;
231
- if ($[32] !== skillQuery.query || $[33] !== skills) {
232
- const query = skillQuery.query.toLowerCase();
233
- t10 = skills.filter(skill_0 => skill_0.name.toLowerCase().includes(query)).slice(0, 8);
234
- $[32] = skillQuery.query;
235
- $[33] = skills;
236
- $[34] = t10;
237
- } else {
238
- t10 = $[34];
239
- }
240
- t9 = t10;
241
- }
242
- const skillMatches = t9;
243
- const commandMenuOpen = commandQuery !== null && commands.length > 0;
244
- const skillMenuOpen = !commandMenuOpen && skillQuery !== null && skillMatches.length > 0;
245
- const mentionMenuOpen = !commandMenuOpen && !skillMenuOpen && mention !== null;
246
- const files_0 = mention === null ? [] : searched.files;
247
- const mentionCount = files_0.length;
248
- let t10;
249
- if ($[35] !== referables.chatsOnly) {
250
- t10 = item => !referables.chatsOnly || item.kind === "chat";
251
- $[35] = referables.chatsOnly;
252
- $[36] = t10;
253
- } else {
254
- t10 = $[36];
255
- }
256
- const offersReferences = referables.items.some(t10);
257
- const referenceMenuOpen = !commandMenuOpen && !skillMenuOpen && !mentionMenuOpen && referenceQuery !== null && offersReferences;
258
- const referenceMatches = referenceMenuOpen ? referenceSuggestions(referables, referenceQuery.query, [chatId, ...draft.chats, ...draft.references], REFERENCE_RESULTS) : [];
259
- let t11;
260
- if ($[37] !== draft.chats || $[38] !== draft.referenceNames || $[39] !== draft.references || $[40] !== referables.items) {
261
- let t12;
262
- if ($[42] !== referables.items) {
263
- t12 = token => ({
264
- ...token,
265
- kind: referables.items.find(item_0 => item_0.id === token.id)?.kind ?? null
266
- });
267
- $[42] = referables.items;
268
- $[43] = t12;
269
- } else {
270
- t12 = $[43];
271
- }
272
- t11 = referenceTokens([...draft.chats, ...draft.references], referables.items, draft.referenceNames).map(t12);
273
- $[37] = draft.chats;
274
- $[38] = draft.referenceNames;
275
- $[39] = draft.references;
276
- $[40] = referables.items;
277
- $[41] = t11;
278
- } else {
279
- t11 = $[41];
280
- }
281
- const referenceChips = t11;
282
- const listId = useId();
283
- const menuOpen = commandMenuOpen || skillMenuOpen || mentionMenuOpen || referenceMenuOpen;
284
- const menuCount = commandMenuOpen ? commands.length : skillMenuOpen ? skillMatches.length : mentionMenuOpen ? mentionCount : referenceMatches.length;
285
- const activeIndex = clampMenuIndex(menuIndex, menuCount);
286
- const inputAria = composerMenuAria({
287
- label: t("composer.inputLabel"),
288
- listId,
289
- open: menuOpen,
290
- activeIndex,
291
- count: menuCount
292
- });
293
- let t12;
294
- if ($[44] !== capabilities?.mentions || $[45] !== draft.mentions || $[46] !== draft.skills || $[47] !== referenceChips) {
295
- t12 = (value, selection, state) => {
296
- const empty = selection.from === selection.to;
297
- const tree = empty ? ensureSyntaxTree(state, selection.from, 50) ?? syntaxTree(state) : null;
298
- const caret = tree !== null && !inCode(tree, value, selection.from) ? selection.from : null;
299
- const chips = caret === null ? [] : chipRanges(value, draft.mentions, draft.skills, [], referenceChips);
300
- const skill_1 = caret === null ? null : queryOutsideChips(findSkillQuery(value, caret), chips);
301
- setSkillQuery(current => sameQuery(current, skill_1) ? current : skill_1);
302
- const next = caret === null || capabilities?.mentions === false ? null : queryOutsideChips(findMentionQuery(value, caret), chips);
303
- setMention(current_0 => sameQuery(current_0, next) ? current_0 : next);
304
- const reference = caret === null ? null : queryOutsideChips(findReferenceQuery(value, caret), chips);
305
- setReferenceQuery(current_1 => sameQuery(current_1, reference) ? current_1 : reference);
306
- };
307
- $[44] = capabilities?.mentions;
308
- $[45] = draft.mentions;
309
- $[46] = draft.skills;
310
- $[47] = referenceChips;
311
- $[48] = t12;
312
- } else {
313
- t12 = $[48];
314
- }
315
- const trackTriggers = t12;
316
- let t13;
317
- if ($[49] !== inputRef) {
318
- t13 = caret_0 => {
319
- requestAnimationFrame(() => inputRef.current?.setCaret(caret_0));
320
- };
321
- $[49] = inputRef;
322
- $[50] = t13;
323
- } else {
324
- t13 = $[50];
325
- }
326
- const moveCaret = t13;
327
- let t14;
328
- if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
329
- t14 = () => {
330
- setMention(null);
331
- setSkillQuery(null);
332
- setReferenceQuery(null);
333
- };
334
- $[51] = t14;
335
- } else {
336
- t14 = $[51];
337
- }
338
- const close = t14;
339
- let t15;
340
- if ($[52] !== draft.mentions || $[53] !== mention || $[54] !== moveCaret || $[55] !== setText || $[56] !== text) {
341
- t15 = path => {
342
- if (!mention) {
343
- return;
344
- }
345
- const result = insertMention(text, mention, path);
346
- setText(result.text, draft.mentions.includes(path) ? draft.mentions : [...draft.mentions, path]);
347
- setMention(null);
348
- moveCaret(result.caret);
349
- };
350
- $[52] = draft.mentions;
351
- $[53] = mention;
352
- $[54] = moveCaret;
353
- $[55] = setText;
354
- $[56] = text;
355
- $[57] = t15;
356
- } else {
357
- t15 = $[57];
358
- }
359
- const chooseMention = t15;
360
- let t16;
361
- if ($[58] !== chooseMention || $[59] !== mention || $[60] !== searched) {
362
- t16 = index => {
363
- const path_0 = mention === null ? null : mentionPick(index, searched, mention.query);
364
- if (path_0 !== null) {
365
- chooseMention(path_0);
366
- }
367
- };
368
- $[58] = chooseMention;
369
- $[59] = mention;
370
- $[60] = searched;
371
- $[61] = t16;
372
- } else {
373
- t16 = $[61];
374
- }
375
- const chooseMentionAt = t16;
376
- let t17;
377
- if ($[62] !== moveCaret || $[63] !== referenceQuery || $[64] !== setDraft || $[65] !== text) {
378
- t17 = item_1 => {
379
- if (!referenceQuery) {
380
- return;
381
- }
382
- const result_0 = insertReference(text, referenceQuery, item_1.name);
383
- const chat = item_1.kind === "chat";
384
- const add = ids => ids.includes(item_1.id) ? ids : [...ids, item_1.id];
385
- setDraft(current_2 => ({
386
- ...current_2,
387
- text: result_0.text,
388
- chats: chat ? add(current_2.chats) : current_2.chats,
389
- references: chat ? current_2.references : add(current_2.references),
390
- referenceNames: {
391
- ...current_2.referenceNames,
392
- [item_1.id]: item_1.name
393
- }
394
- }));
395
- setReferenceQuery(null);
396
- moveCaret(result_0.caret);
397
- };
398
- $[62] = moveCaret;
399
- $[63] = referenceQuery;
400
- $[64] = setDraft;
401
- $[65] = text;
402
- $[66] = t17;
403
- } else {
404
- t17 = $[66];
405
- }
406
- const chooseReference = t17;
407
- let t18;
408
- if ($[67] !== chooseReference || $[68] !== referenceMatches) {
409
- t18 = index_0 => {
410
- const item_2 = referenceMatches[index_0] ?? referenceMatches[0];
411
- if (item_2 !== undefined) {
412
- chooseReference(item_2);
413
- }
414
- };
415
- $[67] = chooseReference;
416
- $[68] = referenceMatches;
417
- $[69] = t18;
418
- } else {
419
- t18 = $[69];
420
- }
421
- const chooseReferenceAt = t18;
422
- let t19;
423
- if ($[70] !== draft.mentions || $[71] !== draft.skills || $[72] !== moveCaret || $[73] !== setText || $[74] !== skillQuery || $[75] !== text) {
424
- t19 = name_2 => {
425
- const result_1 = skillQuery ? insertSkill(text, skillQuery, name_2) : {
426
- text: `$${name_2} `,
427
- caret: name_2.length + 2
428
- };
429
- setText(result_1.text, draft.mentions, draft.skills.includes(name_2) ? draft.skills : [...draft.skills, name_2]);
430
- setSkillQuery(null);
431
- moveCaret(result_1.caret);
432
- };
433
- $[70] = draft.mentions;
434
- $[71] = draft.skills;
435
- $[72] = moveCaret;
436
- $[73] = setText;
437
- $[74] = skillQuery;
438
- $[75] = text;
439
- $[76] = t19;
440
- } else {
441
- t19 = $[76];
442
- }
443
- const chooseSkill = t19;
444
- let t20;
445
- if ($[77] !== chooseSkill || $[78] !== inputRef || $[79] !== setText) {
446
- t20 = (command_0, index_1) => {
447
- setMenuIndex(index_1);
448
- if (command_0.skill) {
449
- chooseSkill(command_0.name);
450
- return;
451
- }
452
- setText(`/${command_0.name}`);
453
- inputRef.current?.focus();
454
- };
455
- $[77] = chooseSkill;
456
- $[78] = inputRef;
457
- $[79] = setText;
458
- $[80] = t20;
459
- } else {
460
- t20 = $[80];
461
- }
462
- const pickCommand = t20;
463
- let t21;
464
- if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
465
- t21 = (key, count) => {
466
- if (key === "ArrowDown") {
467
- setMenuIndex(i => (i + 1) % count);
468
- return true;
469
- }
470
- if (key === "ArrowUp") {
471
- setMenuIndex(i_0 => (i_0 - 1 + count) % count);
472
- return true;
473
- }
474
- return false;
475
- };
476
- $[81] = t21;
477
- } else {
478
- t21 = $[81];
479
- }
480
- const moveInMenu = t21;
481
- const t22 = skills.length > 0;
482
- let t23;
483
- if ($[82] !== skills) {
484
- t23 = skills.map(_temp4);
485
- $[82] = skills;
486
- $[83] = t23;
487
- } else {
488
- t23 = $[83];
489
- }
490
- let t24;
491
- if ($[84] !== activeIndex || $[85] !== chooseMention || $[86] !== chooseMentionAt || $[87] !== chooseReference || $[88] !== chooseReferenceAt || $[89] !== chooseSkill || $[90] !== commandMenuOpen || $[91] !== commandQuery || $[92] !== commands || $[93] !== files_0 || $[94] !== inputAria || $[95] !== listId || $[96] !== mention || $[97] !== mentionCount || $[98] !== mentionMenuOpen || $[99] !== pickCommand || $[100] !== referables || $[101] !== referenceChips || $[102] !== referenceMatches || $[103] !== referenceMenuOpen || $[104] !== skillMatches || $[105] !== skillMenuOpen || $[106] !== t22 || $[107] !== t23 || $[108] !== trackTriggers) {
492
- t24 = {
493
- listId,
494
- activeIndex,
495
- inputAria,
496
- hasSkills: t22,
497
- skillNames: t23,
498
- commandQuery,
499
- commands,
500
- commandMenuOpen,
501
- skillMatches,
502
- skillMenuOpen,
503
- mention,
504
- mentionMenuOpen,
505
- mentionCount,
506
- files: files_0,
507
- referenceMenuOpen,
508
- referenceMatches,
76
+ if ($[11] !== chatId || $[12] !== draft || $[13] !== info.slashCommands || $[14] !== inputRef || $[15] !== providerName || $[16] !== referables || $[17] !== skills || $[18] !== t4 || $[19] !== t6 || $[20] !== t7) {
77
+ t8 = {
78
+ draft,
79
+ inputRef,
80
+ cwd: t4,
81
+ skills,
82
+ slashCommands: t5,
83
+ localCommands: LOCAL_COMMANDS,
84
+ goals: t6,
85
+ providerName,
509
86
  referables,
510
- referenceChips,
511
- setMenuIndex,
512
- trackTriggers,
513
- close,
514
- chooseMention,
515
- chooseMentionAt,
516
- chooseReference,
517
- chooseReferenceAt,
518
- chooseSkill,
519
- pickCommand,
520
- moveInMenu
87
+ ownId: chatId,
88
+ label: t7
521
89
  };
522
- $[84] = activeIndex;
523
- $[85] = chooseMention;
524
- $[86] = chooseMentionAt;
525
- $[87] = chooseReference;
526
- $[88] = chooseReferenceAt;
527
- $[89] = chooseSkill;
528
- $[90] = commandMenuOpen;
529
- $[91] = commandQuery;
530
- $[92] = commands;
531
- $[93] = files_0;
532
- $[94] = inputAria;
533
- $[95] = listId;
534
- $[96] = mention;
535
- $[97] = mentionCount;
536
- $[98] = mentionMenuOpen;
537
- $[99] = pickCommand;
538
- $[100] = referables;
539
- $[101] = referenceChips;
540
- $[102] = referenceMatches;
541
- $[103] = referenceMenuOpen;
542
- $[104] = skillMatches;
543
- $[105] = skillMenuOpen;
544
- $[106] = t22;
545
- $[107] = t23;
546
- $[108] = trackTriggers;
547
- $[109] = t24;
90
+ $[11] = chatId;
91
+ $[12] = draft;
92
+ $[13] = info.slashCommands;
93
+ $[14] = inputRef;
94
+ $[15] = providerName;
95
+ $[16] = referables;
96
+ $[17] = skills;
97
+ $[18] = t4;
98
+ $[19] = t6;
99
+ $[20] = t7;
100
+ $[21] = t8;
548
101
  } else {
549
- t24 = $[109];
102
+ t8 = $[21];
550
103
  }
551
- return t24;
552
- }
553
- function _temp4(skill_2) {
554
- return skill_2.name;
555
- }
556
- function _temp3(skill) {
557
- return skill.name;
104
+ return usePromptMenus(t8);
558
105
  }
559
- function _temp2() {}
560
106
  function _temp() {}
@@ -1,5 +1,4 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { useMemo } from 'react';
3
2
  import { useChatRow } from '../../../state/chats.js';
4
3
  import { continuableTurn } from '../../logic/continue-after-stop.js';
5
4
  /* The turn a person stopped that Continue would pick up, or null when there is none. */
@@ -1,5 +1,6 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useEffect, useState } from 'react';
3
+ import { errorMessage } from '../../../transport.js';
3
4
  const NOTICE_MS = 4000;
4
5
  /* A line under the box that says what went wrong, gone again after a few seconds. */
5
6
  export function useNotice() {
@@ -42,7 +43,7 @@ export function useNotice() {
42
43
  const t4 = shown?.tone ?? "error";
43
44
  let t5;
44
45
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
45
- t5 = error => setNotice(error instanceof Error ? error.message : String(error));
46
+ t5 = error => setNotice(errorMessage(error));
46
47
  $[4] = t5;
47
48
  } else {
48
49
  t5 = $[4];
@@ -1,5 +1,5 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { useMemo, useState } from 'react';
2
+ import { useState } from 'react';
3
3
  import { useChatRow } from '../../../state/chats.js';
4
4
  // How many sent prompts the arrow keys walk back through, per chat.
5
5
  const PROMPT_HISTORY = 50;