@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
package/README.md CHANGED
@@ -44,7 +44,7 @@ Session identity (`lib/eve/session-identity.ts`) is a core contract. MCP and res
44
44
 
45
45
  ## Plugin database schemas
46
46
 
47
- A plugin may declare `databaseSchemas` in its `chatjs.json`, using app-relative TypeScript paths beneath `chatjs/plugins/<id>/`. Sync validates the selected descriptors and files, then generates `chatjs/generated/installed-database.ts`. Drizzle consumes that list alongside `lib/db/schema.ts`. This is composition metadata, not a barrel that core runtime modules import. MCP contributes `chatjs/plugins/mcp/db/mcp-schema.ts` and consumes the core user table for its foreign key.
47
+ A plugin may declare `databaseSchemas` in its `plugin.json`, using app-relative TypeScript paths beneath `chatjs/plugins/<id>/`. Sync validates the selected descriptors and files, then generates `chatjs/generated/installed-database.ts`. Drizzle consumes that list alongside `lib/db/schema.ts`. This is composition metadata, not a barrel that core runtime modules import. MCP contributes `chatjs/plugins/mcp/db/mcp-schema.ts` and consumes the core user table for its foreign key.
48
48
 
49
49
  Fresh scaffolds exclude the demo's historical migrations. After installing dependencies, create runs the offline `db:generate` script to generate the selected schema's initial migration. Only create generates a baseline, and it refuses a nonempty migration directory. Add and sync preserve the app's migration history. Schema generation and applying migrations remain separate actions. ChatJS supports new installations, without migration support for older template versions.
50
50
 
