@chat-js/registry 0.2.0-beta.2 → 0.2.0-beta.4
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.
- package/README.md +15 -11
- package/dist/r/ai-titles.json +10 -10
- package/dist/r/akamai-storage.json +1 -1
- package/dist/r/alibaba-storage.json +1 -1
- package/dist/r/appwrite-storage.json +1 -1
- package/dist/r/archil-storage.json +1 -1
- package/dist/r/attach-workspace-file.json +82 -0
- package/dist/r/attachment-uploads.json +19 -21
- package/dist/r/azure-storage.json +1 -1
- package/dist/r/backblaze-b2-storage.json +1 -1
- package/dist/r/base/ai-titles.json +10 -10
- package/dist/r/base/akamai-storage.json +1 -1
- package/dist/r/base/alibaba-storage.json +1 -1
- package/dist/r/base/appwrite-storage.json +1 -1
- package/dist/r/base/archil-storage.json +1 -1
- package/dist/r/base/attach-workspace-file.json +82 -0
- package/dist/r/base/attachment-uploads.json +19 -21
- package/dist/r/base/azure-storage.json +1 -1
- package/dist/r/base/backblaze-b2-storage.json +1 -1
- package/dist/r/base/bunny-storage-storage.json +1 -1
- package/dist/r/base/cloudinary-storage.json +1 -1
- package/dist/r/base/credits.json +22 -22
- package/dist/r/base/deep-research.json +57 -139
- package/dist/r/base/default-sandbox.json +35 -0
- package/dist/r/base/desktop.json +144 -0
- package/dist/r/base/digitalocean-spaces-storage.json +1 -1
- package/dist/r/base/docker-sandbox.json +35 -0
- package/dist/r/base/dropbox-storage.json +1 -1
- package/dist/r/base/exoscale-storage.json +1 -1
- package/dist/r/base/feedback.json +25 -25
- package/dist/r/base/filebase-storage.json +1 -1
- package/dist/r/base/firebase-storage-storage.json +1 -1
- package/dist/r/base/followup-suggestions.json +40 -40
- package/dist/r/base/ftp-storage.json +1 -1
- package/dist/r/base/gcs-storage.json +1 -1
- package/dist/r/base/generate-image.json +21 -15
- package/dist/r/base/generate-video.json +15 -9
- package/dist/r/base/google-drive-storage.json +1 -1
- package/dist/r/base/guest-chat.json +181 -0
- package/dist/r/base/hetzner-storage.json +1 -1
- package/dist/r/base/ibm-cos-storage.json +1 -1
- package/dist/r/base/idrive-e2-storage.json +1 -1
- package/dist/r/base/image-viewer.json +55 -0
- package/dist/r/base/just-bash-sandbox.json +32 -0
- package/dist/r/base/litellm-gateway.json +2 -5
- package/dist/r/base/mcp.json +123 -93
- package/dist/r/base/memory-storage.json +1 -1
- package/dist/r/base/minio-storage.json +1 -1
- package/dist/r/base/model-preferences.json +35 -28
- package/dist/r/base/neon-storage.json +1 -1
- package/dist/r/base/netlify-blobs-storage.json +1 -1
- package/dist/r/base/onedrive-storage.json +1 -1
- package/dist/r/base/openai-compatible-gateway.json +2 -5
- package/dist/r/base/openai-gateway.json +2 -5
- package/dist/r/base/openrouter-gateway.json +2 -6
- package/dist/r/base/oracle-cloud-storage.json +1 -1
- package/dist/r/base/ovhcloud-storage.json +1 -1
- package/dist/r/base/pocketbase-storage.json +1 -1
- package/dist/r/base/projects.json +104 -83
- package/dist/r/base/r2-storage.json +1 -1
- package/dist/r/base/registry.json +1725 -2117
- package/dist/r/base/s3-storage.json +1 -1
- package/dist/r/base/scaleway-storage.json +1 -1
- package/dist/r/base/search.json +70 -40
- package/dist/r/base/sftp-storage.json +1 -1
- package/dist/r/base/sharepoint-storage.json +1 -1
- package/dist/r/base/sharing.json +55 -39
- package/dist/r/base/spreadsheet-grid.json +20 -0
- package/dist/r/base/spreadsheet-viewer.json +68 -0
- package/dist/r/base/storj-storage.json +1 -1
- package/dist/r/base/supabase-storage.json +1 -1
- package/dist/r/base/tencent-storage.json +1 -1
- package/dist/r/base/tigris-storage.json +1 -1
- package/dist/r/base/uploadthing-storage.json +1 -1
- package/dist/r/base/vercel-blob-storage.json +1 -1
- package/dist/r/base/vercel-gateway.json +2 -6
- package/dist/r/base/vercel-sandbox.json +8 -26
- package/dist/r/base/video-viewer.json +48 -0
- package/dist/r/base/vultr-storage.json +1 -1
- package/dist/r/base/wasabi-storage.json +1 -1
- package/dist/r/base/webdav-storage.json +1 -1
- package/dist/r/base/yandex-storage.json +1 -1
- package/dist/r/bunny-storage-storage.json +1 -1
- package/dist/r/cloudinary-storage.json +1 -1
- package/dist/r/credits.json +22 -22
- package/dist/r/deep-research.json +57 -139
- package/dist/r/default-sandbox.json +35 -0
- package/dist/r/desktop.json +144 -0
- package/dist/r/digitalocean-spaces-storage.json +1 -1
- package/dist/r/docker-sandbox.json +35 -0
- package/dist/r/dropbox-storage.json +1 -1
- package/dist/r/eve/deep-research.json +47 -0
- package/dist/r/eve/registry.json +53 -0
- package/dist/r/exoscale-storage.json +1 -1
- package/dist/r/feedback.json +25 -25
- package/dist/r/filebase-storage.json +1 -1
- package/dist/r/firebase-storage-storage.json +1 -1
- package/dist/r/followup-suggestions.json +40 -40
- package/dist/r/ftp-storage.json +1 -1
- package/dist/r/gcs-storage.json +1 -1
- package/dist/r/generate-image.json +21 -15
- package/dist/r/generate-video.json +15 -9
- package/dist/r/google-drive-storage.json +1 -1
- package/dist/r/guest-chat.json +181 -0
- package/dist/r/hetzner-storage.json +1 -1
- package/dist/r/ibm-cos-storage.json +1 -1
- package/dist/r/idrive-e2-storage.json +1 -1
- package/dist/r/image-viewer.json +55 -0
- package/dist/r/just-bash-sandbox.json +32 -0
- package/dist/r/litellm-gateway.json +2 -5
- package/dist/r/mcp.json +123 -93
- package/dist/r/memory-storage.json +1 -1
- package/dist/r/minio-storage.json +1 -1
- package/dist/r/model-preferences.json +35 -28
- package/dist/r/neon-storage.json +1 -1
- package/dist/r/netlify-blobs-storage.json +1 -1
- package/dist/r/onedrive-storage.json +1 -1
- package/dist/r/openai-compatible-gateway.json +2 -5
- package/dist/r/openai-gateway.json +2 -5
- package/dist/r/openrouter-gateway.json +2 -6
- package/dist/r/oracle-cloud-storage.json +1 -1
- package/dist/r/ovhcloud-storage.json +1 -1
- package/dist/r/pocketbase-storage.json +1 -1
- package/dist/r/projects.json +104 -83
- package/dist/r/r2-storage.json +1 -1
- package/dist/r/radix/ai-titles.json +10 -10
- package/dist/r/radix/akamai-storage.json +1 -1
- package/dist/r/radix/alibaba-storage.json +1 -1
- package/dist/r/radix/appwrite-storage.json +1 -1
- package/dist/r/radix/archil-storage.json +1 -1
- package/dist/r/radix/attach-workspace-file.json +82 -0
- package/dist/r/radix/attachment-uploads.json +19 -21
- package/dist/r/radix/azure-storage.json +1 -1
- package/dist/r/radix/backblaze-b2-storage.json +1 -1
- package/dist/r/radix/bunny-storage-storage.json +1 -1
- package/dist/r/radix/cloudinary-storage.json +1 -1
- package/dist/r/radix/credits.json +22 -22
- package/dist/r/radix/deep-research.json +57 -139
- package/dist/r/radix/default-sandbox.json +35 -0
- package/dist/r/radix/desktop.json +144 -0
- package/dist/r/radix/digitalocean-spaces-storage.json +1 -1
- package/dist/r/radix/docker-sandbox.json +35 -0
- package/dist/r/radix/dropbox-storage.json +1 -1
- package/dist/r/radix/exoscale-storage.json +1 -1
- package/dist/r/radix/feedback.json +25 -25
- package/dist/r/radix/filebase-storage.json +1 -1
- package/dist/r/radix/firebase-storage-storage.json +1 -1
- package/dist/r/radix/followup-suggestions.json +40 -40
- package/dist/r/radix/ftp-storage.json +1 -1
- package/dist/r/radix/gcs-storage.json +1 -1
- package/dist/r/radix/generate-image.json +21 -15
- package/dist/r/radix/generate-video.json +15 -9
- package/dist/r/radix/google-drive-storage.json +1 -1
- package/dist/r/radix/guest-chat.json +181 -0
- package/dist/r/radix/hetzner-storage.json +1 -1
- package/dist/r/radix/ibm-cos-storage.json +1 -1
- package/dist/r/radix/idrive-e2-storage.json +1 -1
- package/dist/r/radix/image-viewer.json +55 -0
- package/dist/r/radix/just-bash-sandbox.json +32 -0
- package/dist/r/radix/litellm-gateway.json +2 -5
- package/dist/r/radix/mcp.json +123 -93
- package/dist/r/radix/memory-storage.json +1 -1
- package/dist/r/radix/minio-storage.json +1 -1
- package/dist/r/radix/model-preferences.json +35 -28
- package/dist/r/radix/neon-storage.json +1 -1
- package/dist/r/radix/netlify-blobs-storage.json +1 -1
- package/dist/r/radix/onedrive-storage.json +1 -1
- package/dist/r/radix/openai-compatible-gateway.json +2 -5
- package/dist/r/radix/openai-gateway.json +2 -5
- package/dist/r/radix/openrouter-gateway.json +2 -6
- package/dist/r/radix/oracle-cloud-storage.json +1 -1
- package/dist/r/radix/ovhcloud-storage.json +1 -1
- package/dist/r/radix/pocketbase-storage.json +1 -1
- package/dist/r/radix/projects.json +104 -83
- package/dist/r/radix/r2-storage.json +1 -1
- package/dist/r/radix/registry.json +1728 -2120
- package/dist/r/radix/s3-storage.json +1 -1
- package/dist/r/radix/scaleway-storage.json +1 -1
- package/dist/r/radix/search.json +70 -40
- package/dist/r/radix/sftp-storage.json +1 -1
- package/dist/r/radix/sharepoint-storage.json +1 -1
- package/dist/r/radix/sharing.json +55 -39
- package/dist/r/radix/spreadsheet-grid.json +20 -0
- package/dist/r/radix/spreadsheet-viewer.json +68 -0
- package/dist/r/radix/storj-storage.json +1 -1
- package/dist/r/radix/supabase-storage.json +1 -1
- package/dist/r/radix/tencent-storage.json +1 -1
- package/dist/r/radix/tigris-storage.json +1 -1
- package/dist/r/radix/uploadthing-storage.json +1 -1
- package/dist/r/radix/vercel-blob-storage.json +1 -1
- package/dist/r/radix/vercel-gateway.json +2 -6
- package/dist/r/radix/vercel-sandbox.json +8 -26
- package/dist/r/radix/video-viewer.json +48 -0
- package/dist/r/radix/vultr-storage.json +1 -1
- package/dist/r/radix/wasabi-storage.json +1 -1
- package/dist/r/radix/webdav-storage.json +1 -1
- package/dist/r/radix/yandex-storage.json +1 -1
- package/dist/r/registry.json +1725 -2117
- package/dist/r/s3-storage.json +1 -1
- package/dist/r/scaleway-storage.json +1 -1
- package/dist/r/search.json +70 -40
- package/dist/r/sftp-storage.json +1 -1
- package/dist/r/sharepoint-storage.json +1 -1
- package/dist/r/sharing.json +55 -39
- package/dist/r/spreadsheet-grid.json +20 -0
- package/dist/r/spreadsheet-viewer.json +68 -0
- package/dist/r/storj-storage.json +1 -1
- package/dist/r/supabase-storage.json +1 -1
- package/dist/r/tencent-storage.json +1 -1
- package/dist/r/tigris-storage.json +1 -1
- package/dist/r/uploadthing-storage.json +1 -1
- package/dist/r/vercel-blob-storage.json +1 -1
- package/dist/r/vercel-gateway.json +2 -6
- package/dist/r/vercel-sandbox.json +8 -26
- package/dist/r/video-viewer.json +48 -0
- package/dist/r/vultr-storage.json +1 -1
- package/dist/r/wasabi-storage.json +1 -1
- package/dist/r/webdav-storage.json +1 -1
- package/dist/r/yandex-storage.json +1 -1
- package/package.json +9 -30
- package/dist/r/base/code-documents.json +0 -96
- package/dist/r/base/code-execution-runtime.json +0 -25
- package/dist/r/base/code-execution-ui.json +0 -32
- package/dist/r/base/code-execution.json +0 -69
- package/dist/r/base/daytona-sandbox.json +0 -55
- package/dist/r/base/delete-document.json +0 -58
- package/dist/r/base/firecrawl-search.json +0 -72
- package/dist/r/base/get-weather.json +0 -52
- package/dist/r/base/langfuse.json +0 -63
- package/dist/r/base/read-document.json +0 -34
- package/dist/r/base/retrieve-url.json +0 -69
- package/dist/r/base/saved-code-execution.json +0 -84
- package/dist/r/base/sheet-documents.json +0 -94
- package/dist/r/base/tavily-search.json +0 -72
- package/dist/r/base/text-documents.json +0 -117
- package/dist/r/base/vercel-analytics.json +0 -46
- package/dist/r/base/vercel-speed-insights.json +0 -46
- package/dist/r/base/word-count.json +0 -51
- package/dist/r/code-documents.json +0 -96
- package/dist/r/code-execution-runtime.json +0 -25
- package/dist/r/code-execution-ui.json +0 -32
- package/dist/r/code-execution.json +0 -69
- package/dist/r/daytona-sandbox.json +0 -55
- package/dist/r/delete-document.json +0 -58
- package/dist/r/firecrawl-search.json +0 -72
- package/dist/r/get-weather.json +0 -52
- package/dist/r/langfuse.json +0 -63
- package/dist/r/radix/code-documents.json +0 -96
- package/dist/r/radix/code-execution-runtime.json +0 -25
- package/dist/r/radix/code-execution-ui.json +0 -32
- package/dist/r/radix/code-execution.json +0 -69
- package/dist/r/radix/daytona-sandbox.json +0 -55
- package/dist/r/radix/delete-document.json +0 -58
- package/dist/r/radix/firecrawl-search.json +0 -72
- package/dist/r/radix/get-weather.json +0 -52
- package/dist/r/radix/langfuse.json +0 -63
- package/dist/r/radix/read-document.json +0 -34
- package/dist/r/radix/retrieve-url.json +0 -69
- package/dist/r/radix/saved-code-execution.json +0 -84
- package/dist/r/radix/sheet-documents.json +0 -94
- package/dist/r/radix/tavily-search.json +0 -72
- package/dist/r/radix/text-documents.json +0 -117
- package/dist/r/radix/vercel-analytics.json +0 -46
- package/dist/r/radix/vercel-speed-insights.json +0 -46
- package/dist/r/radix/word-count.json +0 -51
- package/dist/r/read-document.json +0 -34
- package/dist/r/retrieve-url.json +0 -69
- package/dist/r/saved-code-execution.json +0 -84
- package/dist/r/sheet-documents.json +0 -94
- package/dist/r/tavily-search.json +0 -72
- package/dist/r/text-documents.json +0 -117
- package/dist/r/vercel-analytics.json +0 -46
- package/dist/r/vercel-speed-insights.json +0 -46
- package/dist/r/word-count.json +0 -51
package/dist/r/feedback.json
CHANGED
|
@@ -12,63 +12,63 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
{
|
|
14
14
|
"path": "src/plugins/feedback/src/chat.ts",
|
|
15
|
-
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/
|
|
15
|
+
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/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",
|
|
16
16
|
"type": "registry:file",
|
|
17
|
-
"target": "~/plugins/feedback/chat.ts"
|
|
17
|
+
"target": "~/chatjs/plugins/feedback/chat.ts"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"path": "src/plugins/feedback/src/client-plugin.ts",
|
|
21
|
-
"content": "
|
|
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 feedbackClient = definePlugin({\n id: \"feedback\",\n slots: [slot(MessageActions, FeedbackActions)],\n});\n",
|
|
22
22
|
"type": "registry:file",
|
|
23
|
-
"target": "~/plugins/feedback/client-plugin.ts"
|
|
23
|
+
"target": "~/chatjs/plugins/feedback/client-plugin.ts"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"path": "src/plugins/feedback/src/feedback-actions.tsx",
|
|
27
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 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",
|
|
28
28
|
"type": "registry:file",
|
|
29
|
-
"target": "~/plugins/feedback/feedback-actions.tsx"
|
|
29
|
+
"target": "~/chatjs/plugins/feedback/feedback-actions.tsx"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"path": "src/plugins/feedback/src/message-vote-actions.tsx",
|
|
33
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",
|
|
34
34
|
"type": "registry:file",
|
|
35
|
-
"target": "~/plugins/feedback/message-vote-actions.tsx"
|
|
35
|
+
"target": "~/chatjs/plugins/feedback/message-vote-actions.tsx"
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"path": "src/plugins/feedback/src/feedback-queries.ts",
|
|
39
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} 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",
|
|
40
40
|
"type": "registry:file",
|
|
41
|
-
"target": "~/plugins/feedback/feedback-queries.ts"
|
|
41
|
+
"target": "~/chatjs/plugins/feedback/feedback-queries.ts"
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"path": "src/plugins/feedback/src/router.ts",
|
|
45
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;\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",
|
|
46
46
|
"type": "registry:file",
|
|
47
|
-
"target": "~/plugins/feedback/router.ts"
|
|
47
|
+
"target": "~/chatjs/plugins/feedback/router.ts"
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"path": "src/plugins/feedback/src/feedback-schema.ts",
|
|
51
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 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",
|
|
52
52
|
"type": "registry:file",
|
|
53
|
-
"target": "~/plugins/feedback/feedback-schema.ts"
|
|
53
|
+
"target": "~/chatjs/plugins/feedback/feedback-schema.ts"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"path": "src/plugins/feedback/src/server-plugin.ts",
|
|
57
|
-
"content": "import type { ChatPlugin } from \"@/
|
|
57
|
+
"content": "import type { ChatPlugin } from \"@/chatjs/core/installation/plugin\";\nimport { feedbackRouter } from \"./router\";\n\nexport const feedback = () =>\n ({\n id: \"feedback\",\n routers: { feedback: feedbackRouter },\n }) satisfies ChatPlugin;\n",
|
|
58
58
|
"type": "registry:file",
|
|
59
|
-
"target": "~/plugins/feedback/server-plugin.ts"
|
|
59
|
+
"target": "~/chatjs/plugins/feedback/server-plugin.ts"
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"path": "src/plugins/feedback/src/vote-message.ts",
|
|
63
|
-
"content": "import { Client,
|
|
63
|
+
"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 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 { 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.conversationId,\n input.messageId,\n input.type === \"up\"\n );\n};\n",
|
|
64
64
|
"type": "registry:file",
|
|
65
|
-
"target": "~/plugins/feedback/vote-message.ts"
|
|
65
|
+
"target": "~/chatjs/plugins/feedback/vote-message.ts"
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"path": "dist/source/feedback.json",
|
|
69
|
-
"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",
|
|
69
|
+
"content": "{\n \"id\": \"feedback\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/feedback/chat.ts\",\n \"chatjs/plugins/feedback/client-plugin.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/server-plugin.ts\",\n \"chatjs/plugins/feedback/vote-message.ts\"\n ],\n \"databaseSchemas\": [\"chatjs/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",
|
|
70
70
|
"type": "registry:file",
|
|
71
|
-
"target": "~/plugins/feedback/chatjs.json"
|
|
71
|
+
"target": "~/chatjs/plugins/feedback/chatjs.json"
|
|
72
72
|
}
|
|
73
73
|
],
|
|
74
74
|
"meta": {
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
"id": "feedback",
|
|
77
77
|
"kind": "plugin",
|
|
78
78
|
"files": [
|
|
79
|
-
"plugins/feedback/chat.ts",
|
|
80
|
-
"plugins/feedback/client-plugin.ts",
|
|
81
|
-
"plugins/feedback/feedback-actions.tsx",
|
|
82
|
-
"plugins/feedback/message-vote-actions.tsx",
|
|
83
|
-
"plugins/feedback/feedback-queries.ts",
|
|
84
|
-
"plugins/feedback/router.ts",
|
|
85
|
-
"plugins/feedback/feedback-schema.ts",
|
|
86
|
-
"plugins/feedback/server-plugin.ts",
|
|
87
|
-
"plugins/feedback/vote-message.ts"
|
|
79
|
+
"chatjs/plugins/feedback/chat.ts",
|
|
80
|
+
"chatjs/plugins/feedback/client-plugin.ts",
|
|
81
|
+
"chatjs/plugins/feedback/feedback-actions.tsx",
|
|
82
|
+
"chatjs/plugins/feedback/message-vote-actions.tsx",
|
|
83
|
+
"chatjs/plugins/feedback/feedback-queries.ts",
|
|
84
|
+
"chatjs/plugins/feedback/router.ts",
|
|
85
|
+
"chatjs/plugins/feedback/feedback-schema.ts",
|
|
86
|
+
"chatjs/plugins/feedback/server-plugin.ts",
|
|
87
|
+
"chatjs/plugins/feedback/vote-message.ts"
|
|
88
88
|
],
|
|
89
89
|
"databaseSchemas": [
|
|
90
|
-
"plugins/feedback/feedback-schema.ts"
|
|
90
|
+
"chatjs/plugins/feedback/feedback-schema.ts"
|
|
91
91
|
],
|
|
92
92
|
"chat": {
|
|
93
93
|
"export": "feedbackChat"
|
|
@@ -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": "~/
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
"meta": {
|
|
@@ -12,7 +12,7 @@
|
|
|
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": "~/
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"meta": {
|
|
@@ -10,99 +10,99 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
{
|
|
12
12
|
"path": "src/plugins/followup-suggestions/src/chat.ts",
|
|
13
|
-
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/
|
|
13
|
+
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/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",
|
|
14
14
|
"type": "registry:file",
|
|
15
|
-
"target": "~/plugins/followup-suggestions/chat.ts"
|
|
15
|
+
"target": "~/chatjs/plugins/followup-suggestions/chat.ts"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"path": "src/plugins/followup-suggestions/src/client-plugin.ts",
|
|
19
|
-
"content": "
|
|
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 followupSuggestionsClient = definePlugin({\n id: \"followup-suggestions\",\n slots: [slot(ChatSuggestions, FollowupSuggestions)],\n});\n",
|
|
20
20
|
"type": "registry:file",
|
|
21
|
-
"target": "~/plugins/followup-suggestions/client-plugin.ts"
|
|
21
|
+
"target": "~/chatjs/plugins/followup-suggestions/client-plugin.ts"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"path": "src/plugins/followup-suggestions/src/followup-completion.ts",
|
|
25
|
-
"content": "import type {
|
|
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",
|
|
26
26
|
"type": "registry:file",
|
|
27
|
-
"target": "~/plugins/followup-suggestions/followup-completion.ts"
|
|
27
|
+
"target": "~/chatjs/plugins/followup-suggestions/followup-completion.ts"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"path": "src/plugins/followup-suggestions/src/followup-context.ts",
|
|
31
|
-
"content": "import type { HookEvent } from \"eve/hooks\";\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",
|
|
32
32
|
"type": "registry:file",
|
|
33
|
-
"target": "~/plugins/followup-suggestions/followup-context.ts"
|
|
33
|
+
"target": "~/chatjs/plugins/followup-suggestions/followup-context.ts"
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
"path": "src/plugins/followup-suggestions/src/followup-hook.ts",
|
|
37
|
-
"content": "import {
|
|
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",
|
|
38
38
|
"type": "registry:file",
|
|
39
|
-
"target": "~/plugins/followup-suggestions/followup-hook.ts"
|
|
39
|
+
"target": "~/chatjs/plugins/followup-suggestions/followup-hook.ts"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"path": "src/plugins/followup-suggestions/src/followup-queries.ts",
|
|
43
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 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",
|
|
44
44
|
"type": "registry:file",
|
|
45
|
-
"target": "~/plugins/followup-suggestions/followup-queries.ts"
|
|
45
|
+
"target": "~/chatjs/plugins/followup-suggestions/followup-queries.ts"
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"path": "src/plugins/followup-suggestions/src/followup-schema.ts",
|
|
49
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",
|
|
50
50
|
"type": "registry:file",
|
|
51
|
-
"target": "~/plugins/followup-suggestions/followup-schema.ts"
|
|
51
|
+
"target": "~/chatjs/plugins/followup-suggestions/followup-schema.ts"
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
"path": "src/plugins/followup-suggestions/src/followup-suggestions-view.tsx",
|
|
55
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",
|
|
56
56
|
"type": "registry:file",
|
|
57
|
-
"target": "~/plugins/followup-suggestions/followup-suggestions-view.tsx"
|
|
57
|
+
"target": "~/chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx"
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"path": "src/plugins/followup-suggestions/src/generate-suggestions.ts",
|
|
61
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",
|
|
62
62
|
"type": "registry:file",
|
|
63
|
-
"target": "~/plugins/followup-suggestions/generate-suggestions.ts"
|
|
63
|
+
"target": "~/chatjs/plugins/followup-suggestions/generate-suggestions.ts"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"path": "src/plugins/followup-suggestions/src/router.ts",
|
|
67
67
|
"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",
|
|
68
68
|
"type": "registry:file",
|
|
69
|
-
"target": "~/plugins/followup-suggestions/router.ts"
|
|
69
|
+
"target": "~/chatjs/plugins/followup-suggestions/router.ts"
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"path": "src/plugins/followup-suggestions/src/server-plugin.ts",
|
|
73
|
-
"content": "import type { ChatPlugin } from \"@/
|
|
73
|
+
"content": "import type { ChatPlugin } from \"@/chatjs/core/installation/plugin\";\nimport { followupSuggestionsRouter } from \"./router\";\n\nexport const followupSuggestions = () =>\n ({\n id: \"followup-suggestions\",\n routers: { followupSuggestions: followupSuggestionsRouter },\n }) satisfies ChatPlugin;\n",
|
|
74
74
|
"type": "registry:file",
|
|
75
|
-
"target": "~/plugins/followup-suggestions/server-plugin.ts"
|
|
75
|
+
"target": "~/chatjs/plugins/followup-suggestions/server-plugin.ts"
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
"path": "src/plugins/followup-suggestions/src/suggestion-output.ts",
|
|
79
79
|
"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",
|
|
80
80
|
"type": "registry:file",
|
|
81
|
-
"target": "~/plugins/followup-suggestions/suggestion-output.ts"
|
|
81
|
+
"target": "~/chatjs/plugins/followup-suggestions/suggestion-output.ts"
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"path": "src/plugins/followup-suggestions/src/suggestions.tsx",
|
|
85
|
-
"content": "\"use client\";\n\nimport React from \"react\";\nimport type { ChatSuggestionsProps } from \"@/
|
|
85
|
+
"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 conversationId,\n sessionId,\n events,\n lastMessage,\n onSelect,\n disabled,\n}: ChatSuggestionsProps): React.JSX.Element | null => {\n const suggestions = useEveFollowups(\n conversationId,\n sessionId,\n events,\n lastMessage\n );\n return (\n <FollowUpSuggestionsView\n suggestions={suggestions}\n onSelect={onSelect}\n disabled={disabled}\n />\n );\n};\n",
|
|
86
86
|
"type": "registry:file",
|
|
87
|
-
"target": "~/plugins/followup-suggestions/suggestions.tsx"
|
|
87
|
+
"target": "~/chatjs/plugins/followup-suggestions/suggestions.tsx"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"path": "src/plugins/followup-suggestions/src/use-followups.ts",
|
|
91
|
-
"content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTRPC } from \"@/trpc/react\";\nimport type { ChatSuggestionsProps } from \"@/
|
|
91
|
+
"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 conversationId: 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 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",
|
|
92
92
|
"type": "registry:file",
|
|
93
|
-
"target": "~/plugins/followup-suggestions/use-followups.ts"
|
|
93
|
+
"target": "~/chatjs/plugins/followup-suggestions/use-followups.ts"
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"path": "src/plugins/followup-suggestions/adapters/agent/hooks/followup-suggestions.ts",
|
|
97
|
-
"content": "
|
|
97
|
+
"content": "// ChatJS source: followup-suggestions. Ownership: chatjs/plugins/followup-suggestions/chatjs.json.\nexport { default } from \"@/chatjs/plugins/followup-suggestions/followup-hook\";\n",
|
|
98
98
|
"type": "registry:file",
|
|
99
99
|
"target": "~/agent/hooks/followup-suggestions.ts"
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"path": "dist/source/followup-suggestions.json",
|
|
103
|
-
"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",
|
|
103
|
+
"content": "{\n \"id\": \"followup-suggestions\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/followup-suggestions/chat.ts\",\n \"chatjs/plugins/followup-suggestions/client-plugin.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/server-plugin.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 \"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",
|
|
104
104
|
"type": "registry:file",
|
|
105
|
-
"target": "~/plugins/followup-suggestions/chatjs.json"
|
|
105
|
+
"target": "~/chatjs/plugins/followup-suggestions/chatjs.json"
|
|
106
106
|
}
|
|
107
107
|
],
|
|
108
108
|
"meta": {
|
|
@@ -110,24 +110,24 @@
|
|
|
110
110
|
"id": "followup-suggestions",
|
|
111
111
|
"kind": "plugin",
|
|
112
112
|
"files": [
|
|
113
|
-
"plugins/followup-suggestions/chat.ts",
|
|
114
|
-
"plugins/followup-suggestions/client-plugin.ts",
|
|
115
|
-
"plugins/followup-suggestions/followup-completion.ts",
|
|
116
|
-
"plugins/followup-suggestions/followup-context.ts",
|
|
117
|
-
"plugins/followup-suggestions/followup-hook.ts",
|
|
118
|
-
"plugins/followup-suggestions/followup-queries.ts",
|
|
119
|
-
"plugins/followup-suggestions/followup-schema.ts",
|
|
120
|
-
"plugins/followup-suggestions/followup-suggestions-view.tsx",
|
|
121
|
-
"plugins/followup-suggestions/generate-suggestions.ts",
|
|
122
|
-
"plugins/followup-suggestions/router.ts",
|
|
123
|
-
"plugins/followup-suggestions/server-plugin.ts",
|
|
124
|
-
"plugins/followup-suggestions/suggestion-output.ts",
|
|
125
|
-
"plugins/followup-suggestions/suggestions.tsx",
|
|
126
|
-
"plugins/followup-suggestions/use-followups.ts",
|
|
113
|
+
"chatjs/plugins/followup-suggestions/chat.ts",
|
|
114
|
+
"chatjs/plugins/followup-suggestions/client-plugin.ts",
|
|
115
|
+
"chatjs/plugins/followup-suggestions/followup-completion.ts",
|
|
116
|
+
"chatjs/plugins/followup-suggestions/followup-context.ts",
|
|
117
|
+
"chatjs/plugins/followup-suggestions/followup-hook.ts",
|
|
118
|
+
"chatjs/plugins/followup-suggestions/followup-queries.ts",
|
|
119
|
+
"chatjs/plugins/followup-suggestions/followup-schema.ts",
|
|
120
|
+
"chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx",
|
|
121
|
+
"chatjs/plugins/followup-suggestions/generate-suggestions.ts",
|
|
122
|
+
"chatjs/plugins/followup-suggestions/router.ts",
|
|
123
|
+
"chatjs/plugins/followup-suggestions/server-plugin.ts",
|
|
124
|
+
"chatjs/plugins/followup-suggestions/suggestion-output.ts",
|
|
125
|
+
"chatjs/plugins/followup-suggestions/suggestions.tsx",
|
|
126
|
+
"chatjs/plugins/followup-suggestions/use-followups.ts",
|
|
127
127
|
"agent/hooks/followup-suggestions.ts"
|
|
128
128
|
],
|
|
129
129
|
"databaseSchemas": [
|
|
130
|
-
"plugins/followup-suggestions/followup-schema.ts"
|
|
130
|
+
"chatjs/plugins/followup-suggestions/followup-schema.ts"
|
|
131
131
|
],
|
|
132
132
|
"chat": {
|
|
133
133
|
"export": "followupChat"
|
package/dist/r/ftp-storage.json
CHANGED
|
@@ -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": "~/
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"meta": {
|
package/dist/r/gcs-storage.json
CHANGED
|
@@ -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": "~/
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"meta": {
|