@chat-js/registry 0.2.0-beta.0 → 0.2.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +16 -12
  2. package/dist/r/ai-titles.json +17 -17
  3. package/dist/r/akamai-storage.json +13 -1
  4. package/dist/r/alibaba-storage.json +13 -1
  5. package/dist/r/appwrite-storage.json +8 -1
  6. package/dist/r/archil-storage.json +8 -1
  7. package/dist/r/attach-workspace-file.json +82 -0
  8. package/dist/r/attachment-uploads.json +26 -34
  9. package/dist/r/azure-storage.json +8 -1
  10. package/dist/r/backblaze-b2-storage.json +13 -1
  11. package/dist/r/base/ai-titles.json +47 -0
  12. package/dist/r/base/akamai-storage.json +56 -0
  13. package/dist/r/base/alibaba-storage.json +56 -0
  14. package/dist/r/base/appwrite-storage.json +57 -0
  15. package/dist/r/base/archil-storage.json +59 -0
  16. package/dist/r/base/attach-workspace-file.json +82 -0
  17. package/dist/r/base/attachment-uploads.json +79 -0
  18. package/dist/r/base/azure-storage.json +58 -0
  19. package/dist/r/base/backblaze-b2-storage.json +56 -0
  20. package/dist/r/base/bunny-storage-storage.json +49 -0
  21. package/dist/r/base/cloudinary-storage.json +44 -0
  22. package/dist/r/base/credits.json +81 -0
  23. package/dist/r/base/deep-research.json +138 -0
  24. package/dist/r/base/default-sandbox.json +35 -0
  25. package/dist/r/base/desktop.json +129 -0
  26. package/dist/r/base/digitalocean-spaces-storage.json +56 -0
  27. package/dist/r/base/docker-sandbox.json +35 -0
  28. package/dist/r/base/dropbox-storage.json +44 -0
  29. package/dist/r/base/exoscale-storage.json +56 -0
  30. package/dist/r/base/feedback.json +90 -0
  31. package/dist/r/base/filebase-storage.json +50 -0
  32. package/dist/r/base/firebase-storage-storage.json +53 -0
  33. package/dist/r/base/followup-suggestions.json +130 -0
  34. package/dist/r/base/ftp-storage.json +71 -0
  35. package/dist/r/base/gcs-storage.json +40 -0
  36. package/dist/r/base/generate-image.json +107 -0
  37. package/dist/r/base/generate-video.json +76 -0
  38. package/dist/r/base/google-drive-storage.json +48 -0
  39. package/dist/r/base/guest-chat.json +166 -0
  40. package/dist/r/base/hetzner-storage.json +56 -0
  41. package/dist/r/base/ibm-cos-storage.json +56 -0
  42. package/dist/r/base/idrive-e2-storage.json +56 -0
  43. package/dist/r/base/image-viewer.json +49 -0
  44. package/dist/r/base/just-bash-sandbox.json +32 -0
  45. package/dist/r/base/litellm-gateway.json +64 -0
  46. package/dist/r/base/mcp.json +327 -0
  47. package/dist/r/base/memory-storage.json +30 -0
  48. package/dist/r/base/minio-storage.json +56 -0
  49. package/dist/r/base/model-preferences.json +117 -0
  50. package/dist/r/base/neon-storage.json +51 -0
  51. package/dist/r/base/netlify-blobs-storage.json +39 -0
  52. package/dist/r/base/onedrive-storage.json +49 -0
  53. package/dist/r/base/openai-compatible-gateway.json +66 -0
  54. package/dist/r/base/openai-gateway.json +64 -0
  55. package/dist/r/base/openrouter-gateway.json +71 -0
  56. package/dist/r/base/oracle-cloud-storage.json +62 -0
  57. package/dist/r/base/ovhcloud-storage.json +56 -0
  58. package/dist/r/base/pocketbase-storage.json +51 -0
  59. package/dist/r/base/projects.json +274 -0
  60. package/dist/r/base/r2-storage.json +52 -0
  61. package/dist/r/base/registry.json +4734 -0
  62. package/dist/r/base/s3-storage.json +58 -0
  63. package/dist/r/base/scaleway-storage.json +56 -0
  64. package/dist/r/base/search.json +154 -0
  65. package/dist/r/base/sftp-storage.json +75 -0
  66. package/dist/r/base/sharepoint-storage.json +51 -0
  67. package/dist/r/base/sharing.json +138 -0
  68. package/dist/r/base/spreadsheet-grid.json +20 -0
  69. package/dist/r/base/spreadsheet-viewer.json +62 -0
  70. package/dist/r/base/storj-storage.json +50 -0
  71. package/dist/r/base/streamdown-math.json +35 -0
  72. package/dist/r/base/streamdown-mermaid.json +34 -0
  73. package/dist/r/base/supabase-storage.json +55 -0
  74. package/dist/r/base/tencent-storage.json +56 -0
  75. package/dist/r/base/tigris-storage.json +50 -0
  76. package/dist/r/base/uploadthing-storage.json +39 -0
  77. package/dist/r/base/vercel-blob-storage.json +44 -0
  78. package/dist/r/base/vercel-gateway.json +75 -0
  79. package/dist/r/base/vercel-sandbox.json +49 -0
  80. package/dist/r/base/video-viewer.json +42 -0
  81. package/dist/r/base/vultr-storage.json +56 -0
  82. package/dist/r/base/wasabi-storage.json +56 -0
  83. package/dist/r/base/webdav-storage.json +64 -0
  84. package/dist/r/base/yandex-storage.json +50 -0
  85. package/dist/r/bunny-storage-storage.json +2 -1
  86. package/dist/r/cloudinary-storage.json +2 -1
  87. package/dist/r/credits.json +29 -46
  88. package/dist/r/deep-research.json +56 -138
  89. package/dist/r/default-sandbox.json +35 -0
  90. package/dist/r/desktop.json +129 -0
  91. package/dist/r/digitalocean-spaces-storage.json +13 -1
  92. package/dist/r/docker-sandbox.json +35 -0
  93. package/dist/r/dropbox-storage.json +2 -1
  94. package/dist/r/eve/deep-research.json +47 -0
  95. package/dist/r/eve/registry.json +53 -0
  96. package/dist/r/exoscale-storage.json +13 -1
  97. package/dist/r/feedback.json +38 -53
  98. package/dist/r/filebase-storage.json +8 -1
  99. package/dist/r/firebase-storage-storage.json +2 -1
  100. package/dist/r/followup-suggestions.json +49 -66
  101. package/dist/r/ftp-storage.json +18 -1
  102. package/dist/r/gcs-storage.json +8 -1
  103. package/dist/r/generate-image.json +24 -18
  104. package/dist/r/generate-video.json +17 -11
  105. package/dist/r/google-drive-storage.json +2 -1
  106. package/dist/r/guest-chat.json +166 -0
  107. package/dist/r/hetzner-storage.json +13 -1
  108. package/dist/r/ibm-cos-storage.json +13 -1
  109. package/dist/r/idrive-e2-storage.json +13 -1
  110. package/dist/r/image-viewer.json +49 -0
  111. package/dist/r/just-bash-sandbox.json +32 -0
  112. package/dist/r/litellm-gateway.json +5 -8
  113. package/dist/r/mcp.json +143 -120
  114. package/dist/r/memory-storage.json +5 -3
  115. package/dist/r/minio-storage.json +13 -1
  116. package/dist/r/model-preferences.json +47 -55
  117. package/dist/r/neon-storage.json +8 -1
  118. package/dist/r/netlify-blobs-storage.json +10 -2
  119. package/dist/r/onedrive-storage.json +2 -1
  120. package/dist/r/openai-compatible-gateway.json +6 -9
  121. package/dist/r/openai-gateway.json +6 -9
  122. package/dist/r/openrouter-gateway.json +5 -9
  123. package/dist/r/oracle-cloud-storage.json +18 -1
  124. package/dist/r/ovhcloud-storage.json +13 -1
  125. package/dist/r/pocketbase-storage.json +2 -1
  126. package/dist/r/projects.json +116 -108
  127. package/dist/r/r2-storage.json +9 -1
  128. package/dist/r/radix/ai-titles.json +47 -0
  129. package/dist/r/radix/akamai-storage.json +56 -0
  130. package/dist/r/radix/alibaba-storage.json +56 -0
  131. package/dist/r/radix/appwrite-storage.json +57 -0
  132. package/dist/r/radix/archil-storage.json +59 -0
  133. package/dist/r/radix/attach-workspace-file.json +82 -0
  134. package/dist/r/radix/attachment-uploads.json +79 -0
  135. package/dist/r/radix/azure-storage.json +58 -0
  136. package/dist/r/radix/backblaze-b2-storage.json +56 -0
  137. package/dist/r/radix/bunny-storage-storage.json +49 -0
  138. package/dist/r/radix/cloudinary-storage.json +44 -0
  139. package/dist/r/radix/credits.json +81 -0
  140. package/dist/r/radix/deep-research.json +138 -0
  141. package/dist/r/radix/default-sandbox.json +35 -0
  142. package/dist/r/radix/desktop.json +129 -0
  143. package/dist/r/radix/digitalocean-spaces-storage.json +56 -0
  144. package/dist/r/radix/docker-sandbox.json +35 -0
  145. package/dist/r/radix/dropbox-storage.json +44 -0
  146. package/dist/r/radix/exoscale-storage.json +56 -0
  147. package/dist/r/radix/feedback.json +90 -0
  148. package/dist/r/radix/filebase-storage.json +50 -0
  149. package/dist/r/radix/firebase-storage-storage.json +53 -0
  150. package/dist/r/radix/followup-suggestions.json +130 -0
  151. package/dist/r/radix/ftp-storage.json +71 -0
  152. package/dist/r/radix/gcs-storage.json +40 -0
  153. package/dist/r/radix/generate-image.json +107 -0
  154. package/dist/r/radix/generate-video.json +76 -0
  155. package/dist/r/radix/google-drive-storage.json +48 -0
  156. package/dist/r/radix/guest-chat.json +166 -0
  157. package/dist/r/radix/hetzner-storage.json +56 -0
  158. package/dist/r/radix/ibm-cos-storage.json +56 -0
  159. package/dist/r/radix/idrive-e2-storage.json +56 -0
  160. package/dist/r/radix/image-viewer.json +49 -0
  161. package/dist/r/radix/just-bash-sandbox.json +32 -0
  162. package/dist/r/radix/litellm-gateway.json +64 -0
  163. package/dist/r/radix/mcp.json +327 -0
  164. package/dist/r/radix/memory-storage.json +30 -0
  165. package/dist/r/radix/minio-storage.json +56 -0
  166. package/dist/r/radix/model-preferences.json +117 -0
  167. package/dist/r/radix/neon-storage.json +51 -0
  168. package/dist/r/radix/netlify-blobs-storage.json +39 -0
  169. package/dist/r/radix/onedrive-storage.json +49 -0
  170. package/dist/r/radix/openai-compatible-gateway.json +66 -0
  171. package/dist/r/radix/openai-gateway.json +64 -0
  172. package/dist/r/radix/openrouter-gateway.json +71 -0
  173. package/dist/r/radix/oracle-cloud-storage.json +62 -0
  174. package/dist/r/radix/ovhcloud-storage.json +56 -0
  175. package/dist/r/radix/pocketbase-storage.json +51 -0
  176. package/dist/r/radix/projects.json +274 -0
  177. package/dist/r/radix/r2-storage.json +52 -0
  178. package/dist/r/radix/registry.json +4734 -0
  179. package/dist/r/radix/s3-storage.json +58 -0
  180. package/dist/r/radix/scaleway-storage.json +56 -0
  181. package/dist/r/radix/search.json +154 -0
  182. package/dist/r/radix/sftp-storage.json +75 -0
  183. package/dist/r/radix/sharepoint-storage.json +51 -0
  184. package/dist/r/radix/sharing.json +138 -0
  185. package/dist/r/radix/spreadsheet-grid.json +20 -0
  186. package/dist/r/radix/spreadsheet-viewer.json +62 -0
  187. package/dist/r/radix/storj-storage.json +50 -0
  188. package/dist/r/radix/streamdown-math.json +35 -0
  189. package/dist/r/radix/streamdown-mermaid.json +34 -0
  190. package/dist/r/radix/supabase-storage.json +55 -0
  191. package/dist/r/radix/tencent-storage.json +56 -0
  192. package/dist/r/radix/tigris-storage.json +50 -0
  193. package/dist/r/radix/uploadthing-storage.json +39 -0
  194. package/dist/r/radix/vercel-blob-storage.json +44 -0
  195. package/dist/r/radix/vercel-gateway.json +75 -0
  196. package/dist/r/radix/vercel-sandbox.json +49 -0
  197. package/dist/r/radix/video-viewer.json +42 -0
  198. package/dist/r/radix/vultr-storage.json +56 -0
  199. package/dist/r/radix/wasabi-storage.json +56 -0
  200. package/dist/r/radix/webdav-storage.json +64 -0
  201. package/dist/r/radix/yandex-storage.json +50 -0
  202. package/dist/r/registry.json +2006 -2142
  203. package/dist/r/s3-storage.json +15 -1
  204. package/dist/r/scaleway-storage.json +13 -1
  205. package/dist/r/search.json +80 -66
  206. package/dist/r/sftp-storage.json +18 -1
  207. package/dist/r/sharepoint-storage.json +2 -1
  208. package/dist/r/sharing.json +65 -64
  209. package/dist/r/spreadsheet-grid.json +20 -0
  210. package/dist/r/spreadsheet-viewer.json +62 -0
  211. package/dist/r/storj-storage.json +8 -1
  212. package/dist/r/streamdown-math.json +35 -0
  213. package/dist/r/streamdown-mermaid.json +34 -0
  214. package/dist/r/supabase-storage.json +8 -1
  215. package/dist/r/tencent-storage.json +13 -1
  216. package/dist/r/tigris-storage.json +8 -1
  217. package/dist/r/uploadthing-storage.json +2 -1
  218. package/dist/r/vercel-blob-storage.json +3 -1
  219. package/dist/r/vercel-gateway.json +7 -9
  220. package/dist/r/vercel-sandbox.json +8 -26
  221. package/dist/r/video-viewer.json +42 -0
  222. package/dist/r/vultr-storage.json +13 -1
  223. package/dist/r/wasabi-storage.json +13 -1
  224. package/dist/r/webdav-storage.json +13 -1
  225. package/dist/r/yandex-storage.json +8 -1
  226. package/package.json +20 -38
  227. package/dist/r/code-documents.json +0 -96
  228. package/dist/r/code-execution-runtime.json +0 -25
  229. package/dist/r/code-execution-ui.json +0 -31
  230. package/dist/r/code-execution.json +0 -69
  231. package/dist/r/daytona-sandbox.json +0 -55
  232. package/dist/r/delete-document.json +0 -58
  233. package/dist/r/firecrawl-search.json +0 -72
  234. package/dist/r/get-weather.json +0 -52
  235. package/dist/r/langfuse.json +0 -63
  236. package/dist/r/read-document.json +0 -34
  237. package/dist/r/retrieve-url.json +0 -67
  238. package/dist/r/saved-code-execution.json +0 -81
  239. package/dist/r/sheet-documents.json +0 -93
  240. package/dist/r/tavily-search.json +0 -72
  241. package/dist/r/text-documents.json +0 -116
  242. package/dist/r/vercel-analytics.json +0 -46
  243. package/dist/r/vercel-speed-insights.json +0 -46
  244. package/dist/r/word-count.json +0 -51
