@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.
- package/README.md +16 -12
- package/dist/r/ai-titles.json +17 -17
- package/dist/r/akamai-storage.json +13 -1
- package/dist/r/alibaba-storage.json +13 -1
- package/dist/r/appwrite-storage.json +8 -1
- package/dist/r/archil-storage.json +8 -1
- package/dist/r/attach-workspace-file.json +82 -0
- package/dist/r/attachment-uploads.json +26 -34
- package/dist/r/azure-storage.json +8 -1
- package/dist/r/backblaze-b2-storage.json +13 -1
- package/dist/r/base/ai-titles.json +47 -0
- package/dist/r/base/akamai-storage.json +56 -0
- package/dist/r/base/alibaba-storage.json +56 -0
- package/dist/r/base/appwrite-storage.json +57 -0
- package/dist/r/base/archil-storage.json +59 -0
- package/dist/r/base/attach-workspace-file.json +82 -0
- package/dist/r/base/attachment-uploads.json +79 -0
- package/dist/r/base/azure-storage.json +58 -0
- package/dist/r/base/backblaze-b2-storage.json +56 -0
- package/dist/r/base/bunny-storage-storage.json +49 -0
- package/dist/r/base/cloudinary-storage.json +44 -0
- package/dist/r/base/credits.json +81 -0
- package/dist/r/base/deep-research.json +138 -0
- package/dist/r/base/default-sandbox.json +35 -0
- package/dist/r/base/desktop.json +129 -0
- package/dist/r/base/digitalocean-spaces-storage.json +56 -0
- package/dist/r/base/docker-sandbox.json +35 -0
- package/dist/r/base/dropbox-storage.json +44 -0
- package/dist/r/base/exoscale-storage.json +56 -0
- package/dist/r/base/feedback.json +90 -0
- package/dist/r/base/filebase-storage.json +50 -0
- package/dist/r/base/firebase-storage-storage.json +53 -0
- package/dist/r/base/followup-suggestions.json +130 -0
- package/dist/r/base/ftp-storage.json +71 -0
- package/dist/r/base/gcs-storage.json +40 -0
- package/dist/r/base/generate-image.json +107 -0
- package/dist/r/base/generate-video.json +76 -0
- package/dist/r/base/google-drive-storage.json +48 -0
- package/dist/r/base/guest-chat.json +166 -0
- package/dist/r/base/hetzner-storage.json +56 -0
- package/dist/r/base/ibm-cos-storage.json +56 -0
- package/dist/r/base/idrive-e2-storage.json +56 -0
- package/dist/r/base/image-viewer.json +49 -0
- package/dist/r/base/just-bash-sandbox.json +32 -0
- package/dist/r/base/litellm-gateway.json +64 -0
- package/dist/r/base/mcp.json +327 -0
- package/dist/r/base/memory-storage.json +30 -0
- package/dist/r/base/minio-storage.json +56 -0
- package/dist/r/base/model-preferences.json +117 -0
- package/dist/r/base/neon-storage.json +51 -0
- package/dist/r/base/netlify-blobs-storage.json +39 -0
- package/dist/r/base/onedrive-storage.json +49 -0
- package/dist/r/base/openai-compatible-gateway.json +66 -0
- package/dist/r/base/openai-gateway.json +64 -0
- package/dist/r/base/openrouter-gateway.json +71 -0
- package/dist/r/base/oracle-cloud-storage.json +62 -0
- package/dist/r/base/ovhcloud-storage.json +56 -0
- package/dist/r/base/pocketbase-storage.json +51 -0
- package/dist/r/base/projects.json +274 -0
- package/dist/r/base/r2-storage.json +52 -0
- package/dist/r/base/registry.json +4734 -0
- package/dist/r/base/s3-storage.json +58 -0
- package/dist/r/base/scaleway-storage.json +56 -0
- package/dist/r/base/search.json +154 -0
- package/dist/r/base/sftp-storage.json +75 -0
- package/dist/r/base/sharepoint-storage.json +51 -0
- package/dist/r/base/sharing.json +138 -0
- package/dist/r/base/spreadsheet-grid.json +20 -0
- package/dist/r/base/spreadsheet-viewer.json +62 -0
- package/dist/r/base/storj-storage.json +50 -0
- package/dist/r/base/streamdown-math.json +35 -0
- package/dist/r/base/streamdown-mermaid.json +34 -0
- package/dist/r/base/supabase-storage.json +55 -0
- package/dist/r/base/tencent-storage.json +56 -0
- package/dist/r/base/tigris-storage.json +50 -0
- package/dist/r/base/uploadthing-storage.json +39 -0
- package/dist/r/base/vercel-blob-storage.json +44 -0
- package/dist/r/base/vercel-gateway.json +75 -0
- package/dist/r/base/vercel-sandbox.json +49 -0
- package/dist/r/base/video-viewer.json +42 -0
- package/dist/r/base/vultr-storage.json +56 -0
- package/dist/r/base/wasabi-storage.json +56 -0
- package/dist/r/base/webdav-storage.json +64 -0
- package/dist/r/base/yandex-storage.json +50 -0
- package/dist/r/bunny-storage-storage.json +2 -1
- package/dist/r/cloudinary-storage.json +2 -1
- package/dist/r/credits.json +29 -46
- package/dist/r/deep-research.json +56 -138
- package/dist/r/default-sandbox.json +35 -0
- package/dist/r/desktop.json +129 -0
- package/dist/r/digitalocean-spaces-storage.json +13 -1
- package/dist/r/docker-sandbox.json +35 -0
- package/dist/r/dropbox-storage.json +2 -1
- package/dist/r/eve/deep-research.json +47 -0
- package/dist/r/eve/registry.json +53 -0
- package/dist/r/exoscale-storage.json +13 -1
- package/dist/r/feedback.json +38 -53
- package/dist/r/filebase-storage.json +8 -1
- package/dist/r/firebase-storage-storage.json +2 -1
- package/dist/r/followup-suggestions.json +49 -66
- package/dist/r/ftp-storage.json +18 -1
- package/dist/r/gcs-storage.json +8 -1
- package/dist/r/generate-image.json +24 -18
- package/dist/r/generate-video.json +17 -11
- package/dist/r/google-drive-storage.json +2 -1
- package/dist/r/guest-chat.json +166 -0
- package/dist/r/hetzner-storage.json +13 -1
- package/dist/r/ibm-cos-storage.json +13 -1
- package/dist/r/idrive-e2-storage.json +13 -1
- package/dist/r/image-viewer.json +49 -0
- package/dist/r/just-bash-sandbox.json +32 -0
- package/dist/r/litellm-gateway.json +5 -8
- package/dist/r/mcp.json +143 -120
- package/dist/r/memory-storage.json +5 -3
- package/dist/r/minio-storage.json +13 -1
- package/dist/r/model-preferences.json +47 -55
- package/dist/r/neon-storage.json +8 -1
- package/dist/r/netlify-blobs-storage.json +10 -2
- package/dist/r/onedrive-storage.json +2 -1
- package/dist/r/openai-compatible-gateway.json +6 -9
- package/dist/r/openai-gateway.json +6 -9
- package/dist/r/openrouter-gateway.json +5 -9
- package/dist/r/oracle-cloud-storage.json +18 -1
- package/dist/r/ovhcloud-storage.json +13 -1
- package/dist/r/pocketbase-storage.json +2 -1
- package/dist/r/projects.json +116 -108
- package/dist/r/r2-storage.json +9 -1
- package/dist/r/radix/ai-titles.json +47 -0
- package/dist/r/radix/akamai-storage.json +56 -0
- package/dist/r/radix/alibaba-storage.json +56 -0
- package/dist/r/radix/appwrite-storage.json +57 -0
- package/dist/r/radix/archil-storage.json +59 -0
- package/dist/r/radix/attach-workspace-file.json +82 -0
- package/dist/r/radix/attachment-uploads.json +79 -0
- package/dist/r/radix/azure-storage.json +58 -0
- package/dist/r/radix/backblaze-b2-storage.json +56 -0
- package/dist/r/radix/bunny-storage-storage.json +49 -0
- package/dist/r/radix/cloudinary-storage.json +44 -0
- package/dist/r/radix/credits.json +81 -0
- package/dist/r/radix/deep-research.json +138 -0
- package/dist/r/radix/default-sandbox.json +35 -0
- package/dist/r/radix/desktop.json +129 -0
- package/dist/r/radix/digitalocean-spaces-storage.json +56 -0
- package/dist/r/radix/docker-sandbox.json +35 -0
- package/dist/r/radix/dropbox-storage.json +44 -0
- package/dist/r/radix/exoscale-storage.json +56 -0
- package/dist/r/radix/feedback.json +90 -0
- package/dist/r/radix/filebase-storage.json +50 -0
- package/dist/r/radix/firebase-storage-storage.json +53 -0
- package/dist/r/radix/followup-suggestions.json +130 -0
- package/dist/r/radix/ftp-storage.json +71 -0
- package/dist/r/radix/gcs-storage.json +40 -0
- package/dist/r/radix/generate-image.json +107 -0
- package/dist/r/radix/generate-video.json +76 -0
- package/dist/r/radix/google-drive-storage.json +48 -0
- package/dist/r/radix/guest-chat.json +166 -0
- package/dist/r/radix/hetzner-storage.json +56 -0
- package/dist/r/radix/ibm-cos-storage.json +56 -0
- package/dist/r/radix/idrive-e2-storage.json +56 -0
- package/dist/r/radix/image-viewer.json +49 -0
- package/dist/r/radix/just-bash-sandbox.json +32 -0
- package/dist/r/radix/litellm-gateway.json +64 -0
- package/dist/r/radix/mcp.json +327 -0
- package/dist/r/radix/memory-storage.json +30 -0
- package/dist/r/radix/minio-storage.json +56 -0
- package/dist/r/radix/model-preferences.json +117 -0
- package/dist/r/radix/neon-storage.json +51 -0
- package/dist/r/radix/netlify-blobs-storage.json +39 -0
- package/dist/r/radix/onedrive-storage.json +49 -0
- package/dist/r/radix/openai-compatible-gateway.json +66 -0
- package/dist/r/radix/openai-gateway.json +64 -0
- package/dist/r/radix/openrouter-gateway.json +71 -0
- package/dist/r/radix/oracle-cloud-storage.json +62 -0
- package/dist/r/radix/ovhcloud-storage.json +56 -0
- package/dist/r/radix/pocketbase-storage.json +51 -0
- package/dist/r/radix/projects.json +274 -0
- package/dist/r/radix/r2-storage.json +52 -0
- package/dist/r/radix/registry.json +4734 -0
- package/dist/r/radix/s3-storage.json +58 -0
- package/dist/r/radix/scaleway-storage.json +56 -0
- package/dist/r/radix/search.json +154 -0
- package/dist/r/radix/sftp-storage.json +75 -0
- package/dist/r/radix/sharepoint-storage.json +51 -0
- package/dist/r/radix/sharing.json +138 -0
- package/dist/r/radix/spreadsheet-grid.json +20 -0
- package/dist/r/radix/spreadsheet-viewer.json +62 -0
- package/dist/r/radix/storj-storage.json +50 -0
- package/dist/r/radix/streamdown-math.json +35 -0
- package/dist/r/radix/streamdown-mermaid.json +34 -0
- package/dist/r/radix/supabase-storage.json +55 -0
- package/dist/r/radix/tencent-storage.json +56 -0
- package/dist/r/radix/tigris-storage.json +50 -0
- package/dist/r/radix/uploadthing-storage.json +39 -0
- package/dist/r/radix/vercel-blob-storage.json +44 -0
- package/dist/r/radix/vercel-gateway.json +75 -0
- package/dist/r/radix/vercel-sandbox.json +49 -0
- package/dist/r/radix/video-viewer.json +42 -0
- package/dist/r/radix/vultr-storage.json +56 -0
- package/dist/r/radix/wasabi-storage.json +56 -0
- package/dist/r/radix/webdav-storage.json +64 -0
- package/dist/r/radix/yandex-storage.json +50 -0
- package/dist/r/registry.json +2006 -2142
- package/dist/r/s3-storage.json +15 -1
- package/dist/r/scaleway-storage.json +13 -1
- package/dist/r/search.json +80 -66
- package/dist/r/sftp-storage.json +18 -1
- package/dist/r/sharepoint-storage.json +2 -1
- package/dist/r/sharing.json +65 -64
- package/dist/r/spreadsheet-grid.json +20 -0
- package/dist/r/spreadsheet-viewer.json +62 -0
- package/dist/r/storj-storage.json +8 -1
- package/dist/r/streamdown-math.json +35 -0
- package/dist/r/streamdown-mermaid.json +34 -0
- package/dist/r/supabase-storage.json +8 -1
- package/dist/r/tencent-storage.json +13 -1
- package/dist/r/tigris-storage.json +8 -1
- package/dist/r/uploadthing-storage.json +2 -1
- package/dist/r/vercel-blob-storage.json +3 -1
- package/dist/r/vercel-gateway.json +7 -9
- package/dist/r/vercel-sandbox.json +8 -26
- package/dist/r/video-viewer.json +42 -0
- package/dist/r/vultr-storage.json +13 -1
- package/dist/r/wasabi-storage.json +13 -1
- package/dist/r/webdav-storage.json +13 -1
- package/dist/r/yandex-storage.json +8 -1
- package/package.json +20 -38
- 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 -31
- 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/read-document.json +0 -34
- package/dist/r/retrieve-url.json +0 -67
- package/dist/r/saved-code-execution.json +0 -81
- package/dist/r/sheet-documents.json +0 -93
- package/dist/r/tavily-search.json +0 -72
- package/dist/r/text-documents.json +0 -116
- 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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "desktop",
|
|
4
|
+
"description": "Electron authentication, browser handoff and renderer integration",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@better-auth/electron@1.6.2",
|
|
7
|
+
"better-auth@1.6.2",
|
|
8
|
+
"lucide-react@0.553.0",
|
|
9
|
+
"sonner@^2.0.7"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/plugins/desktop/src/desktop-auth-client.ts",
|
|
14
|
+
"content": "import {\n ELECTRON_AUTH_CALLBACK_PATH,\n ELECTRON_AUTH_CLIENT_ID,\n ELECTRON_AUTH_COOKIE_PREFIX,\n} from \"./protocol\";\nimport { ELECTRON_APP_SCHEME } from \"./electron-auth\";\nimport { createAuthClient } from \"better-auth/react\";\nimport { electronProxyClient } from \"@better-auth/electron/proxy\";\nimport { lastLoginMethodClient } from \"better-auth/client/plugins\";\n\nconst electronAuthPlugin = electronProxyClient({\n callbackPath: ELECTRON_AUTH_CALLBACK_PATH,\n clientID: ELECTRON_AUTH_CLIENT_ID,\n cookiePrefix: ELECTRON_AUTH_COOKIE_PREFIX,\n protocol: {\n scheme: ELECTRON_APP_SCHEME,\n },\n});\n\n// Better Auth auto-detects the base URL from window.location.origin on client\n// and uses relative URLs for SSR, so we don't need to specify baseURL\nconst authClient = createAuthClient({\n plugins: [lastLoginMethodClient(), electronAuthPlugin],\n});\n\nexport default authClient;\n",
|
|
15
|
+
"type": "registry:file",
|
|
16
|
+
"target": "~/chatjs/plugins/desktop/desktop-auth-client.ts"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "src/plugins/desktop/src/auth-form.tsx",
|
|
20
|
+
"content": "\"use client\";\nimport { isElectronRenderer } from \"./bridge\";\nimport { useSyncExternalStore } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useSearchParams } from \"next/navigation\";\nimport { AuthCardSkeleton } from \"@/components/auth-card-skeleton\";\nimport { AuthFormView } from \"@/components/auth-form-view\";\nimport { SocialAuthProviders } from \"@/components/auth-providers\";\nimport authClient from \"@/lib/auth-client\";\nimport {\n buildSocialAuthRequest,\n isElectronTransferQuery,\n} from \"./electron-auth\";\nimport { ElectronBrowserSignIn, ElectronTransferUser } from \"./auth-ui\";\n\n// Preload capabilities are fixed for the lifetime of the renderer.\nconst subscribe = () => () => {\n /* No subscription to release. */\n};\nconst BrowserTransfer = ({\n mode,\n query,\n}: {\n readonly mode: \"login\" | \"register\";\n readonly query: Readonly<Record<string, string>>;\n}) => {\n const { data: session, isPending } = authClient.useSession();\n if (isPending) {\n return (\n <AuthCardSkeleton\n title=\"Connecting…\"\n description=\"Connecting your desktop app\"\n />\n );\n }\n if (session?.user) {\n return <ElectronTransferUser query={query} session={session} />;\n }\n const request = buildSocialAuthRequest(query, globalThis.location?.origin);\n return (\n <AuthFormView mode={mode} query={query}>\n <SocialAuthProviders {...request} query={query} />\n </AuthFormView>\n );\n};\n\nconst DesktopAuthForm = ({\n mode,\n children,\n}: {\n readonly mode: \"login\" | \"register\";\n readonly children: ReactNode;\n}): ReactNode => {\n const query = Object.fromEntries(useSearchParams().entries());\n const native = useSyncExternalStore(\n subscribe,\n isElectronRenderer,\n () => false\n );\n if (native) {\n return (\n <AuthFormView\n mode={mode}\n query={query}\n title=\"Continue in browser\"\n description=\"Use your browser to sign in or create an account.\"\n footer={\n <div className=\"text-muted-foreground text-center text-sm\">\n New and existing accounts both continue through the browser flow.\n </div>\n }\n >\n <ElectronBrowserSignIn buttonLabel=\"Continue in browser\" />\n </AuthFormView>\n );\n }\n if (isElectronTransferQuery(query)) {\n return <BrowserTransfer mode={mode} query={query} />;\n }\n return children;\n};\n\nexport default DesktopAuthForm;\n",
|
|
21
|
+
"type": "registry:file",
|
|
22
|
+
"target": "~/chatjs/plugins/desktop/auth-form.tsx"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "src/plugins/desktop/src/auth-handler.tsx",
|
|
26
|
+
"content": "\"use client\";\nimport type {\n ElectronAuthErrorContext,\n ElectronRendererAuthState,\n} from \"./bridge\";\n\nimport { nonEmptyText } from \"@/components/text-value\";\n\nimport { AlertCircle, LoaderCircle } from \"lucide-react\";\nimport React, { useEffect, useState } from \"react\";\n\nimport type { JSX as ReactJSX } from \"react\";\n\nimport { toast } from \"sonner\";\nimport { Button } from \"@/components/ui/button\";\n\nimport authClient from \"@/chatjs/plugins/desktop/desktop-auth-client\";\n\nimport { useRouter } from \"next/navigation\";\n\nconst ElectronAuthOverlay = ({\n state,\n}: {\n readonly state: Readonly<ElectronRendererAuthState>;\n}): ReactJSX.Element | null => {\n const [, startEventAction] = React.useTransition();\n const [isDismissed, setIsDismissed] = useState(false);\n\n if (state.status === \"idle\" || !state.message) {\n return null;\n }\n\n const isLoading =\n state.status === \"awaiting-browser\" || state.status === \"finishing\";\n const canCancel = state.status === \"awaiting-browser\";\n let detailMessage: string;\n\n if (state.status === \"awaiting-browser\") {\n detailMessage = \"Complete sign-in in your browser, then come back here.\";\n } else if (state.status === \"finishing\") {\n detailMessage =\n \"Your browser has returned to ChatJS. We're finalizing the session now.\";\n } else {\n const { detail } = state;\n detailMessage =\n typeof detail === \"string\" && detail !== \"\"\n ? detail\n : \"If nothing changes, try the browser flow again.\";\n }\n\n if (!isLoading && isDismissed) {\n return null;\n }\n\n return (\n <div className=\"bg-background/90 pointer-events-auto fixed inset-0 z-[999999] flex items-center justify-center px-4 backdrop-blur-sm\">\n <div className=\"bg-background w-full max-w-sm rounded-2xl border p-6 shadow-2xl\">\n <div className=\"flex items-start gap-3\">\n <div className=\"text-muted-foreground mt-0.5\">\n {isLoading ? (\n <LoaderCircle className=\"size-5 animate-spin\" />\n ) : (\n <AlertCircle className=\"size-5 text-amber-600\" />\n )}\n </div>\n <div className=\"space-y-2\">\n <p className=\"font-medium\">{state.message}</p>\n <p className=\"text-muted-foreground text-sm\">{detailMessage}</p>\n {canCancel ? (\n <Button\n className=\"mt-2\"\n\n onClick={() => {\n startEventAction(async () => {\n try {\n await window.electronAPI?.cancelAuthFlow?.();\n } catch (error) {\n console.error(\n \"Failed to cancel Electron auth flow\",\n error\n );\n }\n });\n }}\n size=\"sm\"\n type=\"button\"\n variant=\"outline\"\n >\n Go back\n </Button>\n ) : null}\n {isLoading ? null : (\n <Button\n className=\"mt-2\"\n onClick={() => {\n setIsDismissed(true);\n }}\n size=\"sm\"\n type=\"button\"\n variant=\"outline\"\n >\n Dismiss\n </Button>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\n/**\n * Handles the electron auth redirect after OAuth completes in the browser.\n * When the user finishes OAuth, `ensureElectronRedirect` detects the\n * electron redirect cookie and sends the user back to the Electron app\n * via deep link.\n *\n * Mount this in the root layout so it runs on every page.\n *\n * @returns {ReactJSX.Element | null} The current overlay, or null outside the enabled desktop flow.\n */\nexport const ElectronAuthHandler = (): ReactJSX.Element | null => {\n const router = useRouter();\n const [authState, setAuthState] = useState<ElectronRendererAuthState>({\n message: null,\n status: \"idle\",\n });\n\n useEffect((): (() => void) | undefined => {\n const id = authClient.ensureElectronRedirect();\n\n return (): void => {\n clearInterval(id);\n };\n }, []);\n\n useEffect((): (() => void) | undefined => {\n if (typeof window.requestAuth !== \"function\") {\n return undefined;\n }\n\n if (\n typeof window.onAuthenticated !== \"function\" ||\n typeof window.onUserUpdated !== \"function\" ||\n typeof window.onAuthError !== \"function\" ||\n typeof window.electronAPI?.onAuthStateChanged !== \"function\"\n ) {\n return undefined;\n }\n\n const loadAuthState = async (): Promise<void> => {\n try {\n const state = await window.electronAPI?.getAuthState?.();\n if (state) {\n setAuthState(state);\n }\n } catch (error) {\n console.error(\"Failed to read Electron auth state\", error);\n }\n };\n void loadAuthState();\n\n const syncAndRefresh = async (): Promise<void> => {\n await window.electronAPI?.syncAuthSession?.();\n router.refresh();\n };\n const syncAuthenticatedSession = async (): Promise<void> => {\n try {\n await syncAndRefresh();\n } catch (error) {\n console.error(\n \"Failed to sync auth session after authentication\",\n error\n );\n }\n };\n const unsubscribeAuthenticated = window.onAuthenticated(() => {\n void syncAuthenticatedSession();\n });\n const syncUpdatedUser = async (): Promise<void> => {\n try {\n await syncAndRefresh();\n } catch (error) {\n console.error(\"Failed to sync auth session after user update\", error);\n }\n };\n const unsubscribeUserUpdated = window.onUserUpdated(() => {\n void syncUpdatedUser();\n });\n const unsubscribeAuthError = window.onAuthError(\n (ctx: Readonly<ElectronAuthErrorContext>) => {\n toast.error(nonEmptyText(ctx.message) ?? \"Authentication failed\");\n }\n );\n const unsubscribeAuthState = window.electronAPI.onAuthStateChanged(\n (state: Readonly<ElectronRendererAuthState>) => {\n setAuthState(state);\n }\n );\n\n return (): void => {\n unsubscribeAuthenticated();\n unsubscribeUserUpdated();\n unsubscribeAuthError();\n unsubscribeAuthState();\n };\n }, [router]);\n\n const overlayKey = `${authState.status}:${authState.message ?? \"\"}:${\n authState.status === \"idle\" ? \"\" : (authState.detail ?? \"\")\n }`;\n\n return <ElectronAuthOverlay key={overlayKey} state={authState} />;\n};\n",
|
|
27
|
+
"type": "registry:file",
|
|
28
|
+
"target": "~/chatjs/plugins/desktop/auth-handler.tsx"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "src/plugins/desktop/src/auth-server.ts",
|
|
32
|
+
"content": "import type { AuthenticationIntegration } from \"@/chatjs/core/authentication/contracts\";\nimport {\n ELECTRON_AUTH_CLIENT_ID,\n ELECTRON_AUTH_COOKIE_PREFIX,\n} from \"./protocol\";\nimport { ELECTRON_APP_SCHEME } from \"./electron-auth\";\nimport type { AuthContext } from \"better-auth\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { electron } from \"@better-auth/electron\";\n\nconst plugin = electron({\n clientID: ELECTRON_AUTH_CLIENT_ID,\n cookiePrefix: ELECTRON_AUTH_COOKIE_PREFIX,\n});\n\n// Better Auth matches custom trusted origins by prefix. Electron sends one\n// exact synthetic origin; validate it before the plugin promotes the header.\nconst electronAuthPlugin = {\n ...plugin,\n\n async onRequest(\n request: ReadonlyNativeSurface<Request>,\n\n context: AuthContext\n ): Promise<{ response: Response } | { request: Request } | undefined> {\n const origin = request.headers.get(\"origin\");\n const electronOrigin = request.headers.get(\"electron-origin\");\n const expectedOrigin = `${ELECTRON_APP_SCHEME}:/`;\n if (\n (electronOrigin !== null && electronOrigin !== expectedOrigin) ||\n ((origin ?? \"\").startsWith(`${ELECTRON_APP_SCHEME}:`) &&\n origin !== expectedOrigin)\n ) {\n return {\n response: new Response(\"Invalid Electron origin\", { status: 403 }),\n };\n }\n return await plugin.onRequest(request, context);\n },\n};\n\nconst desktopAuth = {\n plugins: [electronAuthPlugin],\n trustedOrigins: [`${ELECTRON_APP_SCHEME}:/`],\n isAuthRoute: (url) =>\n url.pathname === \"/device-login\" ||\n ((url.pathname === \"/login\" || url.pathname === \"/register\") &&\n url.searchParams.get(\"client_id\") === ELECTRON_AUTH_CLIENT_ID),\n} satisfies AuthenticationIntegration;\nexport { electronAuthPlugin };\n\nexport default desktopAuth;\n",
|
|
33
|
+
"type": "registry:file",
|
|
34
|
+
"target": "~/chatjs/plugins/desktop/auth-server.ts"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "src/plugins/desktop/src/auth-ui.tsx",
|
|
38
|
+
"content": "\"use client\";\n\nimport { ExternalLink, LoaderCircle } from \"lucide-react\";\nimport React, {\n useEffect,\n useMemo,\n useRef,\n useState,\n useTransition,\n} from \"react\";\n\nimport type { JSX as ReactJSX } from \"react\";\n\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\n\nimport type { Session } from \"@/lib/auth\";\n\nimport config from \"@/chat.config\";\n\nimport authClient from \"@/chatjs/plugins/desktop/desktop-auth-client\";\n\nimport { Button, buttonVariants } from \"@/components/ui/button\";\n\nimport { useRouter } from \"next/navigation\";\n\nconst AUTH_FEEDBACK_DELAY_MS = 300;\n\nconst ElectronBrowserSignIn = ({\n buttonLabel = \"Continue with browser\",\n}: {\n readonly buttonLabel?: string;\n}): ReactJSX.Element => {\n const [opened, setOpened] = useState(false);\n\n return (\n <div className=\"space-y-3\">\n <p className=\"text-muted-foreground text-center text-sm\">\n Sign-in opens in your browser. On macOS, {config.appName} may ask to use\n Keychain so it can store your session securely.\n </p>\n <Button\n className=\"w-full\"\n onClick={() => {\n const { requestAuth } = window;\n if (typeof requestAuth !== \"function\") {\n return;\n }\n const launchBrowserSignIn = async (): Promise<void> => {\n try {\n await Promise.resolve();\n await requestAuth();\n } catch (error) {\n console.error(\"Failed to launch browser sign-in\", error);\n }\n };\n void launchBrowserSignIn();\n globalThis.setTimeout(() => {\n setOpened(true);\n }, AUTH_FEEDBACK_DELAY_MS);\n }}\n type=\"button\"\n variant=\"outline\"\n >\n <ExternalLink className=\"mr-2 size-4\" />\n {buttonLabel}\n </Button>\n\n {opened ? (\n <p className=\"text-muted-foreground text-center text-sm\">\n Finish signing in through your browser. If macOS asks about Keychain\n access, allow it to keep your session saved securely.\n </p>\n ) : null}\n </div>\n );\n};\n\nconst ElectronTransferUser = ({\n query,\n session,\n}: {\n readonly query: Readonly<Record<string, string>>;\n readonly session: ReadonlyNativeSurface<Session>;\n}): ReactJSX.Element => {\n const [isPending, startTransition] = useTransition();\n const router = useRouter();\n const hasStartedTransferRef = useRef(false);\n const useAnotherAccountHref = useMemo(() => {\n const params = new URLSearchParams(query);\n params.delete(\"client_id\");\n params.delete(\"state\");\n params.delete(\"code_challenge\");\n params.delete(\"code_challenge_method\");\n\n const nextQuery = params.toString();\n if (nextQuery) {\n return `/login?${nextQuery}`;\n }\n return \"/login\";\n }, [query]);\n\n useEffect(() => {\n if (hasStartedTransferRef.current) {\n return;\n }\n hasStartedTransferRef.current = true;\n\n startTransition(async () => {\n await authClient.electron.transferUser({ fetchOptions: { query } });\n router.refresh();\n });\n }, [query, router]);\n\n return (\n <div className=\"space-y-4\">\n <div className=\"rounded-lg border px-4 py-3 text-sm\">\n <p className=\"font-medium\">{session.user.name || session.user.email}</p>\n <p className=\"text-muted-foreground\">{session.user.email}</p>\n </div>\n\n <Button\n className=\"w-full\"\n disabled={isPending}\n onClick={() => {\n startTransition(async () => {\n await authClient.electron.transferUser({ fetchOptions: { query } });\n router.refresh();\n });\n }}\n type=\"button\"\n >\n {isPending ? (\n <>\n <LoaderCircle className=\"mr-2 size-4 animate-spin\" />\n Connecting…\n </>\n ) : (\n \"Continue to desktop app\"\n )}\n </Button>\n\n <a\n className={buttonVariants({ className: \"w-full\", variant: \"ghost\" })}\n href={useAnotherAccountHref}\n >\n Use another account\n </a>\n </div>\n );\n};\nexport { ElectronBrowserSignIn, ElectronTransferUser };\n",
|
|
39
|
+
"type": "registry:file",
|
|
40
|
+
"target": "~/chatjs/plugins/desktop/auth-ui.tsx"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"path": "src/plugins/desktop/src/bridge.ts",
|
|
44
|
+
"content": "// Types exposed by the Electron companion preload bridge.\nexport interface ElectronAuthErrorContext {\n message?: string;\n path?: string;\n status?: number;\n statusText?: string;\n}\n\nexport type ElectronRendererAuthState =\n | {\n status: \"idle\";\n message: null;\n }\n | {\n status: \"awaiting-browser\" | \"finishing\" | \"timed-out\" | \"error\";\n message: string;\n detail?: string | null;\n };\n\ndeclare global {\n interface Window {\n electronAPI?: {\n cancelAuthFlow?: () => Promise<void>;\n getAuthState?: () => Promise<ElectronRendererAuthState>;\n isElectron: boolean;\n onAuthStateChanged?: (\n callback: (state: Readonly<ElectronRendererAuthState>) => void\n ) => () => void;\n platform: string;\n syncAuthSession?: () => Promise<void>;\n };\n onAuthError?: (\n callback: (context: Readonly<ElectronAuthErrorContext>) => void\n ) => () => void;\n onAuthenticated?: (callback: (user: unknown) => void) => () => void;\n onUserUpdated?: (callback: (user: unknown) => void) => () => void;\n requestAuth?: (options?: {\n readonly provider?: string;\n }) => Promise<void> | void;\n signOut?: () => Promise<void>;\n }\n}\n\nexport const isElectronRenderer = (): boolean =>\n typeof window !== \"undefined\" && typeof window.requestAuth === \"function\";\n",
|
|
45
|
+
"type": "registry:file",
|
|
46
|
+
"target": "~/chatjs/plugins/desktop/bridge.ts"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"path": "src/plugins/desktop/src/layout-ui.ts",
|
|
50
|
+
"content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { LayoutEffects } from \"@/components/layout-slots\";\nimport { ElectronAuthHandler } from \"./auth-handler\";\n\nexport const layoutUi = definePlugin({\n id: \"desktop\",\n slots: [slot(LayoutEffects, ElectronAuthHandler)],\n});\n",
|
|
51
|
+
"type": "registry:file",
|
|
52
|
+
"target": "~/chatjs/plugins/desktop/layout-ui.ts"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"path": "src/plugins/desktop/src/navigation.ts",
|
|
56
|
+
"content": "import { isElectronRenderer } from \"./bridge\";\n\nconst desktopNavigation = (): boolean => isElectronRenderer();\n\nexport default desktopNavigation;\n",
|
|
57
|
+
"type": "registry:file",
|
|
58
|
+
"target": "~/chatjs/plugins/desktop/navigation.ts"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"path": "src/plugins/desktop/src/protocol.ts",
|
|
62
|
+
"content": "export const ELECTRON_AUTH_CLIENT_ID = \"electron\";\n\nexport const ELECTRON_AUTH_COOKIE_PREFIX = \"better-auth\";\n\nexport const ELECTRON_AUTH_CALLBACK_PATH = \"/auth/callback\";\n",
|
|
63
|
+
"type": "registry:file",
|
|
64
|
+
"target": "~/chatjs/plugins/desktop/protocol.ts"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"path": "src/plugins/desktop/src/device-login-page.tsx",
|
|
68
|
+
"content": "\"use client\";\n\nimport { CheckCircle2, LoaderCircle } from \"lucide-react\";\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { usePathname, useSearchParams } from \"next/navigation\";\n\nimport Link from \"next/link\";\n\nimport { Button, buttonVariants } from \"@/components/ui/button\";\n\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\n\nimport type { JSX as ReactJSX } from \"react\";\n\nimport authClient from \"@/chatjs/plugins/desktop/desktop-auth-client\";\nimport { config } from \"@/lib/config\";\nimport { isElectronTransferQuery } from \"@/chatjs/plugins/desktop/electron-auth\";\n\ntype DeviceLoginState = \"checking-session\" | \"transferring\" | \"waiting-for-app\";\n\nconst DEVICE_LOGIN_COMPLETED_PARAM = \"done\";\n\nconst DeviceAuthScreen = ({\n state,\n onRetry,\n}: {\n readonly state: \"checking-session\" | \"transferring\" | \"waiting-for-app\";\n readonly onRetry: () => void;\n}): React.JSX.Element => {\n const isLoading = state === \"checking-session\" || state === \"transferring\";\n let title = \"You're signed in\";\n\n if (isLoading) {\n title =\n state === \"checking-session\"\n ? \"Checking your session...\"\n : \"Opening the desktop app...\";\n }\n\n return (\n <div className=\"bg-background flex min-h-dvh w-screen items-center justify-center\">\n <div className=\"w-full max-w-sm px-6\">\n <Card>\n <CardHeader className=\"text-center\">\n <div className=\"mb-2 flex justify-center\">\n {isLoading ? (\n <LoaderCircle className=\"text-muted-foreground size-8 animate-spin\" />\n ) : (\n <div className=\"bg-foreground text-background inline-flex h-14 w-14 items-center justify-center rounded-2xl\">\n <CheckCircle2 className=\"size-7\" />\n </div>\n )}\n </div>\n <CardTitle className=\"text-xl\">{title}</CardTitle>\n {!isLoading && (\n <CardDescription>\n You can close this tab and return to {config.appName}.\n </CardDescription>\n )}\n </CardHeader>\n {!isLoading && (\n <CardContent className=\"text-center\">\n <div className=\"mb-4\">\n <Link\n className={buttonVariants({\n className: \"w-full\",\n variant: \"outline\",\n })}\n href=\"/\"\n >\n Continue on web\n </Link>\n </div>\n <p className=\"text-muted-foreground/60 text-xs\">\n Didn't open?{\" \"}\n <Button\n className=\"text-muted-foreground/60 hover:text-muted-foreground h-auto p-0 text-xs underline underline-offset-2 hover:no-underline\"\n onClick={onRetry}\n type=\"button\"\n variant=\"link\"\n >\n Try again\n </Button>\n </p>\n </CardContent>\n )}\n </Card>\n </div>\n </div>\n );\n};\n\nexport const DeviceLoginPage = (): ReactJSX.Element => {\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const [state, setState] = useState<DeviceLoginState>(\"checking-session\");\n const transferStartedRef = useRef(false);\n\n const query = useMemo(\n () => Object.fromEntries(searchParams.entries()),\n [searchParams]\n );\n const isCompletedView =\n searchParams.get(DEVICE_LOGIN_COMPLETED_PARAM) === \"1\";\n const shouldWaitForApp = isCompletedView || !isElectronTransferQuery(query);\n const displayState =\n shouldWaitForApp && state === \"checking-session\"\n ? \"waiting-for-app\"\n : state;\n\n useEffect((): (() => void) | undefined => {\n if (shouldWaitForApp) {\n return undefined;\n }\n\n let cancelled = false;\n\n const checkSession = async (): Promise<void> => {\n const { data: session } = await authClient.getSession();\n\n if (cancelled || transferStartedRef.current) {\n return;\n }\n\n if (!session?.user) {\n setState(\"waiting-for-app\");\n return;\n }\n\n transferStartedRef.current = true;\n setState(\"transferring\");\n\n await authClient.electron.transferUser({\n fetchOptions: {\n onError: () => {\n transferStartedRef.current = false;\n setState(\"waiting-for-app\");\n },\n onSuccess: () => {\n globalThis.history.replaceState(\n {},\n \"\",\n `${pathname}?${DEVICE_LOGIN_COMPLETED_PARAM}=1`\n );\n setState(\"waiting-for-app\");\n },\n query,\n },\n });\n };\n const sessionCheck = checkSession();\n void (async (): Promise<void> => {\n try {\n await sessionCheck;\n } catch {\n if (cancelled) {\n return;\n }\n\n transferStartedRef.current = false;\n setState(\"waiting-for-app\");\n }\n })();\n\n return (): void => {\n cancelled = true;\n };\n }, [pathname, query, shouldWaitForApp]);\n\n return (\n <DeviceAuthScreen\n onRetry={() => {\n transferStartedRef.current = false;\n setState(\"transferring\");\n const transfer = authClient.electron.transferUser({\n fetchOptions: {\n onError: () => {\n transferStartedRef.current = false;\n setState(\"waiting-for-app\");\n },\n onSuccess: () => {\n globalThis.history.replaceState(\n {},\n \"\",\n `${pathname}?${DEVICE_LOGIN_COMPLETED_PARAM}=1`\n );\n setState(\"waiting-for-app\");\n },\n query,\n },\n });\n void (async (): Promise<void> => {\n try {\n await transfer;\n } catch {\n transferStartedRef.current = false;\n setState(\"waiting-for-app\");\n }\n })();\n }}\n state={displayState}\n />\n );\n};\n",
|
|
69
|
+
"type": "registry:file",
|
|
70
|
+
"target": "~/chatjs/plugins/desktop/device-login-page.tsx"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"path": "src/plugins/desktop/src/device-login-route.tsx",
|
|
74
|
+
"content": "import type { Metadata } from \"next\";\nimport { headers } from \"next/headers\";\nimport { redirect } from \"next/navigation\";\nimport React, { Suspense } from \"react\";\n\nimport { AuthCardSkeleton } from \"@/components/auth-card-skeleton\";\nimport { DeviceLoginPage } from \"@/chatjs/plugins/desktop/device-login-page\";\nimport { auth } from \"@/lib/auth\";\nimport { toSearchParamRecord } from \"@/chatjs/plugins/desktop/electron-auth\";\n\nconst metadata: Metadata = {\n description: \"Sign in for the desktop app\",\n title: \"Device Login\",\n};\n\nconst DeviceLoginFallback = (): React.JSX.Element => (\n <div className=\"container mx-auto flex h-dvh w-screen items-center justify-center px-4\">\n <AuthCardSkeleton\n cardClassName=\"w-full max-w-md\"\n description=\"Connecting your desktop app\"\n title=\"Device login\"\n variant=\"device\"\n />\n </div>\n);\n\nconst DeviceLoginContent = async ({\n searchParams,\n}: {\n readonly searchParams: Readonly<\n Promise<Readonly<Record<string, string | readonly string[] | undefined>>>\n >;\n}): Promise<React.JSX.Element> => {\n const resolvedSearchParams = await searchParams;\n const query = toSearchParamRecord(resolvedSearchParams);\n const isCompletedView = query.done === \"1\";\n const queryString = new URLSearchParams(query).toString();\n const currentHref = queryString\n ? `/device-login?${queryString}`\n : \"/device-login\";\n const session = await auth.api.getSession({ headers: await headers() });\n\n if (!(session?.user || isCompletedView)) {\n redirect(`/login?returnTo=${encodeURIComponent(currentHref)}`);\n }\n\n return (\n <Suspense fallback={<DeviceLoginFallback />}>\n <DeviceLoginPage />\n </Suspense>\n );\n};\n\nconst DeviceLoginRoute = ({\n searchParams,\n}: {\n readonly searchParams: Readonly<\n Promise<Readonly<Record<string, string | readonly string[] | undefined>>>\n >;\n}): React.JSX.Element => (\n <Suspense fallback={<DeviceLoginFallback />}>\n <DeviceLoginContent searchParams={searchParams} />\n </Suspense>\n);\n\nexport { metadata };\nexport default DeviceLoginRoute;\n",
|
|
75
|
+
"type": "registry:file",
|
|
76
|
+
"target": "~/chatjs/plugins/desktop/device-login-route.tsx"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"path": "src/plugins/desktop/src/electron-auth.ts",
|
|
80
|
+
"content": "import type { SocialAuthSignInOptions } from \"@/lib/social-auth\";\nimport { config } from \"@/lib/config\";\n\nimport { ELECTRON_AUTH_CLIENT_ID } from \"./protocol\";\n\nconst ELECTRON_APP_SCHEME = config.appPrefix;\n\n// @better-auth/electron sends this synthetic Origin for the current protocol.\nconst ELECTRON_TRUSTED_ORIGINS = [`${ELECTRON_APP_SCHEME}:/`] as const;\n\ntype SearchParamValue = string | readonly string[] | undefined;\n\nconst toSearchParamRecord = (\n searchParams: Readonly<Record<string, SearchParamValue>>\n): Record<string, string> => {\n const query: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(searchParams)) {\n if (typeof value === \"string\") {\n query[key] = value;\n } else if (typeof value === \"object\") {\n const [firstValue] = value;\n if (typeof firstValue === \"string\" && firstValue !== \"\") {\n query[key] = firstValue;\n }\n }\n }\n\n return query;\n};\n\nconst isElectronTransferQuery = (\n query: Readonly<Record<string, string>>\n): boolean => query.client_id === ELECTRON_AUTH_CLIENT_ID;\n\nconst buildSocialAuthRequest = (\n query: Readonly<Record<string, string>>,\n origin?: string\n): {\n callbackURL?: string;\n onRedirectToUrl?: (url: string) => void;\n signInOptions?: SocialAuthSignInOptions;\n} => {\n const isElectronTransfer = isElectronTransferQuery(query);\n const deviceLoginCallbackURL =\n typeof origin === \"string\" && origin !== \"\"\n ? new URL(\"/device-login\", origin).toString()\n : \"/device-login\";\n\n if (isElectronTransfer) {\n return {\n callbackURL: deviceLoginCallbackURL,\n onRedirectToUrl: (url: string): void => {\n const { location } = globalThis;\n if (typeof location === \"object\" && location !== null) {\n location.assign(url);\n }\n },\n signInOptions: {\n disableRedirect: true,\n errorCallbackURL: deviceLoginCallbackURL,\n newUserCallbackURL: deviceLoginCallbackURL,\n },\n };\n }\n\n return {\n callbackURL: query.returnTo,\n };\n};\n\nexport {\n ELECTRON_APP_SCHEME,\n ELECTRON_TRUSTED_ORIGINS,\n toSearchParamRecord,\n isElectronTransferQuery,\n buildSocialAuthRequest,\n};\n",
|
|
81
|
+
"type": "registry:file",
|
|
82
|
+
"target": "~/chatjs/plugins/desktop/electron-auth.ts"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"path": "src/plugins/desktop/src/sign-out.ts",
|
|
86
|
+
"content": "import { isElectronRenderer } from \"./bridge\";\n\nconst signOutDesktop = async (): Promise<boolean> => {\n if (!isElectronRenderer()) {\n return false;\n }\n if (typeof window.signOut !== \"function\") {\n throw new TypeError(\"Desktop sign-out is unavailable.\");\n }\n await window.signOut();\n try {\n await window.electronAPI?.syncAuthSession?.();\n } catch (error) {\n // A refresh failure cannot undo a completed native sign-out.\n console.error(\"Failed to refresh the signed-out desktop session\", error);\n }\n return true;\n};\n\nexport default signOutDesktop;\n",
|
|
87
|
+
"type": "registry:file",
|
|
88
|
+
"target": "~/chatjs/plugins/desktop/sign-out.ts"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"path": "src/plugins/desktop/adapters/app/(auth)/device-login/page.tsx",
|
|
92
|
+
"content": "// ChatJS source: desktop. Ownership: chatjs/plugins/desktop/plugin.json.\nexport { default, metadata } from \"@/chatjs/plugins/desktop/device-login-route\";\n",
|
|
93
|
+
"type": "registry:file",
|
|
94
|
+
"target": "~/app/(auth)/device-login/page.tsx"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"path": "dist/source/desktop.json",
|
|
98
|
+
"content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"radix\",\n \"id\": \"desktop\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/desktop/desktop-auth-client.ts\",\n \"chatjs/plugins/desktop/auth-form.tsx\",\n \"chatjs/plugins/desktop/auth-handler.tsx\",\n \"chatjs/plugins/desktop/auth-server.ts\",\n \"chatjs/plugins/desktop/auth-ui.tsx\",\n \"chatjs/plugins/desktop/bridge.ts\",\n \"chatjs/plugins/desktop/layout-ui.ts\",\n \"chatjs/plugins/desktop/navigation.ts\",\n \"chatjs/plugins/desktop/protocol.ts\",\n \"chatjs/plugins/desktop/device-login-page.tsx\",\n \"chatjs/plugins/desktop/device-login-route.tsx\",\n \"chatjs/plugins/desktop/electron-auth.ts\",\n \"chatjs/plugins/desktop/sign-out.ts\",\n \"app/(auth)/device-login/page.tsx\"\n ]\n}\n",
|
|
99
|
+
"type": "registry:file",
|
|
100
|
+
"target": "~/chatjs/plugins/desktop/plugin.json"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"meta": {
|
|
104
|
+
"icon": "setup/electron",
|
|
105
|
+
"chatjs": {
|
|
106
|
+
"contractVersion": 3,
|
|
107
|
+
"uiBase": "radix",
|
|
108
|
+
"id": "desktop",
|
|
109
|
+
"kind": "plugin",
|
|
110
|
+
"files": [
|
|
111
|
+
"chatjs/plugins/desktop/desktop-auth-client.ts",
|
|
112
|
+
"chatjs/plugins/desktop/auth-form.tsx",
|
|
113
|
+
"chatjs/plugins/desktop/auth-handler.tsx",
|
|
114
|
+
"chatjs/plugins/desktop/auth-server.ts",
|
|
115
|
+
"chatjs/plugins/desktop/auth-ui.tsx",
|
|
116
|
+
"chatjs/plugins/desktop/bridge.ts",
|
|
117
|
+
"chatjs/plugins/desktop/layout-ui.ts",
|
|
118
|
+
"chatjs/plugins/desktop/navigation.ts",
|
|
119
|
+
"chatjs/plugins/desktop/protocol.ts",
|
|
120
|
+
"chatjs/plugins/desktop/device-login-page.tsx",
|
|
121
|
+
"chatjs/plugins/desktop/device-login-route.tsx",
|
|
122
|
+
"chatjs/plugins/desktop/electron-auth.ts",
|
|
123
|
+
"chatjs/plugins/desktop/sign-out.ts",
|
|
124
|
+
"app/(auth)/device-login/page.tsx"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"type": "registry:item"
|
|
129
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "digitalocean-spaces-storage",
|
|
4
|
+
"title": "DigitalOcean Spaces",
|
|
5
|
+
"description": "DigitalOcean Spaces via the S3-compatible API. Endpoint derived from the region, virtual-hosted addressing.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@aws-sdk/client-s3@^3.1079.0",
|
|
9
|
+
"@aws-sdk/s3-presigned-post@^3.700.0",
|
|
10
|
+
"@aws-sdk/s3-request-presigner@^3.700.0"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/storage/digitalocean-spaces/storage-provider.ts",
|
|
15
|
+
"content": "export { digitaloceanSpaces as createStorageAdapter } from \"files-sdk/digitalocean-spaces\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket",
|
|
24
|
+
"region"
|
|
25
|
+
],
|
|
26
|
+
"configFields": [
|
|
27
|
+
{
|
|
28
|
+
"key": "bucket",
|
|
29
|
+
"label": "bucket",
|
|
30
|
+
"type": "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"key": "region",
|
|
34
|
+
"label": "region",
|
|
35
|
+
"type": "text"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"contractVersion": 1,
|
|
39
|
+
"envRequirements": [
|
|
40
|
+
{
|
|
41
|
+
"description": "DigitalOcean Spaces credentials",
|
|
42
|
+
"options": [
|
|
43
|
+
[
|
|
44
|
+
"DO_SPACES_KEY",
|
|
45
|
+
"DO_SPACES_SECRET"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"id": "digitalocean-spaces",
|
|
51
|
+
"kind": "storage",
|
|
52
|
+
"optionalEnv": []
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"type": "registry:item"
|
|
56
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "docker-sandbox",
|
|
4
|
+
"title": "Docker",
|
|
5
|
+
"description": "Containers on a reachable Docker host, with native Python and Node processes.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "src/sandboxes/docker/sandbox.ts",
|
|
12
|
+
"content": "import { defineSandbox } from \"eve/sandbox\";\nimport { DockerSandbox } from \"eve/sandbox/docker\";\n\nexport const environment = DockerSandbox.environment();\nexport default defineSandbox(async () => await environment.open());\n",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"target": "~/agent/sandbox.ts"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"meta": {
|
|
18
|
+
"chatjs": {
|
|
19
|
+
"contractVersion": 1,
|
|
20
|
+
"kind": "sandbox",
|
|
21
|
+
"id": "docker",
|
|
22
|
+
"capabilities": {
|
|
23
|
+
"persistent": true,
|
|
24
|
+
"runtimes": [
|
|
25
|
+
"python",
|
|
26
|
+
"javascript"
|
|
27
|
+
],
|
|
28
|
+
"cleanup": "eve-session",
|
|
29
|
+
"cancellation": "eve"
|
|
30
|
+
},
|
|
31
|
+
"envRequirements": []
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"type": "registry:item"
|
|
35
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "dropbox-storage",
|
|
4
|
+
"title": "Dropbox",
|
|
5
|
+
"description": "Dropbox via the official SDK. Path-addressable, virtual keys map directly to Dropbox paths - no cache.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"dropbox@^10.34.0"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/storage/dropbox/storage-provider.ts",
|
|
13
|
+
"content": "export { dropbox as createStorageAdapter } from \"files-sdk/dropbox\";\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"chatjs": {
|
|
20
|
+
"configKeys": [],
|
|
21
|
+
"configFields": [],
|
|
22
|
+
"contractVersion": 1,
|
|
23
|
+
"envRequirements": [
|
|
24
|
+
{
|
|
25
|
+
"description": "Dropbox credentials",
|
|
26
|
+
"options": [
|
|
27
|
+
[
|
|
28
|
+
"DROPBOX_ACCESS_TOKEN"
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"DROPBOX_REFRESH_TOKEN",
|
|
32
|
+
"DROPBOX_APP_KEY",
|
|
33
|
+
"DROPBOX_APP_SECRET"
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"id": "dropbox",
|
|
39
|
+
"kind": "storage",
|
|
40
|
+
"optionalEnv": []
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"type": "registry:item"
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "exoscale-storage",
|
|
4
|
+
"title": "Exoscale Object Storage",
|
|
5
|
+
"description": "Exoscale Object Storage (SOS) via the S3-compatible API. Endpoint derived from the zone code (ch-gva-2, de-fra-1, ...).",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@aws-sdk/client-s3@^3.1079.0",
|
|
9
|
+
"@aws-sdk/s3-presigned-post@^3.700.0",
|
|
10
|
+
"@aws-sdk/s3-request-presigner@^3.700.0"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/storage/exoscale/storage-provider.ts",
|
|
15
|
+
"content": "export { exoscale as createStorageAdapter } from \"files-sdk/exoscale\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket",
|
|
24
|
+
"region"
|
|
25
|
+
],
|
|
26
|
+
"configFields": [
|
|
27
|
+
{
|
|
28
|
+
"key": "bucket",
|
|
29
|
+
"label": "bucket",
|
|
30
|
+
"type": "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"key": "region",
|
|
34
|
+
"label": "region",
|
|
35
|
+
"type": "text"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"contractVersion": 1,
|
|
39
|
+
"envRequirements": [
|
|
40
|
+
{
|
|
41
|
+
"description": "Exoscale Object Storage credentials",
|
|
42
|
+
"options": [
|
|
43
|
+
[
|
|
44
|
+
"EXOSCALE_API_KEY",
|
|
45
|
+
"EXOSCALE_API_SECRET"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"id": "exoscale",
|
|
51
|
+
"kind": "storage",
|
|
52
|
+
"optionalEnv": []
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"type": "registry:item"
|
|
56
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "feedback",
|
|
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
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
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",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/plugins/feedback/chat-server.ts"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
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",
|
|
22
|
+
"type": "registry:file",
|
|
23
|
+
"target": "~/chatjs/plugins/feedback/chat-ui.ts"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"path": "src/plugins/feedback/src/feedback-actions.tsx",
|
|
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",
|
|
28
|
+
"type": "registry:file",
|
|
29
|
+
"target": "~/chatjs/plugins/feedback/feedback-actions.tsx"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "src/plugins/feedback/src/message-vote-actions.tsx",
|
|
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
|
+
"type": "registry:file",
|
|
35
|
+
"target": "~/chatjs/plugins/feedback/message-vote-actions.tsx"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"path": "src/plugins/feedback/src/feedback-queries.ts",
|
|
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",
|
|
40
|
+
"type": "registry:file",
|
|
41
|
+
"target": "~/chatjs/plugins/feedback/feedback-queries.ts"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"path": "src/plugins/feedback/src/router.ts",
|
|
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",
|
|
46
|
+
"type": "registry:file",
|
|
47
|
+
"target": "~/chatjs/plugins/feedback/router.ts"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"path": "src/plugins/feedback/src/feedback-schema.ts",
|
|
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",
|
|
52
|
+
"type": "registry:file",
|
|
53
|
+
"target": "~/chatjs/plugins/feedback/feedback-schema.ts"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"path": "src/plugins/feedback/src/vote-message.ts",
|
|
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",
|
|
58
|
+
"type": "registry:file",
|
|
59
|
+
"target": "~/chatjs/plugins/feedback/vote-message.ts"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"path": "dist/source/feedback.json",
|
|
63
|
+
"content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"radix\",\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\": [\n \"chatjs/plugins/feedback/feedback-schema.ts\"\n ]\n}\n",
|
|
64
|
+
"type": "registry:file",
|
|
65
|
+
"target": "~/chatjs/plugins/feedback/plugin.json"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"meta": {
|
|
69
|
+
"chatjs": {
|
|
70
|
+
"contractVersion": 3,
|
|
71
|
+
"uiBase": "radix",
|
|
72
|
+
"id": "feedback",
|
|
73
|
+
"kind": "plugin",
|
|
74
|
+
"files": [
|
|
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"
|
|
83
|
+
],
|
|
84
|
+
"databaseSchemas": [
|
|
85
|
+
"chatjs/plugins/feedback/feedback-schema.ts"
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"type": "registry:item"
|
|
90
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "filebase-storage",
|
|
4
|
+
"title": "Filebase",
|
|
5
|
+
"description": "Filebase via the S3-compatible API. Fronts decentralized networks (IPFS, Sia, Storj) chosen per-bucket.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@aws-sdk/client-s3@^3.1079.0",
|
|
9
|
+
"@aws-sdk/s3-presigned-post@^3.700.0",
|
|
10
|
+
"@aws-sdk/s3-request-presigner@^3.700.0"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/storage/filebase/storage-provider.ts",
|
|
15
|
+
"content": "export { filebase as createStorageAdapter } from \"files-sdk/filebase\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket"
|
|
24
|
+
],
|
|
25
|
+
"configFields": [
|
|
26
|
+
{
|
|
27
|
+
"key": "bucket",
|
|
28
|
+
"label": "bucket",
|
|
29
|
+
"type": "text"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"contractVersion": 1,
|
|
33
|
+
"envRequirements": [
|
|
34
|
+
{
|
|
35
|
+
"description": "Filebase credentials",
|
|
36
|
+
"options": [
|
|
37
|
+
[
|
|
38
|
+
"FILEBASE_ACCESS_KEY_ID",
|
|
39
|
+
"FILEBASE_SECRET_ACCESS_KEY"
|
|
40
|
+
]
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"id": "filebase",
|
|
45
|
+
"kind": "storage",
|
|
46
|
+
"optionalEnv": []
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"type": "registry:item"
|
|
50
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "firebase-storage-storage",
|
|
4
|
+
"title": "Firebase Storage",
|
|
5
|
+
"description": "Firebase Cloud Storage via the official firebase-admin SDK. Underlying client is @google-cloud/storage, so V4 signed URLs and POST policy uploads come for free.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"firebase-admin@^14.1.0"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/storage/firebase-storage/storage-provider.ts",
|
|
13
|
+
"content": "export { firebaseStorage as createStorageAdapter } from \"files-sdk/firebase-storage\";\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"chatjs": {
|
|
20
|
+
"configKeys": [],
|
|
21
|
+
"configFields": [],
|
|
22
|
+
"contractVersion": 1,
|
|
23
|
+
"envRequirements": [
|
|
24
|
+
{
|
|
25
|
+
"description": "Firebase Storage configuration",
|
|
26
|
+
"options": [
|
|
27
|
+
[
|
|
28
|
+
"FIREBASE_STORAGE_BUCKET"
|
|
29
|
+
]
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"description": "Firebase Storage credentials",
|
|
34
|
+
"options": [
|
|
35
|
+
[
|
|
36
|
+
"GOOGLE_APPLICATION_CREDENTIALS"
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"FIREBASE_CLIENT_EMAIL",
|
|
40
|
+
"FIREBASE_PRIVATE_KEY"
|
|
41
|
+
]
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"id": "firebase-storage",
|
|
46
|
+
"kind": "storage",
|
|
47
|
+
"optionalEnv": [
|
|
48
|
+
"FIREBASE_PROJECT_ID"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"type": "registry:item"
|
|
53
|
+
}
|