@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.
Files changed (62) hide show
  1. package/README.md +4 -4
  2. package/dist/r/ai-titles.json +10 -13
  3. package/dist/r/attach-workspace-file.json +2 -2
  4. package/dist/r/attachment-uploads.json +13 -22
  5. package/dist/r/base/ai-titles.json +10 -13
  6. package/dist/r/base/attach-workspace-file.json +2 -2
  7. package/dist/r/base/attachment-uploads.json +13 -22
  8. package/dist/r/base/credits.json +11 -33
  9. package/dist/r/base/deep-research.json +0 -4
  10. package/dist/r/base/desktop.json +14 -30
  11. package/dist/r/base/feedback.json +18 -40
  12. package/dist/r/base/followup-suggestions.json +18 -40
  13. package/dist/r/base/guest-chat.json +20 -35
  14. package/dist/r/base/image-viewer.json +9 -15
  15. package/dist/r/base/mcp.json +24 -47
  16. package/dist/r/base/memory-storage.json +2 -2
  17. package/dist/r/base/model-preferences.json +16 -37
  18. package/dist/r/base/projects.json +23 -45
  19. package/dist/r/base/registry.json +138 -370
  20. package/dist/r/base/search.json +21 -43
  21. package/dist/r/base/sharing.json +18 -40
  22. package/dist/r/base/spreadsheet-viewer.json +9 -15
  23. package/dist/r/base/vercel-gateway.json +2 -1
  24. package/dist/r/base/video-viewer.json +9 -15
  25. package/dist/r/credits.json +11 -33
  26. package/dist/r/deep-research.json +0 -4
  27. package/dist/r/desktop.json +14 -30
  28. package/dist/r/feedback.json +18 -40
  29. package/dist/r/followup-suggestions.json +18 -40
  30. package/dist/r/guest-chat.json +20 -35
  31. package/dist/r/image-viewer.json +9 -15
  32. package/dist/r/mcp.json +24 -47
  33. package/dist/r/memory-storage.json +2 -2
  34. package/dist/r/model-preferences.json +16 -37
  35. package/dist/r/projects.json +23 -45
  36. package/dist/r/radix/ai-titles.json +10 -13
  37. package/dist/r/radix/attach-workspace-file.json +2 -2
  38. package/dist/r/radix/attachment-uploads.json +13 -22
  39. package/dist/r/radix/credits.json +11 -33
  40. package/dist/r/radix/deep-research.json +0 -4
  41. package/dist/r/radix/desktop.json +14 -30
  42. package/dist/r/radix/feedback.json +18 -40
  43. package/dist/r/radix/followup-suggestions.json +18 -40
  44. package/dist/r/radix/guest-chat.json +20 -35
  45. package/dist/r/radix/image-viewer.json +9 -15
  46. package/dist/r/radix/mcp.json +24 -47
  47. package/dist/r/radix/memory-storage.json +2 -2
  48. package/dist/r/radix/model-preferences.json +16 -37
  49. package/dist/r/radix/projects.json +23 -45
  50. package/dist/r/radix/registry.json +138 -370
  51. package/dist/r/radix/search.json +21 -43
  52. package/dist/r/radix/sharing.json +18 -40
  53. package/dist/r/radix/spreadsheet-viewer.json +9 -15
  54. package/dist/r/radix/vercel-gateway.json +2 -1
  55. package/dist/r/radix/video-viewer.json +9 -15
  56. package/dist/r/registry.json +138 -370
  57. package/dist/r/search.json +21 -43
  58. package/dist/r/sharing.json +18 -40
  59. package/dist/r/spreadsheet-viewer.json +9 -15
  60. package/dist/r/vercel-gateway.json +2 -1
  61. package/dist/r/video-viewer.json +9 -15
  62. package/package.json +1 -1
@@ -27,20 +27,20 @@
27
27
  ],
28
28
  "files": [
29
29
  {
30
- "path": "src/plugins/projects/src/chat.ts",
31
- "content": "import type { SQL } from \"drizzle-orm\";\nimport { and, eq, inArray, sql } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveChat } from \"@/lib/db/schema\";\nimport type {\n ChatServerIntegration,\n ChatLinks,\n} from \"@/chatjs/core/chat/contracts\";\nimport { eveChatProject } from \"./db/project-schema\";\nimport { assignCreationProject } from \"./creation\";\n\nexport const projectsChat = {\n onCreate: assignCreationProject,\n historyFilter: (\n { projectId }: { readonly projectId?: string | null },\n surface: \"sidebar\" | \"all\"\n ): SQL | undefined => {\n if (projectId === undefined && surface === \"all\") {\n return undefined;\n }\n const membership = sql`select 1 from ${eveChatProject} where ${eveChatProject.chatId} = ${eveChat.id} and ${eveChatProject.ownerId} = ${eveChat.ownerId}`;\n return typeof projectId === \"string\"\n ? sql`exists (${membership} and ${eveChatProject.projectId} = ${projectId})`\n : sql`not exists (${membership})`;\n },\n links: async (\n ownerId: string,\n chatIds: readonly string[]\n ): Promise<ReadonlyMap<string, ChatLinks>> => {\n if (chatIds.length === 0) {\n return new Map();\n }\n const rows = await db\n .select()\n .from(eveChatProject)\n .where(\n and(\n eq(eveChatProject.ownerId, ownerId),\n inArray(eveChatProject.chatId, [...chatIds])\n )\n );\n return new Map(\n rows.map((row) => [\n row.chatId,\n {\n href: `/project/${row.projectId}/chat/${row.chatId}`,\n parentHref: `/project/${row.projectId}`,\n },\n ])\n );\n },\n onDelete: async (tx, chatId) => {\n await tx.delete(eveChatProject).where(eq(eveChatProject.chatId, chatId));\n },\n} satisfies ChatServerIntegration;\n",
30
+ "path": "src/plugins/projects/src/chat-server.ts",
31
+ "content": "import type { SQL } from \"drizzle-orm\";\nimport { and, eq, inArray, sql } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveChat } from \"@/lib/db/schema\";\nimport type {\n ChatServerIntegration,\n ChatLinks,\n} from \"@/chatjs/core/chat/contracts\";\nimport { eveChatProject } from \"./db/project-schema\";\nimport { assignCreationProject } from \"./creation\";\n\nconst projectsChat = {\n onCreate: assignCreationProject,\n historyFilter: (\n { projectId }: { readonly projectId?: string | null },\n surface: \"sidebar\" | \"all\"\n ): SQL | undefined => {\n if (projectId === undefined && surface === \"all\") {\n return undefined;\n }\n const membership = sql`select 1 from ${eveChatProject} where ${eveChatProject.chatId} = ${eveChat.id} and ${eveChatProject.ownerId} = ${eveChat.ownerId}`;\n return typeof projectId === \"string\"\n ? sql`exists (${membership} and ${eveChatProject.projectId} = ${projectId})`\n : sql`not exists (${membership})`;\n },\n links: async (\n ownerId: string,\n chatIds: readonly string[]\n ): Promise<ReadonlyMap<string, ChatLinks>> => {\n if (chatIds.length === 0) {\n return new Map();\n }\n const rows = await db\n .select()\n .from(eveChatProject)\n .where(\n and(\n eq(eveChatProject.ownerId, ownerId),\n inArray(eveChatProject.chatId, [...chatIds])\n )\n );\n return new Map(\n rows.map((row) => [\n row.chatId,\n {\n href: `/project/${row.projectId}/chat/${row.chatId}`,\n parentHref: `/project/${row.projectId}`,\n },\n ])\n );\n },\n onDelete: async (tx, chatId) => {\n await tx.delete(eveChatProject).where(eq(eveChatProject.chatId, chatId));\n },\n} satisfies ChatServerIntegration;\n\nexport default projectsChat;\n",
32
32
  "type": "registry:file",
33
- "target": "~/chatjs/plugins/projects/chat.ts"
33
+ "target": "~/chatjs/plugins/projects/chat-server.ts"
34
34
  },
35
35
  {
36
- "path": "src/plugins/projects/src/client-plugin.ts",
37
- "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport {\n SidebarSections,\n ChatActions,\n ChatBreadcrumbs,\n} from \"@/components/chat-slots\";\nimport {\n ProjectsSidebar,\n ProjectChatActions,\n ProjectBreadcrumb,\n} from \"./ui/chat-contributions\";\n\nexport const projectsClient = definePlugin({\n id: \"projects\",\n slots: [\n slot(SidebarSections, ProjectsSidebar),\n slot(ChatActions, ProjectChatActions),\n slot(ChatBreadcrumbs, ProjectBreadcrumb),\n ],\n});\n",
36
+ "path": "src/plugins/projects/src/chat-ui.ts",
37
+ "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport {\n SidebarSections,\n ChatActions,\n ChatBreadcrumbs,\n} from \"@/components/chat-slots\";\nimport {\n ProjectsSidebar,\n ProjectChatActions,\n ProjectBreadcrumb,\n} from \"./ui/chat-contributions\";\n\nexport const chatUi = definePlugin({\n id: \"projects\",\n slots: [\n slot(SidebarSections, ProjectsSidebar),\n slot(ChatActions, ProjectChatActions),\n slot(ChatBreadcrumbs, ProjectBreadcrumb),\n ],\n});\n",
38
38
  "type": "registry:file",
39
- "target": "~/chatjs/plugins/projects/client-plugin.ts"
39
+ "target": "~/chatjs/plugins/projects/chat-ui.ts"
40
40
  },
41
41
  {
42
42
  "path": "src/plugins/projects/src/conversation-hook.ts",
43
- "content": "import { isAccountSession } from \"@/lib/eve/session-identity\";\nimport type { HookContext } from \"eve/hooks\";\nimport { defineHook } from \"eve/hooks\";\n\nimport { getEveConversationProject } from \"./db/project-queries\";\nimport { projectInstructions } from \"./instructions-state\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\n\nconst conversationScopeTimeoutMilliseconds = 10_000;\n\nexport default defineHook({\n events: {\n \"turn.started\": async (\n _event: unknown,\n context: Readonly<{\n session: Readonly<\n Pick<HookContext[\"session\"], \"id\" | \"auth\" | \"parent\">\n >;\n }>\n ) => {\n if (!isAccountSession(context.session)) {\n return;\n }\n projectInstructions.update(() => ({ content: null }));\n const scope = await resolveEveConversationScope(\n context.session.auth.initiator?.principalId,\n context.session.parent?.rootSessionId ?? context.session.id,\n AbortSignal.timeout(conversationScopeTimeoutMilliseconds),\n // Native lineage identifies the existing root binding. An inherited\n // reservation attribute never authorizes a child to claim that binding.\n context.session.parent\n ? undefined\n : context.session.auth.initiator?.attributes.chatjsReservationId\n );\n const project = await getEveConversationProject(\n scope.ownerId,\n scope.conversationId\n );\n projectInstructions.update(() => ({\n content: project?.instructions ?? null,\n }));\n },\n },\n});\n",
43
+ "content": "import { isAccountSession } from \"@/lib/eve/session-identity\";\nimport type { HookContext } from \"eve/hooks\";\nimport { defineHook } from \"eve/hooks\";\n\nimport { getEveConversationProject } from \"./db/project-queries\";\nimport { projectInstructions } from \"./instructions-state\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\n\nconst conversationScopeTimeoutMilliseconds = 10_000;\n\nexport default defineHook({\n events: {\n \"turn.started\": async (\n _event: unknown,\n context: Readonly<{\n session: Readonly<\n Pick<HookContext[\"session\"], \"id\" | \"auth\" | \"parent\">\n >;\n }>\n ) => {\n if (!isAccountSession(context.session)) {\n return;\n }\n projectInstructions.update(() => ({ content: null }));\n const scope = await resolveEveConversationScope(\n context.session.auth.initiator?.principalId,\n context.session.parent?.rootSessionId ?? context.session.id,\n AbortSignal.timeout(conversationScopeTimeoutMilliseconds),\n // Native lineage identifies the existing root binding. An inherited\n // reservation attribute never authorizes a child to claim that binding.\n context.session.parent\n ? undefined\n : context.session.auth.initiator?.attributes.chatjsReservationId\n );\n const project = await getEveConversationProject(\n scope.ownerId,\n scope.branchId\n );\n projectInstructions.update(() => ({\n content: project?.instructions ?? null,\n }));\n },\n },\n});\n",
44
44
  "type": "registry:file",
45
45
  "target": "~/chatjs/plugins/projects/conversation-hook.ts"
46
46
  },
@@ -52,7 +52,7 @@
52
52
  },
