@chat-js/registry 0.2.0-beta.0 → 0.2.0-beta.10

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 (244) hide show
  1. package/README.md +16 -12
  2. package/dist/r/ai-titles.json +17 -17
  3. package/dist/r/akamai-storage.json +13 -1
  4. package/dist/r/alibaba-storage.json +13 -1
  5. package/dist/r/appwrite-storage.json +8 -1
  6. package/dist/r/archil-storage.json +8 -1
  7. package/dist/r/attach-workspace-file.json +82 -0
  8. package/dist/r/attachment-uploads.json +26 -34
  9. package/dist/r/azure-storage.json +8 -1
  10. package/dist/r/backblaze-b2-storage.json +13 -1
  11. package/dist/r/base/ai-titles.json +47 -0
  12. package/dist/r/base/akamai-storage.json +56 -0
  13. package/dist/r/base/alibaba-storage.json +56 -0
  14. package/dist/r/base/appwrite-storage.json +57 -0
  15. package/dist/r/base/archil-storage.json +59 -0
  16. package/dist/r/base/attach-workspace-file.json +82 -0
  17. package/dist/r/base/attachment-uploads.json +79 -0
  18. package/dist/r/base/azure-storage.json +58 -0
  19. package/dist/r/base/backblaze-b2-storage.json +56 -0
  20. package/dist/r/base/bunny-storage-storage.json +49 -0
  21. package/dist/r/base/cloudinary-storage.json +44 -0
  22. package/dist/r/base/credits.json +81 -0
  23. package/dist/r/base/deep-research.json +138 -0
  24. package/dist/r/base/default-sandbox.json +35 -0
  25. package/dist/r/base/desktop.json +129 -0
  26. package/dist/r/base/digitalocean-spaces-storage.json +56 -0
  27. package/dist/r/base/docker-sandbox.json +35 -0
  28. package/dist/r/base/dropbox-storage.json +44 -0
  29. package/dist/r/base/exoscale-storage.json +56 -0
  30. package/dist/r/base/feedback.json +90 -0
  31. package/dist/r/base/filebase-storage.json +50 -0
  32. package/dist/r/base/firebase-storage-storage.json +53 -0
  33. package/dist/r/base/followup-suggestions.json +130 -0
  34. package/dist/r/base/ftp-storage.json +71 -0
  35. package/dist/r/base/gcs-storage.json +40 -0
  36. package/dist/r/base/generate-image.json +107 -0
  37. package/dist/r/base/generate-video.json +76 -0
  38. package/dist/r/base/google-drive-storage.json +48 -0
  39. package/dist/r/base/guest-chat.json +166 -0
  40. package/dist/r/base/hetzner-storage.json +56 -0
  41. package/dist/r/base/ibm-cos-storage.json +56 -0
  42. package/dist/r/base/idrive-e2-storage.json +56 -0
  43. package/dist/r/base/image-viewer.json +49 -0
  44. package/dist/r/base/just-bash-sandbox.json +32 -0
  45. package/dist/r/base/litellm-gateway.json +64 -0
  46. package/dist/r/base/mcp.json +327 -0
  47. package/dist/r/base/memory-storage.json +30 -0
  48. package/dist/r/base/minio-storage.json +56 -0
  49. package/dist/r/base/model-preferences.json +117 -0
  50. package/dist/r/base/neon-storage.json +51 -0
  51. package/dist/r/base/netlify-blobs-storage.json +39 -0
  52. package/dist/r/base/onedrive-storage.json +49 -0
  53. package/dist/r/base/openai-compatible-gateway.json +66 -0
  54. package/dist/r/base/openai-gateway.json +64 -0
  55. package/dist/r/base/openrouter-gateway.json +71 -0
  56. package/dist/r/base/oracle-cloud-storage.json +62 -0
  57. package/dist/r/base/ovhcloud-storage.json +56 -0
  58. package/dist/r/base/pocketbase-storage.json +51 -0
  59. package/dist/r/base/projects.json +274 -0
  60. package/dist/r/base/r2-storage.json +52 -0
  61. package/dist/r/base/registry.json +4734 -0
  62. package/dist/r/base/s3-storage.json +58 -0
  63. package/dist/r/base/scaleway-storage.json +56 -0
  64. package/dist/r/base/search.json +154 -0
  65. package/dist/r/base/sftp-storage.json +75 -0
  66. package/dist/r/base/sharepoint-storage.json +51 -0
  67. package/dist/r/base/sharing.json +138 -0
  68. package/dist/r/base/spreadsheet-grid.json +20 -0
  69. package/dist/r/base/spreadsheet-viewer.json +62 -0
  70. package/dist/r/base/storj-storage.json +50 -0
  71. package/dist/r/base/streamdown-math.json +35 -0
  72. package/dist/r/base/streamdown-mermaid.json +34 -0
  73. package/dist/r/base/supabase-storage.json +55 -0
  74. package/dist/r/base/tencent-storage.json +56 -0
  75. package/dist/r/base/tigris-storage.json +50 -0
  76. package/dist/r/base/uploadthing-storage.json +39 -0
  77. package/dist/r/base/vercel-blob-storage.json +44 -0
  78. package/dist/r/base/vercel-gateway.json +75 -0
  79. package/dist/r/base/vercel-sandbox.json +49 -0
  80. package/dist/r/base/video-viewer.json +42 -0
  81. package/dist/r/base/vultr-storage.json +56 -0
  82. package/dist/r/base/wasabi-storage.json +56 -0
  83. package/dist/r/base/webdav-storage.json +64 -0
  84. package/dist/r/base/yandex-storage.json +50 -0
  85. package/dist/r/bunny-storage-storage.json +2 -1
  86. package/dist/r/cloudinary-storage.json +2 -1
  87. package/dist/r/credits.json +29 -46
  88. package/dist/r/deep-research.json +56 -138
  89. package/dist/r/default-sandbox.json +35 -0
  90. package/dist/r/desktop.json +129 -0
  91. package/dist/r/digitalocean-spaces-storage.json +13 -1
  92. package/dist/r/docker-sandbox.json +35 -0
  93. package/dist/r/dropbox-storage.json +2 -1
  94. package/dist/r/eve/deep-research.json +47 -0
  95. package/dist/r/eve/registry.json +53 -0
  96. package/dist/r/exoscale-storage.json +13 -1
  97. package/dist/r/feedback.json +38 -53
  98. package/dist/r/filebase-storage.json +8 -1
  99. package/dist/r/firebase-storage-storage.json +2 -1
  100. package/dist/r/followup-suggestions.json +49 -66
  101. package/dist/r/ftp-storage.json +18 -1
  102. package/dist/r/gcs-storage.json +8 -1
  103. package/dist/r/generate-image.json +24 -18
  104. package/dist/r/generate-video.json +17 -11
  105. package/dist/r/google-drive-storage.json +2 -1
  106. package/dist/r/guest-chat.json +166 -0
  107. package/dist/r/hetzner-storage.json +13 -1
  108. package/dist/r/ibm-cos-storage.json +13 -1
  109. package/dist/r/idrive-e2-storage.json +13 -1
  110. package/dist/r/image-viewer.json +49 -0
  111. package/dist/r/just-bash-sandbox.json +32 -0
  112. package/dist/r/litellm-gateway.json +5 -8
  113. package/dist/r/mcp.json +143 -120
  114. package/dist/r/memory-storage.json +5 -3
  115. package/dist/r/minio-storage.json +13 -1
  116. package/dist/r/model-preferences.json +47 -55
  117. package/dist/r/neon-storage.json +8 -1
  118. package/dist/r/netlify-blobs-storage.json +10 -2
  119. package/dist/r/onedrive-storage.json +2 -1
  120. package/dist/r/openai-compatible-gateway.json +6 -9
  121. package/dist/r/openai-gateway.json +6 -9
  122. package/dist/r/openrouter-gateway.json +5 -9
  123. package/dist/r/oracle-cloud-storage.json +18 -1
  124. package/dist/r/ovhcloud-storage.json +13 -1
  125. package/dist/r/pocketbase-storage.json +2 -1
  126. package/dist/r/projects.json +116 -108
  127. package/dist/r/r2-storage.json +9 -1
  128. package/dist/r/radix/ai-titles.json +47 -0
  129. package/dist/r/radix/akamai-storage.json +56 -0
  130. package/dist/r/radix/alibaba-storage.json +56 -0
  131. package/dist/r/radix/appwrite-storage.json +57 -0
  132. package/dist/r/radix/archil-storage.json +59 -0
  133. package/dist/r/radix/attach-workspace-file.json +82 -0
  134. package/dist/r/radix/attachment-uploads.json +79 -0
  135. package/dist/r/radix/azure-storage.json +58 -0
  136. package/dist/r/radix/backblaze-b2-storage.json +56 -0
  137. package/dist/r/radix/bunny-storage-storage.json +49 -0
  138. package/dist/r/radix/cloudinary-storage.json +44 -0
  139. package/dist/r/radix/credits.json +81 -0
  140. package/dist/r/radix/deep-research.json +138 -0
  141. package/dist/r/radix/default-sandbox.json +35 -0
  142. package/dist/r/radix/desktop.json +129 -0
  143. package/dist/r/radix/digitalocean-spaces-storage.json +56 -0
  144. package/dist/r/radix/docker-sandbox.json +35 -0
  145. package/dist/r/radix/dropbox-storage.json +44 -0
  146. package/dist/r/radix/exoscale-storage.json +56 -0
  147. package/dist/r/radix/feedback.json +90 -0
  148. package/dist/r/radix/filebase-storage.json +50 -0
  149. package/dist/r/radix/firebase-storage-storage.json +53 -0
  150. package/dist/r/radix/followup-suggestions.json +130 -0
  151. package/dist/r/radix/ftp-storage.json +71 -0
  152. package/dist/r/radix/gcs-storage.json +40 -0
  153. package/dist/r/radix/generate-image.json +107 -0
  154. package/dist/r/radix/generate-video.json +76 -0
  155. package/dist/r/radix/google-drive-storage.json +48 -0
  156. package/dist/r/radix/guest-chat.json +166 -0
  157. package/dist/r/radix/hetzner-storage.json +56 -0
  158. package/dist/r/radix/ibm-cos-storage.json +56 -0
  159. package/dist/r/radix/idrive-e2-storage.json +56 -0
  160. package/dist/r/radix/image-viewer.json +49 -0
  161. package/dist/r/radix/just-bash-sandbox.json +32 -0
  162. package/dist/r/radix/litellm-gateway.json +64 -0
  163. package/dist/r/radix/mcp.json +327 -0
  164. package/dist/r/radix/memory-storage.json +30 -0
  165. package/dist/r/radix/minio-storage.json +56 -0
  166. package/dist/r/radix/model-preferences.json +117 -0
  167. package/dist/r/radix/neon-storage.json +51 -0
  168. package/dist/r/radix/netlify-blobs-storage.json +39 -0
  169. package/dist/r/radix/onedrive-storage.json +49 -0
  170. package/dist/r/radix/openai-compatible-gateway.json +66 -0
  171. package/dist/r/radix/openai-gateway.json +64 -0
  172. package/dist/r/radix/openrouter-gateway.json +71 -0
  173. package/dist/r/radix/oracle-cloud-storage.json +62 -0
  174. package/dist/r/radix/ovhcloud-storage.json +56 -0
  175. package/dist/r/radix/pocketbase-storage.json +51 -0
  176. package/dist/r/radix/projects.json +274 -0
  177. package/dist/r/radix/r2-storage.json +52 -0
  178. package/dist/r/radix/registry.json +4734 -0
  179. package/dist/r/radix/s3-storage.json +58 -0
  180. package/dist/r/radix/scaleway-storage.json +56 -0
  181. package/dist/r/radix/search.json +154 -0
  182. package/dist/r/radix/sftp-storage.json +75 -0
  183. package/dist/r/radix/sharepoint-storage.json +51 -0
  184. package/dist/r/radix/sharing.json +138 -0
  185. package/dist/r/radix/spreadsheet-grid.json +20 -0
  186. package/dist/r/radix/spreadsheet-viewer.json +62 -0
  187. package/dist/r/radix/storj-storage.json +50 -0
  188. package/dist/r/radix/streamdown-math.json +35 -0
  189. package/dist/r/radix/streamdown-mermaid.json +34 -0
  190. package/dist/r/radix/supabase-storage.json +55 -0
  191. package/dist/r/radix/tencent-storage.json +56 -0
  192. package/dist/r/radix/tigris-storage.json +50 -0
  193. package/dist/r/radix/uploadthing-storage.json +39 -0
  194. package/dist/r/radix/vercel-blob-storage.json +44 -0
  195. package/dist/r/radix/vercel-gateway.json +75 -0
  196. package/dist/r/radix/vercel-sandbox.json +49 -0
  197. package/dist/r/radix/video-viewer.json +42 -0
  198. package/dist/r/radix/vultr-storage.json +56 -0
  199. package/dist/r/radix/wasabi-storage.json +56 -0
  200. package/dist/r/radix/webdav-storage.json +64 -0
  201. package/dist/r/radix/yandex-storage.json +50 -0
  202. package/dist/r/registry.json +2006 -2142
  203. package/dist/r/s3-storage.json +15 -1
  204. package/dist/r/scaleway-storage.json +13 -1
  205. package/dist/r/search.json +80 -66
  206. package/dist/r/sftp-storage.json +18 -1
  207. package/dist/r/sharepoint-storage.json +2 -1
  208. package/dist/r/sharing.json +65 -64
  209. package/dist/r/spreadsheet-grid.json +20 -0
  210. package/dist/r/spreadsheet-viewer.json +62 -0
  211. package/dist/r/storj-storage.json +8 -1
  212. package/dist/r/streamdown-math.json +35 -0
  213. package/dist/r/streamdown-mermaid.json +34 -0
  214. package/dist/r/supabase-storage.json +8 -1
  215. package/dist/r/tencent-storage.json +13 -1
  216. package/dist/r/tigris-storage.json +8 -1
  217. package/dist/r/uploadthing-storage.json +2 -1
  218. package/dist/r/vercel-blob-storage.json +3 -1
  219. package/dist/r/vercel-gateway.json +7 -9
  220. package/dist/r/vercel-sandbox.json +8 -26
  221. package/dist/r/video-viewer.json +42 -0
  222. package/dist/r/vultr-storage.json +13 -1
  223. package/dist/r/wasabi-storage.json +13 -1
  224. package/dist/r/webdav-storage.json +13 -1
  225. package/dist/r/yandex-storage.json +8 -1
  226. package/package.json +20 -38
  227. package/dist/r/code-documents.json +0 -96
  228. package/dist/r/code-execution-runtime.json +0 -25
  229. package/dist/r/code-execution-ui.json +0 -31
  230. package/dist/r/code-execution.json +0 -69
  231. package/dist/r/daytona-sandbox.json +0 -55
  232. package/dist/r/delete-document.json +0 -58
  233. package/dist/r/firecrawl-search.json +0 -72
  234. package/dist/r/get-weather.json +0 -52
  235. package/dist/r/langfuse.json +0 -63
  236. package/dist/r/read-document.json +0 -34
  237. package/dist/r/retrieve-url.json +0 -67
  238. package/dist/r/saved-code-execution.json +0 -81
  239. package/dist/r/sheet-documents.json +0 -93
  240. package/dist/r/tavily-search.json +0 -72
  241. package/dist/r/text-documents.json +0 -116
  242. package/dist/r/vercel-analytics.json +0 -46
  243. package/dist/r/vercel-speed-insights.json +0 -46
  244. package/dist/r/word-count.json +0 -51