package/README.md CHANGED
@@ -12,13 +12,13 @@ bun run build
12
12
 
13
13
  `build.ts` serializes the catalog and tool descriptors, then runs published `shadcn@4.21.0 build`. shadcn reads the source files and emits `dist/r/*.json`. Both the intermediate `registry.json` and output are generated, never edited. The output directory is cleared first, so deleted items cannot survive a build.
14
14
 
15
- The npm package publishes `dist/r/`. The Base UI release uses `https://unpkg.com/@chat-js/registry@0.2.0-beta.0/dist/r/{name}.json`. Historical version 0 npm artifacts retain their legacy `items/` format for already-published CLIs; existing standard-registry clients retain their configured release. Base-dependent plugins and document bundles declare `contractVersion: 2` and `uiBase: "base"` so incompatible hosts are rejected before ChatJS installation or synchronization writes. Publish the shared gateway and sandbox contracts first, then the registry beta, then the matching CLI beta. Use `--tag beta` for both prereleases and keep stable `latest` unchanged. Descriptor contract version 2 is independent of npm versioning. The static Vercel deployment serves the same output.
15
+ The npm package publishes `dist/r/`. CLI `1.0.0-beta.0` uses registry `0.2.0-beta.10`. The root namespace at `https://unpkg.com/@chat-js/registry@0.2.0-beta.10/dist/r/{name}.json` and the `/base/{name}.json` namespace provide Base UI source. The `/radix/{name}.json` namespace provides Radix source. Existing apps use the registry configured in `components.json`. The release workflow publishes the registry first and the matching CLI second, both under the npm `beta` tag.
16
16
 
