@aigentic/ruflo 3.7.0-alpha.69

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 (524) hide show
  1. package/README.md +410 -0
  2. package/bin/ruflo.js +57 -0
  3. package/package.json +98 -0
  4. package/src/chat-ui/Dockerfile +25 -0
  5. package/src/chat-ui/patch-mcp-url-safety.sh +28 -0
  6. package/src/chat-ui/static/chatui/icon-144x144.png +0 -0
  7. package/src/chat-ui/static/chatui/omni-welcome.gif +0 -0
  8. package/src/config/config.example.json +76 -0
  9. package/src/mcp-bridge/Dockerfile +45 -0
  10. package/src/mcp-bridge/index.js +1668 -0
  11. package/src/mcp-bridge/mcp-stdio-kernel.js +159 -0
  12. package/src/mcp-bridge/package.json +17 -0
  13. package/src/mcp-bridge/test-harness.js +470 -0
  14. package/src/nginx/Dockerfile +10 -0
  15. package/src/nginx/nginx.conf +67 -0
  16. package/src/nginx/static/favicon-dark.svg +4 -0
  17. package/src/nginx/static/favicon.svg +4 -0
  18. package/src/nginx/static/icon.svg +5 -0
  19. package/src/nginx/static/logo.svg +9 -0
  20. package/src/nginx/static/manifest.json +22 -0
  21. package/src/nginx/static/welcome.js +184 -0
  22. package/src/ruvocal/.claude/skills/add-model-descriptions/SKILL.md +73 -0
  23. package/src/ruvocal/.devcontainer/Dockerfile +9 -0
  24. package/src/ruvocal/.devcontainer/devcontainer.json +36 -0
  25. package/src/ruvocal/.dockerignore +17 -0
  26. package/src/ruvocal/.eslintignore +13 -0
  27. package/src/ruvocal/.eslintrc.cjs +45 -0
  28. package/src/ruvocal/.gcloudignore +18 -0
  29. package/src/ruvocal/.github/ISSUE_TEMPLATE/bug-report--chat-ui-.md +43 -0
  30. package/src/ruvocal/.github/ISSUE_TEMPLATE/config-support.md +9 -0
  31. package/src/ruvocal/.github/ISSUE_TEMPLATE/feature-request--chat-ui-.md +17 -0
  32. package/src/ruvocal/.github/ISSUE_TEMPLATE/huggingchat.md +11 -0
  33. package/src/ruvocal/.github/release.yml +16 -0
  34. package/src/ruvocal/.github/workflows/build-docs.yml +18 -0
  35. package/src/ruvocal/.github/workflows/build-image.yml +142 -0
  36. package/src/ruvocal/.github/workflows/build-pr-docs.yml +20 -0
  37. package/src/ruvocal/.github/workflows/deploy-dev.yml +63 -0
  38. package/src/ruvocal/.github/workflows/deploy-prod.yml +78 -0
  39. package/src/ruvocal/.github/workflows/lint-and-test.yml +84 -0
  40. package/src/ruvocal/.github/workflows/slugify.yaml +72 -0
  41. package/src/ruvocal/.github/workflows/trufflehog.yml +17 -0
  42. package/src/ruvocal/.github/workflows/upload-pr-documentation.yml +16 -0
  43. package/src/ruvocal/.husky/lint-stage-config.js +4 -0
  44. package/src/ruvocal/.husky/pre-commit +2 -0
  45. package/src/ruvocal/.prettierignore +14 -0
  46. package/src/ruvocal/.prettierrc +7 -0
  47. package/src/ruvocal/CLAUDE.md +126 -0
  48. package/src/ruvocal/Dockerfile +96 -0
  49. package/src/ruvocal/LICENSE +203 -0
  50. package/src/ruvocal/PRIVACY.md +41 -0
  51. package/src/ruvocal/README.md +164 -0
  52. package/src/ruvocal/chart/Chart.yaml +5 -0
  53. package/src/ruvocal/chart/env/dev.yaml +260 -0
  54. package/src/ruvocal/chart/env/prod.yaml +273 -0
  55. package/src/ruvocal/chart/templates/_helpers.tpl +22 -0
  56. package/src/ruvocal/chart/templates/config.yaml +10 -0
  57. package/src/ruvocal/chart/templates/deployment.yaml +81 -0
  58. package/src/ruvocal/chart/templates/hpa.yaml +45 -0
  59. package/src/ruvocal/chart/templates/infisical.yaml +24 -0
  60. package/src/ruvocal/chart/templates/ingress-internal.yaml +32 -0
  61. package/src/ruvocal/chart/templates/ingress.yaml +32 -0
  62. package/src/ruvocal/chart/templates/network-policy.yaml +36 -0
  63. package/src/ruvocal/chart/templates/service-account.yaml +13 -0
  64. package/src/ruvocal/chart/templates/service-monitor.yaml +17 -0
  65. package/src/ruvocal/chart/templates/service.yaml +21 -0
  66. package/src/ruvocal/chart/values.yaml +73 -0
  67. package/src/ruvocal/cloudbuild.yaml +68 -0
  68. package/src/ruvocal/config/branding.env.example +19 -0
  69. package/src/ruvocal/docker-compose.yml +21 -0
  70. package/src/ruvocal/docs/adr/ADR-029-HUGGINGFACE-CHAT-UI-CLOUD-RUN.md +1236 -0
  71. package/src/ruvocal/docs/adr/ADR-033-RUVECTOR-RUFLO-MCP-INTEGRATION.md +111 -0
  72. package/src/ruvocal/docs/adr/ADR-034-OPTIONAL-MCP-BACKENDS.md +117 -0
  73. package/src/ruvocal/docs/adr/ADR-035-MCP-TOOL-GROUPS.md +186 -0
  74. package/src/ruvocal/docs/adr/ADR-037-AUTOPILOT-CHAT-MODE.md +1500 -0
  75. package/src/ruvocal/docs/adr/ADR-038-RUVOCAL-FORK.md +286 -0
  76. package/src/ruvocal/docs/source/_toctree.yml +30 -0
  77. package/src/ruvocal/docs/source/configuration/common-issues.md +38 -0
  78. package/src/ruvocal/docs/source/configuration/llm-router.md +105 -0
  79. package/src/ruvocal/docs/source/configuration/mcp-tools.md +84 -0
  80. package/src/ruvocal/docs/source/configuration/metrics.md +9 -0
  81. package/src/ruvocal/docs/source/configuration/open-id.md +57 -0
  82. package/src/ruvocal/docs/source/configuration/overview.md +89 -0
  83. package/src/ruvocal/docs/source/configuration/theming.md +20 -0
  84. package/src/ruvocal/docs/source/developing/architecture.md +48 -0
  85. package/src/ruvocal/docs/source/index.md +53 -0
  86. package/src/ruvocal/docs/source/installation/docker.md +43 -0
  87. package/src/ruvocal/docs/source/installation/helm.md +43 -0
  88. package/src/ruvocal/docs/source/installation/local.md +62 -0
  89. package/src/ruvocal/entrypoint.sh +19 -0
  90. package/src/ruvocal/mcp-bridge/Dockerfile +45 -0
  91. package/src/ruvocal/mcp-bridge/cloudbuild.yaml +49 -0
  92. package/src/ruvocal/mcp-bridge/index.js +1878 -0
  93. package/src/ruvocal/mcp-bridge/mcp-stdio-kernel.js +159 -0
  94. package/src/ruvocal/mcp-bridge/package-lock.json +762 -0
  95. package/src/ruvocal/mcp-bridge/package.json +17 -0
  96. package/src/ruvocal/mcp-bridge/test-harness.js +470 -0
  97. package/src/ruvocal/models/add-your-models-here.txt +1 -0
  98. package/src/ruvocal/package-lock.json +11741 -0
  99. package/src/ruvocal/package.json +121 -0
  100. package/src/ruvocal/postcss.config.js +6 -0
  101. package/src/ruvocal/rvf.manifest.json +204 -0
  102. package/src/ruvocal/scripts/config.ts +64 -0
  103. package/src/ruvocal/scripts/generate-welcome.mjs +181 -0
  104. package/src/ruvocal/scripts/populate.ts +288 -0
  105. package/src/ruvocal/scripts/samples.txt +194 -0
  106. package/src/ruvocal/scripts/setups/vitest-setup-client.ts +0 -0
  107. package/src/ruvocal/scripts/setups/vitest-setup-server.ts +44 -0
  108. package/src/ruvocal/scripts/updateLocalEnv.ts +48 -0
  109. package/src/ruvocal/src/ambient.d.ts +7 -0
  110. package/src/ruvocal/src/app.d.ts +29 -0
  111. package/src/ruvocal/src/app.html +53 -0
  112. package/src/ruvocal/src/hooks.server.ts +32 -0
  113. package/src/ruvocal/src/hooks.ts +6 -0
  114. package/src/ruvocal/src/lib/APIClient.ts +148 -0
  115. package/src/ruvocal/src/lib/actions/clickOutside.ts +18 -0
  116. package/src/ruvocal/src/lib/actions/snapScrollToBottom.ts +346 -0
  117. package/src/ruvocal/src/lib/buildPrompt.ts +33 -0
  118. package/src/ruvocal/src/lib/components/AnnouncementBanner.svelte +20 -0
  119. package/src/ruvocal/src/lib/components/BackgroundGenerationPoller.svelte +168 -0
  120. package/src/ruvocal/src/lib/components/CodeBlock.svelte +73 -0
  121. package/src/ruvocal/src/lib/components/CopyToClipBoardBtn.svelte +92 -0
  122. package/src/ruvocal/src/lib/components/DeleteConversationModal.svelte +75 -0
  123. package/src/ruvocal/src/lib/components/EditConversationModal.svelte +100 -0
  124. package/src/ruvocal/src/lib/components/ExpandNavigation.svelte +22 -0
  125. package/src/ruvocal/src/lib/components/FoundationBackground.svelte +242 -0
  126. package/src/ruvocal/src/lib/components/HoverTooltip.svelte +44 -0
  127. package/src/ruvocal/src/lib/components/HtmlPreviewModal.svelte +143 -0
  128. package/src/ruvocal/src/lib/components/InfiniteScroll.svelte +50 -0
  129. package/src/ruvocal/src/lib/components/MobileNav.svelte +300 -0
  130. package/src/ruvocal/src/lib/components/Modal.svelte +115 -0
  131. package/src/ruvocal/src/lib/components/ModelCardMetadata.svelte +71 -0
  132. package/src/ruvocal/src/lib/components/NavConversationItem.svelte +151 -0
  133. package/src/ruvocal/src/lib/components/NavMenu.svelte +313 -0
  134. package/src/ruvocal/src/lib/components/Pagination.svelte +97 -0
  135. package/src/ruvocal/src/lib/components/PaginationArrow.svelte +27 -0
  136. package/src/ruvocal/src/lib/components/Portal.svelte +24 -0
  137. package/src/ruvocal/src/lib/components/RetryBtn.svelte +18 -0
  138. package/src/ruvocal/src/lib/components/RuFloUniverse.svelte +185 -0
  139. package/src/ruvocal/src/lib/components/RufloHelpModal.svelte +411 -0
  140. package/src/ruvocal/src/lib/components/ScrollToBottomBtn.svelte +47 -0
  141. package/src/ruvocal/src/lib/components/ScrollToPreviousBtn.svelte +77 -0
  142. package/src/ruvocal/src/lib/components/ShareConversationModal.svelte +182 -0
  143. package/src/ruvocal/src/lib/components/StopGeneratingBtn.svelte +69 -0
  144. package/src/ruvocal/src/lib/components/SubscribeModal.svelte +87 -0
  145. package/src/ruvocal/src/lib/components/Switch.svelte +36 -0
  146. package/src/ruvocal/src/lib/components/SystemPromptModal.svelte +44 -0
  147. package/src/ruvocal/src/lib/components/Toast.svelte +27 -0
  148. package/src/ruvocal/src/lib/components/Tooltip.svelte +30 -0
  149. package/src/ruvocal/src/lib/components/WelcomeModal.svelte +46 -0
  150. package/src/ruvocal/src/lib/components/chat/Alternatives.svelte +77 -0
  151. package/src/ruvocal/src/lib/components/chat/BlockWrapper.svelte +72 -0
  152. package/src/ruvocal/src/lib/components/chat/ChatInput.svelte +490 -0
  153. package/src/ruvocal/src/lib/components/chat/ChatIntroduction.svelte +123 -0
  154. package/src/ruvocal/src/lib/components/chat/ChatMessage.svelte +548 -0
  155. package/src/ruvocal/src/lib/components/chat/ChatWindow.svelte +1057 -0
  156. package/src/ruvocal/src/lib/components/chat/FileDropzone.svelte +92 -0
  157. package/src/ruvocal/src/lib/components/chat/ImageLightbox.svelte +66 -0
  158. package/src/ruvocal/src/lib/components/chat/MarkdownBlock.svelte +23 -0
  159. package/src/ruvocal/src/lib/components/chat/MarkdownRenderer.svelte +69 -0
  160. package/src/ruvocal/src/lib/components/chat/MarkdownRenderer.svelte.test.ts +58 -0
  161. package/src/ruvocal/src/lib/components/chat/MessageAvatar.svelte +103 -0
  162. package/src/ruvocal/src/lib/components/chat/ModelSwitch.svelte +64 -0
  163. package/src/ruvocal/src/lib/components/chat/OpenReasoningResults.svelte +81 -0
  164. package/src/ruvocal/src/lib/components/chat/TaskGroup.svelte +88 -0
  165. package/src/ruvocal/src/lib/components/chat/ToolUpdate.svelte +273 -0
  166. package/src/ruvocal/src/lib/components/chat/UploadedFile.svelte +253 -0
  167. package/src/ruvocal/src/lib/components/chat/UrlFetchModal.svelte +203 -0
  168. package/src/ruvocal/src/lib/components/chat/VoiceRecorder.svelte +214 -0
  169. package/src/ruvocal/src/lib/components/icons/IconBurger.svelte +20 -0
  170. package/src/ruvocal/src/lib/components/icons/IconCheap.svelte +20 -0
  171. package/src/ruvocal/src/lib/components/icons/IconChevron.svelte +24 -0
  172. package/src/ruvocal/src/lib/components/icons/IconDazzled.svelte +40 -0
  173. package/src/ruvocal/src/lib/components/icons/IconFast.svelte +20 -0
  174. package/src/ruvocal/src/lib/components/icons/IconLoading.svelte +22 -0
  175. package/src/ruvocal/src/lib/components/icons/IconMCP.svelte +28 -0
  176. package/src/ruvocal/src/lib/components/icons/IconMoon.svelte +21 -0
  177. package/src/ruvocal/src/lib/components/icons/IconNew.svelte +20 -0
  178. package/src/ruvocal/src/lib/components/icons/IconOmni.svelte +90 -0
  179. package/src/ruvocal/src/lib/components/icons/IconPaperclip.svelte +24 -0
  180. package/src/ruvocal/src/lib/components/icons/IconPro.svelte +37 -0
  181. package/src/ruvocal/src/lib/components/icons/IconShare.svelte +21 -0
  182. package/src/ruvocal/src/lib/components/icons/IconSun.svelte +93 -0
  183. package/src/ruvocal/src/lib/components/icons/Logo.svelte +68 -0
  184. package/src/ruvocal/src/lib/components/icons/LogoHuggingFaceBorderless.svelte +54 -0
  185. package/src/ruvocal/src/lib/components/mcp/AddServerForm.svelte +250 -0
  186. package/src/ruvocal/src/lib/components/mcp/MCPServerManager.svelte +185 -0
  187. package/src/ruvocal/src/lib/components/mcp/ServerCard.svelte +203 -0
  188. package/src/ruvocal/src/lib/components/players/AudioPlayer.svelte +82 -0
  189. package/src/ruvocal/src/lib/components/voice/AudioWaveform.svelte +96 -0
  190. package/src/ruvocal/src/lib/components/wasm/GalleryPanel.svelte +357 -0
  191. package/src/ruvocal/src/lib/constants/mcpExamples.ts +114 -0
  192. package/src/ruvocal/src/lib/constants/mime.ts +11 -0
  193. package/src/ruvocal/src/lib/constants/pagination.ts +1 -0
  194. package/src/ruvocal/src/lib/constants/publicSepToken.ts +1 -0
  195. package/src/ruvocal/src/lib/constants/routerExamples.ts +133 -0
  196. package/src/ruvocal/src/lib/constants/rvagentPresets.ts +206 -0
  197. package/src/ruvocal/src/lib/createShareLink.ts +27 -0
  198. package/src/ruvocal/src/lib/jobs/refresh-conversation-stats.ts +297 -0
  199. package/src/ruvocal/src/lib/migrations/lock.ts +56 -0
  200. package/src/ruvocal/src/lib/migrations/migrations.spec.ts +74 -0
  201. package/src/ruvocal/src/lib/migrations/migrations.ts +109 -0
  202. package/src/ruvocal/src/lib/migrations/routines/01-update-search-assistants.ts +50 -0
  203. package/src/ruvocal/src/lib/migrations/routines/02-update-assistants-models.ts +48 -0
  204. package/src/ruvocal/src/lib/migrations/routines/04-update-message-updates.ts +151 -0
  205. package/src/ruvocal/src/lib/migrations/routines/05-update-message-files.ts +56 -0
  206. package/src/ruvocal/src/lib/migrations/routines/06-trim-message-updates.ts +56 -0
  207. package/src/ruvocal/src/lib/migrations/routines/08-update-featured-to-review.ts +32 -0
  208. package/src/ruvocal/src/lib/migrations/routines/09-delete-empty-conversations.spec.ts +214 -0
  209. package/src/ruvocal/src/lib/migrations/routines/09-delete-empty-conversations.ts +88 -0
  210. package/src/ruvocal/src/lib/migrations/routines/10-update-reports-assistantid.ts +29 -0
  211. package/src/ruvocal/src/lib/migrations/routines/index.ts +15 -0
  212. package/src/ruvocal/src/lib/server/__tests__/conversation-stop-generating.spec.ts +103 -0
  213. package/src/ruvocal/src/lib/server/abortRegistry.ts +57 -0
  214. package/src/ruvocal/src/lib/server/abortedGenerations.ts +43 -0
  215. package/src/ruvocal/src/lib/server/adminToken.ts +62 -0
  216. package/src/ruvocal/src/lib/server/api/__tests__/conversations-id.spec.ts +296 -0
  217. package/src/ruvocal/src/lib/server/api/__tests__/conversations-message.spec.ts +216 -0
  218. package/src/ruvocal/src/lib/server/api/__tests__/conversations.spec.ts +235 -0
  219. package/src/ruvocal/src/lib/server/api/__tests__/misc.spec.ts +72 -0
  220. package/src/ruvocal/src/lib/server/api/__tests__/testHelpers.ts +86 -0
  221. package/src/ruvocal/src/lib/server/api/__tests__/user-reports.spec.ts +78 -0
  222. package/src/ruvocal/src/lib/server/api/__tests__/user.spec.ts +239 -0
  223. package/src/ruvocal/src/lib/server/api/types.ts +37 -0
  224. package/src/ruvocal/src/lib/server/api/utils/requireAuth.ts +22 -0
  225. package/src/ruvocal/src/lib/server/api/utils/resolveConversation.ts +69 -0
  226. package/src/ruvocal/src/lib/server/api/utils/resolveModel.ts +27 -0
  227. package/src/ruvocal/src/lib/server/api/utils/superjsonResponse.ts +15 -0
  228. package/src/ruvocal/src/lib/server/apiToken.ts +11 -0
  229. package/src/ruvocal/src/lib/server/auth.ts +554 -0
  230. package/src/ruvocal/src/lib/server/config.ts +187 -0
  231. package/src/ruvocal/src/lib/server/conversation.ts +83 -0
  232. package/src/ruvocal/src/lib/server/database/__tests__/rvf.spec.ts +709 -0
  233. package/src/ruvocal/src/lib/server/database/postgres.ts +700 -0
  234. package/src/ruvocal/src/lib/server/database/rvf.ts +1078 -0
  235. package/src/ruvocal/src/lib/server/database.ts +145 -0
  236. package/src/ruvocal/src/lib/server/endpoints/document.ts +68 -0
  237. package/src/ruvocal/src/lib/server/endpoints/endpoints.ts +43 -0
  238. package/src/ruvocal/src/lib/server/endpoints/images.ts +211 -0
  239. package/src/ruvocal/src/lib/server/endpoints/openai/endpointOai.ts +266 -0
  240. package/src/ruvocal/src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts +212 -0
  241. package/src/ruvocal/src/lib/server/endpoints/openai/openAICompletionToTextGenerationStream.ts +32 -0
  242. package/src/ruvocal/src/lib/server/endpoints/preprocessMessages.ts +61 -0
  243. package/src/ruvocal/src/lib/server/exitHandler.ts +59 -0
  244. package/src/ruvocal/src/lib/server/files/downloadFile.ts +34 -0
  245. package/src/ruvocal/src/lib/server/files/uploadFile.ts +29 -0
  246. package/src/ruvocal/src/lib/server/findRepoRoot.ts +13 -0
  247. package/src/ruvocal/src/lib/server/fonts/Inter-Black.ttf +0 -0
  248. package/src/ruvocal/src/lib/server/fonts/Inter-Bold.ttf +0 -0
  249. package/src/ruvocal/src/lib/server/fonts/Inter-ExtraBold.ttf +0 -0
  250. package/src/ruvocal/src/lib/server/fonts/Inter-ExtraLight.ttf +0 -0
  251. package/src/ruvocal/src/lib/server/fonts/Inter-Light.ttf +0 -0
  252. package/src/ruvocal/src/lib/server/fonts/Inter-Medium.ttf +0 -0
  253. package/src/ruvocal/src/lib/server/fonts/Inter-Regular.ttf +0 -0
  254. package/src/ruvocal/src/lib/server/fonts/Inter-SemiBold.ttf +0 -0
  255. package/src/ruvocal/src/lib/server/fonts/Inter-Thin.ttf +0 -0
  256. package/src/ruvocal/src/lib/server/generateFromDefaultEndpoint.ts +46 -0
  257. package/src/ruvocal/src/lib/server/hooks/error.ts +37 -0
  258. package/src/ruvocal/src/lib/server/hooks/fetch.ts +22 -0
  259. package/src/ruvocal/src/lib/server/hooks/handle.ts +250 -0
  260. package/src/ruvocal/src/lib/server/hooks/init.ts +51 -0
  261. package/src/ruvocal/src/lib/server/isURLLocal.spec.ts +31 -0
  262. package/src/ruvocal/src/lib/server/isURLLocal.ts +74 -0
  263. package/src/ruvocal/src/lib/server/logger.ts +42 -0
  264. package/src/ruvocal/src/lib/server/mcp/clientPool.spec.ts +175 -0
  265. package/src/ruvocal/src/lib/server/mcp/clientPool.ts +0 -0
  266. package/src/ruvocal/src/lib/server/mcp/hf.ts +32 -0
  267. package/src/ruvocal/src/lib/server/mcp/httpClient.ts +122 -0
  268. package/src/ruvocal/src/lib/server/mcp/registry.ts +76 -0
  269. package/src/ruvocal/src/lib/server/mcp/tools.ts +196 -0
  270. package/src/ruvocal/src/lib/server/metrics.ts +255 -0
  271. package/src/ruvocal/src/lib/server/models.ts +518 -0
  272. package/src/ruvocal/src/lib/server/requestContext.ts +55 -0
  273. package/src/ruvocal/src/lib/server/router/arch.ts +230 -0
  274. package/src/ruvocal/src/lib/server/router/endpoint.ts +316 -0
  275. package/src/ruvocal/src/lib/server/router/multimodal.ts +28 -0
  276. package/src/ruvocal/src/lib/server/router/policy.ts +49 -0
  277. package/src/ruvocal/src/lib/server/router/toolsRoute.ts +51 -0
  278. package/src/ruvocal/src/lib/server/router/types.ts +21 -0
  279. package/src/ruvocal/src/lib/server/sendSlack.ts +23 -0
  280. package/src/ruvocal/src/lib/server/textGeneration/generate.ts +258 -0
  281. package/src/ruvocal/src/lib/server/textGeneration/index.ts +96 -0
  282. package/src/ruvocal/src/lib/server/textGeneration/mcp/fileRefs.ts +155 -0
  283. package/src/ruvocal/src/lib/server/textGeneration/mcp/routerResolution.ts +108 -0
  284. package/src/ruvocal/src/lib/server/textGeneration/mcp/runMcpFlow.ts +831 -0
  285. package/src/ruvocal/src/lib/server/textGeneration/mcp/toolInvocation.ts +349 -0
  286. package/src/ruvocal/src/lib/server/textGeneration/mcp/wasmTools.test.ts +633 -0
  287. package/src/ruvocal/src/lib/server/textGeneration/reasoning.ts +23 -0
  288. package/src/ruvocal/src/lib/server/textGeneration/title.ts +83 -0
  289. package/src/ruvocal/src/lib/server/textGeneration/types.ts +28 -0
  290. package/src/ruvocal/src/lib/server/textGeneration/utils/prepareFiles.ts +88 -0
  291. package/src/ruvocal/src/lib/server/textGeneration/utils/routing.ts +21 -0
  292. package/src/ruvocal/src/lib/server/textGeneration/utils/toolPrompt.ts +49 -0
  293. package/src/ruvocal/src/lib/server/urlSafety.ts +77 -0
  294. package/src/ruvocal/src/lib/server/usageLimits.ts +30 -0
  295. package/src/ruvocal/src/lib/stores/autopilotStore.svelte.ts +175 -0
  296. package/src/ruvocal/src/lib/stores/backgroundGenerations.svelte.ts +32 -0
  297. package/src/ruvocal/src/lib/stores/backgroundGenerations.ts +1 -0
  298. package/src/ruvocal/src/lib/stores/errors.ts +9 -0
  299. package/src/ruvocal/src/lib/stores/isAborted.ts +3 -0
  300. package/src/ruvocal/src/lib/stores/isPro.ts +4 -0
  301. package/src/ruvocal/src/lib/stores/loading.ts +3 -0
  302. package/src/ruvocal/src/lib/stores/mcpServers.ts +534 -0
  303. package/src/ruvocal/src/lib/stores/pendingChatInput.ts +3 -0
  304. package/src/ruvocal/src/lib/stores/pendingMessage.ts +9 -0
  305. package/src/ruvocal/src/lib/stores/settings.ts +182 -0
  306. package/src/ruvocal/src/lib/stores/shareModal.ts +13 -0
  307. package/src/ruvocal/src/lib/stores/titleUpdate.ts +8 -0
  308. package/src/ruvocal/src/lib/stores/wasmMcp.ts +472 -0
  309. package/src/ruvocal/src/lib/switchTheme.ts +124 -0
  310. package/src/ruvocal/src/lib/types/AbortedGeneration.ts +8 -0
  311. package/src/ruvocal/src/lib/types/Assistant.ts +31 -0
  312. package/src/ruvocal/src/lib/types/AssistantStats.ts +11 -0
  313. package/src/ruvocal/src/lib/types/ConfigKey.ts +4 -0
  314. package/src/ruvocal/src/lib/types/ConvSidebar.ts +9 -0
  315. package/src/ruvocal/src/lib/types/Conversation.ts +27 -0
  316. package/src/ruvocal/src/lib/types/ConversationStats.ts +13 -0
  317. package/src/ruvocal/src/lib/types/Message.ts +41 -0
  318. package/src/ruvocal/src/lib/types/MessageEvent.ts +10 -0
  319. package/src/ruvocal/src/lib/types/MessageUpdate.ts +139 -0
  320. package/src/ruvocal/src/lib/types/MigrationResult.ts +7 -0
  321. package/src/ruvocal/src/lib/types/Model.ts +23 -0
  322. package/src/ruvocal/src/lib/types/Report.ts +12 -0
  323. package/src/ruvocal/src/lib/types/Review.ts +6 -0
  324. package/src/ruvocal/src/lib/types/Semaphore.ts +19 -0
  325. package/src/ruvocal/src/lib/types/Session.ts +22 -0
  326. package/src/ruvocal/src/lib/types/Settings.ts +93 -0
  327. package/src/ruvocal/src/lib/types/SharedConversation.ts +9 -0
  328. package/src/ruvocal/src/lib/types/Template.ts +6 -0
  329. package/src/ruvocal/src/lib/types/Timestamps.ts +4 -0
  330. package/src/ruvocal/src/lib/types/TokenCache.ts +6 -0
  331. package/src/ruvocal/src/lib/types/Tool.ts +77 -0
  332. package/src/ruvocal/src/lib/types/UrlDependency.ts +5 -0
  333. package/src/ruvocal/src/lib/types/User.ts +14 -0
  334. package/src/ruvocal/src/lib/utils/PublicConfig.svelte.ts +75 -0
  335. package/src/ruvocal/src/lib/utils/auth.ts +17 -0
  336. package/src/ruvocal/src/lib/utils/chunk.ts +33 -0
  337. package/src/ruvocal/src/lib/utils/cookiesAreEnabled.ts +13 -0
  338. package/src/ruvocal/src/lib/utils/debounce.ts +17 -0
  339. package/src/ruvocal/src/lib/utils/deepestChild.ts +6 -0
  340. package/src/ruvocal/src/lib/utils/favicon.ts +21 -0
  341. package/src/ruvocal/src/lib/utils/fetchJSON.ts +23 -0
  342. package/src/ruvocal/src/lib/utils/file2base64.ts +14 -0
  343. package/src/ruvocal/src/lib/utils/formatUserCount.ts +37 -0
  344. package/src/ruvocal/src/lib/utils/generationState.spec.ts +75 -0
  345. package/src/ruvocal/src/lib/utils/generationState.ts +26 -0
  346. package/src/ruvocal/src/lib/utils/getHref.ts +41 -0
  347. package/src/ruvocal/src/lib/utils/getReturnFromGenerator.ts +7 -0
  348. package/src/ruvocal/src/lib/utils/haptics.ts +64 -0
  349. package/src/ruvocal/src/lib/utils/hashConv.ts +12 -0
  350. package/src/ruvocal/src/lib/utils/hf.ts +17 -0
  351. package/src/ruvocal/src/lib/utils/isDesktop.ts +7 -0
  352. package/src/ruvocal/src/lib/utils/isUrl.ts +8 -0
  353. package/src/ruvocal/src/lib/utils/isVirtualKeyboard.ts +16 -0
  354. package/src/ruvocal/src/lib/utils/loadAttachmentsFromUrls.ts +115 -0
  355. package/src/ruvocal/src/lib/utils/marked.spec.ts +96 -0
  356. package/src/ruvocal/src/lib/utils/marked.ts +531 -0
  357. package/src/ruvocal/src/lib/utils/mcpValidation.ts +147 -0
  358. package/src/ruvocal/src/lib/utils/mergeAsyncGenerators.ts +38 -0
  359. package/src/ruvocal/src/lib/utils/messageUpdates.spec.ts +262 -0
  360. package/src/ruvocal/src/lib/utils/messageUpdates.ts +324 -0
  361. package/src/ruvocal/src/lib/utils/mime.ts +56 -0
  362. package/src/ruvocal/src/lib/utils/models.ts +14 -0
  363. package/src/ruvocal/src/lib/utils/parseBlocks.ts +120 -0
  364. package/src/ruvocal/src/lib/utils/parseIncompleteMarkdown.ts +644 -0
  365. package/src/ruvocal/src/lib/utils/parseStringToList.ts +10 -0
  366. package/src/ruvocal/src/lib/utils/randomUuid.ts +14 -0
  367. package/src/ruvocal/src/lib/utils/searchTokens.ts +33 -0
  368. package/src/ruvocal/src/lib/utils/sha256.ts +7 -0
  369. package/src/ruvocal/src/lib/utils/stringifyError.ts +12 -0
  370. package/src/ruvocal/src/lib/utils/sum.ts +3 -0
  371. package/src/ruvocal/src/lib/utils/template.spec.ts +59 -0
  372. package/src/ruvocal/src/lib/utils/template.ts +53 -0
  373. package/src/ruvocal/src/lib/utils/timeout.ts +9 -0
  374. package/src/ruvocal/src/lib/utils/toolProgress.spec.ts +46 -0
  375. package/src/ruvocal/src/lib/utils/toolProgress.ts +11 -0
  376. package/src/ruvocal/src/lib/utils/tree/addChildren.spec.ts +102 -0
  377. package/src/ruvocal/src/lib/utils/tree/addChildren.ts +48 -0
  378. package/src/ruvocal/src/lib/utils/tree/addSibling.spec.ts +81 -0
  379. package/src/ruvocal/src/lib/utils/tree/addSibling.ts +41 -0
  380. package/src/ruvocal/src/lib/utils/tree/buildSubtree.spec.ts +110 -0
  381. package/src/ruvocal/src/lib/utils/tree/buildSubtree.ts +24 -0
  382. package/src/ruvocal/src/lib/utils/tree/convertLegacyConversation.spec.ts +31 -0
  383. package/src/ruvocal/src/lib/utils/tree/convertLegacyConversation.ts +36 -0
  384. package/src/ruvocal/src/lib/utils/tree/isMessageId.spec.ts +15 -0
  385. package/src/ruvocal/src/lib/utils/tree/isMessageId.ts +5 -0
  386. package/src/ruvocal/src/lib/utils/tree/tree.d.ts +14 -0
  387. package/src/ruvocal/src/lib/utils/tree/treeHelpers.spec.ts +167 -0
  388. package/src/ruvocal/src/lib/utils/updates.ts +39 -0
  389. package/src/ruvocal/src/lib/utils/urlParams.ts +13 -0
  390. package/src/ruvocal/src/lib/wasm/idb.ts +438 -0
  391. package/src/ruvocal/src/lib/wasm/index.ts +1213 -0
  392. package/src/ruvocal/src/lib/wasm/tests/wasm-capabilities.test.ts +565 -0
  393. package/src/ruvocal/src/lib/wasm/wasm.worker.ts +332 -0
  394. package/src/ruvocal/src/lib/wasm/workerClient.ts +166 -0
  395. package/src/ruvocal/src/lib/workers/autopilotWorker.ts +221 -0
  396. package/src/ruvocal/src/lib/workers/detailFetchWorker.ts +100 -0
  397. package/src/ruvocal/src/lib/workers/markdownWorker.ts +61 -0
  398. package/src/ruvocal/src/routes/+error.svelte +20 -0
  399. package/src/ruvocal/src/routes/+layout.svelte +324 -0
  400. package/src/ruvocal/src/routes/+layout.ts +91 -0
  401. package/src/ruvocal/src/routes/+page.svelte +168 -0
  402. package/src/ruvocal/src/routes/.well-known/oauth-cimd/+server.ts +37 -0
  403. package/src/ruvocal/src/routes/__debug/openai/+server.ts +21 -0
  404. package/src/ruvocal/src/routes/admin/export/+server.ts +159 -0
  405. package/src/ruvocal/src/routes/admin/stats/compute/+server.ts +16 -0
  406. package/src/ruvocal/src/routes/api/conversation/[id]/+server.ts +40 -0
  407. package/src/ruvocal/src/routes/api/conversation/[id]/message/[messageId]/+server.ts +42 -0
  408. package/src/ruvocal/src/routes/api/conversations/+server.ts +48 -0
  409. package/src/ruvocal/src/routes/api/fetch-url/+server.ts +147 -0
  410. package/src/ruvocal/src/routes/api/mcp/health/+server.ts +292 -0
  411. package/src/ruvocal/src/routes/api/mcp/servers/+server.ts +32 -0
  412. package/src/ruvocal/src/routes/api/models/+server.ts +25 -0
  413. package/src/ruvocal/src/routes/api/transcribe/+server.ts +104 -0
  414. package/src/ruvocal/src/routes/api/user/+server.ts +15 -0
  415. package/src/ruvocal/src/routes/api/user/validate-token/+server.ts +20 -0
  416. package/src/ruvocal/src/routes/api/v2/conversations/+server.ts +48 -0
  417. package/src/ruvocal/src/routes/api/v2/conversations/[id]/+server.ts +94 -0
  418. package/src/ruvocal/src/routes/api/v2/conversations/[id]/message/[messageId]/+server.ts +43 -0
  419. package/src/ruvocal/src/routes/api/v2/conversations/import-share/+server.ts +23 -0
  420. package/src/ruvocal/src/routes/api/v2/debug/config/+server.ts +16 -0
  421. package/src/ruvocal/src/routes/api/v2/debug/refresh/+server.ts +30 -0
  422. package/src/ruvocal/src/routes/api/v2/export/+server.ts +196 -0
  423. package/src/ruvocal/src/routes/api/v2/feature-flags/+server.ts +14 -0
  424. package/src/ruvocal/src/routes/api/v2/models/+server.ts +38 -0
  425. package/src/ruvocal/src/routes/api/v2/models/[namespace]/+server.ts +8 -0
  426. package/src/ruvocal/src/routes/api/v2/models/[namespace]/[model]/+server.ts +8 -0
  427. package/src/ruvocal/src/routes/api/v2/models/[namespace]/[model]/subscribe/+server.ts +28 -0
  428. package/src/ruvocal/src/routes/api/v2/models/[namespace]/subscribe/+server.ts +28 -0
  429. package/src/ruvocal/src/routes/api/v2/models/old/+server.ts +7 -0
  430. package/src/ruvocal/src/routes/api/v2/models/refresh/+server.ts +33 -0
  431. package/src/ruvocal/src/routes/api/v2/public-config/+server.ts +7 -0
  432. package/src/ruvocal/src/routes/api/v2/user/+server.ts +17 -0
  433. package/src/ruvocal/src/routes/api/v2/user/billing-orgs/+server.ts +73 -0
  434. package/src/ruvocal/src/routes/api/v2/user/reports/+server.ts +17 -0
  435. package/src/ruvocal/src/routes/api/v2/user/settings/+server.ts +110 -0
  436. package/src/ruvocal/src/routes/conversation/+server.ts +115 -0
  437. package/src/ruvocal/src/routes/conversation/[id]/+page.svelte +586 -0
  438. package/src/ruvocal/src/routes/conversation/[id]/+page.ts +60 -0
  439. package/src/ruvocal/src/routes/conversation/[id]/+server.ts +740 -0
  440. package/src/ruvocal/src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts +66 -0
  441. package/src/ruvocal/src/routes/conversation/[id]/share/+server.ts +69 -0
  442. package/src/ruvocal/src/routes/conversation/[id]/stop-generating/+server.ts +35 -0
  443. package/src/ruvocal/src/routes/healthcheck/+server.ts +3 -0
  444. package/src/ruvocal/src/routes/login/+server.ts +5 -0
  445. package/src/ruvocal/src/routes/login/callback/+server.ts +103 -0
  446. package/src/ruvocal/src/routes/login/callback/updateUser.spec.ts +157 -0
  447. package/src/ruvocal/src/routes/login/callback/updateUser.ts +215 -0
  448. package/src/ruvocal/src/routes/logout/+server.ts +18 -0
  449. package/src/ruvocal/src/routes/metrics/+server.ts +18 -0
  450. package/src/ruvocal/src/routes/models/+page.svelte +233 -0
  451. package/src/ruvocal/src/routes/models/[...model]/+page.svelte +161 -0
  452. package/src/ruvocal/src/routes/models/[...model]/+page.ts +14 -0
  453. package/src/ruvocal/src/routes/models/[...model]/thumbnail.png/+server.ts +64 -0
  454. package/src/ruvocal/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte +28 -0
  455. package/src/ruvocal/src/routes/privacy/+page.svelte +11 -0
  456. package/src/ruvocal/src/routes/r/[id]/+page.ts +34 -0
  457. package/src/ruvocal/src/routes/settings/(nav)/+layout.svelte +282 -0
  458. package/src/ruvocal/src/routes/settings/(nav)/+layout.ts +1 -0
  459. package/src/ruvocal/src/routes/settings/(nav)/+page.svelte +0 -0
  460. package/src/ruvocal/src/routes/settings/(nav)/+server.ts +59 -0
  461. package/src/ruvocal/src/routes/settings/(nav)/[...model]/+page.svelte +464 -0
  462. package/src/ruvocal/src/routes/settings/(nav)/[...model]/+page.ts +14 -0
  463. package/src/ruvocal/src/routes/settings/(nav)/application/+page.svelte +362 -0
  464. package/src/ruvocal/src/routes/settings/+layout.svelte +40 -0
  465. package/src/ruvocal/src/styles/highlight-js.css +195 -0
  466. package/src/ruvocal/src/styles/main.css +144 -0
  467. package/src/ruvocal/static/chatui/apple-touch-icon.png +0 -0
  468. package/src/ruvocal/static/chatui/favicon-dark.svg +3 -0
  469. package/src/ruvocal/static/chatui/favicon-dev.svg +3 -0
  470. package/src/ruvocal/static/chatui/favicon.ico +0 -0
  471. package/src/ruvocal/static/chatui/favicon.svg +3 -0
  472. package/src/ruvocal/static/chatui/icon-128x128.png +0 -0
  473. package/src/ruvocal/static/chatui/icon-144x144.png +0 -0
  474. package/src/ruvocal/static/chatui/icon-192x192.png +0 -0
  475. package/src/ruvocal/static/chatui/icon-256x256.png +0 -0
  476. package/src/ruvocal/static/chatui/icon-36x36.png +0 -0
  477. package/src/ruvocal/static/chatui/icon-48x48.png +0 -0
  478. package/src/ruvocal/static/chatui/icon-512x512.png +0 -0
  479. package/src/ruvocal/static/chatui/icon-72x72.png +0 -0
  480. package/src/ruvocal/static/chatui/icon-96x96.png +0 -0
  481. package/src/ruvocal/static/chatui/icon.svg +3 -0
  482. package/src/ruvocal/static/chatui/logo.svg +7 -0
  483. package/src/ruvocal/static/chatui/manifest.json +54 -0
  484. package/src/ruvocal/static/chatui/omni-welcome.gif +0 -0
  485. package/src/ruvocal/static/chatui/omni-welcome.png +0 -0
  486. package/src/ruvocal/static/chatui/welcome.js +184 -0
  487. package/src/ruvocal/static/chatui/welcome.svg +1 -0
  488. package/src/ruvocal/static/huggingchat/apple-touch-icon.png +0 -0
  489. package/src/ruvocal/static/huggingchat/assistants-thumbnail.png +0 -0
  490. package/src/ruvocal/static/huggingchat/castle-example.jpg +0 -0
  491. package/src/ruvocal/static/huggingchat/favicon-dark.svg +4 -0
  492. package/src/ruvocal/static/huggingchat/favicon-dev.svg +4 -0
  493. package/src/ruvocal/static/huggingchat/favicon.ico +0 -0
  494. package/src/ruvocal/static/huggingchat/favicon.svg +4 -0
  495. package/src/ruvocal/static/huggingchat/fulltext-logo.svg +2 -0
  496. package/src/ruvocal/static/huggingchat/icon-128x128.png +0 -0
  497. package/src/ruvocal/static/huggingchat/icon-144x144.png +0 -0
  498. package/src/ruvocal/static/huggingchat/icon-192x192.png +0 -0
  499. package/src/ruvocal/static/huggingchat/icon-256x256.png +0 -0
  500. package/src/ruvocal/static/huggingchat/icon-36x36.png +0 -0
  501. package/src/ruvocal/static/huggingchat/icon-48x48.png +0 -0
  502. package/src/ruvocal/static/huggingchat/icon-512x512.png +0 -0
  503. package/src/ruvocal/static/huggingchat/icon-72x72.png +0 -0
  504. package/src/ruvocal/static/huggingchat/icon-96x96.png +0 -0
  505. package/src/ruvocal/static/huggingchat/icon.svg +4 -0
  506. package/src/ruvocal/static/huggingchat/logo.svg +4 -0
  507. package/src/ruvocal/static/huggingchat/manifest.json +54 -0
  508. package/src/ruvocal/static/huggingchat/omni-welcome.gif +0 -0
  509. package/src/ruvocal/static/huggingchat/routes.chat.json +226 -0
  510. package/src/ruvocal/static/huggingchat/thumbnail.png +0 -0
  511. package/src/ruvocal/static/huggingchat/tools-thumbnail.png +0 -0
  512. package/src/ruvocal/static/robots.txt +10 -0
  513. package/src/ruvocal/static/wasm/rvagent_wasm.js +1539 -0
  514. package/src/ruvocal/static/wasm/rvagent_wasm_bg.wasm +0 -0
  515. package/src/ruvocal/stub/@reflink/reflink/index.js +0 -0
  516. package/src/ruvocal/stub/@reflink/reflink/package.json +5 -0
  517. package/src/ruvocal/svelte.config.js +53 -0
  518. package/src/ruvocal/tailwind.config.cjs +30 -0
  519. package/src/ruvocal/tsconfig.json +19 -0
  520. package/src/ruvocal/vite.config.ts +87 -0
  521. package/src/scripts/deploy.sh +116 -0
  522. package/src/scripts/generate-config.js +245 -0
  523. package/src/scripts/generate-welcome.js +187 -0
  524. package/src/scripts/package-rvf.sh +116 -0
