chat-js 1.0.0-alpha.7 → 1.0.0-beta.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 (305) hide show
  1. package/README.md +8 -6
  2. package/dist/index.js +7487 -6859
  3. package/package.json +2 -2
  4. package/templates/chat-app/AGENTS.md +1 -1
  5. package/templates/chat-app/agent/agent.ts +0 -2
  6. package/templates/chat-app/agent/hooks/followup-suggestions.ts +1 -1
  7. package/templates/chat-app/agent/hooks/projects.ts +1 -1
  8. package/templates/chat-app/agent/hooks/search.ts +1 -1
  9. package/templates/chat-app/agent/instructions/projects.ts +1 -1
  10. package/templates/chat-app/agent/tools/mcp.ts +1 -1
  11. package/templates/chat-app/app/(auth)/device-login/page.tsx +1 -1
  12. package/templates/chat-app/app/(chat)/api/files/upload/route.ts +1 -1
  13. package/templates/chat-app/app/(chat)/chat/{[id] → [chatId]}/page.tsx +4 -4
  14. package/templates/chat-app/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx +1 -1
  15. package/templates/chat-app/app/(chat)/project/[projectId]/page.tsx +1 -1
  16. package/templates/chat-app/app/(chat)/settings/connectors/[connectorId]/page.tsx +1 -1
  17. package/templates/chat-app/app/(chat)/settings/connectors/page.tsx +1 -1
  18. package/templates/chat-app/app/(chat)/settings/models/page.tsx +1 -1
  19. package/templates/chat-app/app/(chat)/share/[id]/page.tsx +1 -1
  20. package/templates/chat-app/app/api/agent-conversations/route.test.ts +5 -5
  21. package/templates/chat-app/app/api/agent-conversations/route.ts +2 -2
  22. package/templates/chat-app/app/api/agent-response-groups/route.test.ts +5 -5
  23. package/templates/chat-app/app/api/agent-response-groups/route.ts +1 -1
  24. package/templates/chat-app/app/api/eve/[...path]/route.test.ts +133 -4
  25. package/templates/chat-app/app/api/eve/[...path]/route.ts +175 -49
  26. package/templates/chat-app/app/api/eve-guest/route.ts +1 -1
  27. package/templates/chat-app/app/api/mcp/oauth/callback/route.ts +1 -1
  28. package/templates/chat-app/app/editor.css +0 -6
  29. package/templates/chat-app/app/layout.tsx +11 -18
  30. package/templates/chat-app/app/opengraph-image.png +0 -0
  31. package/templates/chat-app/chat.config.ts +0 -44
  32. package/templates/chat-app/chatjs/core/chat/compose.ts +4 -4
  33. package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -6
  34. package/templates/chat-app/chatjs/core/gateway/runtime.ts +0 -7
  35. package/templates/chat-app/chatjs/core/installation/contracts.ts +0 -7
  36. package/templates/chat-app/chatjs/core/ui/slots.tsx +15 -5
  37. package/templates/chat-app/chatjs/generated/installed-auth-ui.ts +2 -2
  38. package/templates/chat-app/chatjs/generated/installed-auth.ts +4 -2
  39. package/templates/chat-app/chatjs/generated/installed-billing.ts +2 -2
  40. package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +28 -24
  41. package/templates/chat-app/chatjs/generated/installed-chat.ts +12 -12
  42. package/templates/chat-app/chatjs/generated/installed-cleanup.ts +4 -4
  43. package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +8 -2
  44. package/templates/chat-app/chatjs/generated/installed-layout.ts +2 -2
  45. package/templates/chat-app/chatjs/generated/installed-model-visibility.ts +2 -2
  46. package/templates/chat-app/chatjs/generated/installed-navigation.ts +2 -2
  47. package/templates/chat-app/chatjs/generated/installed-routers.ts +18 -19
  48. package/templates/chat-app/chatjs/generated/installed-session-profiles.ts +5 -3
  49. package/templates/chat-app/chatjs/generated/installed-sign-out.ts +2 -2
  50. package/templates/chat-app/chatjs/generated/installed-signed-out.ts +2 -2
  51. package/templates/chat-app/chatjs/generated/installed-uploads.ts +2 -2
  52. package/templates/chat-app/chatjs/generated/installed.ts +2 -0
  53. package/templates/chat-app/chatjs/plugins/ai-titles/{chat.ts → chat-server.ts} +3 -1
  54. package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +7 -9
  55. package/templates/chat-app/chatjs/plugins/ai-titles/{chatjs.json → plugin.json} +3 -4
  56. package/templates/chat-app/chatjs/plugins/ai-titles/title-queries.ts +4 -4
  57. package/templates/chat-app/chatjs/plugins/attachment-uploads/{client-plugin.ts → chat-ui.ts} +1 -3
  58. package/templates/chat-app/chatjs/plugins/attachment-uploads/plugin.json +16 -0
  59. package/templates/chat-app/chatjs/plugins/credits/billing.ts +3 -1
  60. package/templates/chat-app/chatjs/plugins/credits/{client-plugin.ts → chat-ui.ts} +1 -1
  61. package/templates/chat-app/chatjs/plugins/credits/{chatjs.json → plugin.json} +4 -13
  62. package/templates/chat-app/chatjs/plugins/credits/router.ts +4 -2
  63. package/templates/chat-app/chatjs/plugins/desktop/auth-form.tsx +3 -1
  64. package/templates/chat-app/chatjs/plugins/desktop/auth-server.ts +3 -1
  65. package/templates/chat-app/chatjs/plugins/desktop/{client-plugin.ts → layout-ui.ts} +1 -1
  66. package/templates/chat-app/chatjs/plugins/desktop/navigation.ts +3 -1
  67. package/templates/chat-app/chatjs/plugins/desktop/{chatjs.json → plugin.json} +4 -16
  68. package/templates/chat-app/chatjs/plugins/desktop/sign-out.ts +3 -1
  69. package/templates/chat-app/chatjs/plugins/feedback/chat-server.ts +13 -0
  70. package/templates/chat-app/chatjs/plugins/feedback/{client-plugin.ts → chat-ui.ts} +1 -1
  71. package/templates/chat-app/chatjs/plugins/feedback/feedback-actions.tsx +4 -4
  72. package/templates/chat-app/chatjs/plugins/feedback/feedback-queries.ts +11 -11
  73. package/templates/chat-app/chatjs/plugins/feedback/feedback-schema.ts +2 -2
  74. package/templates/chat-app/chatjs/plugins/feedback/{chatjs.json → plugin.json} +5 -14
  75. package/templates/chat-app/chatjs/plugins/feedback/router.ts +9 -7
  76. package/templates/chat-app/chatjs/plugins/feedback/vote-message.ts +3 -6
  77. package/templates/chat-app/chatjs/plugins/followup-suggestions/{chat.ts → chat-server.ts} +3 -1
  78. package/templates/chat-app/chatjs/plugins/followup-suggestions/{client-plugin.ts → chat-ui.ts} +1 -1
  79. package/templates/chat-app/chatjs/plugins/followup-suggestions/followup-queries.ts +2 -2
  80. package/templates/chat-app/chatjs/plugins/followup-suggestions/{chatjs.json → plugin.json} +5 -17
  81. package/templates/chat-app/chatjs/plugins/followup-suggestions/router.ts +8 -9
  82. package/templates/chat-app/chatjs/plugins/followup-suggestions/suggestions.tsx +2 -7
  83. package/templates/chat-app/chatjs/plugins/followup-suggestions/use-followups.ts +2 -2
  84. package/templates/chat-app/chatjs/plugins/guest-chat/cleanup.ts +1 -7
  85. package/templates/chat-app/chatjs/plugins/guest-chat/guest-auth.ts +1 -0
  86. package/templates/chat-app/chatjs/plugins/guest-chat/instrumentation.ts +6 -0
  87. package/templates/chat-app/chatjs/plugins/guest-chat/{chatjs.json → plugin.json} +6 -12
  88. package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +3 -1
  89. package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +53 -24
  90. package/templates/chat-app/chatjs/plugins/image-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
  91. package/templates/chat-app/chatjs/plugins/image-viewer/plugin.json +11 -0
  92. package/templates/chat-app/chatjs/plugins/mcp/{client-plugin.ts → chat-ui.ts} +1 -1
  93. package/templates/chat-app/chatjs/plugins/mcp/db/encrypted-text.ts +1 -1
  94. package/templates/chat-app/chatjs/plugins/mcp/{chatjs.json → plugin.json} +5 -13
  95. package/templates/chat-app/chatjs/plugins/mcp/router.ts +4 -2
  96. package/templates/chat-app/chatjs/plugins/mcp/routes/connectors-page.tsx +4 -1
  97. package/templates/chat-app/chatjs/plugins/mcp/setup.ts +2 -2
  98. package/templates/chat-app/chatjs/plugins/mcp/ui/connectors-settings.tsx +1 -1
  99. package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-connect-dialog.tsx +1 -1
  100. package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-create-dialog.tsx +1 -1
  101. package/templates/chat-app/chatjs/plugins/mcp/{mcp-env.ts → validate-env.ts} +2 -1
  102. package/templates/chat-app/chatjs/plugins/model-preferences/{client-plugin.ts → chat-ui.ts} +1 -3
  103. package/templates/chat-app/chatjs/plugins/model-preferences/model-row.tsx +3 -0
  104. package/templates/chat-app/chatjs/plugins/model-preferences/{use-model-preferences.ts → model-visibility.ts} +1 -1
  105. package/templates/chat-app/chatjs/plugins/model-preferences/models-settings.tsx +1 -0
  106. package/templates/chat-app/chatjs/plugins/model-preferences/{chatjs.json → plugin.json} +5 -13
  107. package/templates/chat-app/chatjs/plugins/model-preferences/router.ts +5 -1
  108. package/templates/chat-app/chatjs/plugins/projects/{chat.ts → chat-server.ts} +3 -1
  109. package/templates/chat-app/chatjs/plugins/projects/{client-plugin.ts → chat-ui.ts} +1 -1
  110. package/templates/chat-app/chatjs/plugins/projects/conversation-hook.ts +1 -1
  111. package/templates/chat-app/chatjs/plugins/projects/db/project-queries.ts +2 -2
  112. package/templates/chat-app/chatjs/plugins/projects/{chatjs.json → plugin.json} +5 -14
  113. package/templates/chat-app/chatjs/plugins/projects/router.ts +7 -7
  114. package/templates/chat-app/chatjs/plugins/projects/routes/project-page.tsx +10 -1
  115. package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +3 -3
  116. package/templates/chat-app/chatjs/plugins/projects/ui/delete-project-dialog.tsx +0 -3
  117. package/templates/chat-app/chatjs/plugins/projects/ui/eve-move-project-dialog.tsx +1 -1
  118. package/templates/chat-app/chatjs/plugins/projects/ui/project-icon-picker.tsx +1 -0
  119. package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +12 -11
  120. package/templates/chat-app/chatjs/plugins/search/{chat.ts → chat-server.ts} +8 -6
  121. package/templates/chat-app/chatjs/plugins/search/{client-plugin.ts → chat-ui.ts} +1 -1
  122. package/templates/chat-app/chatjs/plugins/search/{chatjs.json → plugin.json} +5 -14
  123. package/templates/chat-app/chatjs/plugins/search/router.ts +4 -2
  124. package/templates/chat-app/chatjs/plugins/search/search-backfill.ts +4 -4
  125. package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +1 -1
  126. package/templates/chat-app/chatjs/plugins/search/search-hook.ts +2 -2
  127. package/templates/chat-app/chatjs/plugins/search/search-queries.ts +13 -13
  128. package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +2 -2
  129. package/templates/chat-app/chatjs/plugins/search/search-schema.ts +3 -3
  130. package/templates/chat-app/chatjs/plugins/sharing/{chat.ts → chat-server.ts} +3 -1
  131. package/templates/chat-app/chatjs/plugins/sharing/{client-plugin.ts → chat-ui.ts} +1 -1
  132. package/templates/chat-app/chatjs/plugins/sharing/{chatjs.json → plugin.json} +5 -14
  133. package/templates/chat-app/chatjs/plugins/sharing/router.ts +4 -2
  134. package/templates/chat-app/chatjs/plugins/sharing/ui/chat-contributions.tsx +9 -11
  135. package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +6 -6
  136. package/templates/chat-app/chatjs/plugins/sharing/ui/share-dialog.tsx +9 -9
  137. package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
  138. package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/plugin.json +12 -0
  139. package/templates/chat-app/chatjs/plugins/streamdown-math/chat-ui.ts +11 -0
  140. package/templates/chat-app/chatjs/plugins/streamdown-math/plugin.json +6 -0
  141. package/templates/chat-app/chatjs/plugins/streamdown-mermaid/chat-ui.ts +10 -0
  142. package/templates/chat-app/chatjs/plugins/streamdown-mermaid/plugin.json +6 -0
  143. package/templates/chat-app/chatjs/plugins/video-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
  144. package/templates/chat-app/chatjs/plugins/video-viewer/plugin.json +10 -0
  145. package/templates/chat-app/chatjs/providers/gateway.ts +49 -55
  146. package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +2 -2
  147. package/templates/chat-app/chatjs/tools/generate-image/tool.test.ts +3 -14
  148. package/templates/chat-app/components/ai-elements/response.tsx +16 -15
  149. package/templates/chat-app/components/auth-form-view.tsx +35 -43
  150. package/templates/chat-app/components/chat/chat-composer.tsx +90 -27
  151. package/templates/chat-app/components/chat/chat-conversation-screen.tsx +3 -3
  152. package/templates/chat-app/components/chat/chat-navigation.tsx +11 -1
  153. package/templates/chat-app/components/chat/chat-sidebar.tsx +8 -9
  154. package/templates/chat-app/components/chat/chat-transcript.tsx +52 -23
  155. package/templates/chat-app/components/chat-slots.tsx +1 -1
  156. package/templates/chat-app/components/composer/composer-menu.tsx +5 -4
  157. package/templates/chat-app/components/composer/prompt-form.tsx +7 -1
  158. package/templates/chat-app/components/eve/eve-chat-error.tsx +12 -2
  159. package/templates/chat-app/components/eve/eve-chat-header.tsx +5 -7
  160. package/templates/chat-app/components/eve/eve-chat-page.tsx +9 -9
  161. package/templates/chat-app/components/eve/eve-composer.tsx +16 -5
  162. package/templates/chat-app/components/eve/eve-conversation.tsx +342 -209
  163. package/templates/chat-app/components/eve/eve-creation-recovery.tsx +53 -3
  164. package/templates/chat-app/components/eve/eve-deletion-provider.tsx +10 -12
  165. package/templates/chat-app/components/eve/eve-history-list.tsx +4 -9
  166. package/templates/chat-app/components/eve/eve-logical-context.tsx +1 -0
  167. package/templates/chat-app/components/eve/eve-logical-navigation.tsx +3 -3
  168. package/templates/chat-app/components/eve/eve-message-content.tsx +252 -0
  169. package/templates/chat-app/components/eve/eve-message-part.tsx +13 -58
  170. package/templates/chat-app/components/eve/eve-pending-input.tsx +82 -5
  171. package/templates/chat-app/components/eve/eve-runtime-provider.tsx +74 -15
  172. package/templates/chat-app/components/eve/use-eve-composer-draft.ts +64 -26
  173. package/templates/chat-app/components/eve/use-eve-fork.ts +14 -16
  174. package/templates/chat-app/components/eve/use-logical-commands.ts +3 -3
  175. package/templates/chat-app/components/eve/use-new-eve-conversation.tsx +42 -7
  176. package/templates/chat-app/components/model-selection-indicator.tsx +12 -10
  177. package/templates/chat-app/components/model-selector-view.tsx +211 -186
  178. package/templates/chat-app/components/new-chat-button.tsx +1 -1
  179. package/templates/chat-app/components/parallel-responses/model-picker.tsx +5 -1
  180. package/templates/chat-app/components/parallel-responses/responses.tsx +2 -2
  181. package/templates/chat-app/components/settings/settings-nav.tsx +1 -1
  182. package/templates/chat-app/components/settings/settings-navigation-link.tsx +1 -0
  183. package/templates/chat-app/components/sidebar-top-row.tsx +1 -1
  184. package/templates/chat-app/components/ui/sidebar.tsx +1 -1
  185. package/templates/chat-app/components/ui/trace.tsx +1 -1
  186. package/templates/chat-app/hooks/use-auto-focus.ts +12 -13
  187. package/templates/chat-app/integrations/routers.ts +1 -1
  188. package/templates/chat-app/lib/ai/active-gateway.ts +0 -9
  189. package/templates/chat-app/lib/ai/app-models.test.ts +0 -4
  190. package/templates/chat-app/lib/ai/app-models.ts +11 -6
  191. package/templates/chat-app/lib/ai/gateways/registry.ts +4 -31
  192. package/templates/chat-app/lib/ai/model-catalog.ts +50 -0
  193. package/templates/chat-app/lib/ai/models.ts +4 -39
  194. package/templates/chat-app/lib/ai/providers.ts +2 -16
  195. package/templates/chat-app/lib/chat-after-create.test.ts +1 -1
  196. package/templates/chat-app/lib/chat-after-create.ts +1 -1
  197. package/templates/chat-app/lib/config-schema.ts +0 -96
  198. package/templates/chat-app/lib/db/eve-creation-failure.ts +3 -3
  199. package/templates/chat-app/lib/db/eve-current-copy.ts +11 -11
  200. package/templates/chat-app/lib/db/eve-deletion.ts +19 -19
  201. package/templates/chat-app/lib/db/eve-dispatch.ts +115 -18
  202. package/templates/chat-app/lib/db/eve-file-purge.ts +4 -4
  203. package/templates/chat-app/lib/db/eve-files.ts +13 -13
  204. package/templates/chat-app/lib/db/eve-queries.ts +28 -43
  205. package/templates/chat-app/lib/db/eve-response-groups.ts +30 -112
  206. package/templates/chat-app/lib/db/eve-subagents.ts +8 -8
  207. package/templates/chat-app/lib/db/eve-title.ts +2 -2
  208. package/templates/chat-app/lib/db/eve-workspace-deletion.ts +3 -3
  209. package/templates/chat-app/lib/db/eve-workspace-turns.ts +37 -5
  210. package/templates/chat-app/lib/db/eve-workspaces.ts +3 -3
  211. package/templates/chat-app/lib/db/migrations/0029_branch_identifiers.sql +23 -0
  212. package/templates/chat-app/lib/db/migrations/meta/0029_snapshot.json +2547 -0
  213. package/templates/chat-app/lib/db/migrations/meta/_journal.json +7 -0
  214. package/templates/chat-app/lib/db/schema.ts +19 -25
  215. package/templates/chat-app/lib/devtools-disabled.ts +1 -0
  216. package/templates/chat-app/lib/eve/completed-copy-source.test.ts +12 -2
  217. package/templates/chat-app/lib/eve/completed-copy-source.ts +5 -2
  218. package/templates/chat-app/lib/eve/contracts.test.ts +5 -5
  219. package/templates/chat-app/lib/eve/contracts.ts +1 -1
  220. package/templates/chat-app/lib/eve/conversation-scope.test.ts +2 -2
  221. package/templates/chat-app/lib/eve/conversation-scope.ts +4 -4
  222. package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +1 -1
  223. package/templates/chat-app/lib/eve/create-response-group.test.ts +3 -3
  224. package/templates/chat-app/lib/eve/delete-local-conversation.ts +3 -3
  225. package/templates/chat-app/lib/eve/generated-files.test.ts +1 -1
  226. package/templates/chat-app/lib/eve/generated-files.ts +2 -2
  227. package/templates/chat-app/lib/eve/logical-chat.test.ts +17 -17
  228. package/templates/chat-app/lib/eve/logical-chat.ts +27 -31
  229. package/templates/chat-app/lib/eve/logical-response-slots.ts +4 -7
  230. package/templates/chat-app/lib/eve/message-delivery.ts +1 -0
  231. package/templates/chat-app/lib/eve/model-selection.test.ts +47 -50
  232. package/templates/chat-app/lib/eve/model-selection.ts +5 -37
  233. package/templates/chat-app/lib/eve/pending-create.test.ts +46 -7
  234. package/templates/chat-app/lib/eve/pending-create.ts +36 -4
  235. package/templates/chat-app/lib/eve/persisted-wire-order.test.ts +2 -2
  236. package/templates/chat-app/lib/eve/prepare-deletion.ts +3 -3
  237. package/templates/chat-app/lib/eve/purge-local-resources.ts +3 -3
  238. package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -2
  239. package/templates/chat-app/lib/eve/request-policy.ts +1 -0
  240. package/templates/chat-app/lib/eve/resolve-creation-request.ts +1 -1
  241. package/templates/chat-app/lib/eve/response-group-contracts.ts +1 -1
  242. package/templates/chat-app/lib/eve/response-group-lineage.test.ts +12 -12
  243. package/templates/chat-app/lib/eve/response-group-lineage.ts +21 -24
  244. package/templates/chat-app/lib/eve/response-group.test.ts +2 -2
  245. package/templates/chat-app/lib/eve/response-group.ts +1 -1
  246. package/templates/chat-app/lib/eve/response-model.ts +11 -1
  247. package/templates/chat-app/lib/eve/restore-message-attachments.test.ts +1 -1
  248. package/templates/chat-app/lib/eve/restore-message-attachments.ts +3 -3
  249. package/templates/chat-app/lib/eve/retire-session.ts +3 -3
  250. package/templates/chat-app/lib/eve/steer-rejected.ts +7 -0
  251. package/templates/chat-app/lib/eve/tool-cost.test.ts +18 -6
  252. package/templates/chat-app/lib/eve/tool-cost.ts +10 -18
  253. package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +27 -0
  254. package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +20 -13
  255. package/templates/chat-app/oxfmt.config.ts +0 -2
  256. package/templates/chat-app/package.json +7 -9
  257. package/templates/chat-app/playwright.config.ts +5 -1
  258. package/templates/chat-app/proxy.ts +2 -4
  259. package/templates/chat-app/scripts/agent-status.ts +6 -19
  260. package/templates/chat-app/scripts/build-eve.test.ts +56 -0
  261. package/templates/chat-app/scripts/build-eve.ts +12 -5
  262. package/templates/chat-app/scripts/check-env.ts +77 -73
  263. package/templates/chat-app/scripts/environment-validation-report.ts +1 -20
  264. package/templates/chat-app/scripts/installed-environment-validation.ts +14 -15
  265. package/templates/chat-app/trpc/init.ts +2 -0
  266. package/templates/chat-app/trpc/react.tsx +2 -2
  267. package/templates/chat-app/trpc/routers/_app.test.ts +56 -0
  268. package/templates/chat-app/trpc/routers/_app.ts +12 -11
  269. package/templates/chat-app/trpc/routers/eve.router.ts +2 -2
  270. package/templates/electron/forge.config.ts +1 -19
  271. package/templates/electron/scripts/write-branding.ts +1 -5
  272. package/templates/chat-app/app/privacy/page.tsx +0 -153
  273. package/templates/chat-app/app/terms/page.tsx +0 -270
  274. package/templates/chat-app/chatjs/core/installation/plugin.ts +0 -13
  275. package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -22
  276. package/templates/chat-app/chatjs/plugins/credits/server-plugin.ts +0 -5
  277. package/templates/chat-app/chatjs/plugins/feedback/chat.ts +0 -13
  278. package/templates/chat-app/chatjs/plugins/feedback/server-plugin.ts +0 -8
  279. package/templates/chat-app/chatjs/plugins/followup-suggestions/server-plugin.ts +0 -8
  280. package/templates/chat-app/chatjs/plugins/guest-chat/server-plugin.ts +0 -12
  281. package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +0 -17
  282. package/templates/chat-app/chatjs/plugins/mcp/server-plugin.ts +0 -5
  283. package/templates/chat-app/chatjs/plugins/model-preferences/server-plugin.ts +0 -8
  284. package/templates/chat-app/chatjs/plugins/projects/server-plugin.ts +0 -8
  285. package/templates/chat-app/chatjs/plugins/search/server-plugin.ts +0 -5
  286. package/templates/chat-app/chatjs/plugins/sharing/server-plugin.ts +0 -5
  287. package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +0 -18
  288. package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +0 -16
  289. package/templates/chat-app/components/ai-elements/context-hover.radix.tsx +0 -15
  290. package/templates/chat-app/components/ai-elements/context-hover.tsx +0 -17
  291. package/templates/chat-app/components/ai-elements/context.tsx +0 -405
  292. package/templates/chat-app/components/composer/editor.css +0 -96
  293. package/templates/chat-app/components/lexical-chat-input.tsx +0 -276
  294. package/templates/chat-app/components/model-selection-indicator.radix.tsx +0 -17
  295. package/templates/chat-app/components/ui/resizable.tsx +0 -49
  296. package/templates/chat-app/lib/ai/gateways/fallback-models.ts +0 -29
  297. package/templates/chat-app/lib/ai/models.generated.ts +0 -4242
  298. package/templates/chat-app/lib/ai/usage-token-details.test.ts +0 -76
  299. package/templates/chat-app/lib/ai/usage-token-details.ts +0 -33
  300. package/templates/chat-app/lib/chat-route.ts +0 -18
  301. package/templates/chat-app/providers/parse-chat-id-from-pathname.test.ts +0 -126
  302. package/templates/chat-app/providers/parse-chat-id-from-pathname.ts +0 -51
  303. package/templates/chat-app/scripts/fetch-models.ts +0 -30
  304. package/templates/chat-app/scripts/gateway-snapshot-warning.test.ts +0 -9
  305. /package/templates/chat-app/chatjs/plugins/attachment-uploads/{integration.tsx → uploads.ts} +0 -0