17
17
  ## Tools
18
18
 
19
- Each tool item installs `tool.ts`, `renderer.tsx`, and `chatjs.json` under `~/tools/chatjs/<id>/`. All tools use native EVE definitions and a single contractVersion 1 descriptor with kind `tool`, id, named tool/renderer exports, optional plugin slot, and environment requirements. The version validates the format and never selects an execution adapter. The build derives it from the same typed metadata used in the catalog.
19
+ Each tool item installs `tool.ts`, `renderer.tsx`, and `chatjs.json` under `~/chatjs/tools/<id>/`. All tools use native EVE definitions and a single contractVersion 1 descriptor with kind `tool`, id, named tool/renderer exports, optional plugin slot, and environment requirements. The version validates the format and never selects an execution adapter. The build derives it from the same typed metadata used in the catalog.
20
20
 
21
- `chat-js add` delegates installation to shadcn, then generates typed server and client indexes. Direct `shadcn add` installs are supported by running `chat-js sync` afterward. Custom registrations belong in `custom-tools.ts` and `custom-ui.ts`. Third-party items use the same shape and standard namespaces in `components.json`.
21
+ `chat-js add` delegates installation to shadcn, then generates typed server and client indexes. Direct `shadcn add` installs are supported by running `chat-js sync` afterward. Custom registrations belong in `integrations/tools/execution.ts` and `integrations/tools/ui.ts`. Third-party items use the same shape and standard namespaces in `components.json`.
22
22
 
23
23
  See [gateway authoring](./src/gateways/README.md) for adapter-specific metadata.
24
24
 
@@ -26,11 +26,11 @@ See [gateway authoring](./src/gateways/README.md) for adapter-specific metadata.
26
26
 
27
27
  Source folders group items by category. Each gateway has a `gateway.ts`; each tool has a `tool.ts` and `renderer.tsx`. Receipt and renderer helpers are supplied by the ChatJS scaffold. Category-level gateway catalog, metadata, and defaults live directly under `src/gateways/`.
28
28
 
29
- `meta.chatjs.kind` identifies a gateway or tool independently of its public name. Registry namespace aliases such as `@chatjs` identify a configured registry source. Public item names remain `vercel-gateway`, `word-count`, and the other existing names. Source folders do not determine registry addresses or installation targets.
29
+ `meta.chatjs.kind` identifies a gateway or tool independently of its public name. Registry namespace aliases such as `@chatjs` identify a configured registry source. Public item names remain `vercel-gateway`, `deep-research`, and the other existing names. Source folders do not determine registry addresses or installation targets.
30
30
 
31
- The selected gateway installs into the app's `lib/ai/gateway.ts` slot. Tools install under `tools/chatjs/<id>/` with generated registrations and separate custom modules. Third-party destination namespacing is not inferred from registry aliases and is not added by this source reorganization.
31
+ The selected gateway installs into the app's `chatjs/providers/gateway.ts` slot. Tools install under `chatjs/tools/<id>/` with generated installation inputs and app-owned integration modules. Third-party destination namespacing is not inferred from registry aliases and is not added by this source reorganization.
32
32
 
33
- `packages/gateways` owns shared runtime contracts. `packages/cli` owns installation and configuration. `apps/chat` is the reference consumer and app template source. New categories such as layouts and caches should introduce source folders and contracts when their first implementation is added, rather than empty scaffolding.
33
+ `apps/chat/chatjs/core/gateway/` contains the shared gateway runtime and types shipped with each app. `packages/cli` owns installation and configuration. `apps/chat` is the reference consumer and app template source. New categories such as layouts and caches should introduce source folders and contracts when their first implementation is added, rather than empty scaffolding.
34
34
 
35
35
  ## Ownership inventory
36
36
 
@@ -44,22 +44,26 @@ 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 `plugins/<id>/`. Sync validates the selected descriptors and files, then generates `composition/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 `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
 
51
51
  ## Tool configuration
52
52
 
53
- Tools can declare `config: { key }` and export `configSchema` from their own `configuration-schema.ts`. Sync generates `composition/generated/installed-config.ts` from installed descriptors, rejecting duplicate or reserved keys. The core composes those schemas under `ai.tools`, deriving both input and output types. The editable interface remains `chat.config.ts`. Unknown tool keys are rejected at the type and runtime boundaries.
53
+ Tools can declare `config: { key }` and export `configSchema` from their own `configuration-schema.ts`. Sync generates `chatjs/generated/installed-config.ts` from installed descriptors, rejecting duplicate or reserved keys. The core composes those schemas under `ai.tools`, deriving both input and output types. The editable interface remains `chat.config.ts`. Unknown tool keys are rejected at the type and runtime boundaries.
54
54
 