@@ -2,103 +2,88 @@
2
2
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
3
  "name": "feedback",
4
4
  "description": "Private feedback on assistant messages",
5
+ "dependencies": [
6
+ "@tanstack/react-query@^5.104.1",
7
+ "@trpc/server@^11.1.2",
8
+ "drizzle-orm@^0.45.1",
9
+ "lucide-react@0.553.0",
10
+ "sonner@^2.0.7"
11
+ ],
5
12
  "files": [
6
13
  {
7
- "path": "src/plugins/feedback/src/chat.ts",
8
- "content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/lib/chat-plugin-contracts\";\nimport { eveVote } from \"./feedback-schema\";\n\nexport const feedbackChat = {\n onDeleteConversations: async (tx, { conversationIds }) => {\n if (conversationIds.length > 0) {\n await tx\n .delete(eveVote)\n .where(inArray(eveVote.conversationId, [...conversationIds]));\n }\n },\n} satisfies ChatServerIntegration;\n",
14
+ "path": "src/plugins/feedback/src/chat-server.ts",
15
+ "content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\nimport { eveVote } from \"./feedback-schema\";\n\nconst feedbackChat = {\n onDeleteConversations: async (tx, { branchIds }) => {\n if (branchIds.length > 0) {\n await tx.delete(eveVote).where(inArray(eveVote.branchId, [...branchIds]));\n }\n },\n} satisfies ChatServerIntegration;\n\nexport default feedbackChat;\n",
9
16
  "type": "registry:file",
10
- "target": "~/plugins/feedback/chat.ts"
17
+ "target": "~/chatjs/plugins/feedback/chat-server.ts"
11
18
  },
12
19
  {
13
- "path": "src/plugins/feedback/src/client-plugin.ts",
14
- "content": "import type { ChatClientPlugin } from \"@/lib/plugin-contracts\";\nimport { FeedbackActions } from \"./feedback-actions\";\n\nexport const feedbackClient = () =>\n ({\n id: \"feedback\",\n chat: { MessageActions: FeedbackActions },\n }) satisfies ChatClientPlugin;\n",
20
+ "path": "src/plugins/feedback/src/chat-ui.ts",
21
+ "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { MessageActions } from \"@/components/chat-slots\";\nimport { FeedbackActions } from \"./feedback-actions\";\n\nexport const chatUi = definePlugin({\n id: \"feedback\",\n slots: [slot(MessageActions, FeedbackActions)],\n});\n",
15
22
  "type": "registry:file",
16
- "target": "~/plugins/feedback/client-plugin.ts"
23
+ "target": "~/chatjs/plugins/feedback/chat-ui.ts"
17
24
  },
18
25
  {
19
26
  "path": "src/plugins/feedback/src/feedback-actions.tsx",
20
- "content": "import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { RefreshCw } from \"lucide-react\";\nimport React from \"react\";\nimport type { JSX as ReactJSX } from \"react\";\n\nimport { MessageAction } from \"@/components/message-action\";\nimport { MessageVoteActions } from \"./message-vote-actions\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const FeedbackActions = ({\n conversationId,\n messageId,\n disabled,\n}: {\n readonly conversationId: string;\n readonly messageId: string;\n readonly disabled: boolean;\n}): ReactJSX.Element => {\n const [, startEventAction] = React.useTransition();\n const trpc = useTRPC();\n const queryClient = useQueryClient();\n // All messages share one cached query and one request per conversation.\n const options = trpc.feedback.votes.queryOptions({ conversationId });\n const votes = useQuery(options);\n const mutation = useMutation(\n trpc.feedback.vote.mutationOptions({\n onMutate: async () => {\n // A background read started before this vote must not overwrite its result.\n await queryClient.cancelQueries({ queryKey: options.queryKey });\n },\n onSuccess: async (saved) => {\n // Focus/reconnect may have started another read while the save was pending.\n await queryClient.cancelQueries({ queryKey: options.queryKey });\n queryClient.setQueryData(options.queryKey, (previous) => [\n ...(previous ?? []).filter(\n (vote) => vote.messageId !== saved.messageId\n ),\n saved,\n ]);\n },\n })\n );\n if (votes.isError) {\n return (\n <MessageAction\n disabled={votes.isFetching}\n\n onClick={() => {\n startEventAction(async () => {\n await votes.refetch();\n });\n }}\n tooltip=\"Retry loading feedback\"\n >\n <RefreshCw size={14} />\n </MessageAction>\n );\n }\n return (\n <MessageVoteActions\n disabled={disabled || votes.isPending || mutation.isPending}\n onVote={async (type) =>\n await mutation.mutateAsync({ conversationId, messageId, type })\n }\n vote={votes.data?.find((vote) => vote.messageId === messageId)}\n />\n );\n};\n",
27
+ "content": "import { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { RefreshCw } from \"lucide-react\";\nimport React from \"react\";\nimport type { JSX as ReactJSX } from \"react\";\n\nimport { MessageAction } from \"@/components/message-action\";\nimport { MessageVoteActions } from \"./message-vote-actions\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const FeedbackActions = ({\n branchId,\n messageId,\n disabled,\n}: {\n readonly branchId: string;\n readonly messageId: string;\n readonly disabled: boolean;\n}): ReactJSX.Element => {\n const [, startEventAction] = React.useTransition();\n const trpc = useTRPC();\n const queryClient = useQueryClient();\n // All messages share one cached query and one request per conversation.\n const options = trpc.feedback.votes.queryOptions({ branchId });\n const votes = useQuery(options);\n const mutation = useMutation(\n trpc.feedback.vote.mutationOptions({\n onMutate: async () => {\n // A background read started before this vote must not overwrite its result.\n await queryClient.cancelQueries({ queryKey: options.queryKey });\n },\n onSuccess: async (saved) => {\n // Focus/reconnect may have started another read while the save was pending.\n await queryClient.cancelQueries({ queryKey: options.queryKey });\n queryClient.setQueryData(options.queryKey, (previous) => [\n ...(previous ?? []).filter(\n (vote) => vote.messageId !== saved.messageId\n ),\n saved,\n ]);\n },\n })\n );\n if (votes.isError) {\n return (\n <MessageAction\n disabled={votes.isFetching}\n\n onClick={() => {\n startEventAction(async () => {\n await votes.refetch();\n });\n }}\n tooltip=\"Retry loading feedback\"\n >\n <RefreshCw size={14} />\n </MessageAction>\n );\n }\n return (\n <MessageVoteActions\n disabled={disabled || votes.isPending || mutation.isPending}\n onVote={async (type) =>\n await mutation.mutateAsync({ branchId, messageId, type })\n }\n vote={votes.data?.find((vote) => vote.messageId === messageId)}\n />\n );\n};\n",
21
28
  "type": "registry:file",
22
- "target": "~/plugins/feedback/feedback-actions.tsx"
29
+ "target": "~/chatjs/plugins/feedback/feedback-actions.tsx"
23
30
  },
24
31
  {
25
32
  "path": "src/plugins/feedback/src/message-vote-actions.tsx",
26
33
  "content": "import { ThumbsDown, ThumbsUp } from \"lucide-react\";\nimport React from \"react\";\nimport { toast } from \"sonner\";\n\nimport { MessageAction } from \"@/components/message-action\";\n\nexport const MessageVoteActions = ({\n vote,\n disabled = false,\n onVote,\n}: {\n readonly vote?: { readonly isUpvoted: boolean };\n readonly disabled?: boolean;\n readonly onVote: (type: \"up\" | \"down\") => Promise<unknown>;\n}): React.JSX.Element => (\n <>\n <MessageAction\n aria-pressed={vote ? !vote.isUpvoted : false}\n className=\"text-muted-foreground hover:bg-accent hover:text-accent-foreground pointer-events-auto! h-7 w-7 p-0\"\n data-testid=\"message-downvote\"\n disabled={disabled || vote?.isUpvoted === false}\n onClick={() => {\n toast.promise(onVote(\"down\"), {\n error: \"Failed to downvote response.\",\n loading: \"Downvoting Response...\",\n success: \"Downvoted Response!\",\n });\n }}\n tooltip=\"Downvote Response\"\n >\n <ThumbsDown size={14} />\n </MessageAction>\n <MessageAction\n aria-pressed={vote?.isUpvoted ?? false}\n className=\"text-muted-foreground hover:bg-accent hover:text-accent-foreground pointer-events-auto! h-7 w-7 p-0\"\n data-testid=\"message-upvote\"\n disabled={disabled || vote?.isUpvoted === true}\n onClick={() => {\n toast.promise(onVote(\"up\"), {\n error: \"Failed to upvote response.\",\n loading: \"Upvoting Response...\",\n success: \"Upvoted Response!\",\n });\n }}\n tooltip=\"Upvote Response\"\n >\n <ThumbsUp size={14} />\n </MessageAction>\n </>\n);\n",
27
34
  "type": "registry:file",
28
- "target": "~/plugins/feedback/message-vote-actions.tsx"
35
+ "target": "~/chatjs/plugins/feedback/message-vote-actions.tsx"
29
36
  },
30
37
  {
31
38
  "path": "src/plugins/feedback/src/feedback-queries.ts",
32
- "content": "import { and, eq, sql } from \"drizzle-orm\";\nimport type { PgSelectBase, PgSelectWithout } from \"drizzle-orm/pg-core\";\nimport type { GetSelectTableName } from \"drizzle-orm/query-builders/select.types\";\nimport { db } from \"@/lib/db/client\";\nimport { eveConversation } from \"@/lib/db/schema\";\nimport { eveVote } from \"./feedback-schema\";\n\nconst hasQueryRow: (row: unknown) => boolean = Boolean;\ntype WriteTransaction = Readonly<\n Pick<typeof db, \"select\" | \"execute\" | \"insert\" | \"delete\" | \"update\">\n>;\n\n/**\n * Reads vote state for messages in one bound conversation owned by the user.\n * Public sharing does not grant access to these owner-only votes.\n * @param {string} ownerId Owner whose vote state is requested.\n * @param {string} conversationId Bound conversation to read.\n * @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.\n */\nexport const getEveMessageVotes = (\n ownerId: string,\n conversationId: string\n): PgSelectWithout<\n PgSelectBase<\n GetSelectTableName<typeof eveVote>,\n Pick<typeof eveVote, \"isUpvoted\" | \"messageId\">,\n \"partial\",\n Record<\n | GetSelectTableName<typeof eveVote>\n | GetSelectTableName<typeof eveConversation>,\n \"not-null\"\n >\n >,\n false,\n \"where\"\n> =>\n db\n .select({ isUpvoted: eveVote.isUpvoted, messageId: eveVote.messageId })\n .from(eveVote)\n .innerJoin(eveConversation, eq(eveConversation.id, eveVote.conversationId))\n .where(\n and(\n eq(eveConversation.id, conversationId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\")\n )\n );\n\n/**\n * Saves a message vote after validating the message against the native Eve snapshot.\n * The owner and bound-conversation check runs under the conversation-family lock.\n * @param {string} ownerId Owner submitting the vote.\n * @param {string} conversationId Bound conversation containing the message.\n * @param {string} messageId Native message ID being rated.\n * @param {boolean} isUpvoted Whether the message received a positive vote.\n * @returns {Promise<{ isUpvoted: boolean; messageId: string } | null>} The saved vote, or null when the conversation is no longer bound to the owner.\n */\nexport const saveEveMessageVote = async (\n ownerId: string,\n conversationId: string,\n messageId: string,\n isUpvoted: boolean\n): Promise<Pick<\n typeof eveVote.$inferSelect,\n \"isUpvoted\" | \"messageId\"\n> | null> =>\n await db.transaction(async (tx: WriteTransaction) => {\n await tx.execute(\n sql`select pg_advisory_xact_lock(hashtextextended(${`eve-family:${ownerId}`}, 0))`\n );\n const [conversation] = await tx\n .select({ id: eveConversation.id })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.id, conversationId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\")\n )\n );\n if (!hasQueryRow(conversation)) {\n return null;\n }\n const [saved] = await tx\n .insert(eveVote)\n .values({ conversationId, isUpvoted, messageId })\n .onConflictDoUpdate({\n set: { isUpvoted },\n target: [eveVote.conversationId, eveVote.messageId],\n })\n .returning({\n isUpvoted: eveVote.isUpvoted,\n messageId: eveVote.messageId,\n });\n return saved;\n });\n\nexport const getFeedbackConversation = async (\n ownerId: string,\n conversationId: string\n) => {\n const conversations = await db\n .select({\n sessionId: eveConversation.sessionId,\n state: eveConversation.state,\n })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.id, conversationId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\")\n )\n );\n return conversations.at(0);\n};\n",
39
+ "content": "import { and, eq, sql } from \"drizzle-orm\";\nimport type { PgSelectBase, PgSelectWithout } from \"drizzle-orm/pg-core\";\nimport type { GetSelectTableName } from \"drizzle-orm/query-builders/select.types\";\nimport { db } from \"@/lib/db/client\";\nimport { eveConversation } from \"@/lib/db/schema\";\nimport { eveVote } from \"./feedback-schema\";\n\nconst hasQueryRow: (row: unknown) => boolean = Boolean;\ntype WriteTransaction = Readonly<\n Pick<typeof db, \"select\" | \"execute\" | \"insert\" | \"delete\" | \"update\">\n>;\n\n/**\n * Reads vote state for messages in one bound conversation owned by the user.\n * Public sharing does not grant access to these owner-only votes.\n * @param {string} ownerId Owner whose vote state is requested.\n * @param {string} branchId Bound conversation to read.\n * @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.\n */\nexport const getEveMessageVotes = (\n ownerId: string,\n branchId: string\n): PgSelectWithout<\n PgSelectBase<\n GetSelectTableName<typeof eveVote>,\n Pick<typeof eveVote, \"isUpvoted\" | \"messageId\">,\n \"partial\",\n Record<\n | GetSelectTableName<typeof eveVote>\n | GetSelectTableName<typeof eveConversation>,\n \"not-null\"\n >\n >,\n false,\n \"where\"\n> =>\n db\n .select({ isUpvoted: eveVote.isUpvoted, messageId: eveVote.messageId })\n .from(eveVote)\n .innerJoin(eveConversation, eq(eveConversation.id, eveVote.branchId))\n .where(\n and(\n eq(eveConversation.id, branchId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\")\n )\n );\n\n/**\n * Saves a message vote after validating the message against the native Eve snapshot.\n * The owner and bound-conversation check runs under the conversation-family lock.\n * @param {string} ownerId Owner submitting the vote.\n * @param {string} branchId Bound conversation containing the message.\n * @param {string} messageId Native message ID being rated.\n * @param {boolean} isUpvoted Whether the message received a positive vote.\n * @returns {Promise<{ isUpvoted: boolean; messageId: string } | null>} The saved vote, or null when the conversation is no longer bound to the owner.\n */\nexport const saveEveMessageVote = async (\n ownerId: string,\n branchId: string,\n messageId: string,\n isUpvoted: boolean\n): Promise<Pick<\n typeof eveVote.$inferSelect,\n \"isUpvoted\" | \"messageId\"\n> | null> =>\n await db.transaction(async (tx: WriteTransaction) => {\n await tx.execute(\n sql`select pg_advisory_xact_lock(hashtextextended(${`eve-family:${ownerId}`}, 0))`\n );\n const [conversation] = await tx\n .select({ id: eveConversation.id })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.id, branchId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\")\n )\n );\n if (!hasQueryRow(conversation)) {\n return null;\n }\n const [saved] = await tx\n .insert(eveVote)\n .values({ branchId, isUpvoted, messageId })\n .onConflictDoUpdate({\n set: { isUpvoted },\n target: [eveVote.branchId, eveVote.messageId],\n })\n .returning({\n isUpvoted: eveVote.isUpvoted,\n messageId: eveVote.messageId,\n });\n return saved;\n });\n\nexport const getFeedbackConversation = async (\n ownerId: string,\n branchId: string\n) => {\n const conversations = await db\n .select({\n sessionId: eveConversation.sessionId,\n state: eveConversation.state,\n })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.id, branchId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\")\n )\n );\n return conversations.at(0);\n};\n",
33
40
  "type": "registry:file",
34
- "target": "~/plugins/feedback/feedback-queries.ts"
41
+ "target": "~/chatjs/plugins/feedback/feedback-queries.ts"
35
42
  },
36
43
  {
37
44
  "path": "src/plugins/feedback/src/router.ts",
38
- "content": "import { TRPCError } from \"@trpc/server\";\nimport { z } from \"zod\";\nimport { createTRPCRouter } from \"@/trpc/init\";\nimport { eveOwnedProcedure } from \"@/trpc/eve-owned-procedure\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { getEveMessageVotes } from \"./feedback-queries\";\nimport { voteEveMessage } from \"./vote-message\";\n\nconst MAX_MESSAGE_ID_LENGTH = 512;\nexport const feedbackRouter = createTRPCRouter({\n vote: eveOwnedProcedure\n .input(\n z.object({\n conversationId: z.uuid(),\n messageId: z.string().nonempty().max(MAX_MESSAGE_ID_LENGTH),\n type: z.enum([\"up\", \"down\"]),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: ReadonlyNativeSurface<{\n conversationId: string;\n messageId: string;\n type: \"up\" | \"down\";\n }>;\n }) => {\n const saved = await voteEveMessage(ctx.eveOwnerId, input);\n if (!saved) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Assistant message not found.\",\n });\n }\n return saved;\n }\n ),\n votes: eveOwnedProcedure\n .input(z.object({ conversationId: z.uuid() }))\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: { readonly conversationId: string };\n }) => await getEveMessageVotes(ctx.eveOwnerId, input.conversationId)\n ),\n});\n",
45
+ "content": "import { TRPCError } from \"@trpc/server\";\nimport { z } from \"zod\";\nimport { createTRPCRouter } from \"@/trpc/init\";\nimport { eveOwnedProcedure } from \"@/trpc/eve-owned-procedure\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { getEveMessageVotes } from \"./feedback-queries\";\nimport { voteEveMessage } from \"./vote-message\";\n\nconst MAX_MESSAGE_ID_LENGTH = 512;\nconst feedbackProcedures = {\n vote: eveOwnedProcedure\n .input(\n z.object({\n branchId: z.uuid(),\n messageId: z.string().nonempty().max(MAX_MESSAGE_ID_LENGTH),\n type: z.enum([\"up\", \"down\"]),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: ReadonlyNativeSurface<{\n branchId: string;\n messageId: string;\n type: \"up\" | \"down\";\n }>;\n }) => {\n const saved = await voteEveMessage(ctx.eveOwnerId, input);\n if (!saved) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Assistant message not found.\",\n });\n }\n return saved;\n }\n ),\n votes: eveOwnedProcedure\n .input(z.object({ branchId: z.uuid() }))\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: { readonly branchId: string };\n }) => await getEveMessageVotes(ctx.eveOwnerId, input.branchId)\n ),\n};\n\nexport const router = createTRPCRouter({ feedback: feedbackProcedures });\n",
39
46
  "type": "registry:file",
40
- "target": "~/plugins/feedback/router.ts"
47
+ "target": "~/chatjs/plugins/feedback/router.ts"
41
48
  },
42
49
  {
43
50
  "path": "src/plugins/feedback/src/feedback-schema.ts",
44
- "content": "import { boolean, pgTable, primaryKey, text, uuid } from \"drizzle-orm/pg-core\";\nimport { eveConversation } from \"@/lib/db/schema\";\n\n/** Feedback references native message IDs without copying the Eve transcript. */\nexport const eveVote = pgTable(\n \"EveVote\",\n {\n conversationId: uuid(\"conversationId\")\n .notNull()\n .references(() => eveConversation.id, { onDelete: \"cascade\" }),\n isUpvoted: boolean(\"isUpvoted\").notNull(),\n messageId: text(\"messageId\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.conversationId, table.messageId] })]\n);\n",
51
+ "content": "import { boolean, pgTable, primaryKey, text, uuid } from \"drizzle-orm/pg-core\";\nimport { eveConversation } from \"@/lib/db/schema\";\n\n/** Feedback references native message IDs without copying the Eve transcript. */\nexport const eveVote = pgTable(\n \"EveVote\",\n {\n branchId: uuid(\"branchId\")\n .notNull()\n .references(() => eveConversation.id, { onDelete: \"cascade\" }),\n isUpvoted: boolean(\"isUpvoted\").notNull(),\n messageId: text(\"messageId\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.branchId, table.messageId] })]\n);\n",
45
52
  "type": "registry:file",
46
- "target": "~/plugins/feedback/feedback-schema.ts"
47
- },
48
- {
49
- "path": "src/plugins/feedback/src/server-plugin.ts",
50
- "content": "import type { ChatPlugin } from \"@/lib/plugin-contracts\";\nimport { feedbackRouter } from \"./router\";\n\nexport const feedback = () =>\n ({\n id: \"feedback\",\n routers: { feedback: feedbackRouter },\n }) satisfies ChatPlugin;\n",
51
- "type": "registry:file",
52
- "target": "~/plugins/feedback/server-plugin.ts"
53
+ "target": "~/chatjs/plugins/feedback/feedback-schema.ts"
53
54
  },
54
55
  {
55
56
  "path": "src/plugins/feedback/src/vote-message.ts",
56
- "content": "import { Client, defaultMessageReducer } from \"eve/client\";\nimport { assertEveConfigured } from \"@/lib/eve/server\";\nimport { getEveConnectionOptions } from \"@/lib/eve/connection-options\";\nimport {\n getFeedbackConversation,\n saveEveMessageVote,\n} from \"./feedback-queries\";\n\nconst VOTE_SNAPSHOT_TIMEOUT_MS = 15_000;\n\nexport const voteEveMessage = async (\n ownerId: string,\n input: {\n readonly conversationId: string;\n readonly messageId: string;\n readonly type: \"up\" | \"down\";\n }\n): Promise<Awaited<ReturnType<typeof saveEveMessageVote>>> => {\n const conversation = await getFeedbackConversation(\n ownerId,\n input.conversationId\n );\n\n if (\n !conversation ||\n typeof conversation.sessionId !== \"string\" ||\n conversation.sessionId === \"\" ||\n conversation.state !== \"bound\"\n ) {\n return null;\n }\n assertEveConfigured();\n const client = new Client(getEveConnectionOptions(ownerId));\n const snapshot = await client.sessions\n .attach(conversation.sessionId)\n .snapshot({ signal: AbortSignal.timeout(VOTE_SNAPSHOT_TIMEOUT_MS) });\n const reducer = defaultMessageReducer();\n const reduceEvent = reducer.reduce.bind(reducer);\n let state = reducer.initial();\n for (const event of snapshot.events) {\n state = reduceEvent(state, event);\n }\n const { messages } = state;\n if (\n !messages.some(\n (message: { readonly id: string; readonly role: string }) =>\n message.id === input.messageId && message.role === \"assistant\"\n )\n ) {\n return null;\n }\n return await saveEveMessageVote(\n ownerId,\n input.conversationId,\n input.messageId,\n input.type === \"up\"\n );\n};\n",
57
+ "content": "import { Client, conversationOf } from \"eve/client\";\nimport { assertEveConfigured } from \"@/lib/eve/server\";\nimport { getEveConnectionOptions } from \"@/lib/eve/connection-options\";\nimport {\n getFeedbackConversation,\n saveEveMessageVote,\n} from \"./feedback-queries\";\n\nconst VOTE_SNAPSHOT_TIMEOUT_MS = 15_000;\n\nexport const voteEveMessage = async (\n ownerId: string,\n input: {\n readonly branchId: string;\n readonly messageId: string;\n readonly type: \"up\" | \"down\";\n }\n): Promise<Awaited<ReturnType<typeof saveEveMessageVote>>> => {\n const conversation = await getFeedbackConversation(ownerId, input.branchId);\n\n if (\n !conversation ||\n typeof conversation.sessionId !== \"string\" ||\n conversation.sessionId === \"\" ||\n conversation.state !== \"bound\"\n ) {\n return null;\n }\n assertEveConfigured();\n const client = new Client(getEveConnectionOptions(ownerId));\n const snapshot = await client.sessions\n .attach(conversation.sessionId)\n .snapshot({ signal: AbortSignal.timeout(VOTE_SNAPSHOT_TIMEOUT_MS) });\n const { messages } = conversationOf(snapshot.events);\n if (\n !messages.some(\n (message: { readonly id: string; readonly role: string }) =>\n message.id === input.messageId && message.role === \"assistant\"\n )\n ) {\n return null;\n }\n return await saveEveMessageVote(\n ownerId,\n input.branchId,\n input.messageId,\n input.type === \"up\"\n );\n};\n",
57
58
  "type": "registry:file",
58
- "target": "~/plugins/feedback/vote-message.ts"
59
+ "target": "~/chatjs/plugins/feedback/vote-message.ts"
59
60
  },
60
61
  {
61
62
  "path": "dist/source/feedback.json",
62
- "content": "{\n \"id\": \"feedback\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/feedback/chat.ts\",\n \"plugins/feedback/client-plugin.ts\",\n \"plugins/feedback/feedback-actions.tsx\",\n \"plugins/feedback/message-vote-actions.tsx\",\n \"plugins/feedback/feedback-queries.ts\",\n \"plugins/feedback/router.ts\",\n \"plugins/feedback/feedback-schema.ts\",\n \"plugins/feedback/server-plugin.ts\",\n \"plugins/feedback/vote-message.ts\"\n ],\n \"databaseSchemas\": [\"plugins/feedback/feedback-schema.ts\"],\n \"chat\": { \"export\": \"feedbackChat\" },\n \"server\": { \"export\": \"feedback\", \"routers\": [\"feedback\"] },\n \"client\": {\n \"export\": \"feedbackClient\",\n \"composerControls\": [],\n \"settingsItems\": [],\n \"chat\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
63
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\n \"id\": \"feedback\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/feedback/chat-server.ts\",\n \"chatjs/plugins/feedback/chat-ui.ts\",\n \"chatjs/plugins/feedback/feedback-actions.tsx\",\n \"chatjs/plugins/feedback/message-vote-actions.tsx\",\n \"chatjs/plugins/feedback/feedback-queries.ts\",\n \"chatjs/plugins/feedback/router.ts\",\n \"chatjs/plugins/feedback/feedback-schema.ts\",\n \"chatjs/plugins/feedback/vote-message.ts\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/feedback/feedback-schema.ts\"]\n}\n",
63
64
  "type": "registry:file",
64
- "target": "~/plugins/feedback/chatjs.json"
65
+ "target": "~/chatjs/plugins/feedback/plugin.json"
65
66
  }
66
67
  ],