@@ -14,12 +14,12 @@ type WriteTransaction = Readonly<
14
14
  * Reads vote state for messages in one bound conversation owned by the user.
15
15
  * Public sharing does not grant access to these owner-only votes.
16
16
  * @param {string} ownerId Owner whose vote state is requested.
17
- * @param {string} conversationId Bound conversation to read.
17
+ * @param {string} branchId Bound conversation to read.
18
18
  * @returns {PromiseLike<Pick<typeof eveVote.$inferSelect, "isUpvoted" | "messageId">[]>} Lazy owner-filtered query. Await it or consume it with .then or .execute to read matching rows; Drizzle query methods remain available before consumption.
19
19
  */
20
20
  export const getEveMessageVotes = (
21
21
  ownerId: string,
22
- conversationId: string
22
+ branchId: string
23
23
  ): PgSelectWithout<
24
24
  PgSelectBase<
25
25
  GetSelectTableName<typeof eveVote>,
@@ -37,10 +37,10 @@ export const getEveMessageVotes = (
37
37
  db
38
38
  .select({ isUpvoted: eveVote.isUpvoted, messageId: eveVote.messageId })
39
39
  .from(eveVote)
40
- .innerJoin(eveConversation, eq(eveConversation.id, eveVote.conversationId))
40
+ .innerJoin(eveConversation, eq(eveConversation.id, eveVote.branchId))
41
41
  .where(
42
42
  and(
43
- eq(eveConversation.id, conversationId),
43
+ eq(eveConversation.id, branchId),
44
44
  eq(eveConversation.ownerId, ownerId),
45
45
  eq(eveConversation.state, "bound")
46
46
  )
@@ -50,14 +50,14 @@ export const getEveMessageVotes = (
50
50
  * Saves a message vote after validating the message against the native Eve snapshot.
51
51
  * The owner and bound-conversation check runs under the conversation-family lock.
52
52
  * @param {string} ownerId Owner submitting the vote.
53
- * @param {string} conversationId Bound conversation containing the message.
53
+ * @param {string} branchId Bound conversation containing the message.
54
54
  * @param {string} messageId Native message ID being rated.
55
55
  * @param {boolean} isUpvoted Whether the message received a positive vote.
56
56
  * @returns {Promise<{ isUpvoted: boolean; messageId: string } | null>} The saved vote, or null when the conversation is no longer bound to the owner.
57
57
  */
58
58
  export const saveEveMessageVote = async (
59
59
  ownerId: string,
60
- conversationId: string,
60
+ branchId: string,
61
61
  messageId: string,
62
62
  isUpvoted: boolean
63
63
  ): Promise<Pick<
@@ -73,7 +73,7 @@ export const saveEveMessageVote = async (
73
73
  .from(eveConversation)
74
74
  .where(
75
75
  and(
76
- eq(eveConversation.id, conversationId),
76
+ eq(eveConversation.id, branchId),
77
77
  eq(eveConversation.ownerId, ownerId),
78
78
  eq(eveConversation.state, "bound")
79
79
  )
@@ -83,10 +83,10 @@ export const saveEveMessageVote = async (
83
83
  }
84
84
  const [saved] = await tx
85
85
  .insert(eveVote)
86
- .values({ conversationId, isUpvoted, messageId })
86
+ .values({ branchId, isUpvoted, messageId })
87
87
  .onConflictDoUpdate({
88
88
  set: { isUpvoted },
89
- target: [eveVote.conversationId, eveVote.messageId],
89
+ target: [eveVote.branchId, eveVote.messageId],
90
90
  })
91
91
  .returning({
92
92
  isUpvoted: eveVote.isUpvoted,
@@ -97,7 +97,7 @@ export const saveEveMessageVote = async (
97
97
 
98
98
  export const getFeedbackConversation = async (
99
99
  ownerId: string,
100
- conversationId: string
100
+ branchId: string
101
101
  ) => {
102
102
  const conversations = await db
103
103
  .select({
@@ -107,7 +107,7 @@ export const getFeedbackConversation = async (
107
107
  .from(eveConversation)
108
108
  .where(
109
109
  and(
110
- eq(eveConversation.id, conversationId),
110
+ eq(eveConversation.id, branchId),
111
111
  eq(eveConversation.ownerId, ownerId),
112
112
  eq(eveConversation.state, "bound")
113
113
  )
@@ -5,11 +5,11 @@ import { eveConversation } from "@/lib/db/schema";
5
5
  export const eveVote = pgTable(
6
6
  "EveVote",
7
7
  {
8
- conversationId: uuid("conversationId")
8
+ branchId: uuid("branchId")
9
9
  .notNull()
10
10
  .references(() => eveConversation.id, { onDelete: "cascade" }),
11
11
  isUpvoted: boolean("isUpvoted").notNull(),
12
12
  messageId: text("messageId").notNull(),
13
13
  },
14
- (table) => [primaryKey({ columns: [table.conversationId, table.messageId] })]
14
+ (table) => [primaryKey({ columns: [table.branchId, table.messageId] })]
15
15
  );
@@ -1,26 +1,17 @@
1
1
  {
2
+ "contractVersion": 3,
3
+ "uiBase": "base",
2
4
  "id": "feedback",
3
5
  "kind": "plugin",
4
6
  "files": [
5
- "chatjs/plugins/feedback/chat.ts",
6
- "chatjs/plugins/feedback/client-plugin.ts",
7
+ "chatjs/plugins/feedback/chat-server.ts",
8
+ "chatjs/plugins/feedback/chat-ui.ts",
7
9
  "chatjs/plugins/feedback/feedback-actions.tsx",
8
10
  "chatjs/plugins/feedback/message-vote-actions.tsx",
9
11
  "chatjs/plugins/feedback/feedback-queries.ts",
10
12
  "chatjs/plugins/feedback/router.ts",
11
13
  "chatjs/plugins/feedback/feedback-schema.ts",
12
- "chatjs/plugins/feedback/server-plugin.ts",
13
14
  "chatjs/plugins/feedback/vote-message.ts"
14
15
  ],
15
- "databaseSchemas": ["chatjs/plugins/feedback/feedback-schema.ts"],
16
- "chat": { "export": "feedbackChat" },
17
- "server": { "export": "feedback", "routers": ["feedback"] },
18
- "client": {
19
- "export": "feedbackClient",
20
- "composerControls": [],
21
- "settingsItems": [],
22
- "chat": true
23
- },
24
- "contractVersion": 2,
25
- "uiBase": "base"
16
+ "databaseSchemas": ["chatjs/plugins/feedback/feedback-schema.ts"]
26
17
  }
@@ -7,11 +7,11 @@ import { getEveMessageVotes } from "./feedback-queries";
7
7
  import { voteEveMessage } from "./vote-message";
8
8
 
9
9
  const MAX_MESSAGE_ID_LENGTH = 512;
10
- export const feedbackRouter = createTRPCRouter({
10
+ const feedbackProcedures = {
11
11
  vote: eveOwnedProcedure
12
12
  .input(
13
13
  z.object({
14
- conversationId: z.uuid(),
14
+ branchId: z.uuid(),
15
15
  messageId: z.string().nonempty().max(MAX_MESSAGE_ID_LENGTH),
16
16
  type: z.enum(["up", "down"]),
17
17
  })
@@ -23,7 +23,7 @@ export const feedbackRouter = createTRPCRouter({
23
23
  }: {
24
24
  readonly ctx: { readonly eveOwnerId: string };
25
25
  readonly input: ReadonlyNativeSurface<{
26
- conversationId: string;
26
+ branchId: string;
27
27
  messageId: string;
28
28
  type: "up" | "down";
29
29
  }>;
@@ -39,14 +39,16 @@ export const feedbackRouter = createTRPCRouter({
39
39
  }
40
40
  ),
41
41
  votes: eveOwnedProcedure
42
- .input(z.object({ conversationId: z.uuid() }))
42
+ .input(z.object({ branchId: z.uuid() }))
43
43
  .query(
44
44
  async ({
45
45
  ctx,
46
46
  input,
47
47
  }: {
48
48
  readonly ctx: { readonly eveOwnerId: string };
49
- readonly input: { readonly conversationId: string };
50
- }) => await getEveMessageVotes(ctx.eveOwnerId, input.conversationId)
49
+ readonly input: { readonly branchId: string };
50
+ }) => await getEveMessageVotes(ctx.eveOwnerId, input.branchId)
51
51
  ),
52
- });
52
+ };
53
+
54
+ export const router = createTRPCRouter({ feedback: feedbackProcedures });
@@ -11,15 +11,12 @@ const VOTE_SNAPSHOT_TIMEOUT_MS = 15_000;
11
11
  export const voteEveMessage = async (
12
12
  ownerId: string,
13
13
  input: {
14
- readonly conversationId: string;
14
+ readonly branchId: string;
15
15
  readonly messageId: string;
16
16
  readonly type: "up" | "down";
17
17
  }
18
18
  ): Promise<Awaited<ReturnType<typeof saveEveMessageVote>>> => {
19
- const conversation = await getFeedbackConversation(
20
- ownerId,
21
- input.conversationId
22
- );
19
+ const conversation = await getFeedbackConversation(ownerId, input.branchId);
23
20
 
24
21
  if (
25
22
  !conversation ||
@@ -45,7 +42,7 @@ export const voteEveMessage = async (
45
42
  }
46
43
  return await saveEveMessageVote(
47
44
  ownerId,
48
- input.conversationId,
45
+ input.branchId,
49
46
  input.messageId,
50
47
  input.type === "up"
51
48
  );
@@ -2,7 +2,7 @@ import { inArray } from "drizzle-orm";
2
2
  import type { ChatServerIntegration } from "@/chatjs/core/chat/contracts";
3
3
  import { eveFollowup } from "./followup-schema";
4
4
 
5
- export const followupChat = {
5
+ const followupChat = {
6
6
  onDeleteConversations: async (tx, { sessionIds }) => {
7
7
  if (sessionIds.length > 0) {
8
8
  await tx
@@ -11,3 +11,5 @@ export const followupChat = {
11
11
  }
12
12
  },
13
13
  } satisfies ChatServerIntegration;
14
+
15
+ export default followupChat;
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
3
3
  import { ChatSuggestions } from "@/components/chat-slots";
4
4
  import { FollowupSuggestions } from "./suggestions";
5
5
 
6
- export const followupSuggestionsClient = definePlugin({
6
+ export const chatUi = definePlugin({
7
7
  id: "followup-suggestions",
8
8
  slots: [slot(ChatSuggestions, FollowupSuggestions)],
9
9
  });
@@ -54,7 +54,7 @@ export const finishEveFollowup = async (
54
54
 
55
55
  export const getEveFollowup = async (
56
56
  ownerId: string,
57
- conversationId: string,
57
+ branchId: string,
58
58
  eventId: string
59
59
  ): Promise<readonly string[] | null> => {
60
60
  const [row] = await db
@@ -69,7 +69,7 @@ export const getEveFollowup = async (
69
69
  )
70
70
  .where(
71
71
  and(
72
- eq(eveConversation.id, conversationId),
72
+ eq(eveConversation.id, branchId),
73
73
  eq(eveConversation.ownerId, ownerId),
74
74
  eq(eveConversation.state, "bound"),
75
75
  eq(eveFollowup.eventId, eventId)
@@ -1,9 +1,11 @@
1
1
  {
2
+ "contractVersion": 3,
3
+ "uiBase": "base",
2
4
  "id": "followup-suggestions",
3
5
  "kind": "plugin",
4
6
  "files": [
5
- "chatjs/plugins/followup-suggestions/chat.ts",
6
- "chatjs/plugins/followup-suggestions/client-plugin.ts",
7
+ "chatjs/plugins/followup-suggestions/chat-server.ts",
8
+ "chatjs/plugins/followup-suggestions/chat-ui.ts",
7
9
  "chatjs/plugins/followup-suggestions/followup-completion.ts",
8
10
  "chatjs/plugins/followup-suggestions/followup-context.ts",
9
11
  "chatjs/plugins/followup-suggestions/followup-hook.ts",
@@ -12,24 +14,10 @@
12
14
  "chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx",
13
15
  "chatjs/plugins/followup-suggestions/generate-suggestions.ts",
14
16
  "chatjs/plugins/followup-suggestions/router.ts",
15
- "chatjs/plugins/followup-suggestions/server-plugin.ts",
16
17
  "chatjs/plugins/followup-suggestions/suggestion-output.ts",
17
18
  "chatjs/plugins/followup-suggestions/suggestions.tsx",
18
19
  "chatjs/plugins/followup-suggestions/use-followups.ts",
19
20
  "agent/hooks/followup-suggestions.ts"
20
21
  ],
21
- "databaseSchemas": ["chatjs/plugins/followup-suggestions/followup-schema.ts"],
22
- "chat": { "export": "followupChat" },
23
- "server": {
24
- "export": "followupSuggestions",
25
- "routers": ["followupSuggestions"]
26
- },
27
- "client": {
28
- "export": "followupSuggestionsClient",
29
- "composerControls": [],
30
- "settingsItems": [],
31
- "chat": true
32
- },
33
- "contractVersion": 2,
34
- "uiBase": "base"
22
+ "databaseSchemas": ["chatjs/plugins/followup-suggestions/followup-schema.ts"]
35
23
  }
@@ -3,11 +3,11 @@ import { createTRPCRouter } from "@/trpc/init";
3
3
  import { eveOwnedProcedure } from "@/trpc/eve-owned-procedure";
4
4
  import { getEveFollowup } from "./followup-queries";
5
5
 
6
- export const followupSuggestionsRouter = createTRPCRouter({
6
+ const followupSuggestionsProcedures = {
7
7
  get: eveOwnedProcedure
8
8
  .input(
9
9
  z.object({
10
- conversationId: z.uuid(),
10
+ branchId: z.uuid(),
11
11
  eventId: z.string().min(1).max(512),
12
12
  })
13
13
  )
@@ -18,14 +18,13 @@ export const followupSuggestionsRouter = createTRPCRouter({
18
18
  }: {
19
19
  readonly ctx: { readonly eveOwnerId: string };
20
20
  readonly input: {
21
- readonly conversationId: string;
21
+ readonly branchId: string;
22
22
  readonly eventId: string;
23
23
  };
24
- }) =>
25
- await getEveFollowup(
26
- ctx.eveOwnerId,
27
- input.conversationId,
28
- input.eventId
29
- )
24
+ }) => await getEveFollowup(ctx.eveOwnerId, input.branchId, input.eventId)
30
25
  ),
26
+ };
27
+
28
+ export const router = createTRPCRouter({
29
+ followupSuggestions: followupSuggestionsProcedures,
31
30
  });
@@ -6,19 +6,14 @@ import { useEveFollowups } from "./use-followups";
6
6
  import { FollowUpSuggestionsView } from "./followup-suggestions-view";
7
7
 
8
8
  export const FollowupSuggestions = ({
9
- conversationId,
9
+ branchId,
10
10
  sessionId,
11
11
  events,
12
12
  lastMessage,
13
13
  onSelect,
14
14
  disabled,
15
15
  }: ChatSuggestionsProps): React.JSX.Element | null => {
16
- const suggestions = useEveFollowups(
17
- conversationId,
18
- sessionId,
19
- events,
20
- lastMessage
21
- );
16
+ const suggestions = useEveFollowups(branchId, sessionId, events, lastMessage);
22
17
  return (
23
18
  <FollowUpSuggestionsView
24
19
  suggestions={suggestions}
@@ -11,7 +11,7 @@ const POLL_INTERVAL_MS = 1000;
11
11
  const MAX_POLLS = 20;
12
12
 
13
13
  export const useEveFollowups = (
14
- conversationId: string,
14
+ branchId: string,
15
15
  sessionId: string,
16
16
  events: Parameters<typeof followupCompletion>[0],
17
17
  message: ChatSuggestionsProps["lastMessage"]
@@ -23,7 +23,7 @@ export const useEveFollowups = (
23
23
  : undefined;
24
24
  const query = useQuery({
25
25
  ...trpc.followupSuggestions.get.queryOptions({
26
- conversationId,
26
+ branchId,
27
27
  eventId: eventId ?? "",
28
28
  }),
29
29
  enabled:
@@ -1,7 +1 @@
1
- import type { CleanupTask } from "@/lib/cleanup/contracts";
2
- import { cleanupGuestRuntimeSessions } from "./guest-cleanup";
3
-
4
- export const guestCleanup = {
5
- id: "guest-chat",
6
- run: cleanupGuestRuntimeSessions,
7
- } satisfies CleanupTask;
1
+ export { cleanupGuestRuntimeSessions as default } from "./guest-cleanup";
@@ -18,6 +18,7 @@ const BEARER_PREFIX = "Bearer ";
18
18
  const message = z
19
19
  .object({
20
20
  message: z.string().trim().min(MIN_FIELD_LENGTH).max(MAX_MESSAGE_LENGTH),
21
+ turnPolicy: z.literal("steer").optional(),
21
22
  })
22
23
  .strict();
23
24
 
@@ -0,0 +1,6 @@
1
+ export default async function registerGuestChat(): Promise<void> {
2
+ if (process.env.NEXT_RUNTIME === "nodejs") {
3
+ const { startLocalEveGuestCleanup } = await import("./guest-scheduler");
4
+ startLocalEveGuestCleanup();
5
+ }
6
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "contractVersion": 3,
3
+ "uiBase": "base",
2
4
  "id": "guest-chat",
3
5
  "kind": "plugin",
4
6
  "files": [
@@ -15,21 +17,13 @@
15
17
  "chatjs/plugins/guest-chat/guest-queries.ts",
16
18
  "chatjs/plugins/guest-chat/guest-scheduler.ts",
17
19
  "chatjs/plugins/guest-chat/guest-schema.ts",
20
+ "chatjs/plugins/guest-chat/instrumentation.ts",
18
21
  "chatjs/plugins/guest-chat/routes/create-session.ts",
19
- "chatjs/plugins/guest-chat/server-plugin.ts",
20
22
  "chatjs/plugins/guest-chat/session-profile.ts",
21
23
  "chatjs/plugins/guest-chat/signed-out.tsx",
22
- "app/api/eve-guest/route.ts",
23
- "agent/instrumentation/guest-retention.ts"
24
+ "agent/instrumentation/guest-retention.ts",
25
+ "app/api/eve-guest/route.ts"
24
26
  ],
25
27
  "databaseSchemas": ["chatjs/plugins/guest-chat/guest-schema.ts"],
26
- "signedOut": { "export": "GuestChatScreen" },
27
- "sessionProfile": {
28
- "export": "guestSessionProfile",
29
- "authenticator": "chatjs-disposable-guest"
30
- },
31
- "cleanup": { "export": "guestCleanup", "id": "guest-chat" },
32
- "server": { "export": "guestChat", "routers": [], "instrumentation": true },
33
- "contractVersion": 2,
34
- "uiBase": "base"
28
+ "sessionAuthenticator": "chatjs-disposable-guest"
35
29
  }
@@ -3,7 +3,7 @@ import { authenticateDisposableGuest } from "./guest-auth";
3
3
  import { resolveGuestModel } from "./guest-model";
4
4
  import { GUEST_INSTRUCTIONS } from "./guest-policy";
5
5
 
6
- export const guestSessionProfile = {
6
+ const guestSessionProfile = {
7
7
  authenticator: "chatjs-disposable-guest",
8
8
  authenticate: authenticateDisposableGuest,
9
9
  toolNames: new Set<string>(),
@@ -11,3 +11,5 @@ export const guestSessionProfile = {
11
11
  resolveModel: resolveGuestModel,
12
12
  instructions: GUEST_INSTRUCTIONS,
13
13
  } satisfies SessionProfile;
14
+
15
+ export default guestSessionProfile;
@@ -65,11 +65,16 @@ const createGuestSession = async (modelId: string) => {
65
65
  return bindingSchema.parse(await response.json());
66
66
  };
67
67
 
68
+ const restoreFailedDraft = (sent: string, followUp: string): string =>
69
+ followUp ? `${sent}\n\n${followUp}` : sent;
70
+
68
71
  /** Shared guest presentation, also exercised with deterministic visual fixtures. */
69
72
  const GuestConversationView = ({
70
73
  messages,
71
74
  modelId,
72
75
  busy,
76
+ sending = false,
77
+ allowSendWhileStreaming,
73
78
  failure,
74
79
  expired,
75
80
  draft,
@@ -80,6 +85,8 @@ const GuestConversationView = ({
80
85
  readonly messages: readonly ReadonlyEveMessage[];
81
86
  readonly modelId: string;
82
87
  readonly busy: boolean;
88
+ readonly sending?: boolean;
89
+ readonly allowSendWhileStreaming?: boolean;
83
90
  readonly failure?: string;
84
91
  readonly expired: boolean;
85
92
  readonly draft: string;
@@ -118,17 +125,20 @@ const GuestConversationView = ({
118
125
  </p>
119
126
  )}
120
127
  {expired && (
121
- <output className="text-muted-foreground mb-3 text-sm">
122
- This chat has expired. Start a new chat to continue.
128
+ <div className="mb-3 flex items-center justify-between gap-3 rounded-2xl border px-3 py-2">
129
+ <output className="text-muted-foreground text-sm">
130
+ This chat has expired.
131
+ </output>
123
132
  <Button
124
- variant="link"
133
+ variant="outline"
134
+ size="sm"
125
135
  onClick={() => {
126
136
  globalThis.dispatchEvent(new Event("chatjs:new-chat"));
127
137
  }}
128
138
  >
129
139
  New chat
130
140
  </Button>
131
- </output>
141
+ </div>
132
142
  )}
133
143
  <EveComposer
134
144
  autoFocus
@@ -140,8 +150,11 @@ const GuestConversationView = ({
140
150
  fallbackModelName={GUEST_POLICY.modelName}
141
151
  />
142
152
  }
143
- status={busy ? "streaming" : "ready"}
144
- disabled={busy || expired}
153
+ status={(busy && "streaming") || (sending && "submitted") || "ready"}
154
+ disabled={sending || expired}
155
+ readOnly={expired}
156
+ allowDraftWhileBusy
157
+ allowSendWhileStreaming={allowSendWhileStreaming}
145
158
  draft={draft}
146
159
  onDraftChange={onDraftChange}
147
160
  onSubmit={() => {
@@ -161,41 +174,51 @@ const GuestConversationView = ({
161
174
 
162
175
  const GuestConversation = ({
163
176
  binding,
177
+ initialDraft,
164
178
  }: {
165
179
  readonly binding: Binding;
180
+ readonly initialDraft: string;
166
181
  }): ReactJSX.Element => {
167
182
  const agent = useEveAgent({
168
183
  agent: "chat",
169
184
  auth: { bearer: binding.credential },
170
185
  initialSession: { sessionId: binding.sessionId, streamIndex: 0 },
171
186
  });
172
- const [draft, setDraft] = useState("");
173
-
187
+ const [draft, setDraft] = useState(initialDraft);
174
188
  const [commandError, setCommandError] = useState("");
175
189
  const [expired, setExpired] = useState(false);
190
+ const [sending, setSending] = useState(true);
176
191
  const started = useRef(false);
177
192
  const pending = useRef(false);
178
193
  const busy = agent.status === "busy" || agent.status === "resuming";
179
- const send = async (text: string): Promise<void> => {
194
+ const send = async (text: string, clearDraft: boolean): Promise<void> => {
180
195
  if (pending.current) {
181
196
  return;
182
197
  }
183
198
  if (Date.now() >= binding.expiresAt) {
184
199
  setExpired(true);
200
+ setSending(false);
185
201
  return;
186
202
  }
187
203
  pending.current = true;
204
+ setSending(true);
188
205
  setCommandError("");
189
- setDraft("");
206
+ if (clearDraft) {
207
+ setDraft("");
208
+ }
190
209
  try {
191
- await agent.send(text);
210
+ await agent.send(
211
+ text,
212
+ agent.status === "busy" ? { turnPolicy: "steer" } : undefined
213
+ );
192
214
  } catch (error) {
193
215
  setCommandError(
194
216
  error instanceof Error ? error.message : "Message could not be sent."
195
217
  );
196
- setDraft(text);
218
+ setDraft((current) => restoreFailedDraft(text, current));
197
219
  }
198
220
  pending.current = false;
221
+ setSending(false);
199
222
  };
200
223
  useEffect(() => {
201
224
  // EVE attaches its observer on the next task. Defer the initial send too,
@@ -203,7 +226,7 @@ const GuestConversation = ({
203
226
  const timer = setTimeout(() => {
204
227
  if (!started.current) {
205
228
  started.current = true;
206
- void send(binding.firstMessage);
229
+ void send(binding.firstMessage, false);
207
230
  }
208
231
  }, 0);
209
232
  return (): void => {
@@ -251,12 +274,14 @@ const GuestConversation = ({
251
274
  messages={agent.messages}
252
275
  modelId={binding.modelId}
253
276
  busy={busy}
277
+ sending={sending}
278
+ allowSendWhileStreaming={agent.status === "busy"}
254
279
  failure={failure}
255
280
  expired={expired}
256
281
  draft={draft}
257
282
  onDraftChange={setDraft}
258
283
  onSend={(text) => {
259
- void send(text);
284
+ void send(text, true);
260
285
  }}
261
286
  onStop={() => {
262
287
  void stop();
@@ -308,6 +333,7 @@ const GuestWelcomeView = ({
308
333
  }
309
334
  status={busy ? "submitted" : "ready"}
310
335
  disabled={busy || !modelId}
336
+ allowDraftWhileBusy
311
337
  draft={draft}
312
338
  onDraftChange={onDraftChange}
313
339
  onSubmit={onSend}
@@ -325,17 +351,19 @@ const GuestChatScreen = (): ReactJSX.Element => {
325
351
  const pending = useRef(false);
326
352
  const generation = useRef(0);
327
353
  const submit = async (): Promise<void> => {
328
- if (pending.current || !draft.trim()) {
354
+ const firstMessage = draft.trim();
355
+ if (pending.current || !firstMessage) {
329
356
  return;
330
357
  }
331
358
  const currentGeneration = generation.current;
332
359
  pending.current = true;
333
360
  setBusy(true);
334
361
  setCommandError("");
362
+ setDraft("");
335
363
  try {
336
364
  const created = {
337
365
  ...(await createGuestSession(modelId)),
338
- firstMessage: draft.trim(),
366
+ firstMessage,
339
367
  modelId,
340
368
  };
341
369
  if (generation.current !== currentGeneration) {
@@ -343,7 +371,6 @@ const GuestChatScreen = (): ReactJSX.Element => {
343
371
  return;
344
372
  }
345
373
  setBinding(created);
346
- setDraft("");
347
374
  } catch (error) {
348
375
  if (generation.current !== currentGeneration) {
349
376
  return;
@@ -351,6 +378,7 @@ const GuestChatScreen = (): ReactJSX.Element => {
351
378
  setCommandError(
352
379
  error instanceof Error ? error.message : "Could not start chat."
353
380
  );
381
+ setDraft((current) => restoreFailedDraft(draft, current));
354
382
  }
355
383
  if (generation.current === currentGeneration) {
356
384
  pending.current = false;
@@ -386,7 +414,11 @@ const GuestChatScreen = (): ReactJSX.Element => {
386
414
  return (
387
415
  <GuestChatLayout>
388
416
  {binding ? (
389
- <GuestConversation binding={binding} key={binding.sessionId} />
417
+ <GuestConversation
418
+ binding={binding}
419
+ initialDraft={draft}
420
+ key={binding.sessionId}
421
+ />
390
422
  ) : (
391
423
  <GuestWelcomeView
392
424
  modelId={modelId}
@@ -403,9 +435,6 @@ const GuestChatScreen = (): ReactJSX.Element => {
403
435
  );
404
436
  };
405
437
 
406
- export {
407
- GuestChatScreen,
408
- GuestChatLayout,
409
- GuestWelcomeView,
410
- GuestConversationView,
411
- };
438
+ export { GuestChatLayout, GuestWelcomeView, GuestConversationView };
439
+
440
+ export default GuestChatScreen;
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
3
3
  import { ArtifactViewerActions } from "@/components/artifact-actions";
4
4
  import { ImageViewerAction } from "./viewer-action";
5
5
 
6
- export const imageViewerClient = definePlugin({
6
+ export const chatUi = definePlugin({
7
7
  id: "image-viewer",
8
8
  slots: [slot(ArtifactViewerActions, ImageViewerAction)],
9
9
  });