55
55
  Gateways supply `roles.smart`, `roles.balanced`, `roles.fast`, and optional `roles.image`/`roles.video`. Tool schemas own their defaults and choose from these roles through the pure `lib/config-models.ts` core contract. They must not import runtime configuration or credentials. Document assistant actions similarly belong to document bundles and enter core through a generated registration. Follow-up suggestions and attachment limits remain core because core runtime code consumes them independently of installable tools.
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 and client factory 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 `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
- Generated tool and plugin registrations live under `composition/generated/`. Editable custom tool and renderer registrations live under `composition/custom/`. `composer-controls.ts`, `settings-items.ts`, 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.
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
- See [plugin authoring](../../apps/docs/plugins/authoring.mdx) for the complete source-installation contract.
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
+
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
+
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.
@@ -2,45 +2,45 @@
2
2
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
3
  "name": "ai-titles",
4
4
  "description": "Automatically name new chats with AI",
5
+ "dependencies": [
6
+ "drizzle-orm@^0.45.1"
7
+ ],
5
8
  "files": [
6
9
  {
7
- "path": "src/plugins/ai-titles/src/chat.ts",
8
- "content": "import type { ChatServerIntegration } from \"@/lib/chat-plugin-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",
9
12
  "type": "registry:file",
10
- "target": "~/plugins/ai-titles/chat.ts"
13
+ "target": "~/chatjs/plugins/ai-titles/chat-server.ts"
11
14
  },
12
15
  {
13
16
  "path": "src/plugins/ai-titles/src/generate-title.ts",
14
- "content": "import { settleEveRootFallbackTitle } from \"@/lib/db/eve-title\";\nimport { generateText } from \"ai\";\n\nimport { getLanguageModel } from \"@/lib/ai/providers\";\nimport { chatTelemetry } from \"@/lib/ai/telemetry\";\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 telemetry: { integrations: chatTelemetry, isEnabled: true },\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",
15
18
  "type": "registry:file",
16
- "target": "~/plugins/ai-titles/generate-title.ts"
19
+ "target": "~/chatjs/plugins/ai-titles/generate-title.ts"
17
20
  },
18
21
  {
19
22
  "path": "src/plugins/ai-titles/src/title-queries.ts",
20
- "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",
21
24
  "type": "registry:file",
22
- "target": "~/plugins/ai-titles/title-queries.ts"
25
+ "target": "~/chatjs/plugins/ai-titles/title-queries.ts"
23
26
  },
24
27
  {
25
28
  "path": "dist/source/ai-titles.json",
26
- "content": "{\n \"id\": \"ai-titles\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/ai-titles/chat.ts\",\n \"plugins/ai-titles/generate-title.ts\",\n \"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",
27
30
  "type": "registry:file",
28
- "target": "~/plugins/ai-titles/chatjs.json"
31
+ "target": "~/chatjs/plugins/ai-titles/plugin.json"
29
32
  }
30
33
  ],
31
34
  "meta": {
32
35
  "chatjs": {
36
+ "contractVersion": 3,
33
37
  "id": "ai-titles",
34
38
  "kind": "plugin",
35
39
  "files": [
36
- "plugins/ai-titles/chat.ts",
37
- "plugins/ai-titles/generate-title.ts",
38
- "plugins/ai-titles/title-queries.ts"
39
- ],
40
- "chat": {
41
- "export": "aiTitlesChat"
42
- },
43
- "contractVersion": 1
40
+ "chatjs/plugins/ai-titles/chat-server.ts",
41
+ "chatjs/plugins/ai-titles/generate-title.ts",
42
+ "chatjs/plugins/ai-titles/title-queries.ts"
43
+ ]
44
44
  }
45
45
  },
46
46
  "type": "registry:item"
@@ -14,7 +14,7 @@
14
14
  "path": "src/storage/akamai/storage-provider.ts",
15
15
  "content": "export { akamai as createStorageAdapter } from \"files-sdk/akamai\";\n",
16
16
  "type": "registry:file",
17
- "target": "~/lib/storage-provider.ts"
17
+ "target": "~/chatjs/providers/storage.ts"
18
18
  }
19
19
  ],
20
20
  "meta": {
@@ -23,6 +23,18 @@
23
23
  "bucket",
24
24
  "endpoint"
25
25
  ],
26
+ "configFields": [
27
+ {
28
+ "key": "bucket",
29
+ "label": "bucket",
30
+ "type": "text"
31
+ },
32
+ {
33
+ "key": "endpoint",
34
+ "label": "endpoint",
35
+ "type": "text"
36
+ }
37
+ ],
26
38
  "contractVersion": 1,
27
39
  "envRequirements": [
28
40
  {
@@ -14,7 +14,7 @@
14
14
  "path": "src/storage/alibaba/storage-provider.ts",
15
15
  "content": "export { alibaba as createStorageAdapter } from \"files-sdk/alibaba\";\n",
16
16
  "type": "registry:file",
17
- "target": "~/lib/storage-provider.ts"
17
+ "target": "~/chatjs/providers/storage.ts"
18
18
  }
19
19
  ],
20
20
  "meta": {
@@ -23,6 +23,18 @@
23
23
  "bucket",
24
24
  "region"
25
25
  ],
26
+ "configFields": [
27
+ {
28
+ "key": "bucket",
29
+ "label": "bucket",
30
+ "type": "text"
31
+ },
32
+ {
33
+ "key": "region",
34
+ "label": "region",
35
+ "type": "text"
36
+ }
37
+ ],
26
38
  "contractVersion": 1,
27
39
  "envRequirements": [
28
40
  {
@@ -12,7 +12,7 @@
12
12
  "path": "src/storage/appwrite/storage-provider.ts",
13
13
  "content": "export { appwrite as createStorageAdapter } from \"files-sdk/appwrite\";\n",
14
14
  "type": "registry:file",
15
- "target": "~/lib/storage-provider.ts"
15
+ "target": "~/chatjs/providers/storage.ts"
16
16
  }
17
17
  ],
18
18
  "meta": {
@@ -20,6 +20,13 @@
20
20
  "configKeys": [
21
21
  "bucket"
22
22
  ],
23
+ "configFields": [
24
+ {
25
+ "key": "bucket",
26
+ "label": "bucket",
27
+ "type": "text"
28
+ }
29
+ ],
23
30
  "contractVersion": 1,
24
31
  "envRequirements": [
25
32
  {
@@ -15,7 +15,7 @@
15
15
  "path": "src/storage/archil/storage-provider.ts",
16
16
  "content": "export { archil as createStorageAdapter } from \"files-sdk/archil\";\n",
17
17
  "type": "registry:file",
18
- "target": "~/lib/storage-provider.ts"
18
+ "target": "~/chatjs/providers/storage.ts"
19
19
  }
20
20
  ],
21
21
  "meta": {
@@ -23,6 +23,13 @@
23
23
  "configKeys": [
24
24
  "bucket"
25
25
  ],
26
+ "configFields": [
27
+ {
28
+ "key": "bucket",
29
+ "label": "bucket",
30
+ "type": "text"
31
+ }
32
+ ],
26
33
  "contractVersion": 1,
27
34
  "envRequirements": [
28
35
  {
@@ -0,0 +1,82 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "attach-workspace-file",
4
+ "description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
5
+ "dependencies": [
6
+ "eve@npm:@chat-js/eve@1.1.1-chatjs.0",
7
+ "zod@4.5.4",
8
+ "lucide-react@0.553.0"
9
+ ],
10
+ "files": [
11
+ {
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, 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
+ "type": "registry:file",
15
+ "target": "~/chatjs/tools/attach-workspace-file/tool.ts"
16
+ },
17
+ {
18
+ "path": "src/tools/attach-workspace-file/attach.ts",
19
+ "content": "import nodePath from \"node:path\";\nimport type { SandboxSession } from \"eve/sandbox\";\nimport type { FileUploader } from \"@/lib/file-storage\";\nimport type { z } from \"zod\";\nimport type { attachWorkspaceFileInput } from \"./schemas\";\nimport {\n maximumWorkspaceFileBytes,\n attachWorkspaceFileResult,\n} from \"./schemas\";\n\n// Active browser formats such as HTML and SVG are delivered as downloads.\nconst mediaTypes: Readonly<Record<string, string>> = {\n \".txt\": \"text/plain\",\n \".md\": \"text/plain\",\n \".csv\": \"text/csv\",\n \".json\": \"application/json\",\n \".pdf\": \"application/pdf\",\n \".xlsx\": \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \".docx\":\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \".pptx\":\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n \".mp4\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".zip\": \"application/zip\",\n};\nconst shellQuote = (value: string): string =>\n `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\nconst inWorkspace = (path: string, root: string): boolean =>\n path.startsWith(`${root}/`);\n\nexport const attachSandboxFile = async (\n input: z.infer<typeof attachWorkspaceFileInput>,\n {\n sandbox,\n upload,\n signal,\n }: {\n readonly sandbox: Pick<SandboxSession, \"resolvePath\" | \"run\" | \"readFile\">;\n readonly upload: FileUploader;\n readonly signal: AbortSignal;\n }\n): Promise<z.infer<typeof attachWorkspaceFileResult>> => {\n signal.throwIfAborted();\n const root = nodePath.posix.normalize(sandbox.resolvePath(\".\"));\n const path = nodePath.posix.normalize(sandbox.resolvePath(input.path));\n if (!inWorkspace(path, root)) {\n throw new Error(\"Attach a file inside the sandbox workspace.\");\n }\n const quoted = shellQuote(path);\n const resolved = await sandbox.run({\n command: `if [ -f ${quoted} ]; then readlink -f -- ${quoted}; fi`,\n signal,\n });\n const realPath = resolved.stdout.replace(/\\n$/u, \"\");\n if (resolved.exitCode !== 0 || !inWorkspace(realPath, root)) {\n throw new Error(\n \"The file is missing, is not a regular file, or resolves outside the workspace.\"\n );\n }\n const stream = await sandbox.readFile({ path: realPath, signal });\n if (!stream) {\n throw new Error(\"The sandbox file is no longer available.\");\n }\n const reader = stream.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n try {\n for (;;) {\n signal.throwIfAborted();\n // oxlint-disable-next-line eslint/no-await-in-loop -- Read ordered chunks and enforce a limit before storing bytes.\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n size += value.byteLength;\n if (size > maximumWorkspaceFileBytes) {\n throw new Error(\"Files must be 32 MiB or smaller.\");\n }\n chunks.push(value);\n }\n } finally {\n await reader.cancel();\n reader.releaseLock();\n }\n signal.throwIfAborted();\n const name = input.name ?? nodePath.posix.basename(path);\n const mediaType =\n mediaTypes[nodePath.posix.extname(name).toLowerCase()] ??\n \"application/octet-stream\";\n const stored = await upload(name, Buffer.concat(chunks, size), mediaType);\n return attachWorkspaceFileResult.parse({\n fileId: stored.fileId,\n url: stored.url,\n name: stored.pathname,\n mediaType,\n size,\n });\n};\n",
20
+ "type": "registry:file",
21
+ "target": "~/chatjs/tools/attach-workspace-file/attach.ts"
22
+ },
23
+ {
24
+ "path": "src/tools/attach-workspace-file/attach-conversation-file.ts",
25
+ "content": "import type { WorkflowStepToolContext } from \"eve/tools\";\nimport type { z } from \"zod\";\nimport { eveGeneratedFileUploader } from \"@/lib/eve/generated-files\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\nimport { attachSandboxFile } from \"./attach\";\nimport type { attachWorkspaceFileInput } from \"./schemas\";\n\n/** Application boundary shared by tools and durable workflows publishing sandbox files. */\nexport const attachConversationFile = async (\n input: z.infer<typeof attachWorkspaceFileInput>,\n context: Readonly<WorkflowStepToolContext>\n) => {\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 \"Publication requires the current ChatJS conversation owner's authority.\"\n );\n }\n // Authorize the application resource before reading sandbox bytes.\n await resolveEveConversationScope(\n current.principalId,\n context.session.id,\n context.abortSignal\n );\n return await attachSandboxFile(input, {\n sandbox: await context.getSandbox(),\n upload: eveGeneratedFileUploader(context),\n signal: context.abortSignal,\n });\n};\n",
26
+ "type": "registry:file",
27
+ "target": "~/chatjs/tools/attach-workspace-file/attach-conversation-file.ts"
28
+ },
29
+ {
30
+ "path": "src/tools/attach-workspace-file/import.ts",
31
+ "content": "import { randomUUID } from \"node:crypto\";\nimport type { SandboxSession } from \"eve/sandbox\";\nimport type { z } from \"zod\";\nimport { maximumWorkspaceFileBytes } from \"./schemas\";\nimport type { importFileInput } from \"./schemas\";\n\n/** Copy authorized stored bytes into a fresh native workspace path. */\nexport const importStoredFile = async (\n input: z.infer<typeof importFileInput>,\n {\n stat,\n read,\n getSandbox,\n signal,\n }: {\n readonly stat: () => Promise<{ readonly size: number }>;\n readonly read: () => Promise<{\n readonly type: string;\n readonly stream: () => ReadableStream<Uint8Array>;\n }>;\n readonly getSandbox: () => PromiseLike<\n Pick<SandboxSession, \"resolvePath\" | \"writeBinaryFile\">\n >;\n readonly signal: AbortSignal;\n }\n) => {\n signal.throwIfAborted();\n const metadata = await stat();\n if (metadata.size > maximumWorkspaceFileBytes) {\n throw new Error(\"Files must be 32 MiB or smaller.\");\n }\n signal.throwIfAborted();\n const file = await read();\n const reader = file.stream().getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n try {\n for (;;) {\n signal.throwIfAborted();\n // oxlint-disable-next-line eslint/no-await-in-loop -- Bound storage reads before acquiring a sandbox or writing any bytes.\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n size += value.byteLength;\n if (size > maximumWorkspaceFileBytes) {\n throw new Error(\"Files must be 32 MiB or smaller.\");\n }\n chunks.push(value);\n }\n } finally {\n await reader.cancel();\n reader.releaseLock();\n }\n signal.throwIfAborted();\n const sandbox = await getSandbox();\n // Fresh flat filenames cannot follow user-selected directories or overwrite an earlier import.\n const path = sandbox.resolvePath(`import-${randomUUID()}-${input.name}`);\n await sandbox.writeBinaryFile({\n path,\n content: Buffer.concat(chunks, size),\n signal,\n });\n return {\n fileId: input.fileId,\n path,\n name: input.name,\n mediaType: file.type,\n size,\n };\n};\n",
32
+ "type": "registry:file",
33
+ "target": "~/chatjs/tools/attach-workspace-file/import.ts"
34
+ },
35
+ {
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\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
+ "type": "registry:file",
39
+ "target": "~/chatjs/tools/attach-workspace-file/schemas.ts"
40
+ },
41
+ {
42
+ "path": "src/tools/attach-workspace-file/renderer.tsx",
43
+ "content": "\"use client\";\nimport React from \"react\";\nimport { FileArtifactCard } from \"@/components/file-artifact-card\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\nimport { attachWorkspaceFileInput, attachWorkspaceFileResult } from \"./schemas\";\n\nexport const AttachWorkspaceFileRenderer = defineToolRenderer({\n inputSchema: attachWorkspaceFileInput,\n outputSchema: attachWorkspaceFileResult,\n render: ({ tool }) =>\n tool.state === \"output-available\" ? (\n <FileArtifactCard artifact={tool.output} />\n ) : (\n <output className=\"text-muted-foreground block rounded-lg border p-4 text-sm\">\n Preparing download\n {tool.input?.name === undefined ? \"…\" : `: ${tool.input.name}`}\n </output>\n ),\n});\n",
44
+ "type": "registry:file",
45
+ "target": "~/chatjs/tools/attach-workspace-file/renderer.tsx"
46
+ },
47
+ {
48
+ "path": "dist/source/attach-workspace-file.json",
49
+ "content": "{\n \"agentCategory\": \"tool\",\n \"requiresChatJS\": true,\n \"channelSupport\": { \"web\": \"supported\", \"slack\": \"unsupported\" },\n \"envRequirements\": [],\n \"id\": \"attach-workspace-file\",\n \"kind\": \"tool\",\n \"requiresStorage\": true,\n \"requiresTools\": [],\n \"tools\": [\n { \"accounting\": \"none\", \"toolExport\": \"import_file\" },\n {\n \"accounting\": \"none\",\n \"rendererExport\": \"AttachWorkspaceFileRenderer\",\n \"toolExport\": \"attach_workspace_file\"\n }\n ],\n \"contractVersion\": 1\n}\n",
50
+ "type": "registry:file",
51
+ "target": "~/chatjs/tools/attach-workspace-file/chatjs.json"
52
+ }
53
+ ],
54
+ "meta": {
55
+ "chatjs": {
56
+ "agentCategory": "tool",
57
+ "requiresChatJS": true,
58
+ "channelSupport": {
59
+ "web": "supported",
60
+ "slack": "unsupported"
61
+ },
62
+ "envRequirements": [],
63
+ "id": "attach-workspace-file",
64
+ "kind": "tool",
65
+ "requiresStorage": true,
66
+ "requiresTools": [],
67
+ "tools": [
68
+ {
69
+ "accounting": "none",
70
+ "toolExport": "import_file"
71
+ },
72
+ {
73
+ "accounting": "none",
74
+ "rendererExport": "AttachWorkspaceFileRenderer",
75
+ "toolExport": "attach_workspace_file"
76
+ }
77
+ ],
78
+ "contractVersion": 1
79
+ }
80
+ },
81
+ "type": "registry:item"
82
+ }
@@ -3,37 +3,38 @@
3
3
  "name": "attachment-uploads",