53
53
  {
54
54
  "path": "src/plugins/projects/src/db/project-queries.ts",
55
- "content": "import type { PgSelectBase, PgSelectWithout } from \"drizzle-orm/pg-core\";\nimport type { GetSelectTableName } from \"drizzle-orm/query-builders/select.types\";\nimport { and, desc, eq, or, sql } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { updateOwnedChat } from \"@/lib/db/update-owned-chat\";\nimport { eveChat, eveConversation } from \"@/lib/db/schema\";\nimport { project, eveChatProject } from \"./project-schema\";\n\nconst hasQueryRow: (row: unknown) => boolean = Boolean;\nconst createProject = ({\n id,\n userId,\n name,\n instructions = \"\",\n icon,\n iconColor,\n}: {\n readonly id: string;\n readonly userId: string;\n readonly name: string;\n readonly instructions?: string;\n readonly icon?: string;\n readonly iconColor?: string;\n}): ReturnType<ReturnType<typeof db.insert<typeof project>>[\"values\"]> =>\n db.insert(project).values({\n createdAt: new Date(),\n ...(typeof icon === \"string\" && icon !== \"\" && { icon }),\n ...(typeof iconColor === \"string\" && iconColor !== \"\" && { iconColor }),\n id,\n instructions,\n name,\n updatedAt: new Date(),\n userId,\n });\n\nconst getProjectsByUserId = ({\n userId,\n}: {\n readonly userId: string;\n}): PgSelectWithout<\n PgSelectBase<\n GetSelectTableName<typeof project>,\n (typeof project)[\"_\"][\"columns\"],\n \"single\",\n Record<GetSelectTableName<typeof project>, \"not-null\">\n >,\n false,\n \"where\" | \"orderBy\"\n> =>\n db\n .select()\n .from(project)\n .where(eq(project.userId, userId))\n .orderBy(desc(project.updatedAt));\n\nconst getProjectById = async ({\n id,\n}: {\n readonly id: string;\n}): Promise<typeof project.$inferSelect> => {\n const [selectedProject] = await db\n .select()\n .from(project)\n .where(eq(project.id, id));\n return selectedProject;\n};\n\nconst updateProject = ({\n id,\n updates,\n}: {\n readonly id: string;\n readonly updates: Partial<{\n readonly name: string;\n readonly instructions: string;\n readonly icon: string;\n readonly iconColor: string;\n }>;\n}): ReturnType<\n ReturnType<ReturnType<typeof db.update<typeof project>>[\"set\"]>[\"where\"]\n> =>\n db\n .update(project)\n .set({ ...updates, updatedAt: new Date() })\n .where(eq(project.id, id));\n\nconst deleteProject = ({\n id,\n}: {\n readonly id: string;\n}): ReturnType<ReturnType<typeof db.delete<typeof project>>[\"where\"]> =>\n db.delete(project).where(eq(project.id, id));\n\nconst assignEveConversationProject = async (\n ownerId: string,\n routeId: string,\n projectId: string | null\n): Promise<{ conversationId: string; projectId: string | null } | null> =>\n await updateOwnedChat(\n { ownerId, chatId: routeId },\n async ({ tx, chatId }) => {\n if (projectId === null) {\n await tx\n .delete(eveChatProject)\n .where(eq(eveChatProject.chatId, chatId));\n } else {\n const [target] = await tx\n .select({ id: project.id })\n .from(project)\n .where(and(eq(project.id, projectId), eq(project.userId, ownerId)))\n .for(\"key share\");\n if (!hasQueryRow(target)) {\n return null;\n }\n await tx\n .insert(eveChatProject)\n .values({ chatId, ownerId, projectId })\n .onConflictDoUpdate({\n set: { projectId },\n target: eveChatProject.chatId,\n });\n }\n return { conversationId: routeId, projectId };\n }\n );\nconst getEveConversationProject = async (\n ownerId: string,\n routeId: string\n): Promise<Pick<\n typeof project.$inferSelect,\n \"id\" | \"instructions\" | \"name\" | \"icon\" | \"iconColor\"\n> | null> => {\n const [assigned] = await db\n .select({\n id: project.id,\n icon: project.icon,\n iconColor: project.iconColor,\n instructions: project.instructions,\n name: project.name,\n })\n .from(eveChat)\n .leftJoin(\n eveConversation,\n and(\n eq(eveConversation.chatId, eveChat.id),\n eq(eveConversation.ownerId, eveChat.ownerId),\n eq(eveConversation.id, routeId)\n )\n )\n .innerJoin(\n eveChatProject,\n and(\n eq(eveChatProject.chatId, eveChat.id),\n eq(eveChatProject.ownerId, eveChat.ownerId)\n )\n )\n .innerJoin(project, eq(project.id, eveChatProject.projectId))\n .where(\n and(\n eq(eveChat.ownerId, ownerId),\n or(eq(eveChat.id, routeId), eq(eveConversation.id, routeId)),\n sql`exists (\n select 1 from \"EveConversation\" member\n where member.\"chatId\" = ${eveChat.id}\n and member.\"ownerId\" = ${ownerId}\n and member.\"state\" in ('creating', 'bound', 'uncertain')\n )`\n )\n );\n return assigned ?? null;\n};\nexport {\n createProject,\n deleteProject,\n getProjectById,\n getProjectsByUserId,\n updateProject,\n assignEveConversationProject,\n getEveConversationProject,\n};\n",
55
+ "content": "import type { PgSelectBase, PgSelectWithout } from \"drizzle-orm/pg-core\";\nimport type { GetSelectTableName } from \"drizzle-orm/query-builders/select.types\";\nimport { and, desc, eq, or, sql } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { updateOwnedChat } from \"@/lib/db/update-owned-chat\";\nimport { eveChat, eveConversation } from \"@/lib/db/schema\";\nimport { project, eveChatProject } from \"./project-schema\";\n\nconst hasQueryRow: (row: unknown) => boolean = Boolean;\nconst createProject = ({\n id,\n userId,\n name,\n instructions = \"\",\n icon,\n iconColor,\n}: {\n readonly id: string;\n readonly userId: string;\n readonly name: string;\n readonly instructions?: string;\n readonly icon?: string;\n readonly iconColor?: string;\n}): ReturnType<ReturnType<typeof db.insert<typeof project>>[\"values\"]> =>\n db.insert(project).values({\n createdAt: new Date(),\n ...(typeof icon === \"string\" && icon !== \"\" && { icon }),\n ...(typeof iconColor === \"string\" && iconColor !== \"\" && { iconColor }),\n id,\n instructions,\n name,\n updatedAt: new Date(),\n userId,\n });\n\nconst getProjectsByUserId = ({\n userId,\n}: {\n readonly userId: string;\n}): PgSelectWithout<\n PgSelectBase<\n GetSelectTableName<typeof project>,\n (typeof project)[\"_\"][\"columns\"],\n \"single\",\n Record<GetSelectTableName<typeof project>, \"not-null\">\n >,\n false,\n \"where\" | \"orderBy\"\n> =>\n db\n .select()\n .from(project)\n .where(eq(project.userId, userId))\n .orderBy(desc(project.updatedAt));\n\nconst getProjectById = async ({\n id,\n}: {\n readonly id: string;\n}): Promise<typeof project.$inferSelect> => {\n const [selectedProject] = await db\n .select()\n .from(project)\n .where(eq(project.id, id));\n return selectedProject;\n};\n\nconst updateProject = ({\n id,\n updates,\n}: {\n readonly id: string;\n readonly updates: Partial<{\n readonly name: string;\n readonly instructions: string;\n readonly icon: string;\n readonly iconColor: string;\n }>;\n}): ReturnType<\n ReturnType<ReturnType<typeof db.update<typeof project>>[\"set\"]>[\"where\"]\n> =>\n db\n .update(project)\n .set({ ...updates, updatedAt: new Date() })\n .where(eq(project.id, id));\n\nconst deleteProject = ({\n id,\n}: {\n readonly id: string;\n}): ReturnType<ReturnType<typeof db.delete<typeof project>>[\"where\"]> =>\n db.delete(project).where(eq(project.id, id));\n\nconst assignEveConversationProject = async (\n ownerId: string,\n routeId: string,\n projectId: string | null\n): Promise<{ id: string; projectId: string | null } | null> =>\n await updateOwnedChat(\n { ownerId, chatId: routeId },\n async ({ tx, chatId }) => {\n if (projectId === null) {\n await tx\n .delete(eveChatProject)\n .where(eq(eveChatProject.chatId, chatId));\n } else {\n const [target] = await tx\n .select({ id: project.id })\n .from(project)\n .where(and(eq(project.id, projectId), eq(project.userId, ownerId)))\n .for(\"key share\");\n if (!hasQueryRow(target)) {\n return null;\n }\n await tx\n .insert(eveChatProject)\n .values({ chatId, ownerId, projectId })\n .onConflictDoUpdate({\n set: { projectId },\n target: eveChatProject.chatId,\n });\n }\n return { id: routeId, projectId };\n }\n );\nconst getEveConversationProject = async (\n ownerId: string,\n routeId: string\n): Promise<Pick<\n typeof project.$inferSelect,\n \"id\" | \"instructions\" | \"name\" | \"icon\" | \"iconColor\"\n> | null> => {\n const [assigned] = await db\n .select({\n id: project.id,\n icon: project.icon,\n iconColor: project.iconColor,\n instructions: project.instructions,\n name: project.name,\n })\n .from(eveChat)\n .leftJoin(\n eveConversation,\n and(\n eq(eveConversation.chatId, eveChat.id),\n eq(eveConversation.ownerId, eveChat.ownerId),\n eq(eveConversation.id, routeId)\n )\n )\n .innerJoin(\n eveChatProject,\n and(\n eq(eveChatProject.chatId, eveChat.id),\n eq(eveChatProject.ownerId, eveChat.ownerId)\n )\n )\n .innerJoin(project, eq(project.id, eveChatProject.projectId))\n .where(\n and(\n eq(eveChat.ownerId, ownerId),\n or(eq(eveChat.id, routeId), eq(eveConversation.id, routeId)),\n sql`exists (\n select 1 from \"EveConversation\" member\n where member.\"chatId\" = ${eveChat.id}\n and member.\"ownerId\" = ${ownerId}\n and member.\"state\" in ('creating', 'bound', 'uncertain')\n )`\n )\n );\n return assigned ?? null;\n};\nexport {\n createProject,\n deleteProject,\n getProjectById,\n getProjectsByUserId,\n updateProject,\n assignEveConversationProject,\n getEveConversationProject,\n};\n",
56
56
  "type": "registry:file",
57
57
  "target": "~/chatjs/plugins/projects/db/project-queries.ts"
58
58
  },
@@ -82,7 +82,7 @@
82
82
  },