@@ -0,0 +1,1057 @@
1
+ <script lang="ts">
2
+ import type { Message, MessageFile } from "$lib/types/Message";
3
+ import { onDestroy } from "svelte";
4
+
5
+ import IconOmni from "$lib/components/icons/IconOmni.svelte";
6
+ import IconCheap from "$lib/components/icons/IconCheap.svelte";
7
+ import IconFast from "$lib/components/icons/IconFast.svelte";
8
+ import CarbonCaretDown from "~icons/carbon/caret-down";
9
+ import { PROVIDERS_HUB_ORGS } from "@huggingface/inference";
10
+ import CarbonDirectionRight from "~icons/carbon/direction-right-01";
11
+ import IconArrowUp from "~icons/lucide/arrow-up";
12
+ import IconMic from "~icons/lucide/mic";
13
+
14
+ import ChatInput from "./ChatInput.svelte";
15
+ import VoiceRecorder from "./VoiceRecorder.svelte";
16
+ import StopGeneratingBtn from "../StopGeneratingBtn.svelte";
17
+ import type { Model } from "$lib/types/Model";
18
+ import FileDropzone from "./FileDropzone.svelte";
19
+ import RetryBtn from "../RetryBtn.svelte";
20
+ import file2base64 from "$lib/utils/file2base64";
21
+ import { base } from "$app/paths";
22
+ import ChatMessage from "./ChatMessage.svelte";
23
+ import ScrollToBottomBtn from "../ScrollToBottomBtn.svelte";
24
+ import ScrollToPreviousBtn from "../ScrollToPreviousBtn.svelte";
25
+ import { browser } from "$app/environment";
26
+ import { snapScrollToBottom } from "$lib/actions/snapScrollToBottom";
27
+ import SystemPromptModal from "../SystemPromptModal.svelte";
28
+ import ShareConversationModal from "../ShareConversationModal.svelte";
29
+ import ChatIntroduction from "./ChatIntroduction.svelte";
30
+ import UploadedFile from "./UploadedFile.svelte";
31
+ import { useSettingsStore } from "$lib/stores/settings";
32
+ import { error } from "$lib/stores/errors";
33
+ import ModelSwitch from "./ModelSwitch.svelte";
34
+ import { routerExamples } from "$lib/constants/routerExamples";
35
+ import { mcpExamples } from "$lib/constants/mcpExamples";
36
+ import type { RouterFollowUp, RouterExample } from "$lib/constants/routerExamples";
37
+ import { allBaseServersEnabled, mcpServersLoaded } from "$lib/stores/mcpServers";
38
+ import { shareModal } from "$lib/stores/shareModal";
39
+ import { pendingChatInput } from "$lib/stores/pendingChatInput";
40
+ import LucideHammer from "~icons/lucide/hammer";
41
+
42
+ import { fly } from "svelte/transition";
43
+ import { cubicInOut } from "svelte/easing";
44
+
45
+ import { isVirtualKeyboard } from "$lib/utils/isVirtualKeyboard";
46
+ import { requireAuthUser } from "$lib/utils/auth";
47
+ import { tap, error as hapticError } from "$lib/utils/haptics";
48
+ import { page } from "$app/state";
49
+ import IconZap from "~icons/lucide/zap";
50
+ import {
51
+ isMessageToolCallUpdate,
52
+ isMessageToolErrorUpdate,
53
+ isMessageToolResultUpdate,
54
+ } from "$lib/utils/messageUpdates";
55
+ import type { ToolFront } from "$lib/types/Tool";
56
+
57
+ interface Props {
58
+ messages?: Message[];
59
+ messagesAlternatives?: Message["id"][][];
60
+ loading?: boolean;
61
+ pending?: boolean;
62
+ shared?: boolean;
63
+ currentModel: Model;
64
+ models: Model[];
65
+ preprompt?: string | undefined;
66
+ files?: File[];
67
+ onmessage?: (content: string) => void;
68
+ onstop?: () => void;
69
+ onretry?: (payload: { id: Message["id"]; content?: string }) => void;
70
+ onshowAlternateMsg?: (payload: { id: Message["id"] }) => void;
71
+ draft?: string;
72
+ }
73
+
74
+ let {
75
+ messages = [],
76
+ messagesAlternatives = [],
77
+ loading = false,
78
+ pending = false,
79
+ shared = false,
80
+ currentModel,
81
+ models,
82
+ preprompt = undefined,
83
+ files = $bindable([]),
84
+ draft = $bindable(""),
85
+ onmessage,
86
+ onstop,
87
+ onretry,
88
+ onshowAlternateMsg,
89
+ }: Props = $props();
90
+
91
+ let isReadOnly = $derived(!models.some((model) => model.id === currentModel.id));
92
+
93
+ let shareModalOpen = $state(false);
94
+ let editMsdgId: Message["id"] | null = $state(null);
95
+ let pastedLongContent = $state(false);
96
+
97
+ // Voice recording state
98
+ let isRecording = $state(false);
99
+ let isTranscribing = $state(false);
100
+ let transcriptionEnabled = $derived(
101
+ !!(page.data as { transcriptionEnabled?: boolean }).transcriptionEnabled
102
+ );
103
+ let isTouchDevice = $derived(browser && navigator.maxTouchPoints > 0);
104
+
105
+ const handleSubmit = () => {
106
+ if (requireAuthUser() || loading || !draft) return;
107
+ tap();
108
+ onmessage?.(draft);
109
+ draft = "";
110
+ };
111
+
112
+ let lastTarget: EventTarget | null = null;
113
+
114
+ let onDrag = $state(false);
115
+
116
+ const onDragEnter = (e: DragEvent) => {
117
+ lastTarget = e.target;
118
+ onDrag = true;
119
+ };
120
+ const onDragLeave = (e: DragEvent) => {
121
+ if (e.target === lastTarget) {
122
+ onDrag = false;
123
+ }
124
+ };
125
+
126
+ const onPaste = (e: ClipboardEvent) => {
127
+ const textContent = e.clipboardData?.getData("text");
128
+
129
+ if (!$settings.directPaste && textContent && textContent.length >= 3984) {
130
+ e.preventDefault();
131
+ pastedLongContent = true;
132
+ setTimeout(() => {
133
+ pastedLongContent = false;
134
+ }, 1000);
135
+ const pastedFile = new File([textContent], "Pasted Content", {
136
+ type: "application/vnd.chatui.clipboard",
137
+ });
138
+
139
+ files = [...files, pastedFile];
140
+ }
141
+
142
+ if (!e.clipboardData) {
143
+ return;
144
+ }
145
+
146
+ // paste of files
147
+ const pastedFiles = Array.from(e.clipboardData.files);
148
+ if (pastedFiles.length !== 0) {
149
+ e.preventDefault();
150
+
151
+ // filter based on activeMimeTypes, including wildcards
152
+ const filteredFiles = pastedFiles.filter((file) => {
153
+ return activeMimeTypes.some((mimeType: string) => {
154
+ const [type, subtype] = mimeType.split("/");
155
+ const [fileType, fileSubtype] = file.type.split("/");
156
+ return (
157
+ (type === "*" || fileType === type) && (subtype === "*" || fileSubtype === subtype)
158
+ );
159
+ });
160
+ });
161
+
162
+ files = [...files, ...filteredFiles];
163
+ }
164
+ };
165
+
166
+ let lastMessage = $derived(browser && (messages.at(-1) as Message));
167
+ // Scroll signal includes tool updates and thinking blocks to trigger scroll on all content changes
168
+ let scrollSignal = $derived.by(() => {
169
+ const last = messages.at(-1) as Message | undefined;
170
+ if (!last) return `${messages.length}:0`;
171
+
172
+ // Count tool updates to trigger scroll when new tools are called or complete
173
+ const toolUpdateCount = last.updates?.length ?? 0;
174
+
175
+ // Include content length, tool count, and message count in signal
176
+ return `${last.id}:${last.content.length}:${messages.length}:${toolUpdateCount}`;
177
+ });
178
+ let streamingAssistantMessage = $derived(
179
+ (() => {
180
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
181
+ const candidate = messages[i];
182
+ if (candidate.from === "assistant") {
183
+ return candidate;
184
+ }
185
+ }
186
+ return undefined;
187
+ })()
188
+ );
189
+ let streamingRouterMetadata = $derived(streamingAssistantMessage?.routerMetadata ?? null);
190
+ let streamingRouterModelName = $derived(
191
+ streamingRouterMetadata?.model
192
+ ? (streamingRouterMetadata.model.split("/").pop() ?? streamingRouterMetadata.model)
193
+ : ""
194
+ );
195
+
196
+ let lastIsError = $derived(
197
+ !loading &&
198
+ (streamingAssistantMessage?.updates?.findIndex(
199
+ (u) => u.type === "status" && u.status === "error"
200
+ ) ?? -1) !== -1
201
+ );
202
+
203
+ // Expose currently running tool call name (if any) from the streaming assistant message
204
+ const availableTools: ToolFront[] = $derived.by(
205
+ () => (page.data as { tools?: ToolFront[] } | undefined)?.tools ?? []
206
+ );
207
+ let streamingToolCallName = $derived.by(() => {
208
+ const updates = streamingAssistantMessage?.updates ?? [];
209
+ if (!updates.length) return null;
210
+ const done = new Set<string>();
211
+ for (const u of updates) {
212
+ if (isMessageToolResultUpdate(u) || isMessageToolErrorUpdate(u)) done.add(u.uuid);
213
+ }
214
+ for (let i = updates.length - 1; i >= 0; i -= 1) {
215
+ const u = updates[i];
216
+ if (isMessageToolCallUpdate(u) && !done.has(u.uuid)) {
217
+ return u.call.name;
218
+ }
219
+ }
220
+ return null;
221
+ });
222
+ // Autopilot step tracking — derived from streaming message updates
223
+ let autopilotStep = $derived.by(() => {
224
+ const updates = streamingAssistantMessage?.updates ?? [];
225
+ for (let i = updates.length - 1; i >= 0; i -= 1) {
226
+ const u = updates[i];
227
+ if (u.type === "autopilotStep") {
228
+ return u as { step: number; maxSteps: number; toolCount: number };
229
+ }
230
+ }
231
+ return null;
232
+ });
233
+
234
+ let showRouterDetails = $state(false);
235
+ let routerDetailsTimeout: ReturnType<typeof setTimeout> | undefined;
236
+
237
+ $effect(() => {
238
+ if (!currentModel.isRouter || !loading) {
239
+ showRouterDetails = false;
240
+ if (routerDetailsTimeout) {
241
+ clearTimeout(routerDetailsTimeout);
242
+ routerDetailsTimeout = undefined;
243
+ }
244
+ return;
245
+ }
246
+
247
+ if (routerDetailsTimeout) {
248
+ clearTimeout(routerDetailsTimeout);
249
+ }
250
+
251
+ showRouterDetails = false;
252
+ routerDetailsTimeout = setTimeout(() => {
253
+ showRouterDetails = true;
254
+ }, 500);
255
+ });
256
+
257
+ let sources = $derived(
258
+ files?.map<Promise<MessageFile>>((file) =>
259
+ file2base64(file).then((value) => ({
260
+ type: "base64",
261
+ value,
262
+ mime: file.type,
263
+ name: file.name,
264
+ }))
265
+ )
266
+ );
267
+
268
+ const unsubscribeShareModal = shareModal.subscribe((value) => {
269
+ shareModalOpen = value;
270
+ });
271
+
272
+ onDestroy(() => {
273
+ unsubscribeShareModal();
274
+ shareModal.close();
275
+ if (routerDetailsTimeout) {
276
+ clearTimeout(routerDetailsTimeout);
277
+ }
278
+ });
279
+
280
+ let chatContainer: HTMLElement | undefined = $state();
281
+
282
+ // Force scroll to bottom when user sends a new message
283
+ // Pattern: user message + empty assistant message are added together
284
+ let prevMessageCount = $state(messages.length);
285
+ let forceReattach = $state(0);
286
+ $effect(() => {
287
+ if (messages.length > prevMessageCount) {
288
+ const last = messages.at(-1);
289
+ const secondLast = messages.at(-2);
290
+ const userJustSentMessage =
291
+ messages.length === prevMessageCount + 2 &&
292
+ secondLast?.from === "user" &&
293
+ last?.from === "assistant" &&
294
+ last?.content === "";
295
+
296
+ if (userJustSentMessage) {
297
+ forceReattach++;
298
+ }
299
+ }
300
+ prevMessageCount = messages.length;
301
+ });
302
+
303
+ // Combined scroll dependency for the action
304
+ let scrollDependency = $derived({ signal: scrollSignal, forceReattach });
305
+
306
+ const settings = useSettingsStore();
307
+ let hideRouterExamples = $derived($settings.hidePromptExamples?.[currentModel.id] ?? false);
308
+
309
+ // Respect per‑model multimodal toggle from settings (force enable)
310
+ let modelIsMultimodalOverride = $derived($settings.multimodalOverrides?.[currentModel.id]);
311
+ let modelIsMultimodal = $derived((modelIsMultimodalOverride ?? currentModel.multimodal) === true);
312
+
313
+ // Determine tool support for the current model (server-provided capability with user override)
314
+ let modelSupportsTools = $derived(
315
+ ($settings.toolsOverrides?.[currentModel.id] ??
316
+ (currentModel as unknown as { supportsTools?: boolean }).supportsTools) === true
317
+ );
318
+
319
+ // Get provider override for the current model (HuggingChat only)
320
+ let providerOverride = $derived($settings.providerOverrides?.[currentModel.id]);
321
+ let hasProviderOverride = $derived(
322
+ providerOverride && providerOverride !== "auto" && !currentModel.isRouter
323
+ );
324
+
325
+ // Always allow common text-like files; add images only when model is multimodal
326
+ import { TEXT_MIME_ALLOWLIST, IMAGE_MIME_ALLOWLIST_DEFAULT } from "$lib/constants/mime";
327
+
328
+ let activeMimeTypes = $derived(
329
+ Array.from(
330
+ new Set([
331
+ ...TEXT_MIME_ALLOWLIST,
332
+ ...(modelIsMultimodal
333
+ ? (currentModel.multimodalAcceptedMimetypes ?? [...IMAGE_MIME_ALLOWLIST_DEFAULT])
334
+ : []),
335
+ ])
336
+ )
337
+ );
338
+ let isFileUploadEnabled = $derived(activeMimeTypes.length > 0);
339
+ let focused = $state(false);
340
+
341
+ let activeRouterExamplePrompt: string | null = $state(null);
342
+ // Use MCP examples when all base servers are enabled, otherwise use router examples
343
+ let activeExamples: RouterExample[] = $derived(
344
+ $allBaseServersEnabled ? mcpExamples : routerExamples
345
+ );
346
+
347
+ // Map a tool name to follow-up suggestions that make sense after that tool ran.
348
+ // Order matters: more-specific patterns first. Each entry returns up to 2 prompts.
349
+ function followUpsForTool(toolName: string): RouterFollowUp[] {
350
+ const n = toolName.toLowerCase();
351
+ if (n.includes("memory_store"))
352
+ return [
353
+ { title: "Verify the save", prompt: "Use ruflo__memory_retrieve with the same key and namespace to confirm the save." },
354
+ { title: "List the namespace", prompt: "Use ruflo__memory_list to show every entry in that namespace." },
355
+ ];
356
+ if (n.includes("memory_search") || n.includes("memory_retrieve") || n.includes("memory_list"))
357
+ return [
358
+ { title: "Save a related item", prompt: "Use ruflo__memory_store to add a related entry to the same namespace." },
359
+ { title: "Semantic search", prompt: "Run ruvector__hooks_recall on the same query for a semantic match." },
360
+ ];
361
+ if (n.includes("system_status") || n.includes("system_health"))
362
+ return [
363
+ { title: "Performance metrics", prompt: "Run ruflo__performance_metrics and ruflo__performance_bottleneck in parallel." },
364
+ { title: "Memory usage", prompt: "Run ruflo__memory_stats and ruflo__system_metrics in parallel." },
365
+ ];
366
+ if (n.includes("performance_metrics") || n.includes("performance_bottleneck"))
367
+ return [
368
+ { title: "Optimize", prompt: "Use ruflo__performance_optimize on the slowest component identified." },
369
+ { title: "Run benchmarks", prompt: "Run ruflo__performance_benchmark with --suite=all." },
370
+ ];
371
+ if (n.includes("agent_spawn") || n.includes("swarm_init"))
372
+ return [
373
+ { title: "Track progress", prompt: "Use ruflo__progress_summary to show what each agent is doing right now." },
374
+ { title: "Add a tester", prompt: "Spawn a tester agent for the same swarm and have it write integration tests." },
375
+ ];
376
+ if (n.includes("hooks_route") || n.includes("hooks_swarm_recommend"))
377
+ return [
378
+ { title: "Spawn the agent", prompt: "Use ruflo__agent_spawn to create the recommended agent type now." },
379
+ { title: "Track this run", prompt: "Begin a trajectory with ruvector__hooks_trajectory_begin so the system learns from this work." },
380
+ ];
381
+ if (n.includes("analyze_diff") || n.includes("analyze_file"))
382
+ return [
383
+ { title: "Suggest reviewers", prompt: "Use ruflo__analyze_diff-reviewers to recommend reviewers for the same diff." },
384
+ { title: "Risk per file", prompt: "Use ruflo__analyze_file-risk on the highest-risk files." },
385
+ ];
386
+ if (n.includes("github_repo_analyze") || n.includes("github_pr_manage") || n.includes("github_issue_track"))
387
+ return [
388
+ { title: "Repo metrics", prompt: "Run ruflo__github_metrics on the same repo and summarize health signals." },
389
+ { title: "Recent issues", prompt: "List the most recently updated issues with ruflo__github_issue_track." },
390
+ ];
391
+ if (n.includes("hooks_trajectory_begin") || n.includes("hooks_trajectory_step"))
392
+ return [
393
+ { title: "Record next step", prompt: "Record this step with ruvector__hooks_trajectory_step." },
394
+ { title: "End trajectory", prompt: "Close the trajectory with ruvector__hooks_trajectory_end so the system learns from it." },
395
+ ];
396
+ if (n.includes("hooks_security_scan") || n.includes("aidefence"))
397
+ return [
398
+ { title: "Detail the highest risk", prompt: "Explain the highest-severity finding and propose a concrete fix." },
399
+ { title: "Re-scan", prompt: "Re-run ruvector__hooks_security_scan after applying the fix." },
400
+ ];
401
+ if (n === "search" || n.includes("__search"))
402
+ return [
403
+ { title: "Deep research", prompt: "Run web_research with action='research' on the same topic for a thorough report." },
404
+ { title: "Compare alternatives", prompt: "Run web_research with action='compare' to compare the top results." },
405
+ ];
406
+ if (n === "web_research" || n.includes("__web_research"))
407
+ return [
408
+ { title: "Fact-check it", prompt: "Run web_research with action='fact_check' to verify the key claims." },
409
+ { title: "Save findings", prompt: "Use ruflo__memory_store to save the research summary into a 'research' namespace." },
410
+ ];
411
+ if (n.includes("guidance"))
412
+ return [
413
+ { title: "List my tools", prompt: "Call guidance with topic='overview' to summarize every available tool group." },
414
+ { title: "Pick one to try", prompt: "Suggest one underused tool from those groups and walk me through calling it." },
415
+ ];
416
+ // Default: no specialized follow-up known for this tool.
417
+ return [];
418
+ }
419
+
420
+ function dedupePrompts(items: RouterFollowUp[], max: number = 4): RouterFollowUp[] {
421
+ const seen = new Set<string>();
422
+ const out: RouterFollowUp[] = [];
423
+ for (const it of items) {
424
+ const key = it.prompt.trim().toLowerCase();
425
+ if (seen.has(key)) continue;
426
+ seen.add(key);
427
+ out.push(it);
428
+ if (out.length >= max) break;
429
+ }
430
+ return out;
431
+ }
432
+
433
+ // Pull tool names from the latest assistant message.
434
+ let lastAssistantToolNames: string[] = $derived((() => {
435
+ for (let i = messages.length - 1; i >= 0; i--) {
436
+ const msg = messages[i];
437
+ if (msg.from !== "assistant") continue;
438
+ const updates = (msg.updates ?? []) as Array<{ type?: string; subtype?: string; call?: { name?: string } }>;
439
+ const names: string[] = [];
440
+ for (const u of updates) {
441
+ if (u.type === "tool" && u.subtype === "call" && u.call?.name) {
442
+ names.push(u.call.name);
443
+ }
444
+ }
445
+ return names;
446
+ }
447
+ return [];
448
+ })());
449
+
450
+ let dynamicFollowUps: RouterFollowUp[] = $derived(
451
+ dedupePrompts(lastAssistantToolNames.flatMap(followUpsForTool), 4)
452
+ );
453
+
454
+ let routerFollowUps: RouterFollowUp[] = $derived(
455
+ activeRouterExamplePrompt
456
+ ? (activeExamples.find((ex) => ex.prompt === activeRouterExamplePrompt)?.followUps ?? [])
457
+ : []
458
+ );
459
+
460
+ // Combined: prefer static example follow-ups (curated by us); fall back to
461
+ // dynamic tool-derived follow-ups generated from the last assistant turn.
462
+ let effectiveFollowUps: RouterFollowUp[] = $derived(
463
+ routerFollowUps.length > 0 ? routerFollowUps : dynamicFollowUps
464
+ );
465
+
466
+ let routerUserMessages = $derived(messages.filter((msg) => msg.from === "user"));
467
+ let shouldShowRouterFollowUps = $derived(
468
+ !draft.length &&
469
+ effectiveFollowUps.length > 0 &&
470
+ // Static followups: only after the very first user message (matches an example)
471
+ // Dynamic followups: any time we have at least one assistant turn that finished
472
+ (routerFollowUps.length > 0
473
+ ? routerUserMessages.length === 1
474
+ : messages.length > 0 && messages[messages.length - 1]?.from === "assistant") &&
475
+ (currentModel.isRouter || (modelSupportsTools && $allBaseServersEnabled)) &&
476
+ !hideRouterExamples &&
477
+ !loading
478
+ );
479
+
480
+ $effect(() => {
481
+ if (
482
+ !(currentModel.isRouter || (modelSupportsTools && $allBaseServersEnabled)) ||
483
+ !messages.length
484
+ ) {
485
+ activeRouterExamplePrompt = null;
486
+ return;
487
+ }
488
+
489
+ const firstUserMessage = messages.find((msg) => msg.from === "user");
490
+ if (!firstUserMessage) {
491
+ activeRouterExamplePrompt = null;
492
+ return;
493
+ }
494
+
495
+ const match = activeExamples.find((ex) => ex.prompt.trim() === firstUserMessage.content.trim());
496
+ activeRouterExamplePrompt = match ? match.prompt : null;
497
+ });
498
+
499
+ $effect(() => {
500
+ if ($pendingChatInput) {
501
+ draft = $pendingChatInput;
502
+ pendingChatInput.set(undefined);
503
+ }
504
+ });
505
+
506
+ function triggerPrompt(prompt: string) {
507
+ if (requireAuthUser() || loading) return;
508
+ draft = prompt;
509
+ handleSubmit();
510
+ }
511
+
512
+ async function startExample(example: RouterExample) {
513
+ if (requireAuthUser()) return;
514
+ activeRouterExamplePrompt = example.prompt;
515
+
516
+ if (browser && example.attachments?.length) {
517
+ const loadedFiles: File[] = [];
518
+ for (const attachment of example.attachments) {
519
+ try {
520
+ const response = await fetch(`${base}/${attachment.src}`);
521
+ if (!response.ok) continue;
522
+
523
+ const blob = await response.blob();
524
+ const name = attachment.src.split("/").pop() ?? "attachment";
525
+ loadedFiles.push(
526
+ new File([blob], name, { type: blob.type || "application/octet-stream" })
527
+ );
528
+ } catch (err) {
529
+ console.error("Error loading attachment:", err);
530
+ }
531
+ }
532
+ files = loadedFiles;
533
+ }
534
+
535
+ triggerPrompt(example.prompt);
536
+ }
537
+
538
+ function startFollowUp(followUp: RouterFollowUp) {
539
+ triggerPrompt(followUp.prompt);
540
+ }
541
+
542
+ async function handleRecordingConfirm(audioBlob: Blob) {
543
+ isRecording = false;
544
+ isTranscribing = true;
545
+
546
+ try {
547
+ const response = await fetch(`${base}/api/transcribe`, {
548
+ method: "POST",
549
+ headers: { "Content-Type": audioBlob.type },
550
+ body: audioBlob,
551
+ });
552
+
553
+ if (!response.ok) {
554
+ throw new Error(await response.text());
555
+ }
556
+
557
+ const { text } = await response.json();
558
+ const trimmedText = text?.trim();
559
+ if (trimmedText) {
560
+ // Append transcribed text to draft
561
+ draft = draft.trim() ? `${draft.trim()} ${trimmedText}` : trimmedText;
562
+ }
563
+ } catch (err) {
564
+ console.error("Transcription error:", err);
565
+ $error = "Transcription failed. Please try again.";
566
+ } finally {
567
+ isTranscribing = false;
568
+ }
569
+ }
570
+
571
+ async function handleRecordingSend(audioBlob: Blob) {
572
+ isRecording = false;
573
+ isTranscribing = true;
574
+
575
+ try {
576
+ const response = await fetch(`${base}/api/transcribe`, {
577
+ method: "POST",
578
+ headers: { "Content-Type": audioBlob.type },
579
+ body: audioBlob,
580
+ });
581
+
582
+ if (!response.ok) {
583
+ throw new Error(await response.text());
584
+ }
585
+
586
+ const { text } = await response.json();
587
+ const trimmedText = text?.trim();
588
+ if (trimmedText) {
589
+ // Set draft and send immediately
590
+ draft = draft.trim() ? `${draft.trim()} ${trimmedText}` : trimmedText;
591
+ handleSubmit();
592
+ }
593
+ } catch (err) {
594
+ console.error("Transcription error:", err);
595
+ $error = "Transcription failed. Please try again.";
596
+ } finally {
597
+ isTranscribing = false;
598
+ }
599
+ }
600
+
601
+ function handleRecordingError(message: string) {
602
+ console.error("Recording error:", message);
603
+ isRecording = false;
604
+ $error = message;
605
+ }
606
+ </script>
607
+
608
+ <svelte:window
609
+ ondragenter={onDragEnter}
610
+ ondragleave={onDragLeave}
611
+ ondragover={(e) => {
612
+ e.preventDefault();
613
+ }}
614
+ ondrop={(e) => {
615
+ e.preventDefault();
616
+ onDrag = false;
617
+ }}
618
+ />
619
+
620
+ <div class="relative z-[-1] min-h-0 min-w-0">
621
+ {#if shareModalOpen}
622
+ <ShareConversationModal open={shareModalOpen} onclose={() => shareModal.close()} />
623
+ {/if}
624
+ <div
625
+ class="scrollbar-custom h-full overflow-y-auto"
626
+ use:snapScrollToBottom={scrollDependency}
627
+ bind:this={chatContainer}
628
+ >
629
+ <div
630
+ class="mx-auto flex h-full max-w-3xl flex-col gap-6 px-5 pt-6 sm:gap-8 xl:max-w-4xl xl:pt-10"
631
+ >
632
+ {#if preprompt && preprompt != currentModel.preprompt}
633
+ <SystemPromptModal preprompt={preprompt ?? ""} />
634
+ {/if}
635
+
636
+ {#if messages.length > 0}
637
+ <div class="flex h-max flex-col gap-8 pb-52">
638
+ {#each messages as message, idx (message.id)}
639
+ <ChatMessage
640
+ {loading}
641
+ {message}
642
+ alternatives={messagesAlternatives.find((a) => a.includes(message.id)) ?? []}
643
+ isAuthor={!shared}
644
+ readOnly={isReadOnly}
645
+ isLast={idx === messages.length - 1}
646
+ bind:editMsdgId
647
+ onretry={(payload) => onretry?.(payload)}
648
+ onshowAlternateMsg={(payload) => onshowAlternateMsg?.(payload)}
649
+ />
650
+ {/each}
651
+ {#if isReadOnly}
652
+ <ModelSwitch {models} {currentModel} />
653
+ {/if}
654
+ </div>
655
+ {:else if pending}
656
+ <ChatMessage
657
+ loading={true}
658
+ message={{
659
+ id: "0-0-0-0-0",
660
+ content: "",
661
+ from: "assistant",
662
+ children: [],
663
+ }}
664
+ isAuthor={!shared}
665
+ readOnly={isReadOnly}
666
+ />
667
+ {:else}
668
+ <ChatIntroduction
669
+ {currentModel}
670
+ onmessage={(content) => {
671
+ onmessage?.(content);
672
+ }}
673
+ />
674
+ {/if}
675
+ </div>
676
+
677
+ <ScrollToPreviousBtn class="fixed bottom-48 right-4 lg:right-10" scrollNode={chatContainer} />
678
+
679
+ <ScrollToBottomBtn class="fixed bottom-36 right-4 lg:right-10" scrollNode={chatContainer} />
680
+ </div>
681
+
682
+ <div
683
+ class="pointer-events-none absolute inset-x-0 bottom-0 z-0 mx-auto flex w-full
684
+ max-w-3xl flex-col items-center justify-center bg-gradient-to-t from-white
685
+ via-white/100 to-white/0 px-3.5 pt-2 dark:border-gray-800
686
+ dark:from-gray-900 dark:via-gray-900/100
687
+ dark:to-gray-900/0 max-sm:py-0 sm:px-5 md:pb-4 xl:max-w-4xl [&>*]:pointer-events-auto"
688
+ >
689
+ {#if !draft.length && !messages.length && !sources.length && !loading && (currentModel.isRouter || (modelSupportsTools && $allBaseServersEnabled)) && activeExamples.length && !hideRouterExamples && !lastIsError && $mcpServersLoaded}
690
+ <div
691
+ class="no-scrollbar mb-3 flex w-full select-none justify-start gap-2 overflow-x-auto whitespace-nowrap text-gray-400 dark:text-gray-500"
692
+ >
693
+ {#each activeExamples as ex}
694
+ <button
695
+ class="flex items-center rounded-lg bg-gray-100/90 px-2 py-0.5 text-center text-sm backdrop-blur hover:text-gray-500 dark:bg-gray-700/50 dark:hover:text-gray-400"
696
+ onclick={() => startExample(ex)}>{ex.title}</button
697
+ >
698
+ {/each}
699
+ </div>
700
+ {/if}
701
+ {#if shouldShowRouterFollowUps && !lastIsError}
702
+ <div
703
+ class="no-scrollbar mb-3 flex w-full select-none justify-start gap-2 overflow-x-auto whitespace-nowrap text-gray-400 dark:text-gray-500"
704
+ >
705
+ <!-- <span class=" text-gray-500 dark:text-gray-400">Follow ups</span> -->
706
+ {#each effectiveFollowUps as followUp}
707
+ <button
708
+ class="flex items-center gap-1 rounded-lg bg-gray-100/90 px-2 py-0.5 text-center text-sm backdrop-blur hover:text-gray-500 dark:bg-gray-700/50 dark:hover:text-gray-400"
709
+ onclick={() => startFollowUp(followUp)}
710
+ >
711
+ <CarbonDirectionRight class="scale-y-[-1] text-xs" />
712
+ {followUp.title}</button
713
+ >
714
+ {/each}
715
+ </div>
716
+ {/if}
717
+ {#if sources?.length && !loading}
718
+ <div
719
+ in:fly|local={sources.length === 1 ? { y: -20, easing: cubicInOut } : undefined}
720
+ class="flex flex-row flex-wrap justify-center gap-2.5 rounded-xl pb-3"
721
+ >
722
+ {#each sources as source, index}
723
+ {#await source then src}
724
+ <UploadedFile
725
+ file={src}
726
+ onclose={() => {
727
+ files = files.filter((_, i) => i !== index);
728
+ }}
729
+ />
730
+ {/await}
731
+ {/each}
732
+ </div>
733
+ {/if}
734
+
735
+ <div class="w-full">
736
+ <div class="flex w-full *:mb-3">
737
+ {#if !loading && lastIsError}
738
+ <RetryBtn
739
+ classNames="ml-auto"
740
+ onClick={() => {
741
+ if (lastMessage && lastMessage.ancestors) {
742
+ onretry?.({
743
+ id: lastMessage.id,
744
+ });
745
+ }
746
+ }}
747
+ />
748
+ {/if}
749
+ </div>
750
+ <form
751
+ tabindex="-1"
752
+ aria-label={isFileUploadEnabled ? "file dropzone" : undefined}
753
+ onsubmit={(e) => {
754
+ e.preventDefault();
755
+ handleSubmit();
756
+ }}
757
+ class={{
758
+ "relative flex w-full max-w-4xl flex-1 items-center rounded-xl border bg-gray-100 dark:border-gray-700 dark:bg-gray-800": true,
759
+ "opacity-30": isReadOnly,
760
+ "max-sm:mb-4": focused && isVirtualKeyboard(),
761
+ }}
762
+ >
763
+ {#if isRecording || isTranscribing}
764
+ <VoiceRecorder
765
+ {isTranscribing}
766
+ {isTouchDevice}
767
+ oncancel={() => {
768
+ isRecording = false;
769
+ }}
770
+ onconfirm={handleRecordingConfirm}
771
+ onsend={handleRecordingSend}
772
+ onerror={handleRecordingError}
773
+ />
774
+ {:else if onDrag && isFileUploadEnabled}
775
+ <FileDropzone bind:files bind:onDrag mimeTypes={activeMimeTypes} />
776
+ {:else}
777
+ <div
778
+ class="flex w-full flex-1 rounded-xl border-none bg-transparent"
779
+ class:paste-glow={pastedLongContent}
780
+ >
781
+ {#if lastIsError}
782
+ <ChatInput value="Sorry, something went wrong. Please try again." disabled={true} />
783
+ {:else}
784
+ <ChatInput
785
+ placeholder={isReadOnly ? "This conversation is read-only." : "Ask anything"}
786
+ {loading}
787
+ bind:value={draft}
788
+ bind:files
789
+ mimeTypes={activeMimeTypes}
790
+ onsubmit={handleSubmit}
791
+ {onPaste}
792
+ disabled={isReadOnly || lastIsError}
793
+ {modelIsMultimodal}
794
+ {modelSupportsTools}
795
+ bind:focused
796
+ />
797
+ {/if}
798
+
799
+ {#if loading}
800
+ <StopGeneratingBtn
801
+ onClick={() => {
802
+ hapticError();
803
+ onstop?.();
804
+ }}
805
+ showBorder={true}
806
+ classNames="absolute bottom-2 right-2 size-8 sm:size-7 self-end rounded-full border bg-white text-black shadow transition-none dark:border-transparent dark:bg-gray-600 dark:text-white"
807
+ />
808
+ {:else}
809
+ <!-- Autopilot toggle -->
810
+ {#if modelSupportsTools}
811
+ <button
812
+ type="button"
813
+ class="btn absolute bottom-2 flex items-center gap-1 self-end rounded-full border px-2.5 py-1 text-xs font-semibold transition-all {transcriptionEnabled ? 'right-[4.75rem] sm:right-[4.25rem]' : 'right-10 sm:right-9'} {$settings.autopilotEnabled
814
+ ? 'animate-pulse-subtle border-emerald-400 bg-emerald-500/90 text-white shadow-lg shadow-emerald-500/30 hover:bg-emerald-500 dark:border-emerald-400 dark:bg-emerald-500/80 dark:shadow-emerald-500/40'
815
+ : 'border-gray-300 bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700 dark:border-gray-500 dark:bg-gray-700 dark:text-gray-400 dark:hover:bg-gray-600 dark:hover:text-gray-200'}"
816
+ disabled={isReadOnly}
817
+ onclick={() => {
818
+ tap();
819
+ settings.update((s) => ({ ...s, autopilotEnabled: !s.autopilotEnabled }));
820
+ }}
821
+ title={$settings.autopilotEnabled ? 'Autopilot ON — AI auto-continues tool calls without asking' : 'Autopilot OFF — AI stops after each tool call'}
822
+ aria-label="Toggle autopilot mode"
823
+ >
824
+ <IconZap class="size-3.5" />
825
+ <span>{$settings.autopilotEnabled ? 'AUTO' : 'MANUAL'}</span>
826
+ </button>
827
+ {/if}
828
+ {#if transcriptionEnabled}
829
+ <button
830
+ type="button"
831
+ class="btn absolute bottom-2 right-10 mr-1.5 size-8 self-end rounded-full border bg-white/50 text-gray-500 transition-none hover:bg-gray-50 hover:text-gray-700 dark:border-transparent dark:bg-gray-600/50 dark:text-gray-300 dark:hover:bg-gray-500 dark:hover:text-white sm:right-9 sm:size-7"
832
+ disabled={isReadOnly}
833
+ onclick={() => {
834
+ isRecording = true;
835
+ }}
836
+ aria-label="Start voice recording"
837
+ >
838
+ <IconMic class="size-4" />
839
+ </button>
840
+ {/if}
841
+ <button
842
+ class="btn absolute bottom-2 right-2 size-8 self-end rounded-full border bg-white text-black shadow transition-none enabled:hover:bg-white enabled:hover:shadow-inner dark:border-transparent dark:bg-gray-600 dark:text-white dark:hover:enabled:bg-black sm:size-7 {!draft ||
843
+ isReadOnly
844
+ ? ''
845
+ : '!bg-black !text-white dark:!bg-white dark:!text-black'}"
846
+ disabled={!draft || isReadOnly}
847
+ type="submit"
848
+ aria-label="Send message"
849
+ name="submit"
850
+ >
851
+ <IconArrowUp />
852
+ </button>
853
+ {/if}
854
+ </div>
855
+ {/if}
856
+ </form>
857
+ <div
858
+ class={{
859
+ "mt-1.5 flex h-5 items-center self-stretch whitespace-nowrap px-0.5 text-xs text-gray-400/90 max-md:mb-2 max-sm:gap-2": true,
860
+ "max-sm:hidden": focused && isVirtualKeyboard(),
861
+ }}
862
+ >
863
+ {#if models.find((m) => m.id === currentModel.id)}
864
+ {#if loading && autopilotStep}
865
+ <span class="inline-flex items-center gap-1 whitespace-nowrap text-xs text-indigo-400">
866
+ <IconZap class="size-3" />
867
+ Autopilot Step {autopilotStep.step}/{autopilotStep.maxSteps}
868
+ {#if streamingToolCallName}
869
+ <span class="text-gray-400">·</span>
870
+ <LucideHammer class="size-3 text-gray-400" />
871
+ <span class="loading-dots font-medium text-gray-400">
872
+ {availableTools.find((t) => t.name === streamingToolCallName)?.displayName ??
873
+ streamingToolCallName}
874
+ </span>
875
+ {/if}
876
+ </span>
877
+ {:else if loading && streamingToolCallName}
878
+ <span class="inline-flex items-center gap-1 whitespace-nowrap text-xs">
879
+ <LucideHammer class="size-3" />
880
+ Calling tool
881
+ <span class="loading-dots font-medium">
882
+ {availableTools.find((t) => t.name === streamingToolCallName)?.displayName ??
883
+ streamingToolCallName}
884
+ </span>
885
+ </span>
886
+ {:else if !currentModel.isRouter || !loading}
887
+ <a
888
+ href="{base}/settings/{currentModel.id}"
889
+ onclick={(e) => {
890
+ if (requireAuthUser()) {
891
+ e.preventDefault();
892
+ }
893
+ }}
894
+ class="inline-flex items-center gap-1 hover:underline"
895
+ >
896
+ {#if currentModel.isRouter}
897
+ <IconOmni />
898
+ {currentModel.displayName}
899
+ {:else}
900
+ Model: {currentModel.displayName}
901
+ {#if hasProviderOverride}
902
+ {@const hubOrg =
903
+ PROVIDERS_HUB_ORGS[providerOverride as keyof typeof PROVIDERS_HUB_ORGS]}
904
+ <span
905
+ class="inline-flex shrink-0 items-center rounded p-0.5 {providerOverride ===
906
+ 'fastest'
907
+ ? 'bg-green-100 text-green-600 dark:bg-green-800/20 dark:text-green-500'
908
+ : providerOverride === 'cheapest'
909
+ ? 'bg-blue-100 text-blue-600 dark:bg-blue-800/20 dark:text-blue-500'
910
+ : ''}"
911
+ title="Provider: {providerOverride}"
912
+ >
913
+ {#if providerOverride === "fastest"}
914
+ <IconFast classNames="text-sm" />
915
+ {:else if providerOverride === "cheapest"}
916
+ <IconCheap classNames="text-sm" />
917
+ {:else if hubOrg}
918
+ <img
919
+ src="https://huggingface.co/api/avatars/{hubOrg}"
920
+ alt={providerOverride}
921
+ class="size-3 flex-none rounded-sm"
922
+ />
923
+ {/if}
924
+ </span>
925
+ {/if}
926
+ {/if}
927
+ <CarbonCaretDown class="-ml-0.5 text-xxs" />
928
+ </a>
929
+ {:else if showRouterDetails && streamingRouterMetadata?.route}
930
+ <div
931
+ class="mr-2 flex items-center gap-1.5 whitespace-nowrap text-[.70rem] text-xs leading-none text-gray-400 dark:text-gray-400"
932
+ >
933
+ <IconOmni classNames="text-xs animate-pulse" />
934
+
935
+ <span class="router-badge-text router-shimmer">
936
+ {streamingRouterMetadata.route}
937
+ </span>
938
+
939
+ <span class="text-gray-500">with</span>
940
+
941
+ <span class="router-badge-text">
942
+ {streamingRouterModelName}
943
+ </span>
944
+ </div>
945
+ {:else}
946
+ <div
947
+ class="loading-dots relative inline-flex items-center text-gray-400 dark:text-gray-400"
948
+ aria-label="Routing…"
949
+ >
950
+ <IconOmni classNames="text-xs animate-pulse mr-1" /> Routing
951
+ </div>
952
+ {/if}
953
+ {:else}
954
+ <span class="inline-flex items-center line-through dark:border-gray-700">
955
+ {currentModel.id}
956
+ </span>
957
+ {/if}
958
+ {#if !messages.length && !loading}
959
+ <span class="max-sm:hidden">Generated content may be inaccurate or false.</span>
960
+ {/if}
961
+ </div>
962
+ </div>
963
+ </div>
964
+ </div>
965
+
966
+ <style lang="postcss">
967
+ .paste-glow {
968
+ animation: glow 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
969
+ will-change: box-shadow;
970
+ }
971
+
972
+ @keyframes glow {
973
+ 0% {
974
+ box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.8);
975
+ }
976
+ 50% {
977
+ box-shadow: 0 0 20px 4px rgba(59, 130, 246, 0.6);
978
+ }
979
+ 100% {
980
+ box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
981
+ }
982
+ }
983
+
984
+ .router-badge-text {
985
+ display: inline-block;
986
+ position: relative;
987
+ color: inherit;
988
+ }
989
+
990
+ .router-shimmer {
991
+ display: inline-block;
992
+ background-image: linear-gradient(
993
+ 90deg,
994
+ rgba(156, 163, 175, 1) 0%,
995
+ rgba(156, 163, 175, 0.6) 10%,
996
+ rgba(156, 163, 175, 0.6) 50%,
997
+ rgba(156, 163, 175, 0.6) 90%,
998
+ rgba(156, 163, 175, 1) 100%
999
+ );
1000
+ background-size: 220% 100%;
1001
+ animation: router-shimmer 2.8s linear infinite;
1002
+ background-clip: text;
1003
+ -webkit-background-clip: text;
1004
+ color: transparent;
1005
+ -webkit-text-fill-color: transparent;
1006
+ }
1007
+
1008
+ :global(.dark) .router-shimmer {
1009
+ background-image: linear-gradient(
1010
+ 90deg,
1011
+ rgba(255, 255, 255, 0.15) 0%,
1012
+ rgba(255, 255, 255, 0.7) 50%,
1013
+ rgba(255, 255, 255, 0.15) 100%
1014
+ );
1015
+ }
1016
+
1017
+ @keyframes router-shimmer {
1018
+ 0% {
1019
+ background-position: 200% 0;
1020
+ }
1021
+ 100% {
1022
+ background-position: -200% 0;
1023
+ }
1024
+ }
1025
+
1026
+ .loading-dots::after {
1027
+ content: "";
1028
+ animation: dots-content 0.9s steps(1, end) infinite;
1029
+ }
1030
+ @keyframes dots-content {
1031
+ 0% {
1032
+ content: "";
1033
+ }
1034
+ 33% {
1035
+ content: ".";
1036
+ }
1037
+ 66% {
1038
+ content: "..";
1039
+ }
1040
+ 88% {
1041
+ content: "...";
1042
+ }
1043
+ }
1044
+
1045
+ :global(.animate-pulse-subtle) {
1046
+ animation: pulse-subtle 2s ease-in-out infinite;
1047
+ }
1048
+ @keyframes pulse-subtle {
1049
+ 0%,
1050
+ 100% {
1051
+ box-shadow: 0 0 4px 1px rgba(16, 185, 129, 0.3);
1052
+ }
1053
+ 50% {
1054
+ box-shadow: 0 0 12px 3px rgba(16, 185, 129, 0.5);
1055
+ }
1056
+ }
1057
+ </style>