chat-js 1.0.0-alpha.7 → 1.0.0-alpha.8

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 (232) hide show
  1. package/README.md +4 -4
  2. package/dist/index.js +433 -658
  3. package/package.json +1 -1
  4. package/templates/chat-app/AGENTS.md +1 -1
  5. package/templates/chat-app/agent/hooks/followup-suggestions.ts +1 -1
  6. package/templates/chat-app/agent/hooks/projects.ts +1 -1
  7. package/templates/chat-app/agent/hooks/search.ts +1 -1
  8. package/templates/chat-app/agent/instructions/projects.ts +1 -1
  9. package/templates/chat-app/agent/tools/mcp.ts +1 -1
  10. package/templates/chat-app/app/(auth)/device-login/page.tsx +1 -1
  11. package/templates/chat-app/app/(chat)/api/files/upload/route.ts +1 -1
  12. package/templates/chat-app/app/(chat)/chat/{[id] → [chatId]}/page.tsx +4 -4
  13. package/templates/chat-app/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx +1 -1
  14. package/templates/chat-app/app/(chat)/project/[projectId]/page.tsx +1 -1
  15. package/templates/chat-app/app/(chat)/settings/connectors/[connectorId]/page.tsx +1 -1
  16. package/templates/chat-app/app/(chat)/settings/connectors/page.tsx +1 -1
  17. package/templates/chat-app/app/(chat)/settings/models/page.tsx +1 -1
  18. package/templates/chat-app/app/(chat)/share/[id]/page.tsx +1 -1
  19. package/templates/chat-app/app/api/agent-conversations/route.test.ts +5 -5
  20. package/templates/chat-app/app/api/agent-conversations/route.ts +2 -2
  21. package/templates/chat-app/app/api/agent-response-groups/route.test.ts +5 -5
  22. package/templates/chat-app/app/api/agent-response-groups/route.ts +1 -1
  23. package/templates/chat-app/app/api/eve/[...path]/route.test.ts +133 -4
  24. package/templates/chat-app/app/api/eve/[...path]/route.ts +175 -49
  25. package/templates/chat-app/app/api/eve-guest/route.ts +1 -1
  26. package/templates/chat-app/app/api/mcp/oauth/callback/route.ts +1 -1
  27. package/templates/chat-app/chatjs/core/chat/compose.ts +4 -4
  28. package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -6
  29. package/templates/chat-app/chatjs/core/installation/contracts.ts +0 -7
  30. package/templates/chat-app/chatjs/generated/installed-auth-ui.ts +2 -2
  31. package/templates/chat-app/chatjs/generated/installed-auth.ts +4 -2
  32. package/templates/chat-app/chatjs/generated/installed-billing.ts +2 -2
  33. package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +24 -24
  34. package/templates/chat-app/chatjs/generated/installed-chat.ts +12 -12
  35. package/templates/chat-app/chatjs/generated/installed-cleanup.ts +4 -4
  36. package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +8 -2
  37. package/templates/chat-app/chatjs/generated/installed-layout.ts +2 -2
  38. package/templates/chat-app/chatjs/generated/installed-model-visibility.ts +2 -2
  39. package/templates/chat-app/chatjs/generated/installed-navigation.ts +2 -2
  40. package/templates/chat-app/chatjs/generated/installed-routers.ts +18 -19
  41. package/templates/chat-app/chatjs/generated/installed-session-profiles.ts +5 -3
  42. package/templates/chat-app/chatjs/generated/installed-sign-out.ts +2 -2
  43. package/templates/chat-app/chatjs/generated/installed-signed-out.ts +2 -2
  44. package/templates/chat-app/chatjs/generated/installed-uploads.ts +2 -2
  45. package/templates/chat-app/chatjs/plugins/ai-titles/{chat.ts → chat-server.ts} +3 -1
  46. package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +7 -9
  47. package/templates/chat-app/chatjs/plugins/ai-titles/{chatjs.json → plugin.json} +3 -4
  48. package/templates/chat-app/chatjs/plugins/ai-titles/title-queries.ts +4 -4
  49. package/templates/chat-app/chatjs/plugins/attachment-uploads/{client-plugin.ts → chat-ui.ts} +1 -3
  50. package/templates/chat-app/chatjs/plugins/attachment-uploads/plugin.json +16 -0
  51. package/templates/chat-app/chatjs/plugins/credits/billing.ts +3 -1
  52. package/templates/chat-app/chatjs/plugins/credits/{client-plugin.ts → chat-ui.ts} +1 -1
  53. package/templates/chat-app/chatjs/plugins/credits/{chatjs.json → plugin.json} +4 -13
  54. package/templates/chat-app/chatjs/plugins/credits/router.ts +4 -2
  55. package/templates/chat-app/chatjs/plugins/desktop/auth-form.tsx +3 -1
  56. package/templates/chat-app/chatjs/plugins/desktop/auth-server.ts +3 -1
  57. package/templates/chat-app/chatjs/plugins/desktop/{client-plugin.ts → layout-ui.ts} +1 -1
  58. package/templates/chat-app/chatjs/plugins/desktop/navigation.ts +3 -1
  59. package/templates/chat-app/chatjs/plugins/desktop/{chatjs.json → plugin.json} +4 -16
  60. package/templates/chat-app/chatjs/plugins/desktop/sign-out.ts +3 -1
  61. package/templates/chat-app/chatjs/plugins/feedback/chat-server.ts +13 -0
  62. package/templates/chat-app/chatjs/plugins/feedback/{client-plugin.ts → chat-ui.ts} +1 -1
  63. package/templates/chat-app/chatjs/plugins/feedback/feedback-actions.tsx +4 -4
  64. package/templates/chat-app/chatjs/plugins/feedback/feedback-queries.ts +11 -11
  65. package/templates/chat-app/chatjs/plugins/feedback/feedback-schema.ts +2 -2
  66. package/templates/chat-app/chatjs/plugins/feedback/{chatjs.json → plugin.json} +5 -14
  67. package/templates/chat-app/chatjs/plugins/feedback/router.ts +9 -7
  68. package/templates/chat-app/chatjs/plugins/feedback/vote-message.ts +3 -6
  69. package/templates/chat-app/chatjs/plugins/followup-suggestions/{chat.ts → chat-server.ts} +3 -1
  70. package/templates/chat-app/chatjs/plugins/followup-suggestions/{client-plugin.ts → chat-ui.ts} +1 -1
  71. package/templates/chat-app/chatjs/plugins/followup-suggestions/followup-queries.ts +2 -2
  72. package/templates/chat-app/chatjs/plugins/followup-suggestions/{chatjs.json → plugin.json} +5 -17
  73. package/templates/chat-app/chatjs/plugins/followup-suggestions/router.ts +8 -9
  74. package/templates/chat-app/chatjs/plugins/followup-suggestions/suggestions.tsx +2 -7
  75. package/templates/chat-app/chatjs/plugins/followup-suggestions/use-followups.ts +2 -2
  76. package/templates/chat-app/chatjs/plugins/guest-chat/cleanup.ts +1 -7
  77. package/templates/chat-app/chatjs/plugins/guest-chat/guest-auth.ts +1 -0
  78. package/templates/chat-app/chatjs/plugins/guest-chat/instrumentation.ts +6 -0
  79. package/templates/chat-app/chatjs/plugins/guest-chat/{chatjs.json → plugin.json} +6 -12
  80. package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +3 -1
  81. package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +46 -20
  82. package/templates/chat-app/chatjs/plugins/image-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
  83. package/templates/chat-app/chatjs/plugins/image-viewer/plugin.json +11 -0
  84. package/templates/chat-app/chatjs/plugins/mcp/{client-plugin.ts → chat-ui.ts} +1 -1
  85. package/templates/chat-app/chatjs/plugins/mcp/db/encrypted-text.ts +1 -1
  86. package/templates/chat-app/chatjs/plugins/mcp/{chatjs.json → plugin.json} +5 -13
  87. package/templates/chat-app/chatjs/plugins/mcp/router.ts +4 -2
  88. package/templates/chat-app/chatjs/plugins/mcp/setup.ts +2 -2
  89. package/templates/chat-app/chatjs/plugins/mcp/{mcp-env.ts → validate-env.ts} +2 -1
  90. package/templates/chat-app/chatjs/plugins/model-preferences/{client-plugin.ts → chat-ui.ts} +1 -3
  91. package/templates/chat-app/chatjs/plugins/model-preferences/{use-model-preferences.ts → model-visibility.ts} +1 -1
  92. package/templates/chat-app/chatjs/plugins/model-preferences/{chatjs.json → plugin.json} +5 -13
  93. package/templates/chat-app/chatjs/plugins/model-preferences/router.ts +5 -1
  94. package/templates/chat-app/chatjs/plugins/projects/{chat.ts → chat-server.ts} +3 -1
  95. package/templates/chat-app/chatjs/plugins/projects/{client-plugin.ts → chat-ui.ts} +1 -1
  96. package/templates/chat-app/chatjs/plugins/projects/conversation-hook.ts +1 -1
  97. package/templates/chat-app/chatjs/plugins/projects/db/project-queries.ts +2 -2
  98. package/templates/chat-app/chatjs/plugins/projects/{chatjs.json → plugin.json} +5 -14
  99. package/templates/chat-app/chatjs/plugins/projects/router.ts +7 -7
  100. package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +3 -3
  101. package/templates/chat-app/chatjs/plugins/projects/ui/eve-move-project-dialog.tsx +1 -1
  102. package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +12 -11
  103. package/templates/chat-app/chatjs/plugins/search/{chat.ts → chat-server.ts} +8 -6
  104. package/templates/chat-app/chatjs/plugins/search/{client-plugin.ts → chat-ui.ts} +1 -1
  105. package/templates/chat-app/chatjs/plugins/search/{chatjs.json → plugin.json} +5 -14
  106. package/templates/chat-app/chatjs/plugins/search/router.ts +4 -2
  107. package/templates/chat-app/chatjs/plugins/search/search-backfill.ts +4 -4
  108. package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +1 -1
  109. package/templates/chat-app/chatjs/plugins/search/search-hook.ts +2 -2
  110. package/templates/chat-app/chatjs/plugins/search/search-queries.ts +13 -13
  111. package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +2 -2
  112. package/templates/chat-app/chatjs/plugins/search/search-schema.ts +3 -3
  113. package/templates/chat-app/chatjs/plugins/sharing/{chat.ts → chat-server.ts} +3 -1
  114. package/templates/chat-app/chatjs/plugins/sharing/{client-plugin.ts → chat-ui.ts} +1 -1
  115. package/templates/chat-app/chatjs/plugins/sharing/{chatjs.json → plugin.json} +5 -14
  116. package/templates/chat-app/chatjs/plugins/sharing/router.ts +4 -2
  117. package/templates/chat-app/chatjs/plugins/sharing/ui/chat-contributions.tsx +9 -11
  118. package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +6 -6
  119. package/templates/chat-app/chatjs/plugins/sharing/ui/share-dialog.tsx +9 -9
  120. package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
  121. package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/plugin.json +12 -0
  122. package/templates/chat-app/chatjs/plugins/video-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
  123. package/templates/chat-app/chatjs/plugins/video-viewer/plugin.json +10 -0
  124. package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +2 -2
  125. package/templates/chat-app/components/chat/chat-composer.tsx +35 -7
  126. package/templates/chat-app/components/chat/chat-conversation-screen.tsx +3 -3
  127. package/templates/chat-app/components/chat/chat-navigation.tsx +11 -1
  128. package/templates/chat-app/components/chat/chat-sidebar.tsx +3 -6
  129. package/templates/chat-app/components/chat/chat-transcript.tsx +52 -23
  130. package/templates/chat-app/components/chat-slots.tsx +1 -1
  131. package/templates/chat-app/components/composer/composer-menu.tsx +5 -4
  132. package/templates/chat-app/components/eve/eve-chat-header.tsx +5 -7
  133. package/templates/chat-app/components/eve/eve-chat-page.tsx +9 -9
  134. package/templates/chat-app/components/eve/eve-composer.tsx +16 -5
  135. package/templates/chat-app/components/eve/eve-conversation.tsx +160 -96
  136. package/templates/chat-app/components/eve/eve-creation-recovery.tsx +21 -2
  137. package/templates/chat-app/components/eve/eve-deletion-provider.tsx +10 -12
  138. package/templates/chat-app/components/eve/eve-history-list.tsx +3 -8
  139. package/templates/chat-app/components/eve/eve-logical-context.tsx +1 -0
  140. package/templates/chat-app/components/eve/eve-logical-navigation.tsx +3 -3
  141. package/templates/chat-app/components/eve/eve-message-content.tsx +252 -0
  142. package/templates/chat-app/components/eve/eve-message-part.tsx +13 -58
  143. package/templates/chat-app/components/eve/eve-pending-input.tsx +82 -5
  144. package/templates/chat-app/components/eve/eve-runtime-provider.tsx +74 -15
  145. package/templates/chat-app/components/eve/use-eve-composer-draft.ts +64 -26
  146. package/templates/chat-app/components/eve/use-eve-fork.ts +14 -16
  147. package/templates/chat-app/components/eve/use-logical-commands.ts +3 -3
  148. package/templates/chat-app/components/eve/use-new-eve-conversation.tsx +42 -7
  149. package/templates/chat-app/components/parallel-responses/model-picker.tsx +5 -1
  150. package/templates/chat-app/components/parallel-responses/responses.tsx +2 -2
  151. package/templates/chat-app/integrations/routers.ts +1 -1
  152. package/templates/chat-app/lib/chat-after-create.test.ts +1 -1
  153. package/templates/chat-app/lib/chat-after-create.ts +1 -1
  154. package/templates/chat-app/lib/db/eve-creation-failure.ts +3 -3
  155. package/templates/chat-app/lib/db/eve-current-copy.ts +11 -11
  156. package/templates/chat-app/lib/db/eve-deletion.ts +19 -19
  157. package/templates/chat-app/lib/db/eve-dispatch.ts +115 -18
  158. package/templates/chat-app/lib/db/eve-file-purge.ts +4 -4
  159. package/templates/chat-app/lib/db/eve-files.ts +13 -13
  160. package/templates/chat-app/lib/db/eve-queries.ts +28 -43
  161. package/templates/chat-app/lib/db/eve-response-groups.ts +30 -112
  162. package/templates/chat-app/lib/db/eve-subagents.ts +8 -8
  163. package/templates/chat-app/lib/db/eve-title.ts +2 -2
  164. package/templates/chat-app/lib/db/eve-workspace-deletion.ts +3 -3
  165. package/templates/chat-app/lib/db/eve-workspace-turns.ts +37 -5
  166. package/templates/chat-app/lib/db/eve-workspaces.ts +3 -3
  167. package/templates/chat-app/lib/db/migrations/0029_branch_identifiers.sql +23 -0
  168. package/templates/chat-app/lib/db/migrations/meta/0029_snapshot.json +2547 -0
  169. package/templates/chat-app/lib/db/migrations/meta/_journal.json +7 -0
  170. package/templates/chat-app/lib/db/schema.ts +19 -25
  171. package/templates/chat-app/lib/eve/completed-copy-source.test.ts +12 -2
  172. package/templates/chat-app/lib/eve/completed-copy-source.ts +5 -2
  173. package/templates/chat-app/lib/eve/contracts.test.ts +5 -5
  174. package/templates/chat-app/lib/eve/contracts.ts +1 -1
  175. package/templates/chat-app/lib/eve/conversation-scope.test.ts +2 -2
  176. package/templates/chat-app/lib/eve/conversation-scope.ts +4 -4
  177. package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +1 -1
  178. package/templates/chat-app/lib/eve/create-response-group.test.ts +3 -3
  179. package/templates/chat-app/lib/eve/delete-local-conversation.ts +3 -3
  180. package/templates/chat-app/lib/eve/generated-files.test.ts +1 -1
  181. package/templates/chat-app/lib/eve/generated-files.ts +2 -2
  182. package/templates/chat-app/lib/eve/logical-chat.test.ts +17 -17
  183. package/templates/chat-app/lib/eve/logical-chat.ts +27 -31
  184. package/templates/chat-app/lib/eve/logical-response-slots.ts +4 -7
  185. package/templates/chat-app/lib/eve/message-delivery.ts +1 -0
  186. package/templates/chat-app/lib/eve/pending-create.test.ts +46 -7
  187. package/templates/chat-app/lib/eve/pending-create.ts +36 -4
  188. package/templates/chat-app/lib/eve/persisted-wire-order.test.ts +2 -2
  189. package/templates/chat-app/lib/eve/prepare-deletion.ts +3 -3
  190. package/templates/chat-app/lib/eve/purge-local-resources.ts +3 -3
  191. package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -2
  192. package/templates/chat-app/lib/eve/request-policy.ts +1 -0
  193. package/templates/chat-app/lib/eve/resolve-creation-request.ts +1 -1
  194. package/templates/chat-app/lib/eve/response-group-contracts.ts +1 -1
  195. package/templates/chat-app/lib/eve/response-group-lineage.test.ts +12 -12
  196. package/templates/chat-app/lib/eve/response-group-lineage.ts +21 -24
  197. package/templates/chat-app/lib/eve/response-group.test.ts +2 -2
  198. package/templates/chat-app/lib/eve/response-group.ts +1 -1
  199. package/templates/chat-app/lib/eve/response-model.ts +11 -1
  200. package/templates/chat-app/lib/eve/restore-message-attachments.test.ts +1 -1
  201. package/templates/chat-app/lib/eve/restore-message-attachments.ts +3 -3
  202. package/templates/chat-app/lib/eve/retire-session.ts +3 -3
  203. package/templates/chat-app/lib/eve/steer-rejected.ts +7 -0
  204. package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +27 -0
  205. package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +20 -13
  206. package/templates/chat-app/playwright.config.ts +5 -1
  207. package/templates/chat-app/scripts/agent-status.ts +6 -19
  208. package/templates/chat-app/scripts/check-env.ts +75 -56
  209. package/templates/chat-app/scripts/installed-environment-validation.ts +14 -15
  210. package/templates/chat-app/trpc/init.ts +2 -0
  211. package/templates/chat-app/trpc/routers/_app.test.ts +56 -0
  212. package/templates/chat-app/trpc/routers/_app.ts +12 -11
  213. package/templates/chat-app/trpc/routers/eve.router.ts +2 -2
  214. package/templates/chat-app/chatjs/core/installation/plugin.ts +0 -13
  215. package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -22
  216. package/templates/chat-app/chatjs/plugins/credits/server-plugin.ts +0 -5
  217. package/templates/chat-app/chatjs/plugins/feedback/chat.ts +0 -13
  218. package/templates/chat-app/chatjs/plugins/feedback/server-plugin.ts +0 -8
  219. package/templates/chat-app/chatjs/plugins/followup-suggestions/server-plugin.ts +0 -8
  220. package/templates/chat-app/chatjs/plugins/guest-chat/server-plugin.ts +0 -12
  221. package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +0 -17
  222. package/templates/chat-app/chatjs/plugins/mcp/server-plugin.ts +0 -5
  223. package/templates/chat-app/chatjs/plugins/model-preferences/server-plugin.ts +0 -8
  224. package/templates/chat-app/chatjs/plugins/projects/server-plugin.ts +0 -8
  225. package/templates/chat-app/chatjs/plugins/search/server-plugin.ts +0 -5
  226. package/templates/chat-app/chatjs/plugins/sharing/server-plugin.ts +0 -5
  227. package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +0 -18
  228. package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +0 -16
  229. package/templates/chat-app/lib/chat-route.ts +0 -18
  230. package/templates/chat-app/providers/parse-chat-id-from-pathname.test.ts +0 -126
  231. package/templates/chat-app/providers/parse-chat-id-from-pathname.ts +0 -51
  232. /package/templates/chat-app/chatjs/plugins/attachment-uploads/{integration.tsx → uploads.ts} +0 -0