83
83
  {
84
84
  "path": "src/plugins/projects/src/router.ts",
85
- "content": "import {\n PROJECT_COLOR_NAMES,\n PROJECT_ICONS,\n} from \"@/chatjs/plugins/projects/project-icons\";\nimport { TRPCError } from \"@trpc/server\";\nimport { z } from \"zod\";\n\nimport {\n assignEveConversationProject,\n getEveConversationProject,\n createProject,\n deleteProject,\n getProjectById,\n getProjectsByUserId,\n updateProject,\n} from \"@/chatjs/plugins/projects/db/project-queries\";\n\nimport { generateUUID } from \"@/lib/id\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\n\nexport const projectRouter = createTRPCRouter({\n assign: protectedProcedure\n .input(\n z.object({ conversationId: z.uuid(), projectId: z.uuid().nullable() })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n conversationId: string;\n projectId: string | null;\n }>;\n }) => {\n const assigned = await assignEveConversationProject(\n ctx.user.id,\n input.conversationId,\n input.projectId\n );\n if (!assigned) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Conversation or project not found.\",\n });\n }\n return assigned;\n }\n ),\n\n forChat: protectedProcedure\n .input(z.object({ id: z.uuid() }))\n .query(\n async ({ ctx, input }) =>\n await getEveConversationProject(ctx.user.id, input.id)\n ),\n create: protectedProcedure\n .input(\n z.object({\n icon: z.enum(PROJECT_ICONS).optional(),\n iconColor: z.enum(PROJECT_COLOR_NAMES).optional(),\n instructions: z.string().default(\"\"),\n name: z.string().nonempty(),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n instructions: string;\n name: string;\n icon?:\n | \"code\"\n | \"folder\"\n | \"briefcase\"\n | \"book\"\n | \"dollar-sign\"\n | \"graduation-cap\"\n | \"heart\"\n | \"home\"\n | \"lightbulb\"\n | \"music\"\n | \"pencil\"\n | \"plane\"\n | \"shopping-cart\"\n | \"star\"\n | \"target\"\n | \"users\"\n | \"zap\"\n | \"coffee\"\n | \"camera\"\n | \"globe\"\n | \"flask\"\n | \"chart-bar\"\n | \"calendar\"\n | \"clipboard\"\n | \"rocket\"\n | undefined;\n iconColor?:\n | \"gray\"\n | \"red\"\n | \"orange\"\n | \"yellow\"\n | \"green\"\n | \"cyan\"\n | \"blue\"\n | \"purple\"\n | \"pink\"\n | undefined;\n }>;\n }) => {\n const id = generateUUID();\n await createProject({\n icon: input.icon,\n iconColor: input.iconColor,\n id,\n instructions: input.instructions,\n name: input.name,\n userId: ctx.user.id,\n });\n return { id };\n }\n ),\n\n getById: protectedProcedure\n .input(z.object({ id: z.uuid() }))\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{ id: string }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n return project;\n }\n ),\n\n list: protectedProcedure.query(\n async ({\n ctx,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n }) => {\n const projects = await getProjectsByUserId({ userId: ctx.user.id });\n return projects;\n }\n ),\n\n remove: protectedProcedure\n .input(z.object({ id: z.uuid() }))\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{ id: string }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n await deleteProject({ id: input.id });\n return { success: true };\n }\n ),\n\n setInstructions: protectedProcedure\n .input(\n z.object({\n id: z.uuid(),\n instructions: z.string(),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n id: string;\n instructions: string;\n }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n await updateProject({\n id: input.id,\n updates: { instructions: input.instructions },\n });\n return { success: true };\n }\n ),\n\n update: protectedProcedure\n .input(\n z.object({\n id: z.uuid(),\n updates: z.object({\n icon: z.enum(PROJECT_ICONS).optional(),\n iconColor: z.enum(PROJECT_COLOR_NAMES).optional(),\n instructions: z.string().optional(),\n name: z.string().nonempty().optional(),\n }),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n id: string;\n updates: {\n icon?:\n | \"code\"\n | \"folder\"\n | \"briefcase\"\n | \"book\"\n | \"dollar-sign\"\n | \"graduation-cap\"\n | \"heart\"\n | \"home\"\n | \"lightbulb\"\n | \"music\"\n | \"pencil\"\n | \"plane\"\n | \"shopping-cart\"\n | \"star\"\n | \"target\"\n | \"users\"\n | \"zap\"\n | \"coffee\"\n | \"camera\"\n | \"globe\"\n | \"flask\"\n | \"chart-bar\"\n | \"calendar\"\n | \"clipboard\"\n | \"rocket\"\n | undefined;\n iconColor?:\n | \"gray\"\n | \"red\"\n | \"orange\"\n | \"yellow\"\n | \"green\"\n | \"cyan\"\n | \"blue\"\n | \"purple\"\n | \"pink\"\n | undefined;\n instructions?: string | undefined;\n name?: string | undefined;\n };\n }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n await updateProject({ id: input.id, updates: input.updates });\n return { success: true };\n }\n ),\n});\n",
85
+ "content": "import {\n PROJECT_COLOR_NAMES,\n PROJECT_ICONS,\n} from \"@/chatjs/plugins/projects/project-icons\";\nimport { TRPCError } from \"@trpc/server\";\nimport { z } from \"zod\";\n\nimport {\n assignEveConversationProject,\n getEveConversationProject,\n createProject,\n deleteProject,\n getProjectById,\n getProjectsByUserId,\n updateProject,\n} from \"@/chatjs/plugins/projects/db/project-queries\";\n\nimport { generateUUID } from \"@/lib/id\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\n\nconst projectProcedures = {\n assign: protectedProcedure\n .input(z.object({ id: z.uuid(), projectId: z.uuid().nullable() }))\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n id: string;\n projectId: string | null;\n }>;\n }) => {\n const assigned = await assignEveConversationProject(\n ctx.user.id,\n input.id,\n input.projectId\n );\n if (!assigned) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Conversation or project not found.\",\n });\n }\n return assigned;\n }\n ),\n\n forChat: protectedProcedure\n .input(z.object({ id: z.uuid() }))\n .query(\n async ({ ctx, input }) =>\n await getEveConversationProject(ctx.user.id, input.id)\n ),\n create: protectedProcedure\n .input(\n z.object({\n icon: z.enum(PROJECT_ICONS).optional(),\n iconColor: z.enum(PROJECT_COLOR_NAMES).optional(),\n instructions: z.string().default(\"\"),\n name: z.string().nonempty(),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n instructions: string;\n name: string;\n icon?:\n | \"code\"\n | \"folder\"\n | \"briefcase\"\n | \"book\"\n | \"dollar-sign\"\n | \"graduation-cap\"\n | \"heart\"\n | \"home\"\n | \"lightbulb\"\n | \"music\"\n | \"pencil\"\n | \"plane\"\n | \"shopping-cart\"\n | \"star\"\n | \"target\"\n | \"users\"\n | \"zap\"\n | \"coffee\"\n | \"camera\"\n | \"globe\"\n | \"flask\"\n | \"chart-bar\"\n | \"calendar\"\n | \"clipboard\"\n | \"rocket\"\n | undefined;\n iconColor?:\n | \"gray\"\n | \"red\"\n | \"orange\"\n | \"yellow\"\n | \"green\"\n | \"cyan\"\n | \"blue\"\n | \"purple\"\n | \"pink\"\n | undefined;\n }>;\n }) => {\n const id = generateUUID();\n await createProject({\n icon: input.icon,\n iconColor: input.iconColor,\n id,\n instructions: input.instructions,\n name: input.name,\n userId: ctx.user.id,\n });\n return { id };\n }\n ),\n\n getById: protectedProcedure\n .input(z.object({ id: z.uuid() }))\n .query(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{ id: string }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n return project;\n }\n ),\n\n list: protectedProcedure.query(\n async ({\n ctx,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n }) => {\n const projects = await getProjectsByUserId({ userId: ctx.user.id });\n return projects;\n }\n ),\n\n remove: protectedProcedure\n .input(z.object({ id: z.uuid() }))\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{ id: string }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n await deleteProject({ id: input.id });\n return { success: true };\n }\n ),\n\n setInstructions: protectedProcedure\n .input(\n z.object({\n id: z.uuid(),\n instructions: z.string(),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n id: string;\n instructions: string;\n }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n await updateProject({\n id: input.id,\n updates: { instructions: input.instructions },\n });\n return { success: true };\n }\n ),\n\n update: protectedProcedure\n .input(\n z.object({\n id: z.uuid(),\n updates: z.object({\n icon: z.enum(PROJECT_ICONS).optional(),\n iconColor: z.enum(PROJECT_COLOR_NAMES).optional(),\n instructions: z.string().optional(),\n name: z.string().nonempty().optional(),\n }),\n })\n )\n .mutation(\n async ({\n ctx,\n input,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n readonly input: ReadonlyNativeSurface<{\n id: string;\n updates: {\n icon?:\n | \"code\"\n | \"folder\"\n | \"briefcase\"\n | \"book\"\n | \"dollar-sign\"\n | \"graduation-cap\"\n | \"heart\"\n | \"home\"\n | \"lightbulb\"\n | \"music\"\n | \"pencil\"\n | \"plane\"\n | \"shopping-cart\"\n | \"star\"\n | \"target\"\n | \"users\"\n | \"zap\"\n | \"coffee\"\n | \"camera\"\n | \"globe\"\n | \"flask\"\n | \"chart-bar\"\n | \"calendar\"\n | \"clipboard\"\n | \"rocket\"\n | undefined;\n iconColor?:\n | \"gray\"\n | \"red\"\n | \"orange\"\n | \"yellow\"\n | \"green\"\n | \"cyan\"\n | \"blue\"\n | \"purple\"\n | \"pink\"\n | undefined;\n instructions?: string | undefined;\n name?: string | undefined;\n };\n }>;\n }) => {\n const project = await getProjectById({ id: input.id });\n if (project === undefined) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Project not found\",\n });\n }\n if (project.userId !== ctx.user.id) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Project not found\",\n });\n }\n await updateProject({ id: input.id, updates: input.updates });\n return { success: true };\n }\n ),\n};\n\nexport const router = createTRPCRouter({ project: projectProcedures });\n",
86
86
  "type": "registry:file",
87
87
  "target": "~/chatjs/plugins/projects/router.ts"
88
88
  },
@@ -98,15 +98,9 @@
98
98
  "type": "registry:file",
99
99
  "target": "~/chatjs/plugins/projects/routes/project-page.tsx"
100
100
  },