4
4
  "description": "User attachment picker, camera, paste/drop, preprocessing and upload endpoint",
5
5
  "dependencies": [
6
- "browser-image-compression",
7
- "react-dropzone"
6
+ "lucide-react@0.553.0",
7
+ "sonner@^2.0.7",
8
+ "browser-image-compression@^2.0.2"
8
9
  ],
9
10
  "files": [
10
11
  {
11
12
  "path": "src/plugins/attachment-uploads/src/controls.tsx",
12
- "content": "\"use client\";\nimport { Camera, Paperclip } from \"lucide-react\";\nimport type { ComposerControlProps } from \"@/components/composer/control\";\nimport React from \"react\";\nimport { toast } from \"sonner\";\n\nimport { DropdownMenuItem } from \"@/components/ui/dropdown-menu\";\nimport { LoginPrompt } from \"@/components/upgrade-cta/login-prompt\";\nimport { installedPlugins } from \"@/composition/generated/installed\";\nimport { useIsMobile } from \"@/hooks/use-mobile\";\nimport { config } from \"@/lib/config\";\nimport { useSession } from \"@/providers/session-provider\";\n\ntype AttachControlProps = Readonly<\n Pick<ComposerControlProps, \"disabled\" | \"onAttach\">\n>;\n\nconst loginPrompt = (\n <LoginPrompt\n title=\"Sign in to attach files\"\n description=\"Sign in to use this plugin in your conversation.\"\n />\n);\n\nconst AttachFilesControl = ({\n disabled,\n onAttach,\n}: AttachControlProps): React.JSX.Element | null => {\n const { data: session } = useSession();\n if (!installedPlugins.has(\"attachment-uploads\")) {\n return null;\n }\n return (\n <DropdownMenuItem\n disabled={disabled}\n onClick={(): void => {\n if (!session?.user) {\n toast(loginPrompt);\n return;\n }\n onAttach(Object.keys(config.attachments.acceptedTypes).join(\",\"));\n }}\n >\n <Paperclip />\n Attach files\n </DropdownMenuItem>\n );\n};\n\nconst TakePhotoControl = ({\n disabled,\n onAttach,\n}: AttachControlProps): React.JSX.Element | null => {\n const mobile = useIsMobile();\n const { data: session } = useSession();\n if (!installedPlugins.has(\"attachment-uploads\") || !mobile) {\n return null;\n }\n return (\n <DropdownMenuItem\n disabled={disabled}\n onClick={(): void => {\n if (!session?.user) {\n toast(loginPrompt);\n return;\n }\n onAttach(\"image/jpeg,image/png\", \"environment\");\n }}\n >\n <Camera />\n Take photo\n </DropdownMenuItem>\n );\n};\n\nAttachFilesControl.isAvailable = (): boolean =>\n installedPlugins.has(\"attachment-uploads\");\nTakePhotoControl.isAvailable = (mobile: boolean): boolean =>\n installedPlugins.has(\"attachment-uploads\") && mobile;\nexport { AttachFilesControl, TakePhotoControl };\n",
13
+ "content": "\"use client\";\nimport { Camera, Paperclip } from \"lucide-react\";\nimport type { ComposerControlProps } from \"@/components/composer/control\";\nimport React from \"react\";\nimport { toast } from \"sonner\";\n\nimport { DropdownMenuItem } from \"@/components/ui/dropdown-menu\";\nimport { LoginPrompt } from \"@/components/upgrade-cta/login-prompt\";\nimport { installedPlugins } from \"@/integrations/plugin-catalog\";\nimport { useIsMobile } from \"@/hooks/use-mobile\";\nimport { config } from \"@/lib/config\";\nimport { useSession } from \"@/providers/session-provider\";\n\ntype AttachControlProps = Readonly<\n Pick<ComposerControlProps, \"disabled\" | \"onAttach\">\n>;\n\nconst loginPrompt = (\n <LoginPrompt\n title=\"Sign in to attach files\"\n description=\"Sign in to use this plugin in your conversation.\"\n />\n);\n\nconst AttachFilesControl = ({\n disabled,\n onAttach,\n}: AttachControlProps): React.JSX.Element | null => {\n const { data: session } = useSession();\n if (!installedPlugins.has(\"attachment-uploads\")) {\n return null;\n }\n return (\n <DropdownMenuItem\n disabled={disabled}\n onClick={(): void => {\n if (!session?.user) {\n toast(loginPrompt);\n return;\n }\n onAttach(Object.keys(config.attachments.acceptedTypes).join(\",\"));\n }}\n >\n <Paperclip />\n Attach files\n </DropdownMenuItem>\n );\n};\n\nconst TakePhotoControl = ({\n disabled,\n onAttach,\n}: AttachControlProps): React.JSX.Element | null => {\n const mobile = useIsMobile();\n const { data: session } = useSession();\n if (!installedPlugins.has(\"attachment-uploads\") || !mobile) {\n return null;\n }\n return (\n <DropdownMenuItem\n disabled={disabled}\n onClick={(): void => {\n if (!session?.user) {\n toast(loginPrompt);\n return;\n }\n onAttach(\"image/jpeg,image/png\", \"environment\");\n }}\n >\n <Camera />\n Take photo\n </DropdownMenuItem>\n );\n};\n\nAttachFilesControl.isAvailable = (): boolean =>\n installedPlugins.has(\"attachment-uploads\");\nTakePhotoControl.isAvailable = (mobile: boolean): boolean =>\n installedPlugins.has(\"attachment-uploads\") && mobile;\nexport { AttachFilesControl, TakePhotoControl };\n",
13
14
  "type": "registry:file",
14
- "target": "~/plugins/attachment-uploads/controls.tsx"
15
+ "target": "~/chatjs/plugins/attachment-uploads/controls.tsx"
15
16
  },
16
17
  {
17
- "path": "src/plugins/attachment-uploads/src/integration.tsx",
18
- "content": "\"use client\";\n\nimport type {\n AttachmentUploadInput,\n AttachmentUploadIntegration,\n} from \"@/lib/installation-contracts\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { useDropzone } from \"react-dropzone\";\nimport { toast } from \"sonner\";\n\nimport { config } from \"@/lib/config\";\nimport { useSession } from \"@/providers/session-provider\";\n\nimport { AttachFilesControl, TakePhotoControl } from \"./controls\";\nimport { uploadAttachment } from \"./upload\";\nimport { processFilesForUpload } from \"./upload-prep\";\n\nconst withUploadCleanup = async (\n upload: () => Promise<void>,\n release: () => void\n): Promise<void> => {\n try {\n await upload();\n } finally {\n release();\n }\n};\n\ntype UploadPasteCaptureEvent = Readonly<{\n clipboardData: Readonly<{\n files: Readonly<Pick<FileList, \"length\" | typeof Symbol.iterator>>;\n }>;\n preventDefault: () => void;\n stopPropagation: () => void;\n}>;\n\ninterface UploadComposer {\n input: React.JSX.Element;\n onAttach: (accept: string, capture?: \"user\" | \"environment\") => void;\n rootProps: Readonly<Record<string, never>> | UploadComposerRootProps;\n}\n\ninterface UploadComposerRootProps {\n onPasteCapture: (event: UploadPasteCaptureEvent) => void;\n role: \"group\";\n}\n\ninterface UploadsResult {\n composer: (disabled: boolean) => UploadComposer;\n uploadQueue: string[];\n}\n\nconst useUploads = ({\n attachmentCount,\n onUploaded,\n}: ReadonlyNativeSurface<AttachmentUploadInput>): UploadsResult => {\n const [, startEventAction] = React.useTransition();\n const input = useRef<HTMLInputElement>(null);\n const { data: session } = useSession();\n const [uploadQueue, setUploadQueue] = useState<string[]>([]);\n const lock = useRef(false);\n const currentCount = useRef(attachmentCount);\n useEffect((): void => {\n currentCount.current = attachmentCount;\n }, [attachmentCount]);\n const upload = async (\n files: ReadonlyNativeSurface<File[]>\n ): Promise<void> => {\n if (lock.current || files.length === 0) {\n return;\n }\n if (!session?.user) {\n toast.error(\"Sign in to attach files.\");\n return;\n }\n if (files.length + currentCount.current > 16) {\n toast.error(\"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 withUploadCleanup(\n async () => {\n const result = await processFilesForUpload(files, config.attachments);\n if (\n result.stillOversized.length > 0 ||\n result.unsupportedFiles.length > 0\n ) {\n toast.error(\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 currentCount.current += 1;\n onUploaded(attachment);\n } catch (error) {\n toast.error(\n error instanceof Error ? error.message : \"Upload failed.\"\n );\n }\n }\n },\n () => {\n lock.current = false;\n setUploadQueue([]);\n }\n );\n };\n const { getRootProps } = useDropzone({\n disabled: uploadQueue.length > 0,\n noClick: true,\n noKeyboard: true,\n\n onDrop: (files: ReadonlyNativeSurface<File[]>) => {\n // Start outside the transition so the upload queue locks Send immediately.\n const completion = upload(files);\n startEventAction(async () => {\n await completion;\n });\n },\n });\n return {\n composer: (disabled: boolean) => ({\n input: (\n <input\n aria-label=\"Attach files\"\n className=\"hidden\"\n disabled={disabled}\n multiple\n ref={input}\n type=\"file\"\n\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n if (disabled) {\n event.target.value = \"\";\n return;\n }\n const completion = upload([...(event.target.files ?? [])]);\n startEventAction(async () => {\n await completion;\n event.target.value = \"\";\n });\n }}\n />\n ),\n onAttach: (accept: string, capture?: \"user\" | \"environment\"): void => {\n if (disabled || !input.current) {\n return;\n }\n input.current.accept = accept;\n if (capture) {\n input.current.capture = capture;\n } else {\n input.current.removeAttribute(\"capture\");\n }\n input.current.click();\n },\n rootProps: disabled\n ? {}\n : {\n ...getRootProps({ role: \"group\" }),\n onPasteCapture: (event: UploadPasteCaptureEvent): void => {\n if (event.clipboardData.files.length > 0) {\n event.preventDefault();\n event.stopPropagation();\n const completion = upload([...event.clipboardData.files]);\n startEventAction(async () => {\n await completion;\n });\n }\n },\n },\n }),\n uploadQueue,\n };\n};\n\nexport const attachmentUploads = {\n controls: [\n { Component: AttachFilesControl, id: \"attach-files\" },\n { Component: TakePhotoControl, id: \"take-photo\" },\n ],\n useUploads,\n} satisfies AttachmentUploadIntegration;\n",
18
+ "path": "src/plugins/attachment-uploads/src/uploads.ts",
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",
19
20
  "type": "registry:file",
20
- "target": "~/plugins/attachment-uploads/integration.tsx"
21
+ "target": "~/chatjs/plugins/attachment-uploads/uploads.ts"
21
22
  },
22
23
  {
23
24
  "path": "src/plugins/attachment-uploads/src/upload.ts",
24
25
  "content": "import { attachmentDigest, draftAttachment } from \"@/lib/eve/draft\";\nimport type { z } from \"zod\";\n\nexport const uploadAttachment = async (\n file: Readonly<File>\n): Promise<z.infer<typeof draftAttachment>> => {\n const body = new FormData();\n body.append(\"file\", file);\n const response = await fetch(\"/api/files/upload\", {\n body,\n method: \"POST\",\n });\n if (!response.ok) {\n const failure: unknown = await response.json().catch(() => null);\n throw new Error(\n failure !== null &&\n typeof failure === \"object\" &&\n \"error\" in failure &&\n typeof failure.error === \"string\"\n ? failure.error\n : `Unable to upload ${file.name}.`\n );\n }\n const uploaded: unknown = await response.json();\n if (uploaded === null || typeof uploaded !== \"object\") {\n throw new Error(`Invalid upload response for ${file.name}.`);\n }\n return draftAttachment.parse({\n ...uploaded,\n contentType: file.type,\n digest: await attachmentDigest(await file.arrayBuffer()),\n name: file.name,\n });\n};\n",
25
26
  "type": "registry:file",
26
- "target": "~/plugins/attachment-uploads/upload.ts"
27
+ "target": "~/chatjs/plugins/attachment-uploads/upload.ts"
27
28
  },
28
29
  {
29
30
  "path": "src/plugins/attachment-uploads/src/upload-prep.ts",
30
31
  "content": "// Utilities for client-side file preparation prior to upload\n\nimport imageCompression from \"browser-image-compression\";\n\nconst FILE_EXTENSION_REGEX = /\\.[^.]+$/u;\n\nconst imageExtension = (mimeType: string): string => {\n if (mimeType === \"image/jpeg\") {\n return \"jpg\";\n }\n if (mimeType === \"image/png\") {\n return \"png\";\n }\n const [, extension] = mimeType.split(\"/\");\n return extension ?? \"jpg\";\n};\n\nconst compressImageIfNeeded = async (\n file: Readonly<File>,\n {\n maxBytes,\n maxDimension,\n minQuality = 0.5,\n }: Readonly<{\n maxBytes: number;\n maxDimension: number;\n minQuality?: number;\n }>\n): Promise<File> => {\n if (!file.type.startsWith(\"image/\")) {\n return file;\n }\n if (file.size <= maxBytes) {\n return file;\n }\n\n // Only compress JPEG/PNG. Leave others unchanged.\n if (![\"image/jpeg\", \"image/png\"].includes(file.type)) {\n return file;\n }\n\n const outputMime = file.type;\n\n const options = {\n fileType: outputMime,\n initialQuality: Math.min(0.9, Math.max(minQuality, 0.1)),\n maxSizeMB: maxBytes / (1024 * 1024),\n maxWidthOrHeight: maxDimension,\n useWebWorker: true,\n } as const;\n\n try {\n const maybeResult = await imageCompression(file, options);\n const resultBlob =\n maybeResult instanceof File\n ? maybeResult\n : new File([maybeResult], file.name, {\n lastModified: Date.now(),\n type: outputMime,\n });\n if (resultBlob.size >= file.size) {\n return file;\n }\n\n const base = file.name.replace(FILE_EXTENSION_REGEX, \"\");\n return new File([resultBlob], `${base}.${imageExtension(outputMime)}`, {\n lastModified: Date.now(),\n type: outputMime,\n });\n } catch {\n return file;\n }\n};\n\nexport const processFilesForUpload = async (\n files: readonly Readonly<File>[],\n options: Readonly<{\n maxBytes: number;\n maxDimension: number;\n acceptedTypes: Readonly<Record<string, readonly string[]>>;\n }>\n): Promise<{\n files: File[];\n stillOversized: File[];\n unsupportedFiles: File[];\n}> => {\n const prepared: File[] = [];\n const stillOversized: File[] = [];\n const unsupportedFiles: File[] = [];\n const { maxBytes } = options;\n\n for (const file of files) {\n if (!Object.hasOwn(options.acceptedTypes, file.type)) {\n unsupportedFiles.push(file);\n } else if (file.type.startsWith(\"image/\")) {\n // oxlint-disable-next-line no-await-in-loop -- Compress one image at a time to bound browser worker and memory use.\n const maybeCompressed = await compressImageIfNeeded(file, options);\n if (maybeCompressed.size > maxBytes) {\n stillOversized.push(file);\n } else {\n prepared.push(maybeCompressed);\n }\n } else if (file.type === \"application/pdf\") {\n if (file.size > maxBytes) {\n stillOversized.push(file);\n } else {\n prepared.push(file);\n }\n } else {\n unsupportedFiles.push(file);\n }\n }\n\n return { files: prepared, stillOversized, unsupportedFiles };\n};\n",
31
32
  "type": "registry:file",
32
- "target": "~/plugins/attachment-uploads/upload-prep.ts"
33
+ "target": "~/chatjs/plugins/attachment-uploads/upload-prep.ts"
33
34
  },
34
35
  {
35
36
  "path": "src/plugins/attachment-uploads/adapters/app/(chat)/api/files/upload/route.ts",
36
- "content": "export { POST } from \"@/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",
37
38
  "type": "registry:file",
38
39
  "target": "~/app/(chat)/api/files/upload/route.ts"
39
40
  },
@@ -41,46 +42,37 @@
41
42
  "path": "src/plugins/attachment-uploads/src/routes/upload.ts",
42
43
  "content": "import type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { headers } from \"next/headers\";\nimport { NextResponse } from \"next/server\";\nimport { z } from \"zod\";\n\nimport { auth } from \"@/lib/auth\";\nimport { config } from \"@/lib/config\";\nimport { reserveEveUpload, writeEveUpload } from \"@/lib/db/eve-files\";\nimport { createFileId, uploadFileAtKey } from \"@/lib/file-storage\";\n\n// Allow multipart headers and fields without buffering an unbounded request.\nconst MAX_MULTIPART_OVERHEAD_BYTES = 65_536;\nconst requestTooLarge = (): NextResponse<{ error: string }> =>\n NextResponse.json(\n { error: \"Upload request exceeds the size limit\" },\n { status: 413 }\n );\n\n// Validate uploaded bytes through the Blob interface; File extends Blob.\nconst FileSchema = z.object({\n file: z\n .instanceof(Blob)\n .refine(\n (file: Readonly<Pick<Blob, \"size\">>): boolean =>\n file.size <= config.attachments.maxBytes,\n {\n message: \"File exceeds the upload size limit\",\n }\n )\n .refine(\n (file: Readonly<Pick<Blob, \"type\">>): boolean =>\n Object.hasOwn(config.attachments.acceptedTypes, file.type),\n {\n message: \"Unsupported file type\",\n }\n ),\n});\n// Keep stream accounting synchronous; the getter observes the counter after parsing.\nconst limitUploadBody = (\n request: ReadonlyNativeSurface<Pick<Request, \"body\">>,\n maxRequestBytes: number\n): {\n readonly body: ReadableStream<Uint8Array> | undefined;\n readonly exceeded: boolean;\n} => {\n let receivedBytes = 0;\n let exceedsLimit = false;\n const body = request.body?.pipeThrough(\n new TransformStream<Uint8Array, Uint8Array>({\n transform(\n chunk: ReadonlyNativeSurface<Uint8Array>,\n controller: Readonly<\n Pick<\n TransformStreamDefaultController<Uint8Array>,\n \"error\" | \"enqueue\"\n >\n >\n ): void {\n receivedBytes += chunk.byteLength;\n if (receivedBytes > maxRequestBytes) {\n exceedsLimit = true;\n controller.error(new Error(\"Upload request exceeds the size limit\"));\n return;\n }\n controller.enqueue(chunk);\n },\n })\n );\n return {\n body,\n get exceeded(): boolean {\n return exceedsLimit;\n },\n };\n};\n\nconst validateUploadForm = (\n formData: ReadonlyNativeSurface<Pick<FormData, \"get\">>\n):\n | { readonly file: File }\n | { readonly response: ReturnType<typeof requestTooLarge> } => {\n const file = formData.get(\"file\");\n\n if (!(file instanceof File)) {\n return {\n response: NextResponse.json(\n { error: \"No file uploaded\" },\n { status: 400 }\n ),\n };\n }\n\n const validatedFile = FileSchema.safeParse({ file });\n\n if (!validatedFile.success) {\n const errorMessage = validatedFile.error.issues\n .map(\n (issue: Readonly<Pick<z.core.$ZodIssue, \"message\">>): string =>\n issue.message\n )\n .join(\", \");\n\n return {\n response: NextResponse.json({ error: errorMessage }, { status: 400 }),\n };\n }\n\n return { file };\n};\n\nexport const POST = async (\n request: ReadonlyNativeSurface<Request>\n): Promise<\n | ReturnType<typeof requestTooLarge>\n | NextResponse<Awaited<ReturnType<typeof uploadFileAtKey>>>\n> => {\n const session = await auth.api.getSession({ headers: await headers() });\n\n if (!session) {\n return NextResponse.json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const maxRequestBytes =\n config.attachments.maxBytes + MAX_MULTIPART_OVERHEAD_BYTES;\n if (Number(request.headers.get(\"content-length\")) > maxRequestBytes) {\n return requestTooLarge();\n }\n\n const limitedBody = limitUploadBody(request, maxRequestBytes);\n const formData = await new Response(limitedBody.body, {\n headers: request.headers,\n })\n .formData()\n .catch(() => null);\n if (limitedBody.exceeded) {\n return requestTooLarge();\n }\n if (!formData) {\n return NextResponse.json({ error: \"Invalid upload form\" }, { status: 400 });\n }\n\n try {\n const validated = validateUploadForm(formData);\n if (\"response\" in validated) {\n return validated.response;\n }\n const { file } = validated;\n\n // Get filename from formData since Blob doesn't have name property\n const filename = file.name;\n const fileBuffer = await file.arrayBuffer();\n\n try {\n const key = createFileId();\n await reserveEveUpload(session.user.id, key);\n // Keep the reservation if storage fails: an uncertain write can still finish.\n const write = async (): ReturnType<typeof uploadFileAtKey> =>\n await uploadFileAtKey(key, filename, fileBuffer, file.type);\n const data = await writeEveUpload(session.user.id, key, write);\n return NextResponse.json(data);\n } catch {\n return NextResponse.json({ error: \"Upload failed\" }, { status: 500 });\n }\n } catch {\n return NextResponse.json(\n { error: \"Failed to process request\" },\n { status: 500 }\n );\n }\n};\n",
43
44
  "type": "registry:file",
44
- "target": "~/plugins/attachment-uploads/routes/upload.ts"
45
+ "target": "~/chatjs/plugins/attachment-uploads/routes/upload.ts"
45
46
  },