@@ -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;
@@ -140,8 +147,11 @@ const GuestConversationView = ({
140
147
  fallbackModelName={GUEST_POLICY.modelName}
141
148
  />
142
149
  }
143
- status={busy ? "streaming" : "ready"}
144
- disabled={busy || expired}
150
+ status={(busy && "streaming") || (sending && "submitted") || "ready"}
151
+ disabled={sending || expired}
152
+ readOnly={expired}
153
+ allowDraftWhileBusy
154
+ allowSendWhileStreaming={allowSendWhileStreaming}
145
155
  draft={draft}
146
156
  onDraftChange={onDraftChange}
147
157
  onSubmit={() => {
@@ -161,41 +171,51 @@ const GuestConversationView = ({
161
171
 
162
172
  const GuestConversation = ({
163
173
  binding,
174
+ initialDraft,
164
175
  }: {
165
176
  readonly binding: Binding;
177
+ readonly initialDraft: string;
166
178
  }): ReactJSX.Element => {
167
179
  const agent = useEveAgent({
168
180
  agent: "chat",
169
181
  auth: { bearer: binding.credential },
170
182
  initialSession: { sessionId: binding.sessionId, streamIndex: 0 },
171
183
  });
172
- const [draft, setDraft] = useState("");
173
-
184
+ const [draft, setDraft] = useState(initialDraft);
174
185
  const [commandError, setCommandError] = useState("");
175
186
  const [expired, setExpired] = useState(false);
187
+ const [sending, setSending] = useState(true);
176
188
  const started = useRef(false);
177
189
  const pending = useRef(false);
178
190
  const busy = agent.status === "busy" || agent.status === "resuming";
179
- const send = async (text: string): Promise<void> => {
191
+ const send = async (text: string, clearDraft: boolean): Promise<void> => {
180
192
  if (pending.current) {
181
193
  return;
182
194
  }
183
195
  if (Date.now() >= binding.expiresAt) {
184
196
  setExpired(true);
197
+ setSending(false);
185
198
  return;
186
199
  }
187
200
  pending.current = true;
201
+ setSending(true);
188
202
  setCommandError("");
189
- setDraft("");
203
+ if (clearDraft) {
204
+ setDraft("");
205
+ }
190
206
  try {
191
- await agent.send(text);
207
+ await agent.send(
208
+ text,
209
+ agent.status === "busy" ? { turnPolicy: "steer" } : undefined
210
+ );
192
211
  } catch (error) {
193
212
  setCommandError(
194
213
  error instanceof Error ? error.message : "Message could not be sent."
195
214
  );
196
- setDraft(text);
215
+ setDraft((current) => restoreFailedDraft(text, current));
197
216
  }
198
217
  pending.current = false;
218
+ setSending(false);
199
219
  };
200
220
  useEffect(() => {
201
221
  // EVE attaches its observer on the next task. Defer the initial send too,
@@ -203,7 +223,7 @@ const GuestConversation = ({
203
223
  const timer = setTimeout(() => {
204
224
  if (!started.current) {
205
225
  started.current = true;
206
- void send(binding.firstMessage);
226
+ void send(binding.firstMessage, false);
207
227
  }
208
228
  }, 0);
209
229
  return (): void => {
@@ -251,12 +271,14 @@ const GuestConversation = ({
251
271
  messages={agent.messages}
252
272
  modelId={binding.modelId}
253
273
  busy={busy}
274
+ sending={sending}
275
+ allowSendWhileStreaming={agent.status === "busy"}
254
276
  failure={failure}
255
277
  expired={expired}
256
278
  draft={draft}
257
279
  onDraftChange={setDraft}
258
280
  onSend={(text) => {
259
- void send(text);
281
+ void send(text, true);
260
282
  }}
261
283
  onStop={() => {
262
284
  void stop();
@@ -308,6 +330,7 @@ const GuestWelcomeView = ({
308
330
  }
309
331
  status={busy ? "submitted" : "ready"}
310
332
  disabled={busy || !modelId}
333
+ allowDraftWhileBusy
311
334
  draft={draft}
312
335
  onDraftChange={onDraftChange}
313
336
  onSubmit={onSend}
@@ -325,17 +348,19 @@ const GuestChatScreen = (): ReactJSX.Element => {
325
348
  const pending = useRef(false);
326
349
  const generation = useRef(0);
327
350
  const submit = async (): Promise<void> => {
328
- if (pending.current || !draft.trim()) {
351
+ const firstMessage = draft.trim();
352
+ if (pending.current || !firstMessage) {
329
353
  return;
330
354
  }
331
355
  const currentGeneration = generation.current;
332
356
  pending.current = true;
333
357
  setBusy(true);
334
358
  setCommandError("");
359
+ setDraft("");
335
360
  try {
336
361
  const created = {
337
362
  ...(await createGuestSession(modelId)),
338
- firstMessage: draft.trim(),
363
+ firstMessage,
339
364
  modelId,
340
365
  };
341
366
  if (generation.current !== currentGeneration) {
@@ -343,7 +368,6 @@ const GuestChatScreen = (): ReactJSX.Element => {
343
368
  return;
344
369
  }
345
370
  setBinding(created);
346
- setDraft("");
347
371
  } catch (error) {
348
372
  if (generation.current !== currentGeneration) {
349
373
  return;
@@ -351,6 +375,7 @@ const GuestChatScreen = (): ReactJSX.Element => {
351
375
  setCommandError(
352
376
  error instanceof Error ? error.message : "Could not start chat."
353
377
  );
378
+ setDraft((current) => restoreFailedDraft(draft, current));
354
379
  }
355
380
  if (generation.current === currentGeneration) {
356
381
  pending.current = false;
@@ -386,7 +411,11 @@ const GuestChatScreen = (): ReactJSX.Element => {
386
411
  return (
387
412
  <GuestChatLayout>
388
413
  {binding ? (
389
- <GuestConversation binding={binding} key={binding.sessionId} />
414
+ <GuestConversation
415
+ binding={binding}
416
+ initialDraft={draft}
417
+ key={binding.sessionId}
418
+ />
390
419
  ) : (
391
420
  <GuestWelcomeView
392
421
  modelId={modelId}
@@ -403,9 +432,6 @@ const GuestChatScreen = (): ReactJSX.Element => {
403
432
  );
404
433
  };
405
434
 
406
- export {
407
- GuestChatScreen,
408
- GuestChatLayout,
409
- GuestWelcomeView,
410
- GuestConversationView,
411
- };
435
+ export { GuestChatLayout, GuestWelcomeView, GuestConversationView };
436
+
437
+ 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
  });
@@ -0,0 +1,11 @@
1
+ {
2
+ "contractVersion": 3,
3
+ "uiBase": "base",
4
+ "id": "image-viewer",
5
+ "kind": "plugin",
6
+ "files": [
7
+ "chatjs/plugins/image-viewer/chat-ui.ts",
8
+ "chatjs/plugins/image-viewer/viewer-action.tsx",
9
+ "chatjs/plugins/image-viewer/image-modal.tsx"
10
+ ]
11
+ }
@@ -4,7 +4,7 @@ import { ComposerExtensions, SettingsLinks } from "@/components/chat-slots";
4
4
  import { ConnectorsControl } from "./composer";
5
5
  import { ConnectorsSettingsLink } from "./settings";
6
6
 
7
- export const mcpClient = definePlugin({
7
+ export const chatUi = definePlugin({
8
8
  id: "mcp",
9
9
  slots: [
10
10
  slot(ComposerExtensions, ConnectorsControl),
@@ -2,7 +2,7 @@ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
2
2
 
3
3
  import { customType } from "drizzle-orm/pg-core";
4
4
 
5
- import { readMcpEncryptionKey } from "@/chatjs/plugins/mcp/mcp-env";
5
+ import { readMcpEncryptionKey } from "@/chatjs/plugins/mcp/validate-env";
6
6
 
7
7
  const isJsonObject = (value: unknown): value is Record<string, unknown> =>
8
8
  typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1,4 +1,6 @@
1
1
  {
2
+ "contractVersion": 3,
3
+ "uiBase": "base",
2
4
  "id": "mcp",
3
5
  "kind": "plugin",
4
6
  "files": [
@@ -20,9 +22,9 @@
20
22
  "chatjs/plugins/mcp/connector-menu-item.tsx",
21
23
  "chatjs/plugins/mcp/db/mcp-schema.ts",
22
24
  "chatjs/plugins/mcp/db/encrypted-text.ts",
23
- "chatjs/plugins/mcp/mcp-env.ts",
24
25
  "chatjs/plugins/mcp/settings.tsx",
25
26
  "chatjs/plugins/mcp/setup.ts",
27
+ "chatjs/plugins/mcp/validate-env.ts",
26
28
  "chatjs/plugins/mcp/oauth/cache.ts",
27
29
  "chatjs/plugins/mcp/oauth/mcp-client-manager.ts",
28
30
  "chatjs/plugins/mcp/oauth/mcp-client.ts",
@@ -38,18 +40,8 @@
38
40
  "chatjs/plugins/mcp/search/mcp-search-params.ts",
39
41
  "chatjs/plugins/mcp/search/mcp-search-params.server.ts",
40
42
  "chatjs/plugins/mcp/router.ts",
41
- "chatjs/plugins/mcp/client-plugin.ts",
42
- "chatjs/plugins/mcp/server-plugin.ts"
43
+ "chatjs/plugins/mcp/chat-ui.ts"
43
44
  ],
44
- "environmentValidation": "mcp-env.ts",
45
45
  "databaseSchemas": ["chatjs/plugins/mcp/db/mcp-schema.ts"],
46
- "envRequirements": [{ "options": [["MCP_ENCRYPTION_KEY"]] }],
47
- "server": { "export": "mcp", "routers": ["mcp"] },
48
- "client": {
49
- "export": "mcpClient",
50
- "composerControls": ["mcp"],
51
- "settingsItems": ["mcp"]
52
- },
53
- "contractVersion": 2,
54
- "uiBase": "base"
46
+ "envRequirements": [{ "options": [["MCP_ENCRYPTION_KEY"]] }]
55
47
  }
@@ -217,7 +217,7 @@ const publicConnector = (connector: PublicConnectorInput): PublicConnector => ({
217
217
  userId: connector.userId,
218
218
  });
219
219
 
220
- export const mcpRouter = createTRPCRouter({
220
+ const mcpProcedures = {
221
221
  /**
222
222
  * Initiate OAuth authorization for an MCP connector.
223
223
  * Returns the authorization URL that the client should open in a popup.
@@ -849,4 +849,6 @@ export const mcpRouter = createTRPCRouter({
849
849
  return { success: true };
850
850
  }
851
851
  ),
852
- });
852
+ };
853
+
854
+ export const router = createTRPCRouter({ mcp: mcpProcedures });
@@ -1,5 +1,5 @@
1
- import descriptor from "@/chatjs/plugins/mcp/chatjs.json";
2
- import { validateEnvironment } from "./mcp-env";
1
+ import descriptor from "@/chatjs/plugins/mcp/plugin.json";
2
+ import validateEnvironment from "./validate-env";
3
3
  import {
4
4
  MissingCredentialsError,
5
5
  requireCredentials,
@@ -23,4 +23,5 @@ const readMcpEncryptionKey = (): string => {
23
23
  }
24
24
  return key;
25
25
  };
26
- export { readMcpEncryptionKey, validateEnvironment };
26
+ export { readMcpEncryptionKey };
27
+ export default validateEnvironment;
@@ -2,10 +2,8 @@
2
2
  import { definePlugin, slot } from "@/chatjs/core/ui/slots";
3
3
  import { ModelSettingsLink } from "@/components/chat-slots";
4
4
  import { ModelPreferencesLink } from "./settings-link";
5
- import { useModelPreferences } from "./use-model-preferences";
6
5
 
7
- export const modelPreferencesClient = definePlugin({
6
+ export const chatUi = definePlugin({
8
7
  id: "model-preferences",
9
8
  slots: [slot(ModelSettingsLink, ModelPreferencesLink)],
10
- useModelVisibility: useModelPreferences,
11
9
  });
@@ -6,7 +6,7 @@ import { useSession } from "@/providers/session-provider";
6
6
  import { useTRPC } from "@/trpc/react";
7
7
  import { applyModelPreferences } from "./apply-model-preferences";
8
8
 
9
- export const useModelPreferences = (
9
+ export const useModelVisibility = (
10
10
  defaults: ReadonlySet<string>
11
11
  ): ReadonlySet<string> => {
12
12
  const trpc = useTRPC();
@@ -1,9 +1,11 @@
1
1
  {
2
+ "contractVersion": 3,
3
+ "uiBase": "base",
2
4
  "id": "model-preferences",
3
5
  "kind": "plugin",
4
6
  "files": [
5
7
  "chatjs/plugins/model-preferences/apply-model-preferences.ts",
6
- "chatjs/plugins/model-preferences/client-plugin.ts",
8
+ "chatjs/plugins/model-preferences/chat-ui.ts",
7
9
  "chatjs/plugins/model-preferences/settings-link.tsx",
8
10
  "chatjs/plugins/model-preferences/model-preferences-queries.ts",
9
11
  "chatjs/plugins/model-preferences/model-preferences-schema.ts",
@@ -12,20 +14,10 @@
12
14
  "chatjs/plugins/model-preferences/models-settings.tsx",
13
15
  "chatjs/plugins/model-preferences/models-table.tsx",
14
16
  "chatjs/plugins/model-preferences/router.ts",
15
- "chatjs/plugins/model-preferences/server-plugin.ts",
16
- "chatjs/plugins/model-preferences/use-model-preferences.ts",
17
+ "chatjs/plugins/model-preferences/model-visibility.ts",
17
18
  "app/(chat)/settings/models/page.tsx"
18
19
  ],
19
20
  "databaseSchemas": [
20
21
  "chatjs/plugins/model-preferences/model-preferences-schema.ts"
21
- ],
22
- "server": { "export": "modelPreferences", "routers": ["modelPreferences"] },
23
- "client": {
24
- "export": "modelPreferencesClient",
25
- "composerControls": [],
26
- "settingsItems": ["models"],
27
- "modelVisibility": true
28
- },
29
- "contractVersion": 2,
30
- "uiBase": "base"
22
+ ]
31
23
  }
@@ -8,7 +8,7 @@ import {
8
8
  import { createTRPCRouter, protectedProcedure } from "@/trpc/init";
9
9
  import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
10
10
 
11
- export const modelPreferencesRouter = createTRPCRouter({
11
+ const modelPreferencesProcedures = {
12
12
  getModelPreferences: protectedProcedure.query(
13
13
  async ({
14
14
  ctx,
@@ -43,4 +43,8 @@ export const modelPreferencesRouter = createTRPCRouter({
43
43
  return { success: true };
44
44
  }
45
45
  ),
46
+ };
47
+
48
+ export const router = createTRPCRouter({
49
+ modelPreferences: modelPreferencesProcedures,
46
50
  });