101
- {
102
- "path": "src/plugins/projects/src/server-plugin.ts",
103
- "content": "import type { ChatPlugin } from \"@/chatjs/core/installation/plugin\";\nimport { projectRouter } from \"./router\";\n\nexport const projects = () =>\n ({\n id: \"projects\",\n routers: { project: projectRouter },\n }) satisfies ChatPlugin;\n",
104
- "type": "registry:file",
105
- "target": "~/chatjs/plugins/projects/server-plugin.ts"
106
- },
107
101
  {
108
102
  "path": "src/plugins/projects/src/ui/chat-contributions.tsx",
109
- "content": "\"use client\";\nimport { BreadcrumbNavigationLink } from \"@/components/navigation-links\";\nimport React, { useState } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { FolderInput } from \"lucide-react\";\nimport { useSession } from \"@/providers/session-provider\";\nimport { useTRPC } from \"@/trpc/react\";\nimport { MoveMenuItem } from \"./move-menu-item\";\nimport {\n BreadcrumbItem,\n BreadcrumbSeparator,\n} from \"@/components/ui/breadcrumb\";\nimport {\n SidebarGroup,\n SidebarGroupLabel,\n SidebarMenu,\n} from \"@/components/ui/sidebar\";\nimport type { ChatActionProps } from \"@/chatjs/core/chat/contracts\";\nimport { SidebarProjects } from \"./sidebar-projects\";\n\nimport { ProjectIcon } from \"./project-icon\";\nimport { getProjectColorName, getProjectIconName } from \"../project-icons\";\n\nimport { EveMoveProjectDialog } from \"./eve-move-project-dialog\";\n\nexport const ProjectsSidebar = ({\n conversationId,\n allowManagement = true,\n onProjectSelect,\n}: {\n readonly conversationId?: string;\n readonly allowManagement?: boolean;\n readonly onProjectSelect?: (id: string) => void;\n}): React.JSX.Element | null => {\n const { data: session } = useSession();\n return session?.user ? (\n <SidebarGroup className=\"group-data-[collapsible=icon]:hidden\">\n <SidebarGroupLabel>Projects</SidebarGroupLabel>\n <SidebarMenu>\n <SidebarProjects\n conversationId={conversationId}\n allowManagement={allowManagement}\n onProjectSelect={onProjectSelect}\n />\n </SidebarMenu>\n </SidebarGroup>\n ) : null;\n};\n\nexport const ProjectChatActions = ({\n chat,\n}: ChatActionProps): React.JSX.Element | null => {\n const { data: session } = useSession();\n const [open, setOpen] = useState(false);\n if (!session?.user || (chat.state !== undefined && chat.state !== \"bound\")) {\n return null;\n }\n return (\n <>\n <MoveMenuItem\n onActivate={() => {\n setOpen(true);\n }}\n >\n <FolderInput size={16} />\n <span>Move to project</span>\n </MoveMenuItem>\n {open && (\n <EveMoveProjectDialog\n conversation={chat}\n onClose={() => {\n setOpen(false);\n }}\n />\n )}\n </>\n );\n};\n\nexport const ProjectBreadcrumb = ({\n chatId,\n onProjectSelect,\n}: {\n readonly chatId: string;\n readonly onProjectSelect?: (id: string) => void;\n}): React.JSX.Element | null => {\n const { data: session } = useSession();\n const trpc = useTRPC();\n const { data: project } = useQuery(\n trpc.project.forChat.queryOptions(\n { id: chatId },\n { enabled: Boolean(session?.user) }\n )\n );\n if (!project || !session?.user) {\n return null;\n }\n return (\n <>\n <BreadcrumbItem>\n <BreadcrumbNavigationLink\n aria-label={project.name}\n title={project.name}\n href={`/project/${project.id}`}\n onClick={(event) => {\n if (onProjectSelect) {\n event.preventDefault();\n onProjectSelect(project.id);\n }\n }}\n >\n <ProjectIcon\n icon={getProjectIconName(project.icon)}\n color={getProjectColorName(project.iconColor)}\n size={16}\n />\n </BreadcrumbNavigationLink>\n </BreadcrumbItem>\n <BreadcrumbSeparator />\n </>\n );\n};\n",
103
+ "content": "\"use client\";\nimport { BreadcrumbNavigationLink } from \"@/components/navigation-links\";\nimport React, { useState } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { FolderInput } from \"lucide-react\";\nimport { useSession } from \"@/providers/session-provider\";\nimport { useTRPC } from \"@/trpc/react\";\nimport { MoveMenuItem } from \"./move-menu-item\";\nimport {\n BreadcrumbItem,\n BreadcrumbSeparator,\n} from \"@/components/ui/breadcrumb\";\nimport {\n SidebarGroup,\n SidebarGroupLabel,\n SidebarMenu,\n} from \"@/components/ui/sidebar\";\nimport type { ChatActionProps } from \"@/chatjs/core/chat/contracts\";\nimport { SidebarProjects } from \"./sidebar-projects\";\n\nimport { ProjectIcon } from \"./project-icon\";\nimport { getProjectColorName, getProjectIconName } from \"../project-icons\";\n\nimport { EveMoveProjectDialog } from \"./eve-move-project-dialog\";\n\nexport const ProjectsSidebar = ({\n chatId,\n allowManagement = true,\n onProjectSelect,\n}: {\n readonly chatId?: string;\n readonly allowManagement?: boolean;\n readonly onProjectSelect?: (id: string) => void;\n}): React.JSX.Element | null => {\n const { data: session } = useSession();\n return session?.user ? (\n <SidebarGroup className=\"group-data-[collapsible=icon]:hidden\">\n <SidebarGroupLabel>Projects</SidebarGroupLabel>\n <SidebarMenu>\n <SidebarProjects\n chatId={chatId}\n allowManagement={allowManagement}\n onProjectSelect={onProjectSelect}\n />\n </SidebarMenu>\n </SidebarGroup>\n ) : null;\n};\n\nexport const ProjectChatActions = ({\n chat,\n}: ChatActionProps): React.JSX.Element | null => {\n const { data: session } = useSession();\n const [open, setOpen] = useState(false);\n if (!session?.user || (chat.state !== undefined && chat.state !== \"bound\")) {\n return null;\n }\n return (\n <>\n <MoveMenuItem\n onActivate={() => {\n setOpen(true);\n }}\n >\n <FolderInput size={16} />\n <span>Move to project</span>\n </MoveMenuItem>\n {open && (\n <EveMoveProjectDialog\n conversation={chat}\n onClose={() => {\n setOpen(false);\n }}\n />\n )}\n </>\n );\n};\n\nexport const ProjectBreadcrumb = ({\n chatId,\n onProjectSelect,\n}: {\n readonly chatId: string;\n readonly onProjectSelect?: (id: string) => void;\n}): React.JSX.Element | null => {\n const { data: session } = useSession();\n const trpc = useTRPC();\n const { data: project } = useQuery(\n trpc.project.forChat.queryOptions(\n { id: chatId },\n { enabled: Boolean(session?.user) }\n )\n );\n if (!project || !session?.user) {\n return null;\n }\n return (\n <>\n <BreadcrumbItem>\n <BreadcrumbNavigationLink\n aria-label={project.name}\n title={project.name}\n href={`/project/${project.id}`}\n onClick={(event) => {\n if (onProjectSelect) {\n event.preventDefault();\n onProjectSelect(project.id);\n }\n }}\n >\n <ProjectIcon\n icon={getProjectIconName(project.icon)}\n color={getProjectColorName(project.iconColor)}\n size={16}\n />\n </BreadcrumbNavigationLink>\n </BreadcrumbItem>\n <BreadcrumbSeparator />\n </>\n );\n};\n",
110
104
  "type": "registry:file",
111
105
  "target": "~/chatjs/plugins/projects/ui/chat-contributions.tsx"
112
106
  },
@@ -124,7 +118,7 @@
124
118
  },
125
119
  {
126
120
  "path": "src/plugins/projects/src/ui/eve-move-project-dialog.tsx",
127
- "content": "\"use client\";\n\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useRouter } from \"next/navigation\";\nimport type { JSX as ReactJSX } from \"react\";\nimport React, { useId, useState } from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"@/components/ui/dialog\";\nimport { Label } from \"@/components/ui/label\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const EveMoveProjectDialog = ({\n conversation,\n onClose,\n}: {\n readonly conversation: {\n readonly id: string;\n readonly title: string;\n };\n readonly onClose: () => void;\n}): ReactJSX.Element => {\n const trpc = useTRPC();\n const cache = useQueryClient();\n const router = useRouter();\n const fieldId = useId();\n const assigned = useQuery(\n trpc.project.forChat.queryOptions({ id: conversation.id })\n );\n const [selectedProjectId, setSelectedProjectId] = useState<string>();\n const projectId = selectedProjectId ?? assigned.data?.id ?? \"\";\n const projects = useQuery(trpc.project.list.queryOptions());\n const move = useMutation(\n trpc.project.assign.mutationOptions({\n onSuccess: async () => {\n await cache.invalidateQueries({\n queryKey: trpc.project.forChat.pathKey(),\n });\n await Promise.all([\n cache.invalidateQueries({ queryKey: trpc.eve.list.pathKey() }),\n cache.invalidateQueries({ queryKey: trpc.eve.get.pathKey() }),\n ]);\n router.refresh();\n onClose();\n },\n })\n );\n const available =\n !projectId ||\n projects.data?.some(\n (project: { readonly id: string }) => project.id === projectId\n );\n return (\n <Dialog\n onOpenChange={(open) => {\n if (!(open || move.isPending)) {\n onClose();\n }\n }}\n open\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Move to project</DialogTitle>\n <DialogDescription>\n Choose a project for “{conversation.title}”. Its instructions will\n apply to subsequent responses.\n </DialogDescription>\n </DialogHeader>\n <Label htmlFor={fieldId}>Project</Label>\n <select\n className=\"bg-background h-10 w-full rounded-md border px-3 text-sm\"\n disabled={projects.isPending || projects.isError || move.isPending}\n id={fieldId}\n onChange={(event: {\n readonly target: { readonly value: string };\n }) => {\n setSelectedProjectId(event.target.value);\n }}\n value={projectId}\n >\n <option value=\"\">No project</option>\n {!(available === true) && (\n <option disabled value={projectId}>\n Project unavailable\n </option>\n )}\n {projects.data?.map(\n (project: {\n readonly id: string;\n readonly name: string;\n }): React.JSX.Element => (\n <option key={project.id} value={project.id}>\n {project.name}\n </option>\n )\n )}\n </select>\n {projects.isPending && <output>Loading projects…</output>}\n {projects.isError && (\n <div role=\"alert\">\n <p>Could not load projects.</p>\n <Button\n onClick={() => {\n void projects.refetch();\n }}\n variant=\"outline\"\n >\n Retry\n </Button>\n </div>\n )}\n {move.isError && (\n <p role=\"alert\">Could not move the conversation. Try again.</p>\n )}\n <DialogFooter>\n <Button disabled={move.isPending} onClick={onClose} variant=\"outline\">\n Cancel\n </Button>\n <Button\n disabled={\n [\n move.isPending,\n assigned.isPending,\n assigned.isError,\n projects.isPending,\n projects.isError,\n ].includes(true) ||\n !(available === true) ||\n projectId === (assigned.data?.id ?? \"\")\n }\n onClick={() => {\n move.mutate({\n conversationId: conversation.id,\n projectId: projectId || null,\n });\n }}\n >\n {move.isPending ? \"Moving…\" : \"Move\"}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n};\n",
121
+ "content": "\"use client\";\n\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useRouter } from \"next/navigation\";\nimport type { JSX as ReactJSX } from \"react\";\nimport React, { useId, useState } from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"@/components/ui/dialog\";\nimport { Label } from \"@/components/ui/label\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const EveMoveProjectDialog = ({\n conversation,\n onClose,\n}: {\n readonly conversation: {\n readonly id: string;\n readonly title: string;\n };\n readonly onClose: () => void;\n}): ReactJSX.Element => {\n const trpc = useTRPC();\n const cache = useQueryClient();\n const router = useRouter();\n const fieldId = useId();\n const assigned = useQuery(\n trpc.project.forChat.queryOptions({ id: conversation.id })\n );\n const [selectedProjectId, setSelectedProjectId] = useState<string>();\n const projectId = selectedProjectId ?? assigned.data?.id ?? \"\";\n const projects = useQuery(trpc.project.list.queryOptions());\n const move = useMutation(\n trpc.project.assign.mutationOptions({\n onSuccess: async () => {\n await cache.invalidateQueries({\n queryKey: trpc.project.forChat.pathKey(),\n });\n await Promise.all([\n cache.invalidateQueries({ queryKey: trpc.eve.list.pathKey() }),\n cache.invalidateQueries({ queryKey: trpc.eve.get.pathKey() }),\n ]);\n router.refresh();\n onClose();\n },\n })\n );\n const available =\n !projectId ||\n projects.data?.some(\n (project: { readonly id: string }) => project.id === projectId\n );\n return (\n <Dialog\n onOpenChange={(open) => {\n if (!(open || move.isPending)) {\n onClose();\n }\n }}\n open\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Move to project</DialogTitle>\n <DialogDescription>\n Choose a project for “{conversation.title}”. Its instructions will\n apply to subsequent responses.\n </DialogDescription>\n </DialogHeader>\n <Label htmlFor={fieldId}>Project</Label>\n <select\n className=\"bg-background h-10 w-full rounded-md border px-3 text-sm\"\n disabled={projects.isPending || projects.isError || move.isPending}\n id={fieldId}\n onChange={(event: {\n readonly target: { readonly value: string };\n }) => {\n setSelectedProjectId(event.target.value);\n }}\n value={projectId}\n >\n <option value=\"\">No project</option>\n {!(available === true) && (\n <option disabled value={projectId}>\n Project unavailable\n </option>\n )}\n {projects.data?.map(\n (project: {\n readonly id: string;\n readonly name: string;\n }): React.JSX.Element => (\n <option key={project.id} value={project.id}>\n {project.name}\n </option>\n )\n )}\n </select>\n {projects.isPending && <output>Loading projects…</output>}\n {projects.isError && (\n <div role=\"alert\">\n <p>Could not load projects.</p>\n <Button\n onClick={() => {\n void projects.refetch();\n }}\n variant=\"outline\"\n >\n Retry\n </Button>\n </div>\n )}\n {move.isError && (\n <p role=\"alert\">Could not move the conversation. Try again.</p>\n )}\n <DialogFooter>\n <Button disabled={move.isPending} onClick={onClose} variant=\"outline\">\n Cancel\n </Button>\n <Button\n disabled={\n [\n move.isPending,\n assigned.isPending,\n assigned.isError,\n projects.isPending,\n projects.isError,\n ].includes(true) ||\n !(available === true) ||\n projectId === (assigned.data?.id ?? \"\")\n }\n onClick={() => {\n move.mutate({\n id: conversation.id,\n projectId: projectId || null,\n });\n }}\n >\n {move.isPending ? \"Moving…\" : \"Move\"}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n};\n",
128
122
  "type": "registry:file",
129
123
  "target": "~/chatjs/plugins/projects/ui/eve-move-project-dialog.tsx"
130
124
  },
@@ -190,7 +184,7 @@
190
184
  },