46
47
  {
47
- "path": "src/plugins/attachment-uploads/src/client-plugin.ts",
48
- "content": "import type { ChatClientPlugin } from \"@/lib/plugin-contracts\";\nimport { attachmentUploads } from \"./integration\";\n\nexport const attachmentUploadsClient = () =>\n ({\n id: \"attachment-uploads\",\n composerControls: attachmentUploads.controls,\n uploads: attachmentUploads,\n }) satisfies ChatClientPlugin;\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",
49
50
  "type": "registry:file",
50
- "target": "~/plugins/attachment-uploads/client-plugin.ts"
51
+ "target": "~/chatjs/plugins/attachment-uploads/chat-ui.ts"
51
52
  },
52
53
  {
53
54
  "path": "dist/source/attachment-uploads.json",
54
- "content": "{\n \"id\": \"attachment-uploads\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/attachment-uploads/controls.tsx\",\n \"plugins/attachment-uploads/integration.tsx\",\n \"plugins/attachment-uploads/upload.ts\",\n \"plugins/attachment-uploads/upload-prep.ts\",\n \"app/(chat)/api/files/upload/route.ts\",\n \"plugins/attachment-uploads/routes/upload.ts\",\n \"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",
55
56
  "type": "registry:file",
56
- "target": "~/plugins/attachment-uploads/chatjs.json"
57
+ "target": "~/chatjs/plugins/attachment-uploads/plugin.json"
57
58
  }
