@chat-js/registry 0.2.0-beta.7 → 0.2.0-beta.9
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 +4 -4
- package/dist/r/ai-titles.json +10 -13
- package/dist/r/attach-workspace-file.json +2 -2
- package/dist/r/attachment-uploads.json +13 -22
- package/dist/r/base/ai-titles.json +10 -13
- package/dist/r/base/attach-workspace-file.json +2 -2
- package/dist/r/base/attachment-uploads.json +13 -22
- package/dist/r/base/credits.json +11 -33
- package/dist/r/base/deep-research.json +0 -4
- package/dist/r/base/desktop.json +14 -30
- package/dist/r/base/feedback.json +18 -40
- package/dist/r/base/followup-suggestions.json +18 -40
- package/dist/r/base/guest-chat.json +20 -35
- package/dist/r/base/image-viewer.json +9 -15
- package/dist/r/base/mcp.json +24 -47
- package/dist/r/base/memory-storage.json +2 -2
- package/dist/r/base/model-preferences.json +16 -37
- package/dist/r/base/projects.json +23 -45
- package/dist/r/base/registry.json +138 -370
- package/dist/r/base/search.json +21 -43
- package/dist/r/base/sharing.json +18 -40
- package/dist/r/base/spreadsheet-viewer.json +9 -15
- package/dist/r/base/vercel-gateway.json +2 -1
- package/dist/r/base/video-viewer.json +9 -15
- package/dist/r/credits.json +11 -33
- package/dist/r/deep-research.json +0 -4
- package/dist/r/desktop.json +14 -30
- package/dist/r/feedback.json +18 -40
- package/dist/r/followup-suggestions.json +18 -40
- package/dist/r/guest-chat.json +20 -35
- package/dist/r/image-viewer.json +9 -15
- package/dist/r/mcp.json +24 -47
- package/dist/r/memory-storage.json +2 -2
- package/dist/r/model-preferences.json +16 -37
- package/dist/r/projects.json +23 -45
- package/dist/r/radix/ai-titles.json +10 -13
- package/dist/r/radix/attach-workspace-file.json +2 -2
- package/dist/r/radix/attachment-uploads.json +13 -22
- package/dist/r/radix/credits.json +11 -33
- package/dist/r/radix/deep-research.json +0 -4
- package/dist/r/radix/desktop.json +14 -30
- package/dist/r/radix/feedback.json +18 -40
- package/dist/r/radix/followup-suggestions.json +18 -40
- package/dist/r/radix/guest-chat.json +20 -35
- package/dist/r/radix/image-viewer.json +9 -15
- package/dist/r/radix/mcp.json +24 -47
- package/dist/r/radix/memory-storage.json +2 -2
- package/dist/r/radix/model-preferences.json +16 -37
- package/dist/r/radix/projects.json +23 -45
- package/dist/r/radix/registry.json +138 -370
- package/dist/r/radix/search.json +21 -43
- package/dist/r/radix/sharing.json +18 -40
- package/dist/r/radix/spreadsheet-viewer.json +9 -15
- package/dist/r/radix/vercel-gateway.json +2 -1
- package/dist/r/radix/video-viewer.json +9 -15
- package/dist/r/registry.json +138 -370
- package/dist/r/search.json +21 -43
- package/dist/r/sharing.json +18 -40
- package/dist/r/spreadsheet-viewer.json +9 -15
- package/dist/r/vercel-gateway.json +2 -1
- package/dist/r/video-viewer.json +9 -15
- package/package.json +1 -1
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"path": "src/plugins/credits/src/billing.ts",
|
|
19
|
-
"content": "import { eq, sql } from \"drizzle-orm\";\nimport type { UsageBilling } from \"@/chatjs/core/billing/contracts\";\nimport { getBalanceCents } from \"./credits-queries\";\nimport { userCredit } from \"./credits-schema\";\n\n/** Core supplies its usage transaction, with the registered owner already locked. */\
|
|
19
|
+
"content": "import { eq, sql } from \"drizzle-orm\";\nimport type { UsageBilling } from \"@/chatjs/core/billing/contracts\";\nimport { getBalanceCents } from \"./credits-queries\";\nimport { userCredit } from \"./credits-schema\";\n\n/** Core supplies its usage transaction, with the registered owner already locked. */\nconst creditsBilling = {\n canSpend: async (ownerId) => (await getBalanceCents(ownerId)) > 0,\n debit: async (tx, { ownerId, cents }) => {\n await tx\n .insert(userCredit)\n .values({ userId: ownerId })\n .onConflictDoNothing();\n await tx\n .update(userCredit)\n .set({ balanceCents: sql`${userCredit.balanceCents} - ${cents}` })\n .where(eq(userCredit.userId, ownerId));\n },\n} satisfies UsageBilling;\n\nexport default creditsBilling;\n",
|
|
20
20
|
"type": "registry:file",
|
|
21
21
|
"target": "~/chatjs/plugins/credits/billing.ts"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
"path": "src/plugins/credits/src/
|
|
25
|
-
"content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { AccountSummary } from \"@/components/chat-slots\";\nimport { CreditBalance } from \"./balance\";\n\nexport const
|
|
24
|
+
"path": "src/plugins/credits/src/chat-ui.ts",
|
|
25
|
+
"content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { AccountSummary } from \"@/components/chat-slots\";\nimport { CreditBalance } from \"./balance\";\n\nexport const chatUi = definePlugin({\n id: \"credits\",\n slots: [slot(AccountSummary, CreditBalance)],\n});\n",
|
|
26
26
|
"type": "registry:file",
|
|
27
|
-
"target": "~/chatjs/plugins/credits/
|
|
27
|
+
"target": "~/chatjs/plugins/credits/chat-ui.ts"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"path": "src/plugins/credits/src/credits-queries.ts",
|
|
@@ -40,16 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"path": "src/plugins/credits/src/router.ts",
|
|
43
|
-
"content": "import { getBalanceCents } from \"./credits-queries\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\n\
|
|
43
|
+
"content": "import { getBalanceCents } from \"./credits-queries\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\n\nconst creditsProcedures = {\n getAvailableCredits: protectedProcedure.query(\n async ({\n ctx,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n }) => {\n const balanceCents = await getBalanceCents(ctx.user.id);\n return { balanceCents };\n }\n ),\n};\n\nexport const router = createTRPCRouter({ credits: creditsProcedures });\n",
|
|
44
44
|
"type": "registry:file",
|
|
45
45
|
"target": "~/chatjs/plugins/credits/router.ts"
|
|
46
46
|
},
|
|
47
|
-
{
|
|
48
|
-
"path": "src/plugins/credits/src/server-plugin.ts",
|
|
49
|
-
"content": "import type { ChatPlugin } from \"@/chatjs/core/installation/plugin\";\nimport { creditsRouter } from \"./router\";\n\nexport const credits = () =>\n ({ id: \"credits\", routers: { credits: creditsRouter } }) satisfies ChatPlugin;\n",
|
|
50
|
-
"type": "registry:file",
|
|
51
|
-
"target": "~/chatjs/plugins/credits/server-plugin.ts"
|
|
52
|
-
},
|
|
53
47
|
{
|
|
54
48
|
"path": "src/plugins/credits/src/use-credits.ts",
|
|
55
49
|
"content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport { useSession } from \"@/providers/session-provider\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const useGetCredits = (): {\n balanceCents: number | undefined;\n isError: boolean;\n} => {\n const { data: session } = useSession();\n const isAuthenticated = Boolean(session?.user);\n const trpc = useTRPC();\n\n const { data: creditsData, isError } = useQuery({\n ...trpc.credits.getAvailableCredits.queryOptions(),\n enabled: isAuthenticated,\n meta: { refreshOnTurnEnd: true },\n });\n\n return {\n balanceCents: creditsData?.balanceCents,\n isError,\n };\n};\n",
|
|
@@ -58,45 +52,29 @@
|
|
|
58
52
|
},
|
|
59
53
|
{
|
|
60
54
|
"path": "dist/source/credits.json",
|
|
61
|
-
"content": "{\n \"id\": \"credits\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/credits/balance.tsx\",\n \"chatjs/plugins/credits/billing.ts\",\n \"chatjs/plugins/credits/
|
|
55
|
+
"content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"radix\",\n \"id\": \"credits\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/credits/balance.tsx\",\n \"chatjs/plugins/credits/billing.ts\",\n \"chatjs/plugins/credits/chat-ui.ts\",\n \"chatjs/plugins/credits/credits-queries.ts\",\n \"chatjs/plugins/credits/credits-schema.ts\",\n \"chatjs/plugins/credits/router.ts\",\n \"chatjs/plugins/credits/use-credits.ts\"\n ],\n \"databaseSchemas\": [\n \"chatjs/plugins/credits/credits-schema.ts\"\n ]\n}\n",
|
|
62
56
|
"type": "registry:file",
|
|
63
|
-
"target": "~/chatjs/plugins/credits/
|
|
57
|
+
"target": "~/chatjs/plugins/credits/plugin.json"
|
|
64
58
|
}
|
|
65
59
|
],
|
|
66
60
|
"meta": {
|
|
67
61
|
"chatjs": {
|
|
62
|
+
"contractVersion": 3,
|
|
63
|
+
"uiBase": "radix",
|
|
68
64
|
"id": "credits",
|
|
69
65
|
"kind": "plugin",
|
|
70
66
|
"files": [
|
|
71
67
|
"chatjs/plugins/credits/balance.tsx",
|
|
72
68
|
"chatjs/plugins/credits/billing.ts",
|
|
73
|
-
"chatjs/plugins/credits/
|
|
69
|
+
"chatjs/plugins/credits/chat-ui.ts",
|
|
74
70
|
"chatjs/plugins/credits/credits-queries.ts",
|
|
75
71
|
"chatjs/plugins/credits/credits-schema.ts",
|
|
76
72
|
"chatjs/plugins/credits/router.ts",
|
|
77
|
-
"chatjs/plugins/credits/server-plugin.ts",
|
|
78
73
|
"chatjs/plugins/credits/use-credits.ts"
|
|
79
74
|
],
|
|
80
75
|
"databaseSchemas": [
|
|
81
76
|
"chatjs/plugins/credits/credits-schema.ts"
|
|
82
|
-
]
|
|
83
|
-
"billing": {
|
|
84
|
-
"export": "creditsBilling"
|
|
85
|
-
},
|
|
86
|
-
"server": {
|
|
87
|
-
"export": "credits",
|
|
88
|
-
"routers": [
|
|
89
|
-
"credits"
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
"client": {
|
|
93
|
-
"export": "creditsClient",
|
|
94
|
-
"composerControls": [],
|
|
95
|
-
"settingsItems": [],
|
|
96
|
-
"accountSummary": true
|
|
97
|
-
},
|
|
98
|
-
"contractVersion": 2,
|
|
99
|
-
"uiBase": "radix"
|
|
77
|
+
]
|
|
100
78
|
}
|
|
101
79
|
},
|
|
102
80
|
"type": "registry:item"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
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\
|
|
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
21
|
"type": "registry:file",
|
|
22
22
|
"target": "~/chatjs/plugins/desktop/auth-form.tsx"
|
|
23
23
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
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\
|
|
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
33
|
"type": "registry:file",
|
|
34
34
|
"target": "~/chatjs/plugins/desktop/auth-server.ts"
|
|
35
35
|
},
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"target": "~/chatjs/plugins/desktop/bridge.ts"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
"path": "src/plugins/desktop/src/
|
|
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
|
|
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
51
|
"type": "registry:file",
|
|
52
|
-
"target": "~/chatjs/plugins/desktop/
|
|
52
|
+
"target": "~/chatjs/plugins/desktop/layout-ui.ts"
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"path": "src/plugins/desktop/src/navigation.ts",
|
|
56
|
-
"content": "import { isElectronRenderer } from \"./bridge\";\n\
|
|
56
|
+
"content": "import { isElectronRenderer } from \"./bridge\";\n\nconst desktopNavigation = (): boolean => isElectronRenderer();\n\nexport default desktopNavigation;\n",
|
|
57
57
|
"type": "registry:file",
|
|
58
58
|
"target": "~/chatjs/plugins/desktop/navigation.ts"
|
|
59
59
|
},
|
|
@@ -83,25 +83,27 @@
|
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"path": "src/plugins/desktop/src/sign-out.ts",
|
|
86
|
-
"content": "import { isElectronRenderer } from \"./bridge\";\n\
|
|
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
87
|
"type": "registry:file",
|
|
88
88
|
"target": "~/chatjs/plugins/desktop/sign-out.ts"
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
"path": "src/plugins/desktop/adapters/app/(auth)/device-login/page.tsx",
|
|
92
|
-
"content": "// ChatJS source: desktop. Ownership: chatjs/plugins/desktop/
|
|
92
|
+
"content": "// ChatJS source: desktop. Ownership: chatjs/plugins/desktop/plugin.json.\nexport { default, metadata } from \"@/chatjs/plugins/desktop/device-login-route\";\n",
|
|
93
93
|
"type": "registry:file",
|
|
94
94
|
"target": "~/app/(auth)/device-login/page.tsx"
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
97
|
"path": "dist/source/desktop.json",
|
|
98
|
-
"content": "{\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/
|
|
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
99
|
"type": "registry:file",
|
|
100
|
-
"target": "~/chatjs/plugins/desktop/
|
|
100
|
+
"target": "~/chatjs/plugins/desktop/plugin.json"
|
|
101
101
|
}
|
|
102
102
|
],
|
|
103
103
|
"meta": {
|
|
104
104
|
"chatjs": {
|
|
105
|
+
"contractVersion": 3,
|
|
106
|
+
"uiBase": "radix",
|
|
105
107
|
"id": "desktop",
|
|
106
108
|
"kind": "plugin",
|
|
107
109
|
"files": [
|
|
@@ -111,7 +113,7 @@
|
|
|
111
113
|
"chatjs/plugins/desktop/auth-server.ts",
|
|
112
114
|
"chatjs/plugins/desktop/auth-ui.tsx",
|
|
113
115
|
"chatjs/plugins/desktop/bridge.ts",
|
|
114
|
-
"chatjs/plugins/desktop/
|
|
116
|
+
"chatjs/plugins/desktop/layout-ui.ts",
|
|
115
117
|
"chatjs/plugins/desktop/navigation.ts",
|
|
116
118
|
"chatjs/plugins/desktop/protocol.ts",
|
|
117
119
|
"chatjs/plugins/desktop/device-login-page.tsx",
|
|
@@ -119,25 +121,7 @@
|
|
|
119
121
|
"chatjs/plugins/desktop/electron-auth.ts",
|
|
120
122
|
"chatjs/plugins/desktop/sign-out.ts",
|
|
121
123
|
"app/(auth)/device-login/page.tsx"
|
|
122
|
-
]
|
|
123
|
-
"authentication": {
|
|
124
|
-
"export": "desktopAuth"
|
|
125
|
-
},
|
|
126
|
-
"authenticationUi": {
|
|
127
|
-
"form": "DesktopAuthForm",
|
|
128
|
-
"signOut": "signOutDesktop"
|
|
129
|
-
},
|
|
130
|
-
"navigation": {
|
|
131
|
-
"export": "desktopNavigation"
|
|
132
|
-
},
|
|
133
|
-
"client": {
|
|
134
|
-
"export": "desktopClient",
|
|
135
|
-
"composerControls": [],
|
|
136
|
-
"settingsItems": [],
|
|
137
|
-
"layout": true
|
|
138
|
-
},
|
|
139
|
-
"contractVersion": 2,
|
|
140
|
-
"uiBase": "radix"
|
|
124
|
+
]
|
|
141
125
|
}
|
|
142
126
|
},
|
|
143
127
|
"type": "registry:item"
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
],
|
|
12
12
|
"files": [
|
|
13
13
|
{
|
|
14
|
-
"path": "src/plugins/feedback/src/chat.ts",
|
|
15
|
-
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\nimport { eveVote } from \"./feedback-schema\";\n\
|
|
14
|
+
"path": "src/plugins/feedback/src/chat-server.ts",
|
|
15
|
+
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\nimport { eveVote } from \"./feedback-schema\";\n\nconst feedbackChat = {\n onDeleteConversations: async (tx, { branchIds }) => {\n if (branchIds.length > 0) {\n await tx.delete(eveVote).where(inArray(eveVote.branchId, [...branchIds]));\n }\n },\n} satisfies ChatServerIntegration;\n\nexport default feedbackChat;\n",
|
|
16
16
|
"type": "registry:file",
|
|
17
|
-
"target": "~/chatjs/plugins/feedback/chat.ts"
|
|
17
|
+
"target": "~/chatjs/plugins/feedback/chat-server.ts"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
"path": "src/plugins/feedback/src/
|
|
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
|
|
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
22
|
"type": "registry:file",
|
|
23
|
-
"target": "~/chatjs/plugins/feedback/
|
|
23
|
+
"target": "~/chatjs/plugins/feedback/chat-ui.ts"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
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
|
|
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
28
|
"type": "registry:file",
|
|
29
29
|
"target": "~/chatjs/plugins/feedback/feedback-actions.tsx"
|
|
30
30
|
},
|
|
@@ -36,76 +36,54 @@
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
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}
|
|
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
40
|
"type": "registry:file",
|
|
41
41
|
"target": "~/chatjs/plugins/feedback/feedback-queries.ts"
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
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;\
|
|
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
46
|
"type": "registry:file",
|
|
47
47
|
"target": "~/chatjs/plugins/feedback/router.ts"
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
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
|
|
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
52
|
"type": "registry:file",
|
|
53
53
|
"target": "~/chatjs/plugins/feedback/feedback-schema.ts"
|
|
54
54
|
},
|
|
55
|
-
{
|
|
56
|
-
"path": "src/plugins/feedback/src/server-plugin.ts",
|
|
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
|
-
"type": "registry:file",
|
|
59
|
-
"target": "~/chatjs/plugins/feedback/server-plugin.ts"
|
|
60
|
-
},
|
|
61
55
|
{
|
|
62
56
|
"path": "src/plugins/feedback/src/vote-message.ts",
|
|
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
|
|
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",
|
|
64
58
|
"type": "registry:file",
|
|
65
59
|
"target": "~/chatjs/plugins/feedback/vote-message.ts"
|
|
66
60
|
},
|
|
67
61
|
{
|
|
68
62
|
"path": "dist/source/feedback.json",
|
|
69
|
-
"content": "{\n \"id\": \"feedback\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/feedback/chat.ts\",\n \"chatjs/plugins/feedback/
|
|
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",
|
|
70
64
|
"type": "registry:file",
|
|
71
|
-
"target": "~/chatjs/plugins/feedback/
|
|
65
|
+
"target": "~/chatjs/plugins/feedback/plugin.json"
|
|
72
66
|
}
|
|
73
67
|
],
|
|
74
68
|
"meta": {
|
|
75
69
|
"chatjs": {
|
|
70
|
+
"contractVersion": 3,
|
|
71
|
+
"uiBase": "radix",
|
|
76
72
|
"id": "feedback",
|
|
77
73
|
"kind": "plugin",
|
|
78
74
|
"files": [
|
|
79
|
-
"chatjs/plugins/feedback/chat.ts",
|
|
80
|
-
"chatjs/plugins/feedback/
|
|
75
|
+
"chatjs/plugins/feedback/chat-server.ts",
|
|
76
|
+
"chatjs/plugins/feedback/chat-ui.ts",
|
|
81
77
|
"chatjs/plugins/feedback/feedback-actions.tsx",
|
|
82
78
|
"chatjs/plugins/feedback/message-vote-actions.tsx",
|
|
83
79
|
"chatjs/plugins/feedback/feedback-queries.ts",
|
|
84
80
|
"chatjs/plugins/feedback/router.ts",
|
|
85
81
|
"chatjs/plugins/feedback/feedback-schema.ts",
|
|
86
|
-
"chatjs/plugins/feedback/server-plugin.ts",
|
|
87
82
|
"chatjs/plugins/feedback/vote-message.ts"
|
|
88
83
|
],
|
|
89
84
|
"databaseSchemas": [
|
|
90
85
|
"chatjs/plugins/feedback/feedback-schema.ts"
|
|
91
|
-
]
|
|
92
|
-
"chat": {
|
|
93
|
-
"export": "feedbackChat"
|
|
94
|
-
},
|
|
95
|
-
"server": {
|
|
96
|
-
"export": "feedback",
|
|
97
|
-
"routers": [
|
|
98
|
-
"feedback"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"client": {
|
|
102
|
-
"export": "feedbackClient",
|
|
103
|
-
"composerControls": [],
|
|
104
|
-
"settingsItems": [],
|
|
105
|
-
"chat": true
|
|
106
|
-
},
|
|
107
|
-
"contractVersion": 2,
|
|
108
|
-
"uiBase": "radix"
|
|
86
|
+
]
|
|
109
87
|
}
|
|
110
88
|
},
|
|
111
89
|
"type": "registry:item"
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
],
|
|
10
10
|
"files": [
|
|
11
11
|
{
|
|
12
|
-
"path": "src/plugins/followup-suggestions/src/chat.ts",
|
|
13
|
-
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\nimport { eveFollowup } from \"./followup-schema\";\n\
|
|
12
|
+
"path": "src/plugins/followup-suggestions/src/chat-server.ts",
|
|
13
|
+
"content": "import { inArray } from \"drizzle-orm\";\nimport type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\nimport { eveFollowup } from \"./followup-schema\";\n\nconst followupChat = {\n onDeleteConversations: async (tx, { sessionIds }) => {\n if (sessionIds.length > 0) {\n await tx\n .delete(eveFollowup)\n .where(inArray(eveFollowup.sessionId, [...sessionIds]));\n }\n },\n} satisfies ChatServerIntegration;\n\nexport default followupChat;\n",
|
|
14
14
|
"type": "registry:file",
|
|
15
|
-
"target": "~/chatjs/plugins/followup-suggestions/chat.ts"
|
|
15
|
+
"target": "~/chatjs/plugins/followup-suggestions/chat-server.ts"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
"path": "src/plugins/followup-suggestions/src/
|
|
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
|
|
18
|
+
"path": "src/plugins/followup-suggestions/src/chat-ui.ts",
|
|
19
|
+
"content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { ChatSuggestions } from \"@/components/chat-slots\";\nimport { FollowupSuggestions } from \"./suggestions\";\n\nexport const chatUi = definePlugin({\n id: \"followup-suggestions\",\n slots: [slot(ChatSuggestions, FollowupSuggestions)],\n});\n",
|
|
20
20
|
"type": "registry:file",
|
|
21
|
-
"target": "~/chatjs/plugins/followup-suggestions/
|
|
21
|
+
"target": "~/chatjs/plugins/followup-suggestions/chat-ui.ts"
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"path": "src/plugins/followup-suggestions/src/followup-completion.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"path": "src/plugins/followup-suggestions/src/followup-queries.ts",
|
|
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
|
|
43
|
+
"content": "import { and, eq } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveConversation } from \"@/lib/db/schema\";\nimport { eveFollowup } from \"./followup-schema\";\n\n/** Claim before any paid call. A crashed claim is deliberately never retried. */\nexport const claimEveFollowup = async (\n ownerId: string,\n sessionId: string,\n turnId: string,\n eventId: string\n): Promise<string | null> =>\n await db.transaction(async (tx) => {\n const conversations = await tx\n .select({ chatId: eveConversation.chatId })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.sessionId, sessionId),\n eq(eveConversation.state, \"bound\")\n )\n )\n .for(\"update\");\n const conversation = conversations.at(0);\n if (conversation === undefined) {\n return null;\n }\n const [claim] = await tx\n .insert(eveFollowup)\n .values({ ...conversation, ownerId, turnId, sessionId, eventId })\n .onConflictDoNothing()\n .returning({ chatId: eveFollowup.chatId });\n return claim?.chatId ?? null;\n });\n\nexport const finishEveFollowup = async (\n ownerId: string,\n chatId: string,\n eventId: string,\n suggestions: readonly string[]\n): Promise<void> => {\n await db\n .update(eveFollowup)\n .set({ suggestions: [...suggestions] })\n .where(\n and(\n eq(eveFollowup.ownerId, ownerId),\n eq(eveFollowup.chatId, chatId),\n eq(eveFollowup.eventId, eventId)\n )\n );\n};\n\nexport const getEveFollowup = async (\n ownerId: string,\n branchId: string,\n eventId: string\n): Promise<readonly string[] | null> => {\n const [row] = await db\n .select({ suggestions: eveFollowup.suggestions })\n .from(eveFollowup)\n .innerJoin(\n eveConversation,\n and(\n eq(eveFollowup.chatId, eveConversation.chatId),\n eq(eveFollowup.ownerId, eveConversation.ownerId)\n )\n )\n .where(\n and(\n eq(eveConversation.id, branchId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\"),\n eq(eveFollowup.eventId, eventId)\n )\n );\n return row?.suggestions ?? null;\n};\n",
|
|
44
44
|
"type": "registry:file",
|
|
45
45
|
"target": "~/chatjs/plugins/followup-suggestions/followup-queries.ts"
|
|
46
46
|
},
|
|
@@ -64,16 +64,10 @@
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"path": "src/plugins/followup-suggestions/src/router.ts",
|
|
67
|
-
"content": "import { z } from \"zod\";\nimport { createTRPCRouter } from \"@/trpc/init\";\nimport { eveOwnedProcedure } from \"@/trpc/eve-owned-procedure\";\nimport { getEveFollowup } from \"./followup-queries\";\n\
|
|
67
|
+
"content": "import { z } from \"zod\";\nimport { createTRPCRouter } from \"@/trpc/init\";\nimport { eveOwnedProcedure } from \"@/trpc/eve-owned-procedure\";\nimport { getEveFollowup } from \"./followup-queries\";\n\nconst followupSuggestionsProcedures = {\n get: eveOwnedProcedure\n .input(\n z.object({\n branchId: z.uuid(),\n eventId: z.string().min(1).max(512),\n })\n )\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly eveOwnerId: string };\n readonly input: {\n readonly branchId: string;\n readonly eventId: string;\n };\n }) => await getEveFollowup(ctx.eveOwnerId, input.branchId, input.eventId)\n ),\n};\n\nexport const router = createTRPCRouter({\n followupSuggestions: followupSuggestionsProcedures,\n});\n",
|
|
68
68
|
"type": "registry:file",
|
|
69
69
|
"target": "~/chatjs/plugins/followup-suggestions/router.ts"
|
|
70
70
|
},
|
|
71
|
-
{
|
|
72
|
-
"path": "src/plugins/followup-suggestions/src/server-plugin.ts",
|
|
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
|
-
"type": "registry:file",
|
|
75
|
-
"target": "~/chatjs/plugins/followup-suggestions/server-plugin.ts"
|
|
76
|
-
},
|
|
77
71
|
{
|
|
78
72
|
"path": "src/plugins/followup-suggestions/src/suggestion-output.ts",
|
|
79
73
|
"content": "import { z } from \"zod\";\n\nexport const eveFollowupSuggestions = z.object({\n suggestions: z.array(z.string().trim().min(1).max(80)).min(3).max(5),\n});\n",
|
|
@@ -82,36 +76,38 @@
|
|
|
82
76
|
},
|
|
83
77
|
{
|
|
84
78
|
"path": "src/plugins/followup-suggestions/src/suggestions.tsx",
|
|
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
|
|
79
|
+
"content": "\"use client\";\n\nimport React from \"react\";\nimport type { ChatSuggestionsProps } from \"@/chatjs/core/chat/contracts\";\nimport { useEveFollowups } from \"./use-followups\";\nimport { FollowUpSuggestionsView } from \"./followup-suggestions-view\";\n\nexport const FollowupSuggestions = ({\n branchId,\n sessionId,\n events,\n lastMessage,\n onSelect,\n disabled,\n}: ChatSuggestionsProps): React.JSX.Element | null => {\n const suggestions = useEveFollowups(branchId, sessionId, events, lastMessage);\n return (\n <FollowUpSuggestionsView\n suggestions={suggestions}\n onSelect={onSelect}\n disabled={disabled}\n />\n );\n};\n",
|
|
86
80
|
"type": "registry:file",
|
|
87
81
|
"target": "~/chatjs/plugins/followup-suggestions/suggestions.tsx"
|
|
88
82
|
},
|
|
89
83
|
{
|
|
90
84
|
"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 \"@/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
|
|
85
|
+
"content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTRPC } from \"@/trpc/react\";\nimport type { ChatSuggestionsProps } from \"@/chatjs/core/chat/contracts\";\nimport { followupCompletion } from \"./followup-completion\";\nimport { config } from \"@/lib/config\";\n\nconst EMPTY_SUGGESTIONS: readonly string[] = [];\nconst POLL_INTERVAL_MS = 1000;\nconst MAX_POLLS = 20;\n\nexport const useEveFollowups = (\n branchId: string,\n sessionId: string,\n events: Parameters<typeof followupCompletion>[0],\n message: ChatSuggestionsProps[\"lastMessage\"]\n): readonly string[] => {\n const trpc = useTRPC();\n const eventId =\n message?.role === \"assistant\"\n ? followupCompletion(events, message.metadata?.turnId, sessionId)\n : undefined;\n const query = useQuery({\n ...trpc.followupSuggestions.get.queryOptions({\n branchId,\n eventId: eventId ?? \"\",\n }),\n enabled:\n config.ai.tools.followupSuggestions.enabled && eventId !== undefined,\n retry: false,\n refetchInterval: (current) =>\n current.state.status !== \"error\" &&\n current.state.data === null &&\n current.state.dataUpdateCount < MAX_POLLS\n ? POLL_INTERVAL_MS\n : false,\n });\n return !config.ai.tools.followupSuggestions.enabled || eventId === undefined\n ? EMPTY_SUGGESTIONS\n : (query.data ?? EMPTY_SUGGESTIONS);\n};\n",
|
|
92
86
|
"type": "registry:file",
|
|
93
87
|
"target": "~/chatjs/plugins/followup-suggestions/use-followups.ts"
|
|
94
88
|
},
|
|
95
89
|
{
|
|
96
90
|
"path": "src/plugins/followup-suggestions/adapters/agent/hooks/followup-suggestions.ts",
|
|
97
|
-
"content": "// ChatJS source: followup-suggestions. Ownership: chatjs/plugins/followup-suggestions/
|
|
91
|
+
"content": "// ChatJS source: followup-suggestions. Ownership: chatjs/plugins/followup-suggestions/plugin.json.\nexport { default } from \"@/chatjs/plugins/followup-suggestions/followup-hook\";\n",
|
|
98
92
|
"type": "registry:file",
|
|
99
93
|
"target": "~/agent/hooks/followup-suggestions.ts"
|
|
100
94
|
},
|
|
101
95
|
{
|
|
102
96
|
"path": "dist/source/followup-suggestions.json",
|
|
103
|
-
"content": "{\n \"id\": \"followup-suggestions\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/followup-suggestions/chat.ts\",\n \"chatjs/plugins/followup-suggestions/
|
|
97
|
+
"content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"radix\",\n \"id\": \"followup-suggestions\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/followup-suggestions/chat-server.ts\",\n \"chatjs/plugins/followup-suggestions/chat-ui.ts\",\n \"chatjs/plugins/followup-suggestions/followup-completion.ts\",\n \"chatjs/plugins/followup-suggestions/followup-context.ts\",\n \"chatjs/plugins/followup-suggestions/followup-hook.ts\",\n \"chatjs/plugins/followup-suggestions/followup-queries.ts\",\n \"chatjs/plugins/followup-suggestions/followup-schema.ts\",\n \"chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx\",\n \"chatjs/plugins/followup-suggestions/generate-suggestions.ts\",\n \"chatjs/plugins/followup-suggestions/router.ts\",\n \"chatjs/plugins/followup-suggestions/suggestion-output.ts\",\n \"chatjs/plugins/followup-suggestions/suggestions.tsx\",\n \"chatjs/plugins/followup-suggestions/use-followups.ts\",\n \"agent/hooks/followup-suggestions.ts\"\n ],\n \"databaseSchemas\": [\n \"chatjs/plugins/followup-suggestions/followup-schema.ts\"\n ]\n}\n",
|
|
104
98
|
"type": "registry:file",
|
|
105
|
-
"target": "~/chatjs/plugins/followup-suggestions/
|
|
99
|
+
"target": "~/chatjs/plugins/followup-suggestions/plugin.json"
|
|
106
100
|
}
|
|
107
101
|
],
|
|
108
102
|
"meta": {
|
|
109
103
|
"chatjs": {
|
|
104
|
+
"contractVersion": 3,
|
|
105
|
+
"uiBase": "radix",
|
|
110
106
|
"id": "followup-suggestions",
|
|
111
107
|
"kind": "plugin",
|
|
112
108
|
"files": [
|
|
113
|
-
"chatjs/plugins/followup-suggestions/chat.ts",
|
|
114
|
-
"chatjs/plugins/followup-suggestions/
|
|
109
|
+
"chatjs/plugins/followup-suggestions/chat-server.ts",
|
|
110
|
+
"chatjs/plugins/followup-suggestions/chat-ui.ts",
|
|
115
111
|
"chatjs/plugins/followup-suggestions/followup-completion.ts",
|
|
116
112
|
"chatjs/plugins/followup-suggestions/followup-context.ts",
|
|
117
113
|
"chatjs/plugins/followup-suggestions/followup-hook.ts",
|
|
@@ -120,7 +116,6 @@
|
|
|
120
116
|
"chatjs/plugins/followup-suggestions/followup-suggestions-view.tsx",
|
|
121
117
|
"chatjs/plugins/followup-suggestions/generate-suggestions.ts",
|
|
122
118
|
"chatjs/plugins/followup-suggestions/router.ts",
|
|
123
|
-
"chatjs/plugins/followup-suggestions/server-plugin.ts",
|
|
124
119
|
"chatjs/plugins/followup-suggestions/suggestion-output.ts",
|
|
125
120
|
"chatjs/plugins/followup-suggestions/suggestions.tsx",
|
|
126
121
|
"chatjs/plugins/followup-suggestions/use-followups.ts",
|
|
@@ -128,24 +123,7 @@
|
|
|
128
123
|
],
|
|
129
124
|
"databaseSchemas": [
|
|
130
125
|
"chatjs/plugins/followup-suggestions/followup-schema.ts"
|
|
131
|
-
]
|
|
132
|
-
"chat": {
|
|
133
|
-
"export": "followupChat"
|
|
134
|
-
},
|
|
135
|
-
"server": {
|
|
136
|
-
"export": "followupSuggestions",
|
|
137
|
-
"routers": [
|
|
138
|
-
"followupSuggestions"
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
|
-
"client": {
|
|
142
|
-
"export": "followupSuggestionsClient",
|
|
143
|
-
"composerControls": [],
|
|
144
|
-
"settingsItems": [],
|
|
145
|
-
"chat": true
|
|
146
|
-
},
|
|
147
|
-
"contractVersion": 2,
|
|
148
|
-
"uiBase": "radix"
|
|
126
|
+
]
|
|
149
127
|
}
|
|
150
128
|
},
|
|
151
129
|
"type": "registry:item"
|