191
185
  {
192
186
  "path": "src/plugins/projects/src/ui/sidebar-projects.tsx",
193
- "content": "\"use client\";\n\nimport React, { useState } from \"react\";\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\n\nimport { usePathname, useRouter } from \"next/navigation\";\n\nimport { FolderPlus } from \"lucide-react\";\n\nimport type { ProjectDetailsData } from \"@/chatjs/plugins/projects/ui/project-details-dialog\";\n\nimport { ProjectDetailsDialog } from \"@/chatjs/plugins/projects/ui/project-details-dialog\";\n\nimport type { JSX as ReactJSX } from \"react\";\nimport { SidebarProjectItem } from \"@/chatjs/plugins/projects/ui/sidebar-project-item\";\n\nimport {\n SidebarMenuButton,\n SidebarMenuItem,\n useSidebar,\n} from \"@/components/ui/sidebar\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\n\nimport { parseChatIdFromPathname } from \"@/providers/parse-chat-id-from-pathname\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const SidebarProjects = ({\n conversationId,\n allowManagement = true,\n onProjectSelect,\n}: {\n readonly conversationId?: string;\n readonly allowManagement?: boolean;\n readonly onProjectSelect?: (id: string) => void;\n}): ReactJSX.Element => {\n const pathname = usePathname();\n const router = useRouter();\n const trpc = useTRPC();\n const queryClient = useQueryClient();\n const { setOpenMobile } = useSidebar();\n const { data: projects, isLoading } = useQuery(\n trpc.project.list.queryOptions()\n );\n const [newProjectDialogOpen, setNewProjectDialogOpen] = useState(false);\n\n const route = parseChatIdFromPathname(pathname);\n const activeConversationId = conversationId ?? route.id;\n const membership = useQuery(\n trpc.project.forChat.queryOptions(\n { id: activeConversationId ?? \"\" },\n { enabled: Boolean(activeConversationId) }\n )\n );\n const currentProjectId =\n (route.pluginId === \"projects\" ? route.contextId : null) ??\n membership.data?.id;\n\n const createProjectMutation = useMutation(\n trpc.project.create.mutationOptions({\n onSuccess: (data: Readonly<{ id: string }>) => {\n void queryClient.invalidateQueries({\n queryKey: trpc.project.list.queryKey(),\n });\n setNewProjectDialogOpen(false);\n setOpenMobile(false);\n if (onProjectSelect) {\n onProjectSelect(data.id);\n } else {\n router.push(`/project/${data.id}`);\n }\n },\n })\n );\n\n const handleCreateProject = async (\n data: ProjectDetailsData\n ): Promise<void> => {\n await createProjectMutation.mutateAsync({\n icon: data.icon,\n iconColor: data.color,\n name: data.name,\n });\n };\n return (\n <>\n {allowManagement && (\n <SidebarMenuItem>\n <SidebarMenuButton\n className=\"cursor-pointer\"\n onClick={() => {\n setNewProjectDialogOpen(true);\n }}\n >\n <FolderPlus className=\"size-4\" />\n <span>New project</span>\n </SidebarMenuButton>\n </SidebarMenuItem>\n )}\n {!isLoading &&\n projects?.map(\n (\n project: ReadonlyNativeSurface<NonNullable<typeof projects>[number]>\n ) => {\n const isActive = currentProjectId === project.id;\n return (\n <SidebarProjectItem\n allowManagement={allowManagement}\n onSelect={onProjectSelect}\n isActive={isActive}\n key={project.id}\n project={project}\n setOpenMobile={setOpenMobile}\n />\n );\n }\n )}\n\n {allowManagement && (\n <ProjectDetailsDialog\n isLoading={createProjectMutation.isPending}\n mode=\"create\"\n onOpenChange={setNewProjectDialogOpen}\n onSubmit={handleCreateProject}\n open={newProjectDialogOpen}\n />\n )}\n </>\n );\n};\n",
187
+ "content": "\"use client\";\n\nimport React, { useState } from \"react\";\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\n\nimport { useParams, useRouter } from \"next/navigation\";\n\nimport { FolderPlus } from \"lucide-react\";\n\nimport type { ProjectDetailsData } from \"@/chatjs/plugins/projects/ui/project-details-dialog\";\n\nimport { ProjectDetailsDialog } from \"@/chatjs/plugins/projects/ui/project-details-dialog\";\n\nimport type { JSX as ReactJSX } from \"react\";\nimport { SidebarProjectItem } from \"@/chatjs/plugins/projects/ui/sidebar-project-item\";\n\nimport {\n SidebarMenuButton,\n SidebarMenuItem,\n useSidebar,\n} from \"@/components/ui/sidebar\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\n\nimport { useActiveChatId } from \"@/components/chat/chat-navigation\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const SidebarProjects = ({\n chatId,\n allowManagement = true,\n onProjectSelect,\n}: {\n readonly chatId?: string;\n readonly allowManagement?: boolean;\n readonly onProjectSelect?: (id: string) => void;\n}): ReactJSX.Element => {\n const params = useParams();\n const router = useRouter();\n const trpc = useTRPC();\n const queryClient = useQueryClient();\n const { setOpenMobile } = useSidebar();\n const { data: projects, isLoading } = useQuery(\n trpc.project.list.queryOptions()\n );\n const [newProjectDialogOpen, setNewProjectDialogOpen] = useState(false);\n\n const routeChatId = useActiveChatId();\n const activeChatId = chatId ?? routeChatId;\n const membership = useQuery(\n trpc.project.forChat.queryOptions(\n { id: activeChatId ?? \"\" },\n { enabled: Boolean(activeChatId) }\n )\n );\n const currentProjectId =\n typeof params?.projectId === \"string\"\n ? params.projectId\n : membership.data?.id;\n\n const createProjectMutation = useMutation(\n trpc.project.create.mutationOptions({\n onSuccess: (data: Readonly<{ id: string }>) => {\n void queryClient.invalidateQueries({\n queryKey: trpc.project.list.queryKey(),\n });\n setNewProjectDialogOpen(false);\n setOpenMobile(false);\n if (onProjectSelect) {\n onProjectSelect(data.id);\n } else {\n router.push(`/project/${data.id}`);\n }\n },\n })\n );\n\n const handleCreateProject = async (\n data: ProjectDetailsData\n ): Promise<void> => {\n await createProjectMutation.mutateAsync({\n icon: data.icon,\n iconColor: data.color,\n name: data.name,\n });\n };\n return (\n <>\n {allowManagement && (\n <SidebarMenuItem>\n <SidebarMenuButton\n className=\"cursor-pointer\"\n onClick={() => {\n setNewProjectDialogOpen(true);\n }}\n >\n <FolderPlus className=\"size-4\" />\n <span>New project</span>\n </SidebarMenuButton>\n </SidebarMenuItem>\n )}\n {!isLoading &&\n projects?.map(\n (\n project: ReadonlyNativeSurface<NonNullable<typeof projects>[number]>\n ) => {\n const isActive = currentProjectId === project.id;\n return (\n <SidebarProjectItem\n allowManagement={allowManagement}\n onSelect={onProjectSelect}\n isActive={isActive}\n key={project.id}\n project={project}\n setOpenMobile={setOpenMobile}\n />\n );\n }\n )}\n\n {allowManagement && (\n <ProjectDetailsDialog\n isLoading={createProjectMutation.isPending}\n mode=\"create\"\n onOpenChange={setNewProjectDialogOpen}\n onSubmit={handleCreateProject}\n open={newProjectDialogOpen}\n />\n )}\n </>\n );\n};\n",
194
188
  "type": "registry:file",
195
189
  "target": "~/chatjs/plugins/projects/ui/sidebar-projects.tsx"
196
190
  },
@@ -202,42 +196,44 @@
202
196
  },
203
197
  {
204
198
  "path": "src/plugins/projects/adapters/agent/hooks/projects.ts",
205
- "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/chatjs.json.\nexport { default } from \"@/chatjs/plugins/projects/conversation-hook\";\n",
199
+ "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/plugin.json.\nexport { default } from \"@/chatjs/plugins/projects/conversation-hook\";\n",
206
200
  "type": "registry:file",
207
201
  "target": "~/agent/hooks/projects.ts"
208
202
  },
209
203
  {
210
204
  "path": "src/plugins/projects/adapters/agent/instructions/projects.ts",
211
- "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/chatjs.json.\nexport { default } from \"@/chatjs/plugins/projects/instructions\";\n",
205
+ "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/plugin.json.\nexport { default } from \"@/chatjs/plugins/projects/instructions\";\n",
212
206
  "type": "registry:file",
213
207
  "target": "~/agent/instructions/projects.ts"
214
208
  },
215
209
  {
216
210
  "path": "src/plugins/projects/adapters/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx",
217
- "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/chatjs.json.\nexport { default } from \"@/chatjs/plugins/projects/routes/project-chat-page\";\n",
211
+ "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/plugin.json.\nexport { default } from \"@/chatjs/plugins/projects/routes/project-chat-page\";\n",
218
212
  "type": "registry:file",
219
213
  "target": "~/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx"
220
214
  },
221
215
  {
222
216
  "path": "src/plugins/projects/adapters/app/(chat)/project/[projectId]/page.tsx",
223
- "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/chatjs.json.\nexport { default } from \"@/chatjs/plugins/projects/routes/project-page\";\n",
217
+ "content": "// ChatJS source: projects. Ownership: chatjs/plugins/projects/plugin.json.\nexport { default } from \"@/chatjs/plugins/projects/routes/project-page\";\n",
224
218
  "type": "registry:file",
225
219
  "target": "~/app/(chat)/project/[projectId]/page.tsx"
226
220
  },
227
221
  {
228
222
  "path": "dist/source/projects.json",
229
- "content": "{\n \"id\": \"projects\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/projects/chat.ts\",\n \"chatjs/plugins/projects/client-plugin.ts\",\n \"chatjs/plugins/projects/conversation-hook.ts\",\n \"chatjs/plugins/projects/creation.ts\",\n \"chatjs/plugins/projects/db/project-queries.ts\",\n \"chatjs/plugins/projects/db/project-schema.ts\",\n \"chatjs/plugins/projects/instructions-state.ts\",\n \"chatjs/plugins/projects/instructions.ts\",\n \"chatjs/plugins/projects/project-icons.ts\",\n \"chatjs/plugins/projects/router.ts\",\n \"chatjs/plugins/projects/routes/project-chat-page.tsx\",\n \"chatjs/plugins/projects/routes/project-page.tsx\",\n \"chatjs/plugins/projects/server-plugin.ts\",\n \"chatjs/plugins/projects/ui/chat-contributions.tsx\",\n \"chatjs/plugins/projects/ui/move-menu-item.tsx\",\n \"chatjs/plugins/projects/ui/delete-project-dialog.tsx\",\n \"chatjs/plugins/projects/ui/eve-move-project-dialog.tsx\",\n \"chatjs/plugins/projects/ui/eve-project-home.tsx\",\n \"chatjs/plugins/projects/ui/project-chat-item.tsx\",\n \"chatjs/plugins/projects/ui/project-config.tsx\",\n \"chatjs/plugins/projects/ui/project-details-dialog.tsx\",\n \"chatjs/plugins/projects/ui/project-history.tsx\",\n \"chatjs/plugins/projects/ui/project-icon-picker.tsx\",\n \"chatjs/plugins/projects/ui/project-icon.tsx\",\n \"chatjs/plugins/projects/ui/project-instructions-dialog.tsx\",\n \"chatjs/plugins/projects/ui/project-menu-items.tsx\",\n \"chatjs/plugins/projects/ui/sidebar-project-item.tsx\",\n \"chatjs/plugins/projects/ui/sidebar-projects.tsx\",\n \"chatjs/plugins/projects/use-projects.ts\",\n \"agent/hooks/projects.ts\",\n \"agent/instructions/projects.ts\",\n \"app/(chat)/project/[projectId]/chat/[chatId]/page.tsx\",\n \"app/(chat)/project/[projectId]/page.tsx\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/projects/db/project-schema.ts\"],\n \"chat\": { \"export\": \"projectsChat\" },\n \"server\": { \"export\": \"projects\", \"routers\": [\"project\"] },\n \"client\": {\n \"export\": \"projectsClient\",\n \"composerControls\": [],\n \"settingsItems\": [],\n \"chat\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
223
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\n \"id\": \"projects\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/projects/chat-server.ts\",\n \"chatjs/plugins/projects/chat-ui.ts\",\n \"chatjs/plugins/projects/conversation-hook.ts\",\n \"chatjs/plugins/projects/creation.ts\",\n \"chatjs/plugins/projects/db/project-queries.ts\",\n \"chatjs/plugins/projects/db/project-schema.ts\",\n \"chatjs/plugins/projects/instructions-state.ts\",\n \"chatjs/plugins/projects/instructions.ts\",\n \"chatjs/plugins/projects/project-icons.ts\",\n \"chatjs/plugins/projects/router.ts\",\n \"chatjs/plugins/projects/routes/project-chat-page.tsx\",\n \"chatjs/plugins/projects/routes/project-page.tsx\",\n \"chatjs/plugins/projects/ui/chat-contributions.tsx\",\n \"chatjs/plugins/projects/ui/move-menu-item.tsx\",\n \"chatjs/plugins/projects/ui/delete-project-dialog.tsx\",\n \"chatjs/plugins/projects/ui/eve-move-project-dialog.tsx\",\n \"chatjs/plugins/projects/ui/eve-project-home.tsx\",\n \"chatjs/plugins/projects/ui/project-chat-item.tsx\",\n \"chatjs/plugins/projects/ui/project-config.tsx\",\n \"chatjs/plugins/projects/ui/project-details-dialog.tsx\",\n \"chatjs/plugins/projects/ui/project-history.tsx\",\n \"chatjs/plugins/projects/ui/project-icon-picker.tsx\",\n \"chatjs/plugins/projects/ui/project-icon.tsx\",\n \"chatjs/plugins/projects/ui/project-instructions-dialog.tsx\",\n \"chatjs/plugins/projects/ui/project-menu-items.tsx\",\n \"chatjs/plugins/projects/ui/sidebar-project-item.tsx\",\n \"chatjs/plugins/projects/ui/sidebar-projects.tsx\",\n \"chatjs/plugins/projects/use-projects.ts\",\n \"agent/hooks/projects.ts\",\n \"agent/instructions/projects.ts\",\n \"app/(chat)/project/[projectId]/chat/[chatId]/page.tsx\",\n \"app/(chat)/project/[projectId]/page.tsx\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/projects/db/project-schema.ts\"]\n}\n",
230
224
  "type": "registry:file",
231
- "target": "~/chatjs/plugins/projects/chatjs.json"
225
+ "target": "~/chatjs/plugins/projects/plugin.json"
232
226
  }