67
68
  "meta": {
68
69
  "chatjs": {
70
+ "contractVersion": 3,
71
+ "uiBase": "base",
69
72
  "id": "feedback",
70
73
  "kind": "plugin",
71
74
  "files": [
72
- "plugins/feedback/chat.ts",
73
- "plugins/feedback/client-plugin.ts",
74
- "plugins/feedback/feedback-actions.tsx",
75
- "plugins/feedback/message-vote-actions.tsx",
76
- "plugins/feedback/feedback-queries.ts",
77
- "plugins/feedback/router.ts",
78
- "plugins/feedback/feedback-schema.ts",
79
- "plugins/feedback/server-plugin.ts",
80
- "plugins/feedback/vote-message.ts"
75
+ "chatjs/plugins/feedback/chat-server.ts",
76
+ "chatjs/plugins/feedback/chat-ui.ts",
77
+ "chatjs/plugins/feedback/feedback-actions.tsx",
78
+ "chatjs/plugins/feedback/message-vote-actions.tsx",
79
+ "chatjs/plugins/feedback/feedback-queries.ts",
80
+ "chatjs/plugins/feedback/router.ts",
81
+ "chatjs/plugins/feedback/feedback-schema.ts",
82
+ "chatjs/plugins/feedback/vote-message.ts"
81
83
  ],
82
84
  "databaseSchemas": [
83
- "plugins/feedback/feedback-schema.ts"
84
- ],
85
- "chat": {
86
- "export": "feedbackChat"
87
- },
88
- "server": {
89
- "export": "feedback",
90
- "routers": [
91
- "feedback"
92
- ]
93
- },
94
- "client": {
95
- "export": "feedbackClient",
96
- "composerControls": [],
97
- "settingsItems": [],
98
- "chat": true
99
- },
100
- "contractVersion": 2,
101
- "uiBase": "base"
85
+ "chatjs/plugins/feedback/feedback-schema.ts"
86
+ ]
102
87
  }