@@ -56,14 +56,14 @@ Gateways supply `roles.smart`, `roles.balanced`, `roles.fast`, and optional `rol
56
56
 
57
57
  ## Plugins and composition
58
58
 
59
- Plugins replace the former installable feature category. Their open ID contract lives in `metadata.ts`. A plugin declares separate server factory and client declaration exports and its router, instrumentation, layout, composer, settings, or upload contributions. The installer reads descriptors without executing plugin entrypoints. Core business logic consumes generated composition rather than importing optional implementations.
59
+ Built-in manifests use `definePluginItem` to derive each installed `plugin.json` from the shadcn item name and file targets. Plugin descriptors use contract version 3. Sync generates imports from owned paths such as `router.ts`, `instrumentation.ts`, `chat-ui.ts`, `layout-ui.ts`, `uploads.ts`, and `model-visibility.ts`. React slot declarations place components in the application.
60
60
 
61
- MCP and attachment uploads keep manifests beside `src/` and `adapters/`. All plugin runtime source installs under `chatjs/plugins/<id>/`; Next and EVE adapters retain explicit ownership despite their framework-required locations. Plugin entrypoints use `server-plugin.ts` and `client-plugin.ts` to avoid basename collisions with host modules during shadcn installation.
61
+ MCP and attachment uploads keep manifests beside `src/` and `adapters/`. All plugin runtime source installs under `chatjs/plugins/<id>/`; Next and EVE adapters retain explicit ownership despite their framework-required locations.
62
62
 
63
63
  Generated tool and plugin registrations live under `chatjs/generated/`. App-owned tool and renderer composition lives in `integrations/tools/execution.ts` and `integrations/tools/ui.ts`. `composer-controls.ts`, app layout JSX, and `chat.config.ts` remain app-owned. Adding a plugin with existing contribution kinds requires no CLI whitelist change. New contribution kinds require an explicit host contract and generator support.
64
64
 
65
65
  UI contributions use `definePlugin` and typed slot references from `chatjs/core/ui/slots.tsx` and `components/chat-slots.tsx`. The generated chat and layout lists import module-scope plugin declarations. App-owned layouts place slot components beside ordinary JSX. Composer attachment and extension slots surround app-owned tool controls. Plugin components and wrappers remain editable source, with normal dynamic imports and Suspense for deferred UI. Installation and synchronization do not patch these files. Global layout plugins use their own list so authentication routes do not import chat plugins.
66
66
 
67
- Keep plugin-owned queries and behavior inside the plugin. The supported host seams are the typed contracts in `chatjs/core/installation/plugin.ts`, `chatjs/core/chat/contracts.ts`, and `chatjs/core/installation/contracts.ts`, together with the host's shared UI primitives, session provider, navigation helpers, and tRPC client. Core consumers import generated composition instead of optional plugins. New host interactions should extend a specific contract rather than introducing a general service locator. Server entries must stay outside client import graphs.
67
+ Keep plugin-owned queries and behavior inside the plugin. The supported host seams are the typed contracts in `chatjs/core/chat/contracts.ts`, and `chatjs/core/installation/contracts.ts`, together with the host's shared UI primitives, session provider, navigation helpers, and tRPC client. Core consumers import generated composition instead of optional plugins. New host interactions should extend a specific contract rather than introducing a general service locator. Server entries must stay outside client import graphs.
68
68
 
69
69
  Declare all Next and EVE adapters in `files`, plugin prerequisites in `requiresPlugins`, and database modules in `databaseSchemas`. `chat-js remove <id>` uses this ownership and the installed-source receipt to disconnect contributions safely. It retains schema modules and their local dependencies for future migration generation. See [CLI removal and composition](../cli/README.md#removing-plugins) for customization and recovery behavior.
@@ -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\": [\"attach-files\", \"take-photo\"],\n \"settingsItems\": [],\n \"uploads\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
55
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\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": "base",
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": "base"
75
+ "requiresStorage": true
85
76
  }
86
77
  },
87
78
  "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\": [\"attach-files\", \"take-photo\"],\n \"settingsItems\": [],\n \"uploads\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
55
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\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": "base",
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": "base"
75
+ "requiresStorage": true
85
76
  }
86
77
  },
87
78
  "type": "registry:item"
@@ -16,15 +16,15 @@
16
16
  },
17
17
  {
18
18
  "path": "src/plugins/credits/src/billing.ts",
19
- "content": "import { eq, sql } from \"drizzle-orm\";\nimport type { UsageBilling } from \"@/chatjs/core/billing/contracts\";\nimport { getBalanceCents } from \"./credits-queries\";\nimport { userCredit } from \"./credits-schema\";\n\n/** Core supplies its usage transaction, with the registered owner already locked. */\nexport const creditsBilling = {\n canSpend: async (ownerId) => (await getBalanceCents(ownerId)) > 0,\n debit: async (tx, { ownerId, cents }) => {\n await tx\n .insert(userCredit)\n .values({ userId: ownerId })\n .onConflictDoNothing();\n await tx\n .update(userCredit)\n .set({ balanceCents: sql`${userCredit.balanceCents} - ${cents}` })\n .where(eq(userCredit.userId, ownerId));\n },\n} satisfies UsageBilling;\n",
19
+ "content": "import { eq, sql } from \"drizzle-orm\";\nimport type { UsageBilling } from \"@/chatjs/core/billing/contracts\";\nimport { getBalanceCents } from \"./credits-queries\";\nimport { userCredit } from \"./credits-schema\";\n\n/** Core supplies its usage transaction, with the registered owner already locked. */\nconst creditsBilling = {\n canSpend: async (ownerId) => (await getBalanceCents(ownerId)) > 0,\n debit: async (tx, { ownerId, cents }) => {\n await tx\n .insert(userCredit)\n .values({ userId: ownerId })\n .onConflictDoNothing();\n await tx\n .update(userCredit)\n .set({ balanceCents: sql`${userCredit.balanceCents} - ${cents}` })\n .where(eq(userCredit.userId, ownerId));\n },\n} satisfies UsageBilling;\n\nexport default creditsBilling;\n",
20
20
  "type": "registry:file",
21
21
  "target": "~/chatjs/plugins/credits/billing.ts"
22
22
  },
23
23
  {
24
- "path": "src/plugins/credits/src/client-plugin.ts",
25
- "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { AccountSummary } from \"@/components/chat-slots\";\nimport { CreditBalance } from \"./balance\";\n\nexport const creditsClient = definePlugin({\n id: \"credits\",\n slots: [slot(AccountSummary, CreditBalance)],\n});\n",
24
+ "path": "src/plugins/credits/src/chat-ui.ts",
25
+ "content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { AccountSummary } from \"@/components/chat-slots\";\nimport { CreditBalance } from \"./balance\";\n\nexport const chatUi = definePlugin({\n id: \"credits\",\n slots: [slot(AccountSummary, CreditBalance)],\n});\n",
26
26
  "type": "registry:file",
27
- "target": "~/chatjs/plugins/credits/client-plugin.ts"
27
+ "target": "~/chatjs/plugins/credits/chat-ui.ts"
28
28
  },
29
29
  {
30
30
  "path": "src/plugins/credits/src/credits-queries.ts",
@@ -40,16 +40,10 @@
40
40
  },
41
41
  {
42
42
  "path": "src/plugins/credits/src/router.ts",
43
- "content": "import { getBalanceCents } from \"./credits-queries\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\n\nexport const creditsRouter = createTRPCRouter({\n getAvailableCredits: protectedProcedure.query(\n async ({\n ctx,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n }) => {\n const balanceCents = await getBalanceCents(ctx.user.id);\n return { balanceCents };\n }\n ),\n});\n",
43
+ "content": "import { getBalanceCents } from \"./credits-queries\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\n\nconst creditsProcedures = {\n getAvailableCredits: protectedProcedure.query(\n async ({\n ctx,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n }) => {\n const balanceCents = await getBalanceCents(ctx.user.id);\n return { balanceCents };\n }\n ),\n};\n\nexport const router = createTRPCRouter({ credits: creditsProcedures });\n",
44
44
  "type": "registry:file",
45
45
  "target": "~/chatjs/plugins/credits/router.ts"
46
46
  },
47
- {
48
- "path": "src/plugins/credits/src/server-plugin.ts",
49
- "content": "import type { ChatPlugin } from \"@/chatjs/core/installation/plugin\";\nimport { creditsRouter } from \"./router\";\n\nexport const credits = () =>\n ({ id: \"credits\", routers: { credits: creditsRouter } }) satisfies ChatPlugin;\n",
50
- "type": "registry:file",
51
- "target": "~/chatjs/plugins/credits/server-plugin.ts"
52
- },
53
47
  {
54
48
  "path": "src/plugins/credits/src/use-credits.ts",
55
49
  "content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport { useSession } from \"@/providers/session-provider\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const useGetCredits = (): {\n balanceCents: number | undefined;\n isError: boolean;\n} => {\n const { data: session } = useSession();\n const isAuthenticated = Boolean(session?.user);\n const trpc = useTRPC();\n\n const { data: creditsData, isError } = useQuery({\n ...trpc.credits.getAvailableCredits.queryOptions(),\n enabled: isAuthenticated,\n meta: { refreshOnTurnEnd: true },\n });\n\n return {\n balanceCents: creditsData?.balanceCents,\n isError,\n };\n};\n",
@@ -58,45 +52,29 @@
58
52
  },
59
53
  {
60
54
  "path": "dist/source/credits.json",
61
- "content": "{\n \"id\": \"credits\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/credits/balance.tsx\",\n \"chatjs/plugins/credits/billing.ts\",\n \"chatjs/plugins/credits/client-plugin.ts\",\n \"chatjs/plugins/credits/credits-queries.ts\",\n \"chatjs/plugins/credits/credits-schema.ts\",\n \"chatjs/plugins/credits/router.ts\",\n \"chatjs/plugins/credits/server-plugin.ts\",\n \"chatjs/plugins/credits/use-credits.ts\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/credits/credits-schema.ts\"],\n \"billing\": { \"export\": \"creditsBilling\" },\n \"server\": { \"export\": \"credits\", \"routers\": [\"credits\"] },\n \"client\": {\n \"export\": \"creditsClient\",\n \"composerControls\": [],\n \"settingsItems\": [],\n \"accountSummary\": true\n },\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
55
+ "content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\n \"id\": \"credits\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/credits/balance.tsx\",\n \"chatjs/plugins/credits/billing.ts\",\n \"chatjs/plugins/credits/chat-ui.ts\",\n \"chatjs/plugins/credits/credits-queries.ts\",\n \"chatjs/plugins/credits/credits-schema.ts\",\n \"chatjs/plugins/credits/router.ts\",\n \"chatjs/plugins/credits/use-credits.ts\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/credits/credits-schema.ts\"]\n}\n",
62
56
  "type": "registry:file",
63
- "target": "~/chatjs/plugins/credits/chatjs.json"
57
+ "target": "~/chatjs/plugins/credits/plugin.json"
64
58
  }
65
59
  ],
66
60
  "meta": {
67
61
  "chatjs": {
62
+ "contractVersion": 3,
63
+ "uiBase": "base",
68
64
  "id": "credits",
69
65
  "kind": "plugin",
70
66
  "files": [
71
67
  "chatjs/plugins/credits/balance.tsx",
72
68
  "chatjs/plugins/credits/billing.ts",
73
- "chatjs/plugins/credits/client-plugin.ts",
69
+ "chatjs/plugins/credits/chat-ui.ts",
74
70
  "chatjs/plugins/credits/credits-queries.ts",
75
71
  "chatjs/plugins/credits/credits-schema.ts",
76
72
  "chatjs/plugins/credits/router.ts",
77
- "chatjs/plugins/credits/server-plugin.ts",
78
73
  "chatjs/plugins/credits/use-credits.ts"
79
74
  ],
80
75
  "databaseSchemas": [
81
76
  "chatjs/plugins/credits/credits-schema.ts"
82
- ],
83
- "billing": {
84
- "export": "creditsBilling"
85
- },
86
- "server": {
87
- "export": "credits",
88
- "routers": [
89
- "credits"
90
- ]
91
- },
92
- "client": {
93
- "export": "creditsClient",
94
- "composerControls": [],
95
- "settingsItems": [],
96
- "accountSummary": true
97
- },
98
- "contractVersion": 2,
99
- "uiBase": "base"
77
+ ]
100
78
  }
101
79
  },
102
80
  "type": "registry:item"
@@ -5,10 +5,6 @@
5
5
  "dependencies": [
6
6
  "lucide-react@0.553.0"
7
7
  ],
8
- "registryDependencies": [
9
- "trace",
10
- "badge"
11
- ],
12
8
  "files": [
13
9
  {
14
10
  "path": "src/tools/deep-research/renderer.tsx",