233
227
  ],
234
228
  "meta": {
235
229
  "chatjs": {
230
+ "contractVersion": 3,
231
+ "uiBase": "base",
236
232
  "id": "projects",
237
233
  "kind": "plugin",
238
234
  "files": [
239
- "chatjs/plugins/projects/chat.ts",
240
- "chatjs/plugins/projects/client-plugin.ts",
235
+ "chatjs/plugins/projects/chat-server.ts",
236
+ "chatjs/plugins/projects/chat-ui.ts",
241
237
  "chatjs/plugins/projects/conversation-hook.ts",
242
238
  "chatjs/plugins/projects/creation.ts",
243
239
  "chatjs/plugins/projects/db/project-queries.ts",
@@ -248,7 +244,6 @@
248
244
  "chatjs/plugins/projects/router.ts",
249
245
  "chatjs/plugins/projects/routes/project-chat-page.tsx",
250
246
  "chatjs/plugins/projects/routes/project-page.tsx",
251
- "chatjs/plugins/projects/server-plugin.ts",
252
247
  "chatjs/plugins/projects/ui/chat-contributions.tsx",
253
248
  "chatjs/plugins/projects/ui/move-menu-item.tsx",
254
249
  "chatjs/plugins/projects/ui/delete-project-dialog.tsx",
@@ -272,24 +267,7 @@
272
267
  ],
273
268
  "databaseSchemas": [
274
269
  "chatjs/plugins/projects/db/project-schema.ts"
275
- ],
276
- "chat": {
277
- "export": "projectsChat"
278
- },
279
- "server": {
280
- "export": "projects",
281
- "routers": [
282
- "project"
283
- ]
284
- },
285
- "client": {
286
- "export": "projectsClient",
287
- "composerControls": [],
288
- "settingsItems": [],
289
- "chat": true
290
- },
291
- "contractVersion": 2,
292
- "uiBase": "base"
270
+ ]
293
271
  }
294
272
  },
295
273
  "type": "registry:item"
@@ -7,43 +7,40 @@
7
7
  ],
8
8
  "files": [
9
9
  {
10
- "path": "src/plugins/ai-titles/src/chat.ts",
11
- "content": "import type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\n\nexport const aiTitlesChat = {\n afterCreate: async (context) => {\n const { persistGeneratedEveConversationTitle } =\n await import(\"./generate-title\");\n await persistGeneratedEveConversationTitle(context);\n },\n} satisfies ChatServerIntegration;\n",
10
+ "path": "src/plugins/ai-titles/src/chat-server.ts",
11
+ "content": "import type { ChatServerIntegration } from \"@/chatjs/core/chat/contracts\";\n\nconst aiTitlesChat = {\n afterCreate: async (context) => {\n const { persistGeneratedEveConversationTitle } =\n await import(\"./generate-title\");\n await persistGeneratedEveConversationTitle(context);\n },\n} satisfies ChatServerIntegration;\n\nexport default aiTitlesChat;\n",
12
12
  "type": "registry:file",
13
- "target": "~/chatjs/plugins/ai-titles/chat.ts"
13
+ "target": "~/chatjs/plugins/ai-titles/chat-server.ts"
14
14
  },
15
15
  {
16
16
  "path": "src/plugins/ai-titles/src/generate-title.ts",
17
- "content": "import { settleEveRootFallbackTitle } from \"@/lib/db/eve-title\";\nimport { generateText } from \"ai\";\n\nimport { getLanguageModel } from \"@/lib/ai/providers\";\nimport { config } from \"@/lib/config\";\nimport {\n isEveRootTitlePending,\n replaceEveRootFallbackTitle,\n} from \"./title-queries\";\nimport { createModuleLogger } from \"@/lib/logger\";\n\nimport {\n compactTitle,\n eveConversationTitleFallback,\n} from \"@/lib/eve/conversation-title\";\nimport type { ReadonlyEveMessageInput } from \"@/lib/eve/readonly-message-types\";\n\nconst TITLE_GENERATION_TIMEOUT_MS = 15_000;\nconst surroundingQuotes = /^[\\s\"'“”‘’]+|[\\s\"'“”‘’]+$/gu;\nconst log = createModuleLogger(\"eve.ai-titles\");\ntype EveTitleResult =\n | { source: \"generated\"; title: string }\n | { source: \"fallback\"; title: string };\n\nconst normalizeGeneratedTitle = (title: string): string =>\n compactTitle(title.replace(surroundingQuotes, \"\"));\n\n/**\n * Auxiliary title generation must never prevent a conversation from starting.\n * @param {ReadonlyEveMessageInput} message First user message supplied to the auxiliary title model.\n * @returns {Promise<EveTitleResult>} A normalized generated title, or its message-derived fallback if generation fails or is empty.\n */\nconst generateEveConversationTitleResult = async (\n message: ReadonlyEveMessageInput\n): Promise<EveTitleResult> => {\n const fallback = eveConversationTitleFallback(message);\n try {\n const { text } = await generateText({\n abortSignal: AbortSignal.timeout(TITLE_GENERATION_TIMEOUT_MS),\n instructions: `Generate a concise title for a chat conversation based on the user's first message.\n\nRules (strictly follow all):\n- Maximum 40 characters — hard limit, never exceed this\n- 3-6 words is ideal\n- No quotes, colons, or punctuation at the end\n- No filler words like \"How to\" or \"Question about\"\n- Use title case\n- Return ONLY the title, nothing else`,\n maxRetries: 0,\n model: await getLanguageModel(config.ai.workflows.title),\n prompt: JSON.stringify(message),\n });\n const title = normalizeGeneratedTitle(text);\n\n if (title) {\n return { source: \"generated\", title };\n }\n return { source: \"fallback\", title: fallback };\n } catch {\n return { source: \"fallback\", title: fallback };\n }\n};\nconst persistGeneratedEveConversationTitle = async ({\n conversationId,\n message,\n ownerId,\n}: Readonly<{\n conversationId: string;\n message: ReadonlyEveMessageInput;\n ownerId: string;\n}>): Promise<EveTitleResult | undefined> => {\n const fallbackTitle = eveConversationTitleFallback(message);\n try {\n if (\n !(await isEveRootTitlePending(ownerId, conversationId, fallbackTitle))\n ) {\n return undefined;\n }\n } catch (error) {\n log.warn(\n {\n conversationId,\n errorName: error instanceof Error ? error.name : typeof error,\n },\n \"Eve title eligibility check failed\"\n );\n return undefined;\n }\n const generated = await generateEveConversationTitleResult(message);\n try {\n await (generated.source === \"generated\"\n ? replaceEveRootFallbackTitle(\n ownerId,\n conversationId,\n fallbackTitle,\n generated.title\n )\n : settleEveRootFallbackTitle(ownerId, conversationId, fallbackTitle));\n } catch (error) {\n log.warn(\n {\n conversationId,\n errorName: error instanceof Error ? error.name : typeof error,\n },\n \"Eve title persistence failed\"\n );\n }\n return generated;\n};\nexport {\n generateEveConversationTitleResult,\n persistGeneratedEveConversationTitle,\n};\n",
17
+ "content": "import { settleEveRootFallbackTitle } from \"@/lib/db/eve-title\";\nimport { generateText } from \"ai\";\n\nimport { getLanguageModel } from \"@/lib/ai/providers\";\nimport { config } from \"@/lib/config\";\nimport {\n isEveRootTitlePending,\n replaceEveRootFallbackTitle,\n} from \"./title-queries\";\nimport { createModuleLogger } from \"@/lib/logger\";\n\nimport {\n compactTitle,\n eveConversationTitleFallback,\n} from \"@/lib/eve/conversation-title\";\nimport type { ReadonlyEveMessageInput } from \"@/lib/eve/readonly-message-types\";\n\nconst TITLE_GENERATION_TIMEOUT_MS = 15_000;\nconst surroundingQuotes = /^[\\s\"'“”‘’]+|[\\s\"'“”‘’]+$/gu;\nconst log = createModuleLogger(\"eve.ai-titles\");\ntype EveTitleResult =\n | { source: \"generated\"; title: string }\n | { source: \"fallback\"; title: string };\n\nconst normalizeGeneratedTitle = (title: string): string =>\n compactTitle(title.replace(surroundingQuotes, \"\"));\n\n/**\n * Auxiliary title generation must never prevent a conversation from starting.\n * @param {ReadonlyEveMessageInput} message First user message supplied to the auxiliary title model.\n * @returns {Promise<EveTitleResult>} A normalized generated title, or its message-derived fallback if generation fails or is empty.\n */\nconst generateEveConversationTitleResult = async (\n message: ReadonlyEveMessageInput\n): Promise<EveTitleResult> => {\n const fallback = eveConversationTitleFallback(message);\n try {\n const { text } = await generateText({\n abortSignal: AbortSignal.timeout(TITLE_GENERATION_TIMEOUT_MS),\n instructions: `Generate a concise title for a chat conversation based on the user's first message.\n\nRules (strictly follow all):\n- Maximum 40 characters — hard limit, never exceed this\n- 3-6 words is ideal\n- No quotes, colons, or punctuation at the end\n- No filler words like \"How to\" or \"Question about\"\n- Use title case\n- Return ONLY the title, nothing else`,\n maxRetries: 0,\n model: await getLanguageModel(config.ai.workflows.title),\n prompt: JSON.stringify(message),\n });\n const title = normalizeGeneratedTitle(text);\n\n if (title) {\n return { source: \"generated\", title };\n }\n return { source: \"fallback\", title: fallback };\n } catch {\n return { source: \"fallback\", title: fallback };\n }\n};\nconst persistGeneratedEveConversationTitle = async ({\n branchId,\n message,\n ownerId,\n}: Readonly<{\n branchId: string;\n message: ReadonlyEveMessageInput;\n ownerId: string;\n}>): Promise<EveTitleResult | undefined> => {\n const fallbackTitle = eveConversationTitleFallback(message);\n try {\n if (!(await isEveRootTitlePending(ownerId, branchId, fallbackTitle))) {\n return undefined;\n }\n } catch (error) {\n log.warn(\n {\n branchId,\n errorName: error instanceof Error ? error.name : typeof error,\n },\n \"Eve title eligibility check failed\"\n );\n return undefined;\n }\n const generated = await generateEveConversationTitleResult(message);\n try {\n await (generated.source === \"generated\"\n ? replaceEveRootFallbackTitle(\n ownerId,\n branchId,\n fallbackTitle,\n generated.title\n )\n : settleEveRootFallbackTitle(ownerId, branchId, fallbackTitle));\n } catch (error) {\n log.warn(\n {\n branchId,\n errorName: error instanceof Error ? error.name : typeof error,\n },\n \"Eve title persistence failed\"\n );\n }\n return generated;\n};\nexport {\n generateEveConversationTitleResult,\n persistGeneratedEveConversationTitle,\n};\n",
18
18
  "type": "registry:file",
19
19
  "target": "~/chatjs/plugins/ai-titles/generate-title.ts"
20
20
  },
21
21
  {
22
22
  "path": "src/plugins/ai-titles/src/title-queries.ts",
23
- "content": "import { and, eq } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveChat, eveConversation } from \"@/lib/db/schema\";\n\nconst SINGLE_MATCH_LIMIT = 1;\nconst isEveRootTitlePending = async (\n ownerId: string,\n conversationId: string,\n fallbackTitle: string\n): Promise<boolean> => {\n const [row] = await db\n .select({ id: eveChat.id })\n .from(eveConversation)\n .innerJoin(\n eveChat,\n and(\n eq(eveChat.id, eveConversation.chatId),\n eq(eveChat.ownerId, eveConversation.ownerId)\n )\n )\n .where(\n and(\n eq(eveConversation.id, conversationId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\"),\n eq(eveChat.title, fallbackTitle),\n eq(eveChat.titleStatus, \"pending\")\n )\n )\n .limit(SINGLE_MATCH_LIMIT);\n return Boolean(row);\n};\n\nconst replaceEveRootFallbackTitle = async (\n ownerId: string,\n conversationId: string,\n fallbackTitle: string,\n generatedTitle: string\n): Promise<boolean> => {\n const [row] = await db\n .update(eveChat)\n .set({ title: generatedTitle, titleStatus: \"generated\" })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.id, conversationId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\"),\n eq(eveChat.id, eveConversation.chatId),\n eq(eveChat.ownerId, ownerId),\n eq(eveChat.title, fallbackTitle),\n eq(eveChat.titleStatus, \"pending\")\n )\n )\n .returning({ id: eveChat.id });\n return Boolean(row);\n};\n\nexport { isEveRootTitlePending, replaceEveRootFallbackTitle };\n",
23
+ "content": "import { and, eq } from \"drizzle-orm\";\nimport { db } from \"@/lib/db/client\";\nimport { eveChat, eveConversation } from \"@/lib/db/schema\";\n\nconst SINGLE_MATCH_LIMIT = 1;\nconst isEveRootTitlePending = async (\n ownerId: string,\n branchId: string,\n fallbackTitle: string\n): Promise<boolean> => {\n const [row] = await db\n .select({ id: eveChat.id })\n .from(eveConversation)\n .innerJoin(\n eveChat,\n and(\n eq(eveChat.id, eveConversation.chatId),\n eq(eveChat.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(eveChat.title, fallbackTitle),\n eq(eveChat.titleStatus, \"pending\")\n )\n )\n .limit(SINGLE_MATCH_LIMIT);\n return Boolean(row);\n};\n\nconst replaceEveRootFallbackTitle = async (\n ownerId: string,\n branchId: string,\n fallbackTitle: string,\n generatedTitle: string\n): Promise<boolean> => {\n const [row] = await db\n .update(eveChat)\n .set({ title: generatedTitle, titleStatus: \"generated\" })\n .from(eveConversation)\n .where(\n and(\n eq(eveConversation.id, branchId),\n eq(eveConversation.ownerId, ownerId),\n eq(eveConversation.state, \"bound\"),\n eq(eveChat.id, eveConversation.chatId),\n eq(eveChat.ownerId, ownerId),\n eq(eveChat.title, fallbackTitle),\n eq(eveChat.titleStatus, \"pending\")\n )\n )\n .returning({ id: eveChat.id });\n return Boolean(row);\n};\n\nexport { isEveRootTitlePending, replaceEveRootFallbackTitle };\n",
24
24
  "type": "registry:file",
25
25
  "target": "~/chatjs/plugins/ai-titles/title-queries.ts"
26
26
  },
27
27
  {
28
28
  "path": "dist/source/ai-titles.json",
29
- "content": "{\n \"id\": \"ai-titles\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/ai-titles/chat.ts\",\n \"chatjs/plugins/ai-titles/generate-title.ts\",\n \"chatjs/plugins/ai-titles/title-queries.ts\"\n ],\n \"chat\": { \"export\": \"aiTitlesChat\" },\n \"contractVersion\": 1\n}\n",
29
+ "content": "{\n \"contractVersion\": 3,\n \"id\": \"ai-titles\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/ai-titles/chat-server.ts\",\n \"chatjs/plugins/ai-titles/generate-title.ts\",\n \"chatjs/plugins/ai-titles/title-queries.ts\"\n ]\n}\n",
30
30
  "type": "registry:file",
31
- "target": "~/chatjs/plugins/ai-titles/chatjs.json"
31
+ "target": "~/chatjs/plugins/ai-titles/plugin.json"
32
32
  }
33
33
  ],