58
59
  ],
59
60
  "meta": {
60
61
  "chatjs": {
62
+ "contractVersion": 3,
63
+ "uiBase": "base",
61
64
  "id": "attachment-uploads",
62
65
  "kind": "plugin",
63
66
  "files": [
64
- "plugins/attachment-uploads/controls.tsx",
65
- "plugins/attachment-uploads/integration.tsx",
66
- "plugins/attachment-uploads/upload.ts",
67
- "plugins/attachment-uploads/upload-prep.ts",
67
+ "chatjs/plugins/attachment-uploads/controls.tsx",
68
+ "chatjs/plugins/attachment-uploads/uploads.ts",
69
+ "chatjs/plugins/attachment-uploads/upload.ts",
70
+ "chatjs/plugins/attachment-uploads/upload-prep.ts",
68
71
  "app/(chat)/api/files/upload/route.ts",
69
- "plugins/attachment-uploads/routes/upload.ts",
70
- "plugins/attachment-uploads/client-plugin.ts"
72
+ "chatjs/plugins/attachment-uploads/routes/upload.ts",
73
+ "chatjs/plugins/attachment-uploads/chat-ui.ts"
71
74
  ],
72
- "requiresStorage": true,
73
- "client": {
74
- "export": "attachmentUploadsClient",
75
- "composerControls": [
76
- "attach-files",
77
- "take-photo"
78
- ],
79
- "settingsItems": [],
80
- "uploads": true
81
- },
82
- "contractVersion": 2,
83
- "uiBase": "base"
75
+ "requiresStorage": true
84
76
  }
85
77
  },
86
78
  "type": "registry:item"
@@ -12,7 +12,7 @@
12
12
  "path": "src/storage/azure/storage-provider.ts",
13
13
  "content": "export { azure as createStorageAdapter } from \"files-sdk/azure\";\n",
14
14
  "type": "registry:file",
15
- "target": "~/lib/storage-provider.ts"
15
+ "target": "~/chatjs/providers/storage.ts"
16
16
  }
17
17
  ],
18
18
  "meta": {
@@ -20,6 +20,13 @@
20
20
  "configKeys": [
21
21
  "container"
22
22
  ],
23
+ "configFields": [
24
+ {
25
+ "key": "container",
26
+ "label": "container",
27
+ "type": "text"
28
+ }
29
+ ],
23
30
  "contractVersion": 1,
24
31
  "envRequirements": [
25
32
  {