103
88
  },
104
89
  "type": "registry:item"
@@ -14,7 +14,7 @@
14
14
  "path": "src/storage/filebase/storage-provider.ts",
15
15
  "content": "export { filebase as createStorageAdapter } from \"files-sdk/filebase\";\n",
16
16
  "type": "registry:file",
17
- "target": "~/lib/storage-provider.ts"
17
+ "target": "~/chatjs/providers/storage.ts"
18
18
  }
19
19
  ],
20
20
  "meta": {
@@ -22,6 +22,13 @@
22
22
  "configKeys": [
23
23
  "bucket"
24
24
  ],
25
+ "configFields": [
26
+ {
27
+ "key": "bucket",
28
+ "label": "bucket",
29
+ "type": "text"
30
+ }
31
+ ],
25
32
  "contractVersion": 1,
26
33
  "envRequirements": [
27
34
  {
@@ -12,12 +12,13 @@
12
12
  "path": "src/storage/firebase-storage/storage-provider.ts",
13
13
  "content": "export { firebaseStorage as createStorageAdapter } from \"files-sdk/firebase-storage\";\n",
14
14
  "type": "registry:file",
15
- "target": "~/lib/storage-provider.ts"
15
+ "target": "~/chatjs/providers/storage.ts"
16
16
  }
17
17
  ],
18
18
  "meta": {
19
19
  "chatjs": {
20
20
  "configKeys": [],
21
+ "configFields": [],
21
22
  "contractVersion": 1,
22
23
  "envRequirements": [
23
24
  {
@@ -2,145 +2,128 @@
2
2
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
3
  "name": "followup-suggestions",
4
4
  "description": "Durable follow-up suggestions for completed answers",
5
+ "dependencies": [
6
+ "@tanstack/react-query@^5.104.1",
7
+ "drizzle-orm@^0.45.1",
8
+ "lucide-react@0.553.0"
9
+ ],
5
10
  "files": [
6
11
  {
7
- "path": "src/plugins/followup-suggestions/src/chat.ts",
8
- "content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/lib/chat-plugin-contracts\";\nimport { eveFollowup } from \"./followup-schema\";\n\nexport const followupChat = {\n onDeleteConversations: async (tx, { sessionIds }) => {\n if (sessionIds.length > 0) {\n await tx\n .delete(eveFollowup)\n .where(inArray(eveFollowup.sessionId, [...sessionIds]));\n }\n },\n} satisfies ChatServerIntegration;\n",
12
+ "path": "src/plugins/followup-suggestions/src/chat-server.ts",
13
+ "content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\nimport { eveFollowup } from \"./followup-schema\";\n\nconst followupChat = {\n onDeleteConversations: async (tx, { sessionIds }) => {\n if (sessionIds.length > 0) {\n await tx\n .delete(eveFollowup)\n .where(inArray(eveFollowup.sessionId, [...sessionIds]));\n }\n },\n} satisfies ChatServerIntegration;\n\nexport default followupChat;\n",
9
14
  "type": "registry:file",
10
- "target": "~/plugins/followup-suggestions/chat.ts"
15
+ "target": "~/chatjs/plugins/followup-suggestions/chat-server.ts"
11
16
  },
12
17
  {
13
- "path": "src/plugins/followup-suggestions/src/client-plugin.ts",
14
- "content": "import type { ChatClientPlugin } from \"@/lib/plugin-contracts\";\nimport { FollowupSuggestions } from \"./suggestions\";\n\nexport const followupSuggestionsClient = () =>\n ({\n id: \"followup-suggestions\",\n chat: { Suggestions: FollowupSuggestions },\n }) satisfies ChatClientPlugin;\n",
18
+ "path": "src/plugins/followup-suggestions/src/chat-ui.ts",
19
+ "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { ChatSuggestions } from \"@/components/chat-slots\";\nimport { FollowupSuggestions } from \"./suggestions\";\n\nexport const chatUi = definePlugin({\n id: \"followup-suggestions\",\n slots: [slot(ChatSuggestions, FollowupSuggestions)],\n});\n",
15
20
  "type": "registry:file",
16
- "target": "~/plugins/followup-suggestions/client-plugin.ts"
21
+ "target": "~/chatjs/plugins/followup-suggestions/chat-ui.ts"
17
22
  },
18
23
  {
19
24
  "path": "src/plugins/followup-suggestions/src/followup-completion.ts",
20
- "content": "import type { MessageStreamEvent } from \"eve/client\";\n\n// Preserve native completion identity through replay.\ntype CompletionEvent =\n | {\n readonly type: \"turn.completed\";\n readonly data: { readonly turnId: string };\n readonly meta: { readonly id: string };\n }\n | {\n readonly type: \"turn.started\" | \"turn.failed\" | \"turn.cancelled\";\n readonly data: { readonly turnId: string };\n }\n | {\n readonly type: Exclude<\n MessageStreamEvent[\"type\"],\n \"turn.completed\" | \"turn.started\" | \"turn.failed\" | \"turn.cancelled\"\n >;\n };\n\nexport const followupCompletion = (\n events: readonly CompletionEvent[],\n turnId: string | undefined\n): string | undefined => {\n let id: string | undefined;\n for (const event of events) {\n if (event.type === \"turn.completed\" && event.data.turnId === turnId) {\n ({ id } = event.meta);\n } else if (\n (event.type === \"turn.started\" ||\n event.type === \"turn.failed\" ||\n event.type === \"turn.cancelled\") &&\n event.data.turnId === turnId\n ) {\n id = undefined;\n }\n }\n return id;\n};\n",
25
+ "content": "import type { SessionStreamEvent } from \"eve/client\";\n\nexport const followupEventId = (sessionId: string, turnId: string): string =>\n JSON.stringify([sessionId, turnId, \"completed\"]);\n\nexport const followupCompletion = (\n events: readonly SessionStreamEvent[],\n turnId: string | undefined,\n sessionId: string\n): string | undefined => {\n const last = events.findLast(\n (event) =>\n (event.type === \"turn.started\" || event.type === \"turn.settled\") &&\n event.data.turnId === turnId\n );\n return last?.type === \"turn.settled\" && last.data.outcome === \"completed\"\n ? followupEventId(sessionId, last.data.turnId)\n : undefined;\n};\n",
21
26
  "type": "registry:file",
22
- "target": "~/plugins/followup-suggestions/followup-completion.ts"
27
+ "target": "~/chatjs/plugins/followup-suggestions/followup-completion.ts"
23
28
  },
24
29
  {
25
30
  "path": "src/plugins/followup-suggestions/src/followup-context.ts",
26
- "content": "import type { HookEvent } from \"eve/hooks\";\n\n/** SDK fields this reader does not inspect remain optional and opaque. */\ntype IgnoredSdkFields<Value> = Value extends object\n ? { readonly [Key in keyof Value]?: unknown }\n : unknown;\n\ntype FollowupEvent = IgnoredSdkFields<HookEvent> &\n (\n | { readonly type: \"turn.started\" }\n | {\n readonly type: \"message.received\";\n readonly data: Readonly<\n Pick<\n Extract<HookEvent, { type: \"message.received\" }>[\"data\"],\n \"message\"\n >\n > &\n IgnoredSdkFields<\n Extract<HookEvent, { type: \"message.received\" }>[\"data\"]\n >;\n }\n | {\n readonly type: \"message.completed\";\n readonly data: Readonly<\n Pick<\n Extract<HookEvent, { type: \"message.completed\" }>[\"data\"],\n \"message\" | \"finishReason\"\n >\n > &\n IgnoredSdkFields<\n Extract<HookEvent, { type: \"message.completed\" }>[\"data\"]\n >;\n }\n | {\n readonly type: Exclude<\n HookEvent[\"type\"],\n \"turn.started\" | \"message.received\" | \"message.completed\"\n >;\n }\n );\n\nconst MAX_CONTEXT_CHARACTERS = 12_000;\nexport interface FollowupContext {\n readonly user: string;\n readonly assistant: string;\n}\n\n/**\n * Retain only the current exchange; the native event log owns history.\n * @param {Readonly<FollowupContext>} current Previously retained user and assistant text.\n * @param {HookEvent} event Native turn or message event used to reset or replace the exchange.\n * @returns {FollowupContext} Current exchange with messages bounded to the context limit, or the original object for unrelated events.\n */\nexport const followupContext = (\n current: FollowupContext,\n\n event: FollowupEvent\n): FollowupContext => {\n if (event.type === \"turn.started\") {\n return { assistant: \"\", user: \"\" };\n }\n if (event.type === \"message.received\") {\n return {\n assistant: \"\",\n user: event.data.message.slice(-MAX_CONTEXT_CHARACTERS),\n };\n }\n if (\n event.type === \"message.completed\" &&\n event.data.finishReason !== \"tool-calls\"\n ) {\n return {\n ...current,\n assistant: (event.data.message ?? \"\").slice(-MAX_CONTEXT_CHARACTERS),\n };\n }\n return current;\n};\n",
31
+ "content": "import type { HookEvent } from \"eve/hooks\";\n\nconst MAX_CONTEXT_CHARACTERS = 12_000;\nexport interface FollowupContext {\n readonly user: string;\n readonly assistant: string;\n}\nexport const followupContext = (\n current: FollowupContext,\n event: HookEvent\n): FollowupContext => {\n if (event.type === \"turn.started\") {\n return { assistant: \"\", user: \"\" };\n }\n if (event.type === \"delivery.consumed\") {\n return {\n assistant: \"\",\n user: event.data.parts\n .flatMap((part) => (part.kind === \"text\" ? [part.text] : []))\n .join(\"\\n\")\n .slice(-MAX_CONTEXT_CHARACTERS),\n };\n }\n if (\n event.type === \"content.completed\" &&\n event.data.kind === \"text\" &&\n event.data.phase === \"reply\" &&\n typeof event.data.value === \"string\"\n ) {\n return {\n ...current,\n assistant: event.data.value.slice(-MAX_CONTEXT_CHARACTERS),\n };\n }\n return current;\n};\n",
27
32
  "type": "registry:file",
28
- "target": "~/plugins/followup-suggestions/followup-context.ts"
33
+ "target": "~/chatjs/plugins/followup-suggestions/followup-context.ts"
29
34
  },
30
35
  {
31
36
  "path": "src/plugins/followup-suggestions/src/followup-hook.ts",
32
- "content": "import { isGuestSession } from \"@/lib/eve/session-identity\";\nimport type { FollowupContext } from \"./followup-context\";\nimport type { HookContext } from \"eve/hooks\";\nimport { defineHook } from \"eve/hooks\";\nimport { defineState } from \"eve/context\";\n\nimport { followupContext } from \"./followup-context\";\nimport { generateEveFollowupSuggestions } from \"./generate-suggestions\";\n\nconst context = defineState<FollowupContext>(\n \"chatjs.followups.context\",\n () => ({ assistant: \"\", user: \"\" })\n);\n\nexport default defineHook({\n events: {\n \"message.completed\": (event: Parameters<typeof followupContext>[1]) => {\n context.update((current: FollowupContext) =>\n followupContext(current, event)\n );\n },\n \"message.received\": (event: Parameters<typeof followupContext>[1]) => {\n context.update((current: FollowupContext) =>\n followupContext(current, event)\n );\n },\n \"turn.completed\": (\n event: {\n readonly data: { readonly turnId: string };\n readonly meta: { readonly id: string };\n },\n hookContext: {\n readonly session: Readonly<\n Pick<HookContext[\"session\"], \"parent\" | \"id\" | \"auth\">\n >;\n }\n ): ReturnType<typeof generateEveFollowupSuggestions> | undefined => {\n // Suggestions are actions for the user-facing branch, not a background task.\n if (isGuestSession(hookContext.session) || hookContext.session.parent) {\n return undefined;\n }\n return generateEveFollowupSuggestions(context.get(), {\n ownerId: hookContext.session.auth.initiator?.principalId ?? \"\",\n sessionId: hookContext.session.id,\n turnId: event.data.turnId,\n eventId: event.meta.id,\n });\n },\n \"turn.started\": (event: Parameters<typeof followupContext>[1]) => {\n context.update((current: FollowupContext) =>\n followupContext(current, event)\n );\n },\n },\n});\n",
37
+ "content": "import { followupEventId } from \"./followup-completion\";\nimport { isAccountSession } from \"@/lib/eve/session-identity\";\nimport type { FollowupContext } from \"./followup-context\";\nimport type { HookContext } from \"eve/hooks\";\nimport { defineHook } from \"eve/hooks\";\nimport { defineState } from \"eve/context\";\n\nimport { followupContext } from \"./followup-context\";\nimport { generateEveFollowupSuggestions } from \"./generate-suggestions\";\n\nconst context = defineState<FollowupContext>(\n \"chatjs.followups.context\",\n () => ({ assistant: \"\", user: \"\" })\n);\n\nexport default defineHook({\n events: {\n \"content.completed\": (event: Parameters<typeof followupContext>[1]) => {\n context.update((current: FollowupContext) =>\n followupContext(current, event)\n );\n },\n \"delivery.consumed\": (event: Parameters<typeof followupContext>[1]) => {\n context.update((current: FollowupContext) =>\n followupContext(current, event)\n );\n },\n \"turn.settled\": (\n event: {\n readonly data: { readonly turnId: string; readonly outcome: string };\n },\n hookContext: {\n readonly session: Readonly<\n Pick<HookContext[\"session\"], \"parent\" | \"id\" | \"auth\">\n >;\n }\n ): ReturnType<typeof generateEveFollowupSuggestions> | undefined => {\n // Suggestions are actions for the user-facing branch, not a background task.\n if (\n event.data.outcome !== \"completed\" ||\n !isAccountSession(hookContext.session) ||\n hookContext.session.parent\n ) {\n return undefined;\n }\n return generateEveFollowupSuggestions(context.get(), {\n ownerId: hookContext.session.auth.initiator?.principalId ?? \"\",\n sessionId: hookContext.session.id,\n turnId: event.data.turnId,\n eventId: followupEventId(hookContext.session.id, event.data.turnId),\n });\n },\n \"turn.started\": (event: Parameters<typeof followupContext>[1]) => {\n context.update((current: FollowupContext) =>\n followupContext(current, event)\n );\n },\n },\n});\n",
33
38
  "type": "registry:file",
34
- "target": "~/plugins/followup-suggestions/followup-hook.ts"
39
+ "target": "~/chatjs/plugins/followup-suggestions/followup-hook.ts"
35
40
  },
36
41
  {
37
42
  "path": "src/plugins/followup-suggestions/src/followup-queries.ts",
38
- "content": "import { and, eq } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveConversation } from \"@/lib/db/schema\";\nimport { eveFollowup } from \"./followup-schema\";\n\n/** Claim before any paid call. A crashed claim is deliberately never retried. */\nexport const claimEveFollowup = async (\n ownerId: string,\n sessionId: string,\n turnId: string,\n eventId: string\n): Promise<string | null> =>\n await db.transaction(async (tx) => {\n const conversations = await tx\n .select({ chatId: eveConversation.chatId })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.sessionId, sessionId),\n eq(eveConversation.state, \"bound\")\n )\n )\n .for(\"update\");\n const conversation = conversations.at(0);\n if (conversation === undefined) {\n return null;\n }\n const [claim] = await tx\n .insert(eveFollowup)\n .values({ ...conversation, ownerId, turnId, sessionId, eventId })\n .onConflictDoNothing()\n .returning({ chatId: eveFollowup.chatId });\n return claim?.chatId ?? null;\n });\n\nexport const finishEveFollowup = async (\n ownerId: string,\n chatId: string,\n eventId: string,\n suggestions: readonly string[]\n): Promise<void> => {\n await db\n .update(eveFollowup)\n .set({ suggestions: [...suggestions] })\n .where(\n and(\n eq(eveFollowup.ownerId, ownerId),\n eq(eveFollowup.chatId, chatId),\n eq(eveFollowup.eventId, eventId)\n )\n );\n};\n\nexport const getEveFollowup = async (\n ownerId: string,\n conversationId: string,\n eventId: string\n): Promise<readonly string[] | null> => {\n const [row] = await db\n .select({ suggestions: eveFollowup.suggestions })\n .from(eveFollowup)\n .innerJoin(\n eveConversation,\n and(\n eq(eveFollowup.chatId, eveConversation.chatId),\n eq(eveFollowup.ownerId, eveConversation.ownerId)\n )\n )\n .where(\n and(\n eq(eveConversation.id, conversationId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\"),\n eq(eveFollowup.eventId, eventId)\n )\n );\n return row?.suggestions ?? null;\n};\n",
43
+ "content": "import { and, eq } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveConversation } from \"@/lib/db/schema\";\nimport { eveFollowup } from \"./followup-schema\";\n\n/** Claim before any paid call. A crashed claim is deliberately never retried. */\nexport const claimEveFollowup = async (\n ownerId: string,\n sessionId: string,\n turnId: string,\n eventId: string\n): Promise<string | null> =>\n await db.transaction(async (tx) => {\n const conversations = await tx\n .select({ chatId: eveConversation.chatId })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.sessionId, sessionId),\n eq(eveConversation.state, \"bound\")\n )\n )\n .for(\"update\");\n const conversation = conversations.at(0);\n if (conversation === undefined) {\n return null;\n }\n const [claim] = await tx\n .insert(eveFollowup)\n .values({ ...conversation, ownerId, turnId, sessionId, eventId })\n .onConflictDoNothing()\n .returning({ chatId: eveFollowup.chatId });\n return claim?.chatId ?? null;\n });\n\nexport const finishEveFollowup = async (\n ownerId: string,\n chatId: string,\n eventId: string,\n suggestions: readonly string[]\n): Promise<void> => {\n await db\n .update(eveFollowup)\n .set({ suggestions: [...suggestions] })\n .where(\n and(\n eq(eveFollowup.ownerId, ownerId),\n eq(eveFollowup.chatId, chatId),\n eq(eveFollowup.eventId, eventId)\n )\n );\n};\n\nexport const getEveFollowup = async (\n ownerId: string,\n branchId: string,\n eventId: string\n): Promise<readonly string[] | null> => {\n const [row] = await db\n .select({ suggestions: eveFollowup.suggestions })\n .from(eveFollowup)\n .innerJoin(\n eveConversation,\n and(\n eq(eveFollowup.chatId, eveConversation.chatId),\n eq(eveFollowup.ownerId, eveConversation.ownerId)\n )\n )\n .where(\n and(\n eq(eveConversation.id, branchId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\"),\n eq(eveFollowup.eventId, eventId)\n )\n );\n return row?.suggestions ?? null;\n};\n",
39
44
  "type": "registry:file",
40
- "target": "~/plugins/followup-suggestions/followup-queries.ts"
45
+ "target": "~/chatjs/plugins/followup-suggestions/followup-queries.ts"
41
46
  },
42
47
  {
43
48
  "path": "src/plugins/followup-suggestions/src/followup-schema.ts",
44
49
  "content": "import {\n foreignKey,\n index,\n jsonb,\n pgTable,\n text,\n unique,\n uuid,\n} from \"drizzle-orm/pg-core\";\nimport { eveChat } from \"@/lib/db/schema\";\n\n/** Optional display output, shared by native branches of the same chat. */\nexport const eveFollowup = pgTable(\n \"EveFollowup\",\n {\n chatId: uuid(\"chatId\").notNull(),\n ownerId: text(\"ownerId\").notNull(),\n turnId: text(\"turnId\").notNull(),\n sessionId: text(\"sessionId\").notNull(),\n eventId: text(\"eventId\").primaryKey(),\n suggestions: jsonb(\"suggestions\").$type<readonly string[]>(),\n },\n (table) => [\n index(\"EveFollowup_chat\").on(table.chatId),\n unique().on(table.sessionId, table.turnId),\n foreignKey({\n columns: [table.chatId, table.ownerId],\n foreignColumns: [eveChat.id, eveChat.ownerId],\n }).onDelete(\"cascade\"),\n ]\n);\n",
45
50
  "type": "registry:file",
46
- "target": "~/plugins/followup-suggestions/followup-schema.ts"
51
+ "target": "~/chatjs/plugins/followup-suggestions/followup-schema.ts"
47
52
  },
48
53
  {
49
54
  "path": "src/plugins/followup-suggestions/src/followup-suggestions-view.tsx",
50
55
  "content": "\"use client\";\n\nimport { Suggestion, Suggestions } from \"@/components/ai-elements/suggestion\";\nimport { PlusIcon } from \"lucide-react\";\nimport React from \"react\";\n\nimport type { JSX as ReactJSX } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport const FollowUpSuggestionsView = ({\n suggestions,\n className,\n onSelect,\n disabled = false,\n}: {\n readonly suggestions: readonly string[];\n readonly className?: string;\n readonly onSelect: (suggestion: string) => void;\n readonly disabled?: boolean;\n}): ReactJSX.Element | null => {\n if (suggestions.length === 0) {\n return null;\n }\n\n return (\n <fieldset\n aria-label=\"Related questions\"\n className={cn(\"mt-2 mb-2 flex min-w-0 flex-col gap-2\", className)}\n >\n <legend className=\"text-muted-foreground text-xs font-medium\">\n Related\n </legend>\n <Suggestions className=\"gap-1.5\">\n {(() => {\n const seen = new Map<string, number>();\n return suggestions.map((suggestion) => {\n const count = seen.get(suggestion) ?? 0;\n seen.set(suggestion, count + 1);\n const key = count === 0 ? suggestion : `${suggestion}-${count}`;\n return (\n <Suggestion\n className=\"text-muted-foreground hover:text-foreground h-7\"\n disabled={disabled}\n key={key}\n onClick={onSelect}\n size=\"sm\"\n suggestion={suggestion}\n type=\"button\"\n variant=\"ghost\"\n >\n {suggestion}\n <PlusIcon className=\"size-3 opacity-70\" />\n </Suggestion>\n );\n });\n })()}\n </Suggestions>\n </fieldset>\n );\n};\n",
51
56
  "type": "registry:file",
52
- "target": "~/plugins/followup-suggestions/followup-suggestions-view.tsx"
57
+ "target": "~/chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx"
53
58
  },
54
59
  {
55
60
  "path": "src/plugins/followup-suggestions/src/generate-suggestions.ts",
56
61
  "content": "import { claimEveFollowup, finishEveFollowup } from \"./followup-queries\";\nimport { Output, generateText } from \"ai\";\nimport type { FollowupContext } from \"./followup-context\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { eveFollowupSuggestions } from \"./suggestion-output\";\nimport { accountEveModel } from \"@/lib/eve/model-accounting\";\nimport type { ModelCallScope } from \"@/lib/eve/model-ledger\";\nimport { resolveEveModel } from \"@/lib/eve/model-selection\";\n\nconst FOLLOWUP_TIMEOUT_MS = 15_000;\nconst log = createModuleLogger(\"eve.followup-suggestions\");\n\n/** Optional generation is claimed once; failures never fail the completed answer. */\nexport const generateEveFollowupSuggestions = async (\n context: FollowupContext,\n scope: ModelCallScope & { readonly turnId: string; readonly eventId: string }\n): Promise<void> => {\n if (\n !(config.ai.tools.followupSuggestions.enabled && context.assistant.trim())\n ) {\n return undefined;\n }\n const modelId = config.ai.tools.followupSuggestions.default;\n try {\n const chatId = await claimEveFollowup(\n scope.ownerId,\n scope.sessionId,\n scope.turnId,\n scope.eventId\n );\n if (chatId === null) {\n return;\n }\n const resolved = accountEveModel(await resolveEveModel(modelId), scope);\n const result = await generateText({\n model: resolved.model,\n ...resolved.modelOptions,\n abortSignal: AbortSignal.timeout(FOLLOWUP_TIMEOUT_MS),\n maxOutputTokens: 512,\n // Hidden provider retries would lose per-attempt usage evidence.\n maxRetries: 0,\n messages: [\n { content: context.user, role: \"user\" },\n { content: context.assistant, role: \"assistant\" },\n {\n content:\n \"What question should I ask next? Return 3 to 5 distinct suggested questions, each at most 80 characters. Use the conversation's language.\",\n role: \"user\",\n },\n ],\n output: Output.object({ schema: eveFollowupSuggestions }),\n });\n // Attempt receipt capture before parsing: malformed JSON can still cost money.\n await finishEveFollowup(scope.ownerId, chatId, scope.eventId, [\n ...new Set(eveFollowupSuggestions.parse(result.output).suggestions),\n ]);\n } catch (error) {\n log.error(\n {\n eventId: scope.eventId,\n errorType: error instanceof Error ? error.name : \"unknown\",\n sessionId: scope.sessionId,\n turnId: scope.turnId,\n },\n \"Follow-up generation or storage failed\"\n );\n }\n};\n",
57
62
  "type": "registry:file",
58
- "target": "~/plugins/followup-suggestions/generate-suggestions.ts"
63
+ "target": "~/chatjs/plugins/followup-suggestions/generate-suggestions.ts"
59
64
  },
60
65
  {
61
66
  "path": "src/plugins/followup-suggestions/src/router.ts",
62
- "content": "import { z } from \"zod\";\nimport { createTRPCRouter } from \"@/trpc/init\";\nimport { eveOwnedProcedure } from \"@/trpc/eve-owned-procedure\";\nimport { getEveFollowup } from \"./followup-queries\";\n\nexport const followupSuggestionsRouter = createTRPCRouter({\n get: eveOwnedProcedure\n .input(\n z.object({\n conversationId: z.uuid(),\n eventId: z.string().min(1).max(512),\n })\n )\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: {\n readonly conversationId: string;\n readonly eventId: string;\n };\n }) =>\n await getEveFollowup(\n ctx.eveOwnerId,\n input.conversationId,\n input.eventId\n )\n ),\n});\n",
67
+ "content": "import { z } from \"zod\";\nimport { createTRPCRouter } from \"@/trpc/init\";\nimport { eveOwnedProcedure } from \"@/trpc/eve-owned-procedure\";\nimport { getEveFollowup } from \"./followup-queries\";\n\nconst followupSuggestionsProcedures = {\n get: eveOwnedProcedure\n .input(\n z.object({\n branchId: z.uuid(),\n eventId: z.string().min(1).max(512),\n })\n )\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: {\n readonly branchId: string;\n readonly eventId: string;\n };\n }) => await getEveFollowup(ctx.eveOwnerId, input.branchId, input.eventId)\n ),\n};\n\nexport const router = createTRPCRouter({\n followupSuggestions: followupSuggestionsProcedures,\n});\n",
63
68
  "type": "registry:file",
64
- "target": "~/plugins/followup-suggestions/router.ts"
65
- },
66
- {
67
- "path": "src/plugins/followup-suggestions/src/server-plugin.ts",
68
- "content": "import type { ChatPlugin } from \"@/lib/plugin-contracts\";\nimport { followupSuggestionsRouter } from \"./router\";\n\nexport const followupSuggestions = () =>\n ({\n id: \"followup-suggestions\",\n routers: { followupSuggestions: followupSuggestionsRouter },\n }) satisfies ChatPlugin;\n",
69
- "type": "registry:file",
70
- "target": "~/plugins/followup-suggestions/server-plugin.ts"
69
+ "target": "~/chatjs/plugins/followup-suggestions/router.ts"
71
70
  },
72
71
  {
73
72
  "path": "src/plugins/followup-suggestions/src/suggestion-output.ts",
74
73
  "content": "import { z } from \"zod\";\n\nexport const eveFollowupSuggestions = z.object({\n suggestions: z.array(z.string().trim().min(1).max(80)).min(3).max(5),\n});\n",
75
74
  "type": "registry:file",
76
- "target": "~/plugins/followup-suggestions/suggestion-output.ts"
75
+ "target": "~/chatjs/plugins/followup-suggestions/suggestion-output.ts"
77
76
  },
78
77
  {
79
78
  "path": "src/plugins/followup-suggestions/src/suggestions.tsx",
80
- "content": "\"use client\";\n\nimport React from \"react\";\nimport type { ChatSuggestionsProps } from \"@/lib/chat-plugin-contracts\";\nimport { useEveFollowups } from \"./use-followups\";\nimport { FollowUpSuggestionsView } from \"./followup-suggestions-view\";\n\nexport const FollowupSuggestions = ({\n conversationId,\n events,\n lastMessage,\n onSelect,\n disabled,\n}: ChatSuggestionsProps): React.JSX.Element | null => {\n const suggestions = useEveFollowups(conversationId, events, lastMessage);\n return (\n <FollowUpSuggestionsView\n suggestions={suggestions}\n onSelect={onSelect}\n disabled={disabled}\n />\n );\n};\n",
79
+ "content": "\"use client\";\n\nimport React from \"react\";\nimport type { ChatSuggestionsProps } from \"@/chatjs/core/chat/contracts\";\nimport { useEveFollowups } from \"./use-followups\";\nimport { FollowUpSuggestionsView } from \"./followup-suggestions-view\";\n\nexport const FollowupSuggestions = ({\n branchId,\n sessionId,\n events,\n lastMessage,\n onSelect,\n disabled,\n}: ChatSuggestionsProps): React.JSX.Element | null => {\n const suggestions = useEveFollowups(branchId, sessionId, events, lastMessage);\n return (\n <FollowUpSuggestionsView\n suggestions={suggestions}\n onSelect={onSelect}\n disabled={disabled}\n />\n );\n};\n",
81
80
  "type": "registry:file",
82
- "target": "~/plugins/followup-suggestions/suggestions.tsx"
81
+ "target": "~/chatjs/plugins/followup-suggestions/suggestions.tsx"
83
82
  },
84
83
  {
85
84
  "path": "src/plugins/followup-suggestions/src/use-followups.ts",
86
- "content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTRPC } from \"@/trpc/react\";\nimport type { ChatSuggestionsProps } from \"@/lib/chat-plugin-contracts\";\nimport { followupCompletion } from \"./followup-completion\";\nimport { config } from \"@/lib/config\";\n\nconst EMPTY_SUGGESTIONS: readonly string[] = [];\nconst POLL_INTERVAL_MS = 1000;\nconst MAX_POLLS = 20;\n\nexport const useEveFollowups = (\n conversationId: string,\n events: Parameters<typeof followupCompletion>[0],\n message: ChatSuggestionsProps[\"lastMessage\"]\n): readonly string[] => {\n const trpc = useTRPC();\n const eventId =\n message?.role === \"assistant\"\n ? followupCompletion(events, message.metadata?.turnId)\n : undefined;\n const query = useQuery({\n ...trpc.followupSuggestions.get.queryOptions({\n conversationId,\n eventId: eventId ?? \"\",\n }),\n enabled:\n config.ai.tools.followupSuggestions.enabled && eventId !== undefined,\n retry: false,\n refetchInterval: (current) =>\n current.state.status !== \"error\" &&\n current.state.data === null &&\n current.state.dataUpdateCount < MAX_POLLS\n ? POLL_INTERVAL_MS\n : false,\n });\n return !config.ai.tools.followupSuggestions.enabled || eventId === undefined\n ? EMPTY_SUGGESTIONS\n : (query.data ?? EMPTY_SUGGESTIONS);\n};\n",
85
+ "content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTRPC } from \"@/trpc/react\";\nimport type { ChatSuggestionsProps } from \"@/chatjs/core/chat/contracts\";\nimport { followupCompletion } from \"./followup-completion\";\nimport { config } from \"@/lib/config\";\n\nconst EMPTY_SUGGESTIONS: readonly string[] = [];\nconst POLL_INTERVAL_MS = 1000;\nconst MAX_POLLS = 20;\n\nexport const useEveFollowups = (\n branchId: string,\n sessionId: string,\n events: Parameters<typeof followupCompletion>[0],\n message: ChatSuggestionsProps[\"lastMessage\"]\n): readonly string[] => {\n const trpc = useTRPC();\n const eventId =\n message?.role === \"assistant\"\n ? followupCompletion(events, message.metadata?.turnId, sessionId)\n : undefined;\n const query = useQuery({\n ...trpc.followupSuggestions.get.queryOptions({\n branchId,\n eventId: eventId ?? \"\",\n }),\n enabled:\n config.ai.tools.followupSuggestions.enabled && eventId !== undefined,\n retry: false,\n refetchInterval: (current) =>\n current.state.status !== \"error\" &&\n current.state.data === null &&\n current.state.dataUpdateCount < MAX_POLLS\n ? POLL_INTERVAL_MS\n : false,\n });\n return !config.ai.tools.followupSuggestions.enabled || eventId === undefined\n ? EMPTY_SUGGESTIONS\n : (query.data ?? EMPTY_SUGGESTIONS);\n};\n",
87
86
  "type": "registry:file",
88
- "target": "~/plugins/followup-suggestions/use-followups.ts"
87
+ "target": "~/chatjs/plugins/followup-suggestions/use-followups.ts"
89
88
  },
90
89
  {
91
90
  "path": "src/plugins/followup-suggestions/adapters/agent/hooks/followup-suggestions.ts",
92
- "content": "export { default } from \"@/plugins/followup-suggestions/followup-hook\";\n",
91
+ "content": "// ChatJS source: followup-suggestions. Ownership: chatjs/plugins/followup-suggestions/plugin.json.\nexport { default } from \"@/chatjs/plugins/followup-suggestions/followup-hook\";\n",
93
92
  "type": "registry:file",
94
93
  "target": "~/agent/hooks/followup-suggestions.ts"
95
94
  },
96
95
  {
97
96
  "path": "dist/source/followup-suggestions.json",
98
- "content": "{\n \"id\": \"followup-suggestions\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/followup-suggestions/chat.ts\",\n \"plugins/followup-suggestions/client-plugin.ts\",\n \"plugins/followup-suggestions/followup-completion.ts\",\n \"plugins/followup-suggestions/followup-context.ts\",\n \"plugins/followup-suggestions/followup-hook.ts\",\n \"plugins/followup-suggestions/followup-queries.ts\",\n \"plugins/followup-suggestions/followup-schema.ts\",\n \"plugins/followup-suggestions/followup-suggestions-view.tsx\",\n \"plugins/followup-suggestions/generate-suggestions.ts\",\n \"plugins/followup-suggestions/router.ts\",\n \"plugins/followup-suggestions/server-plugin.ts\",\n \"plugins/followup-suggestions/suggestion-output.ts\",\n \"plugins/followup-suggestions/suggestions.tsx\",\n \"plugins/followup-suggestions/use-followups.ts\",\n \"agent/hooks/followup-suggestions.ts\"\n ],\n \"databaseSchemas\": [\"plugins/followup-suggestions/followup-schema.ts\"],\n \"chat\": { \"export\": \"followupChat\" },\n \"server\": {\n \"export\": \"followupSuggestions\",\n \"routers\": [\"followupSuggestions\"]\n },\n \"client\": {\n \"export\": \"followupSuggestionsClient\",\n \"composerControls\": [],\n \"settingsItems\": [],\n \"chat\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
97
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\n \"id\": \"followup-suggestions\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/followup-suggestions/chat-server.ts\",\n \"chatjs/plugins/followup-suggestions/chat-ui.ts\",\n \"chatjs/plugins/followup-suggestions/followup-completion.ts\",\n \"chatjs/plugins/followup-suggestions/followup-context.ts\",\n \"chatjs/plugins/followup-suggestions/followup-hook.ts\",\n \"chatjs/plugins/followup-suggestions/followup-queries.ts\",\n \"chatjs/plugins/followup-suggestions/followup-schema.ts\",\n \"chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx\",\n \"chatjs/plugins/followup-suggestions/generate-suggestions.ts\",\n \"chatjs/plugins/followup-suggestions/router.ts\",\n \"chatjs/plugins/followup-suggestions/suggestion-output.ts\",\n \"chatjs/plugins/followup-suggestions/suggestions.tsx\",\n \"chatjs/plugins/followup-suggestions/use-followups.ts\",\n \"agent/hooks/followup-suggestions.ts\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/followup-suggestions/followup-schema.ts\"]\n}\n",
99
98
  "type": "registry:file",
100
- "target": "~/plugins/followup-suggestions/chatjs.json"
99
+ "target": "~/chatjs/plugins/followup-suggestions/plugin.json"
101
100
  }
102
101
  ],
103
102
  "meta": {
104
103
  "chatjs": {
104
+ "contractVersion": 3,
105
+ "uiBase": "base",
105
106
  "id": "followup-suggestions",
106
107
  "kind": "plugin",
107
108
  "files": [
108
- "plugins/followup-suggestions/chat.ts",
109
- "plugins/followup-suggestions/client-plugin.ts",
110
- "plugins/followup-suggestions/followup-completion.ts",
111
- "plugins/followup-suggestions/followup-context.ts",
112
- "plugins/followup-suggestions/followup-hook.ts",
113
- "plugins/followup-suggestions/followup-queries.ts",
114
- "plugins/followup-suggestions/followup-schema.ts",
115
- "plugins/followup-suggestions/followup-suggestions-view.tsx",
116
- "plugins/followup-suggestions/generate-suggestions.ts",
117
- "plugins/followup-suggestions/router.ts",
118
- "plugins/followup-suggestions/server-plugin.ts",
119
- "plugins/followup-suggestions/suggestion-output.ts",
120
- "plugins/followup-suggestions/suggestions.tsx",
121
- "plugins/followup-suggestions/use-followups.ts",
109
+ "chatjs/plugins/followup-suggestions/chat-server.ts",
110
+ "chatjs/plugins/followup-suggestions/chat-ui.ts",
111
+ "chatjs/plugins/followup-suggestions/followup-completion.ts",
112
+ "chatjs/plugins/followup-suggestions/followup-context.ts",
113
+ "chatjs/plugins/followup-suggestions/followup-hook.ts",
114
+ "chatjs/plugins/followup-suggestions/followup-queries.ts",
115
+ "chatjs/plugins/followup-suggestions/followup-schema.ts",
116
+ "chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx",
117
+ "chatjs/plugins/followup-suggestions/generate-suggestions.ts",
118
+ "chatjs/plugins/followup-suggestions/router.ts",
119
+ "chatjs/plugins/followup-suggestions/suggestion-output.ts",
120
+ "chatjs/plugins/followup-suggestions/suggestions.tsx",
121
+ "chatjs/plugins/followup-suggestions/use-followups.ts",
122
122
  "agent/hooks/followup-suggestions.ts"
123
123
  ],
124
124
  "databaseSchemas": [
125
- "plugins/followup-suggestions/followup-schema.ts"
126
- ],
127
- "chat": {
128
- "export": "followupChat"
129
- },
130
- "server": {
131
- "export": "followupSuggestions",
132
- "routers": [
133
- "followupSuggestions"
134
- ]
135
- },
136
- "client": {
137
- "export": "followupSuggestionsClient",
138
- "composerControls": [],
139
- "settingsItems": [],
140
- "chat": true
141
- },
142
- "contractVersion": 2,
143
- "uiBase": "base"
125
+ "chatjs/plugins/followup-suggestions/followup-schema.ts"
126
+ ]
144
127
  }
145
128
  },
146
129
  "type": "registry:item"
@@ -12,7 +12,7 @@
12
12
  "path": "src/storage/ftp/storage-provider.ts",
13
13
  "content": "import type { FtpAdapter, FtpAdapterOptions } from \"files-sdk/ftp\";\nimport { ftp } from \"files-sdk/ftp\";\n\nconst getSecureDefault = (): true | \"implicit\" => {\n if (process.env.FTP_SECURE === \"implicit\") {\n return \"implicit\";\n }\n return true;\n};\n\nexport const createStorageAdapter = (\n options: Readonly<FtpAdapterOptions> = {}\n): FtpAdapter => {\n const secure = options.secure ?? getSecureDefault();\n return ftp({ ...options, secure });\n};\n",
14
14
  "type": "registry:file",
15
- "target": "~/lib/storage-provider.ts"
15
+ "target": "~/chatjs/providers/storage.ts"
16
16
  }
17
17
  ],
18
18
  "meta": {
@@ -22,6 +22,23 @@
22
22
  "port",
23
23
  "root"
24
24
  ],
25
+ "configFields": [
26
+ {
27
+ "key": "host",
28
+ "label": "host",
29
+ "type": "text"
30
+ },
31
+ {
32
+ "key": "port",
33
+ "label": "port",
34
+ "type": "port"
35
+ },
36
+ {
37
+ "key": "root",
38
+ "label": "root",
39
+ "type": "text"
40
+ }
41
+ ],
25
42
  "contractVersion": 1,
26
43
  "envRequirements": [
27
44
  {
@@ -12,7 +12,7 @@
12
12
  "path": "src/storage/gcs/storage-provider.ts",
13
13
  "content": "export { gcs as createStorageAdapter } from \"files-sdk/gcs\";\n",
14
14
  "type": "registry:file",
15
- "target": "~/lib/storage-provider.ts"
15
+ "target": "~/chatjs/providers/storage.ts"
16
16
  }
17
17
  ],
18
18
  "meta": {
@@ -20,6 +20,13 @@
20
20
  "configKeys": [
21
21
  "bucket"
22
22
  ],
23
+ "configFields": [
24
+ {
25
+ "key": "bucket",
26
+ "label": "bucket",
27
+ "type": "text"
28
+ }
29
+ ],
23
30
  "contractVersion": 1,
24
31
  "envRequirements": [],
25
32
  "id": "gcs",