34
34
  "meta": {
35
35
  "chatjs": {
36
+ "contractVersion": 3,
36
37
  "id": "ai-titles",
37
38
  "kind": "plugin",
38
39
  "files": [
39
- "chatjs/plugins/ai-titles/chat.ts",
40
+ "chatjs/plugins/ai-titles/chat-server.ts",
40
41
  "chatjs/plugins/ai-titles/generate-title.ts",
41
42
  "chatjs/plugins/ai-titles/title-queries.ts"
42
- ],
43
- "chat": {
44
- "export": "aiTitlesChat"
45
- },
46
- "contractVersion": 1
43
+ ]
47
44
  }
48
45
  },
49
46
  "type": "registry:item"
@@ -10,7 +10,7 @@
10
10
  "files": [
11
11
  {
12
12
  "path": "src/tools/attach-workspace-file/tool.ts",
13
- "content": "import { defineTool, toolOutput } from \"eve/tools\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\nimport { attachConversationFile } from \"./attach-conversation-file\";\nimport {\n attachWorkspaceFileInput,\n attachWorkspaceFileResult,\n importFileInput,\n importFileResult,\n} from \"./schemas\";\nimport { importStoredFile } from \"./import\";\nimport { withEveConversationFile } from \"@/lib/db/eve-files\";\nimport { downloadFile, getFileMetadata } from \"@/lib/file-storage\";\n\nexport const attach_workspace_file = defineTool({\n description:\n \"Attach a finished workspace file to the current ChatJS conversation as a downloadable artifact. Creates a new durable snapshot; later sandbox edits do not change it. Use for user-requested deliverables, not intermediate files. To revise an earlier artifact, import_file using its exact fileId, edit the workspace copy with native tools, then attach_workspace_file again. Earlier downloads remain unchanged. Maximum 32 MiB. Delegated agents return the file path to the parent so it can attach the file.\",\n inputSchema: attachWorkspaceFileInput,\n outputSchema: attachWorkspaceFileResult,\n availableInSubagents: false,\n async execute(input, context) {\n return await attachConversationFile(input, context);\n },\n toModelOutput: (output) => toolOutput.json(output),\n});\n\nexport const import_file = defineTool({\n description:\n \"Import a published artifact or uploaded file referenced in the current ChatJS conversation into the current EVE workspace. Use before revising an earlier file, including after its original sandbox is gone. Supply its exact fileId and filename from conversation history; ask the user to identify or upload the file if ambiguous. Returns a fresh local copy. Edit it with native tools and attach_workspace_file to deliver a new snapshot. The original is never changed. Maximum 32 MiB.\",\n inputSchema: importFileInput,\n outputSchema: importFileResult,\n availableInSubagents: false,\n async execute(input, context) {\n const { current, initiator } = context.session.auth;\n if (\n context.session.parent ||\n current?.authenticator !== \"chatjs-gateway\" ||\n current.principalId !== initiator?.principalId\n ) {\n throw new Error(\n \"File import requires the current ChatJS conversation owner's authority.\"\n );\n }\n const { ownerId, conversationId } = await resolveEveConversationScope(\n current.principalId,\n context.session.id,\n context.abortSignal\n );\n return await withEveConversationFile(\n ownerId,\n conversationId,\n input.fileId,\n async () =>\n await importStoredFile(input, {\n stat: async () => await getFileMetadata(input.fileId),\n read: async () => await downloadFile(input.fileId),\n getSandbox: async () => await context.getSandbox(),\n signal: context.abortSignal,\n })\n );\n },\n toModelOutput: (output) => toolOutput.json(output),\n});\n",
13
+ "content": "import { defineTool, toolOutput } from \"eve/tools\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\nimport { attachConversationFile } from \"./attach-conversation-file\";\nimport {\n attachWorkspaceFileInput,\n attachWorkspaceFileResult,\n importFileInput,\n importFileResult,\n} from \"./schemas\";\nimport { importStoredFile } from \"./import\";\nimport { withEveConversationFile } from \"@/lib/db/eve-files\";\nimport { downloadFile, getFileMetadata } from \"@/lib/file-storage\";\n\nexport const attach_workspace_file = defineTool({\n description:\n \"Attach a finished workspace file to the current ChatJS conversation as a downloadable artifact. Creates a new durable snapshot; later sandbox edits do not change it. Use for user-requested deliverables, not intermediate files. To revise an earlier artifact, import_file using its exact fileId, edit the workspace copy with native tools, then attach_workspace_file again. Earlier downloads remain unchanged. Maximum 32 MiB. Delegated agents return the file path to the parent so it can attach the file.\",\n inputSchema: attachWorkspaceFileInput,\n outputSchema: attachWorkspaceFileResult,\n availableInSubagents: false,\n async execute(input, context) {\n return await attachConversationFile(input, context);\n },\n toModelOutput: (output) => toolOutput.json(output),\n});\n\nexport const import_file = defineTool({\n description:\n \"Import a published artifact or uploaded file referenced in the current ChatJS conversation into the current EVE workspace. Use before revising an earlier file, including after its original sandbox is gone. Supply its exact fileId and filename from conversation history; ask the user to identify or upload the file if ambiguous. Returns a fresh local copy. Edit it with native tools and attach_workspace_file to deliver a new snapshot. The original is never changed. Maximum 32 MiB.\",\n inputSchema: importFileInput,\n outputSchema: importFileResult,\n availableInSubagents: false,\n async execute(input, context) {\n const { current, initiator } = context.session.auth;\n if (\n context.session.parent ||\n current?.authenticator !== \"chatjs-gateway\" ||\n current.principalId !== initiator?.principalId\n ) {\n throw new Error(\n \"File import requires the current ChatJS conversation owner's authority.\"\n );\n }\n const { ownerId, branchId } = await resolveEveConversationScope(\n current.principalId,\n context.session.id,\n context.abortSignal\n );\n return await withEveConversationFile(\n ownerId,\n branchId,\n input.fileId,\n async () =>\n await importStoredFile(input, {\n stat: async () => await getFileMetadata(input.fileId),\n read: async () => await downloadFile(input.fileId),\n getSandbox: async () => await context.getSandbox(),\n signal: context.abortSignal,\n })\n );\n },\n toModelOutput: (output) => toolOutput.json(output),\n});\n",
14
14
  "type": "registry:file",
15
15
  "target": "~/chatjs/tools/attach-workspace-file/tool.ts"
16
16
  },
@@ -34,7 +34,7 @@
34
34
  },
35
35
  {
36
36
  "path": "src/tools/attach-workspace-file/schemas.ts",
37
- "content": "import { z } from \"zod\";\nimport { isFileStorageKey } from \"@/lib/file-url\";\n\nexport const maximumWorkspaceFileBytes = 32 * 1024 * 1024;\n\nexport const attachWorkspaceFileInput = z.object({\n path: z\n .string()\n .min(1)\n .max(4096)\n .regex(/^[^\\p{Cc}]+$/u)\n .describe(\n \"File in the current EVE sandbox workspace, e.g. /workspace/report.xlsx.\"\n ),\n name: z\n .string()\n .trim()\n .min(1)\n .max(180)\n .regex(/^[^/\\\\\\p{Cc}]+$/u)\n .optional()\n .describe(\"Optional download filename, including its extension.\"),\n});\n\nexport const attachWorkspaceFileResult = z.object({\n fileId: z.string().min(1),\n name: z.string().min(1),\n mediaType: z.string().min(1),\n size: z.number().int().nonnegative().max(maximumWorkspaceFileBytes),\n url: z.string().min(1),\n});\n\nexport const importFileInput = z.object({\n fileId: z\n .string()\n .refine(isFileStorageKey, \"Use a fileId from this conversation.\")\n .describe(\n \"Exact fileId returned by attach_workspace_file, or the storage key in a file attachment URL in this conversation. Never guess a file ID.\"\n ),\n name: attachWorkspaceFileInput.shape.name\n .unwrap()\n .describe(\n \"Filename from the referenced artifact, including its extension.\"\n ),\n});\n\nexport const importFileResult = attachWorkspaceFileResult\n .omit({ url: true })\n .extend({\n path: z.string().min(1),\n });\n",
37
+ "content": "import { z } from \"zod\";\nimport { isFileStorageKey } from \"@/lib/file-url\";\n\nexport const maximumWorkspaceFileBytes = 32 * 1024 * 1024;\n\n// Keep Unicode character validation at runtime so model providers do not have\n// to compile JavaScript Unicode property escapes from the tool's JSON Schema.\nconst controlCharacter = /\\p{Cc}/u;\nconst invalidFilenameCharacter = /[/\\\\\\p{Cc}]/u;\n\nexport const attachWorkspaceFileInput = z.object({\n path: z\n .string()\n .min(1)\n .max(4096)\n .refine(\n (path) => !controlCharacter.test(path),\n \"Path contains a control character.\"\n )\n .describe(\n \"File in the current EVE sandbox workspace, e.g. /workspace/report.xlsx.\"\n ),\n name: z\n .string()\n .trim()\n .min(1)\n .max(180)\n .refine(\n (name) => !invalidFilenameCharacter.test(name),\n \"Filename contains a separator or control character.\"\n )\n .optional()\n .describe(\"Optional download filename, including its extension.\"),\n});\n\nexport const attachWorkspaceFileResult = z.object({\n fileId: z.string().min(1),\n name: z.string().min(1),\n mediaType: z.string().min(1),\n size: z.number().int().nonnegative().max(maximumWorkspaceFileBytes),\n url: z.string().min(1),\n});\n\nexport const importFileInput = z.object({\n fileId: z\n .string()\n .refine(isFileStorageKey, \"Use a fileId from this conversation.\")\n .describe(\n \"Exact fileId returned by attach_workspace_file, or the storage key in a file attachment URL in this conversation. Never guess a file ID.\"\n ),\n name: attachWorkspaceFileInput.shape.name\n .unwrap()\n .describe(\n \"Filename from the referenced artifact, including its extension.\"\n ),\n});\n\nexport const importFileResult = attachWorkspaceFileResult\n .omit({ url: true })\n .extend({\n path: z.string().min(1),\n });\n",
38
38
  "type": "registry:file",
39
39
  "target": "~/chatjs/tools/attach-workspace-file/schemas.ts"
40
40
  },
@@ -15,10 +15,10 @@
15
15
  "target": "~/chatjs/plugins/attachment-uploads/controls.tsx"
16
16
  },
17
17
  {
18
- "path": "src/plugins/attachment-uploads/src/integration.tsx",
18
+ "path": "src/plugins/attachment-uploads/src/uploads.ts",
19
19
  "content": "\"use client\";\n\nimport type {\n AttachmentUploadBehavior,\n AttachmentUploadInput,\n AttachmentUploadIntegration,\n} from \"@/chatjs/core/installation/contracts\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\n\nimport { config } from \"@/lib/config\";\nimport { useSession } from \"@/providers/session-provider\";\n\nimport { uploadAttachment } from \"./upload\";\nimport { processFilesForUpload } from \"./upload-prep\";\n\nconst deliverFiles = async (\n files: readonly File[],\n onUploaded: AttachmentUploadInput[\"onUploaded\"],\n reportError: (message: string) => void\n): Promise<void> => {\n try {\n const result = await processFilesForUpload([...files], config.attachments);\n if (\n result.stillOversized.length > 0 ||\n result.unsupportedFiles.length > 0\n ) {\n reportError(\n \"Some files could not be attached. Use images or PDFs within the upload size limit.\"\n );\n }\n for (const file of result.files) {\n try {\n // oxlint-disable-next-line eslint/no-await-in-loop -- Serialize uploads to preserve order and bound memory.\n const attachment = await uploadAttachment(file);\n onUploaded(attachment);\n } catch (error) {\n reportError(error instanceof Error ? error.message : \"Upload failed.\");\n }\n }\n } catch (error) {\n reportError(error instanceof Error ? error.message : \"Upload failed.\");\n }\n};\n\nexport const useAttachmentUploads = ({\n onError,\n attachmentCount,\n onUploaded,\n}: ReadonlyNativeSurface<AttachmentUploadInput>): AttachmentUploadBehavior => {\n const { data: session } = useSession();\n const [uploadQueue, setUploadQueue] = useState<string[]>([]);\n const [errors, setErrors] = useState<string[]>([]);\n const reportError = (message: string): void => {\n setErrors((current) => [...current, message]);\n onError?.(message);\n };\n const lock = useRef(false);\n const currentCount = useRef(attachmentCount);\n useEffect((): void => {\n currentCount.current = attachmentCount;\n }, [attachmentCount]);\n const enqueue = async (files: readonly File[]): Promise<void> => {\n if (lock.current || files.length === 0) {\n return;\n }\n setErrors([]);\n if (!session?.user) {\n reportError(\"Sign in to attach files.\");\n return;\n }\n if (files.length + currentCount.current > 16) {\n reportError(\"Attach at most 16 files per message.\");\n return;\n }\n lock.current = true;\n setUploadQueue(\n files.map((file: ReadonlyNativeSurface<File>): string => file.name)\n );\n await deliverFiles(\n files,\n (attachment) => {\n currentCount.current += 1;\n onUploaded(attachment);\n },\n reportError\n ).finally(() => {\n lock.current = false;\n setUploadQueue([]);\n });\n };\n return {\n enabled: true,\n busy: uploadQueue.length > 0,\n uploadQueue,\n errors,\n enqueue,\n };\n};\n\nexport const attachmentUploads = {\n useUploads: useAttachmentUploads,\n} satisfies AttachmentUploadIntegration;\n",
20
20
  "type": "registry:file",
21
- "target": "~/chatjs/plugins/attachment-uploads/integration.tsx"
21
+ "target": "~/chatjs/plugins/attachment-uploads/uploads.ts"
22
22
  },
23
23
  {
24
24
  "path": "src/plugins/attachment-uploads/src/upload.ts",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  {
36
36
  "path": "src/plugins/attachment-uploads/adapters/app/(chat)/api/files/upload/route.ts",
37
- "content": "// ChatJS source: attachment-uploads. Ownership: chatjs/plugins/attachment-uploads/chatjs.json.\nexport { POST } from \"@/chatjs/plugins/attachment-uploads/routes/upload\";\n",
37
+ "content": "// ChatJS source: attachment-uploads. Ownership: chatjs/plugins/attachment-uploads/plugin.json.\nexport { POST } from \"@/chatjs/plugins/attachment-uploads/routes/upload\";\n",
38
38
  "type": "registry:file",
39
39
  "target": "~/app/(chat)/api/files/upload/route.ts"
40
40
  },
@@ -45,43 +45,34 @@
45
45
  "target": "~/chatjs/plugins/attachment-uploads/routes/upload.ts"
46
46
  },
47
47
  {
48
- "path": "src/plugins/attachment-uploads/src/client-plugin.ts",
49
- "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { ComposerAttachments } from \"@/components/chat-slots\";\nimport { attachmentUploads } from \"./integration\";\nimport { AttachFilesControl, TakePhotoControl } from \"./controls\";\n\nexport const attachmentUploadsClient = definePlugin({\n id: \"attachment-uploads\",\n slots: [\n slot(ComposerAttachments, AttachFilesControl),\n slot(ComposerAttachments, TakePhotoControl),\n ],\n uploads: attachmentUploads,\n});\n",
48
+ "path": "src/plugins/attachment-uploads/src/chat-ui.ts",
49
+ "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { ComposerAttachments } from \"@/components/chat-slots\";\nimport { AttachFilesControl, TakePhotoControl } from \"./controls\";\n\nexport const chatUi = definePlugin({\n id: \"attachment-uploads\",\n slots: [\n slot(ComposerAttachments, AttachFilesControl),\n slot(ComposerAttachments, TakePhotoControl),\n ],\n});\n",
50
50
  "type": "registry:file",
51
- "target": "~/chatjs/plugins/attachment-uploads/client-plugin.ts"
51
+ "target": "~/chatjs/plugins/attachment-uploads/chat-ui.ts"
52
52
  },
53
53
  {
54
54
  "path": "dist/source/attachment-uploads.json",
55
- "content": "{\n \"id\": \"attachment-uploads\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/attachment-uploads/controls.tsx\",\n \"chatjs/plugins/attachment-uploads/integration.tsx\",\n \"chatjs/plugins/attachment-uploads/upload.ts\",\n \"chatjs/plugins/attachment-uploads/upload-prep.ts\",\n \"app/(chat)/api/files/upload/route.ts\",\n \"chatjs/plugins/attachment-uploads/routes/upload.ts\",\n \"chatjs/plugins/attachment-uploads/client-plugin.ts\"\n ],\n \"requiresStorage\": true,\n \"client\": {\n \"export\": \"attachmentUploadsClient\",\n \"composerControls\": [\n \"attach-files\",\n \"take-photo\"\n ],\n \"settingsItems\": [],\n \"uploads\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"radix\"\n}\n",
55
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"radix\",\n \"id\": \"attachment-uploads\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/attachment-uploads/controls.tsx\",\n \"chatjs/plugins/attachment-uploads/uploads.ts\",\n \"chatjs/plugins/attachment-uploads/upload.ts\",\n \"chatjs/plugins/attachment-uploads/upload-prep.ts\",\n \"app/(chat)/api/files/upload/route.ts\",\n \"chatjs/plugins/attachment-uploads/routes/upload.ts\",\n \"chatjs/plugins/attachment-uploads/chat-ui.ts\"\n ],\n \"requiresStorage\": true\n}\n",
56
56
  "type": "registry:file",
57
- "target": "~/chatjs/plugins/attachment-uploads/chatjs.json"
57
+ "target": "~/chatjs/plugins/attachment-uploads/plugin.json"
58
58
  }
59
59
  ],
60
60
  "meta": {
61
61
  "chatjs": {
62
+ "contractVersion": 3,
63
+ "uiBase": "radix",
62
64
  "id": "attachment-uploads",
63
65
  "kind": "plugin",
64
66
  "files": [
65
67
  "chatjs/plugins/attachment-uploads/controls.tsx",
66
- "chatjs/plugins/attachment-uploads/integration.tsx",
68
+ "chatjs/plugins/attachment-uploads/uploads.ts",
67
69
  "chatjs/plugins/attachment-uploads/upload.ts",
68
70
  "chatjs/plugins/attachment-uploads/upload-prep.ts",
69
71
  "app/(chat)/api/files/upload/route.ts",
70
72
  "chatjs/plugins/attachment-uploads/routes/upload.ts",
71
- "chatjs/plugins/attachment-uploads/client-plugin.ts"
73
+ "chatjs/plugins/attachment-uploads/chat-ui.ts"
72
74
  ],
73
- "requiresStorage": true,
74
- "client": {
75
- "export": "attachmentUploadsClient",
76
- "composerControls": [
77
- "attach-files",
78
- "take-photo"
79
- ],
80
- "settingsItems": [],
81
- "uploads": true
82
- },
83
- "contractVersion": 2,
84
- "uiBase": "radix"
75
+ "requiresStorage": true
85
76
  }
86
77
  },
87
78
  "type": "registry:item"