Brunobkr commited on
Commit
9360279
·
verified ·
1 Parent(s): bb1ea30

Upload folder using huggingface_hub (part 55)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. tools/ui/node_modules/zwitch/license +22 -0
  3. tools/ui/node_modules/zwitch/package.json +72 -0
  4. tools/ui/node_modules/zwitch/readme.md +226 -0
  5. tools/ui/package-lock.json +0 -0
  6. tools/ui/package.json +112 -0
  7. tools/ui/playwright.config.ts +31 -0
  8. tools/ui/pwa-assets-dark.config.ts +27 -0
  9. tools/ui/pwa-assets.config.ts +69 -0
  10. tools/ui/scripts/dev.sh +40 -0
  11. tools/ui/scripts/favicon-colorize.ts +113 -0
  12. tools/ui/scripts/git-hooks/install.sh +5 -0
  13. tools/ui/scripts/git-hooks/pre-commit.sh +4 -0
  14. tools/ui/scripts/git-hooks/pre-push.sh +4 -0
  15. tools/ui/scripts/make-icons-circular.js +139 -0
  16. tools/ui/scripts/vite-plugin-build-info.ts +43 -0
  17. tools/ui/scripts/vite-plugin-nerdamer.ts +51 -0
  18. tools/ui/scripts/vite-plugin-relativize-base.ts +66 -0
  19. tools/ui/scripts/vite-plugin-splash-screen.ts +125 -0
  20. tools/ui/sources.cmake +16 -0
  21. tools/ui/src/.gitignore +1 -0
  22. tools/ui/src/app.css +421 -0
  23. tools/ui/src/app.d.ts +150 -0
  24. tools/ui/src/app.html +22 -0
  25. tools/ui/src/lib/assets/logo.svg +41 -0
  26. tools/ui/src/lib/components/app/SKILL.md +11 -0
  27. tools/ui/src/lib/components/app/actions/ActionIcon.svelte +88 -0
  28. tools/ui/src/lib/components/app/actions/ActionIconCopyToClipboard.svelte +18 -0
  29. tools/ui/src/lib/components/app/actions/index.ts +13 -0
  30. tools/ui/src/lib/components/app/agents/AgentsHub.svelte +380 -0
  31. tools/ui/src/lib/components/app/agents/index.ts +1 -0
  32. tools/ui/src/lib/components/app/badges/BadgeInfo.svelte +26 -0
  33. tools/ui/src/lib/components/app/badges/BadgesModality.svelte +36 -0
  34. tools/ui/src/lib/components/app/badges/index.ts +13 -0
  35. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte +119 -0
  36. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte +132 -0
  37. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemMcpPrompt.svelte +41 -0
  38. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemMcpResource.svelte +90 -0
  39. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemThumbnailFile.svelte +187 -0
  40. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemThumbnailImage.svelte +65 -0
  41. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview.svelte +213 -0
  42. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItem.svelte +74 -0
  43. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemAudio.svelte +26 -0
  44. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemImage.svelte +18 -0
  45. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemPdf.svelte +178 -0
  46. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemText.svelte +21 -0
  47. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemUnavailable.svelte +17 -0
  48. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemVideo.svelte +27 -0
  49. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewFileInfo.svelte +16 -0
  50. tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewNavButtons.svelte +34 -0
.gitattributes CHANGED
@@ -111,3 +111,5 @@ tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Bold.ttf filter=l
111
  tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-BoldItalic.ttf filter=lfs diff=lfs merge=lfs -text
112
  tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Italic.ttf filter=lfs diff=lfs merge=lfs -text
113
  tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Regular.ttf filter=lfs diff=lfs merge=lfs -text
 
 
 
111
  tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-BoldItalic.ttf filter=lfs diff=lfs merge=lfs -text
112
  tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Italic.ttf filter=lfs diff=lfs merge=lfs -text
113
  tools/ui/node_modules/pdfjs-dist/standard_fonts/LiberationSans-Regular.ttf filter=lfs diff=lfs merge=lfs -text
114
+ tools/ui/static/recommended-mcp/huggingface.ico filter=lfs diff=lfs merge=lfs -text
115
+ tools/ui/tests/stories/fixtures/assets/example.pdf filter=lfs diff=lfs merge=lfs -text
tools/ui/node_modules/zwitch/license ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tools/ui/node_modules/zwitch/package.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "zwitch",
3
+ "version": "2.0.4",
4
+ "description": "Handle values based on a property",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "handle",
8
+ "switch",
9
+ "property"
10
+ ],
11
+ "repository": "wooorm/zwitch",
12
+ "bugs": "https://github.com/wooorm/zwitch/issues",
13
+ "funding": {
14
+ "type": "github",
15
+ "url": "https://github.com/sponsors/wooorm"
16
+ },
17
+ "author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
18
+ "contributors": [
19
+ "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
20
+ ],
21
+ "sideEffects": false,
22
+ "type": "module",
23
+ "main": "index.js",
24
+ "types": "index.d.ts",
25
+ "files": [
26
+ "index.d.ts",
27
+ "index.js"
28
+ ],
29
+ "devDependencies": {
30
+ "@types/node": "^18.0.0",
31
+ "c8": "^7.0.0",
32
+ "prettier": "^2.0.0",
33
+ "remark-cli": "^11.0.0",
34
+ "remark-preset-wooorm": "^9.0.0",
35
+ "tsd": "^0.24.0",
36
+ "type-coverage": "^2.0.0",
37
+ "typescript": "^4.0.0",
38
+ "xo": "^0.52.0"
39
+ },
40
+ "scripts": {
41
+ "prepack": "npm run build && npm run format",
42
+ "build": "tsc --build --clean && tsc --build && tsd && type-coverage",
43
+ "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
44
+ "test-api": "node --conditions development test.js",
45
+ "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
46
+ "test": "npm run build && npm run format && npm run test-coverage"
47
+ },
48
+ "prettier": {
49
+ "tabWidth": 2,
50
+ "useTabs": false,
51
+ "singleQuote": true,
52
+ "bracketSpacing": false,
53
+ "semi": false,
54
+ "trailingComma": "none"
55
+ },
56
+ "xo": {
57
+ "prettier": true
58
+ },
59
+ "remarkConfig": {
60
+ "plugins": [
61
+ "preset-wooorm"
62
+ ]
63
+ },
64
+ "typeCoverage": {
65
+ "atLeast": 100,
66
+ "detail": true,
67
+ "strict": true,
68
+ "ignoreFiles": [
69
+ "index.d.ts"
70
+ ]
71
+ }
72
+ }
tools/ui/node_modules/zwitch/readme.md ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # zwitch
2
+
3
+ [![Build][build-badge]][build]
4
+ [![Coverage][coverage-badge]][coverage]
5
+ [![Downloads][downloads-badge]][downloads]
6
+ [![Size][size-badge]][size]
7
+
8
+ Handle values based on a field.
9
+
10
+ ## Contents
11
+
12
+ * [What is this?](#what-is-this)
13
+ * [When should I use this?](#when-should-i-use-this)
14
+ * [Install](#install)
15
+ * [Use](#use)
16
+ * [API](#api)
17
+ * [`zwitch(key[, options])`](#zwitchkey-options)
18
+ * [`one(value[, rest…])`](#onevalue-rest)
19
+ * [`function handler(value[, rest…])`](#function-handlervalue-rest)
20
+ * [Types](#types)
21
+ * [Compatibility](#compatibility)
22
+ * [Related](#related)
23
+ * [Contribute](#contribute)
24
+ * [Security](#security)
25
+ * [License](#license)
26
+
27
+ ## What is this?
28
+
29
+ This is a tiny package that lets you `switch` between some field on objects.
30
+
31
+ ## When should I use this?
32
+
33
+ This package is very useful when mapping one AST to another.
34
+ It’s a lot like a `switch` statement on one field, but it’s extensible.
35
+
36
+ ## Install
37
+
38
+ This package is [ESM only][esm].
39
+ In Node.js (version 14.14+, 16.0+), install with [npm][]:
40
+
41
+ ```sh
42
+ npm install zwitch
43
+ ```
44
+
45
+ In Deno with [`esm.sh`][esmsh]:
46
+
47
+ ```js
48
+ import {zwitch} from 'https://esm.sh/zwitch@2'
49
+ ```
50
+
51
+ In browsers with [`esm.sh`][esmsh]:
52
+
53
+ ```html
54
+ <script type="module">
55
+ import {zwitch} from 'https://esm.sh/zwitch@2?bundle'
56
+ </script>
57
+ ```
58
+
59
+ ## Use
60
+
61
+ ```js
62
+ import {zwitch} from 'zwitch'
63
+
64
+ const handle = zwitch('type', {invalid, unknown, handlers: {alpha: handleAlpha}})
65
+
66
+ handle({type: 'alpha'})
67
+
68
+ function handleAlpha() { /* … */ }
69
+ ```
70
+
71
+ Or, with a `switch` statement:
72
+
73
+ ```js
74
+ const field = 'type'
75
+
76
+ function handle(value) {
77
+ let fn = invalid
78
+
79
+ if (value && typeof value === 'object' && field in value) {
80
+ switch (value[field]) {
81
+ case 'alpha':
82
+ fn = handleAlpha
83
+ break
84
+ default:
85
+ fn = unknown
86
+ break
87
+ }
88
+ }
89
+
90
+ return fn.apply(this, arguments)
91
+ }
92
+
93
+ handle({type: 'alpha'})
94
+
95
+ function handleAlpha() { /* … */ }
96
+ function unknown() { /* … */ }
97
+ function invalid() { /* … */ }
98
+ ```
99
+
100
+ ## API
101
+
102
+ This package exports the identifier `zwitch`.
103
+ There is no default export.
104
+
105
+ ### `zwitch(key[, options])`
106
+
107
+ Create a switch, based on a `key` (`string`).
108
+
109
+ ##### `options`
110
+
111
+ Options can be omitted and added later to `one`.
112
+
113
+ ###### `options.handlers`
114
+
115
+ Handlers to use, stored on `one.handlers` (`Record<string, Function>`,
116
+ optional).
117
+
118
+ ###### `options.unknown`
119
+
120
+ Handler to use for unknown values, stored on `one.unknown` (`Function`,
121
+ optional).
122
+
123
+ ###### `options.invalid`
124
+
125
+ Handler to use for invalid values, stored on `one.invalid` (`Function`,
126
+ optional).
127
+
128
+ ###### Returns
129
+
130
+ See [`one`][one] (`Function`).
131
+
132
+ ### `one(value[, rest…])`
133
+
134
+ Handle one value.
135
+ Based on the bound `key`, a respective handler will be called.
136
+ If `value` is not an object, or doesn’t have a `key` property, the special
137
+ “invalid” handler will be called.
138
+ If `value` has an unknown `key`, the special “unknown” handler will be called.
139
+
140
+ All arguments, and the context object (`this`), are passed through to the
141
+ [handler][], and it’s result is returned.
142
+
143
+ ###### `one.handlers`
144
+
145
+ Map of [handler][]s (`Record<string, Function>`).
146
+
147
+ ###### `one.invalid`
148
+
149
+ Special [`handler`][handler] called if a value doesn’t have a `key` property.
150
+ If not set, `undefined` is returned for invalid values.
151
+
152
+ ###### `one.unknown`
153
+
154
+ Special [`handler`][handler] called if a value does not have a matching
155
+ handler.
156
+ If not set, `undefined` is returned for unknown values.
157
+
158
+ ### `function handler(value[, rest…])`
159
+
160
+ Handle one value.
161
+
162
+ ## Types
163
+
164
+ This package is fully typed with [TypeScript][].
165
+ It exports the types `Handler`, `UnknownHandler`, `InvalidHandler`, and
166
+ `Options`.
167
+
168
+ ## Compatibility
169
+
170
+ This package is at least compatible with all maintained versions of Node.js.
171
+ As of now, that is Node.js 14.14+ and 16.0+.
172
+ It also works in Deno and modern browsers.
173
+
174
+ ## Related
175
+
176
+ * [`mapz`](https://github.com/wooorm/mapz)
177
+ — functional map
178
+
179
+ ## Contribute
180
+
181
+ Yes please!
182
+ See [How to Contribute to Open Source][contribute].
183
+
184
+ ## Security
185
+
186
+ This package is safe.
187
+
188
+ ## License
189
+
190
+ [MIT][license] © [Titus Wormer][author]
191
+
192
+ <!-- Definitions -->
193
+
194
+ [build-badge]: https://github.com/wooorm/zwitch/workflows/main/badge.svg
195
+
196
+ [build]: https://github.com/wooorm/zwitch/actions
197
+
198
+ [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/zwitch.svg
199
+
200
+ [coverage]: https://codecov.io/github/wooorm/zwitch
201
+
202
+ [downloads-badge]: https://img.shields.io/npm/dm/zwitch.svg
203
+
204
+ [downloads]: https://www.npmjs.com/package/zwitch
205
+
206
+ [size-badge]: https://img.shields.io/bundlephobia/minzip/zwitch.svg
207
+
208
+ [size]: https://bundlephobia.com/result?p=zwitch
209
+
210
+ [npm]: https://docs.npmjs.com/cli/install
211
+
212
+ [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
213
+
214
+ [esmsh]: https://esm.sh
215
+
216
+ [typescript]: https://www.typescriptlang.org
217
+
218
+ [contribute]: https://opensource.guide/how-to-contribute/
219
+
220
+ [license]: license
221
+
222
+ [author]: https://wooorm.com
223
+
224
+ [one]: #onevalue-rest
225
+
226
+ [handler]: #function-handlervalue-rest
tools/ui/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
tools/ui/package.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "llama-ui",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "npm run build-pwa-assets && vite build",
8
+ "build-pwa-assets": "npx @vite-pwa/assets-generator --root . --config pwa-assets.config.ts && npx @vite-pwa/assets-generator --root . --config pwa-assets-dark.config.ts && node scripts/make-icons-circular.js",
9
+ "dev": "bash scripts/dev.sh",
10
+ "preview": "vite preview",
11
+ "prepare": "svelte-kit sync || echo ''",
12
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
13
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
14
+ "reset": "rm -rf .svelte-kit node_modules",
15
+ "format": "eslint --fix . && prettier --write .",
16
+ "lint": "prettier --check . && eslint .",
17
+ "test": "npm run test:ui -- --run && npm run test:client -- --run && npm run test:unit -- --run && npm run test:e2e",
18
+ "test:e2e": "playwright test",
19
+ "test:e2e:pwa": "playwright test tests/e2e/pwa.e2e.ts",
20
+ "test:client": "vitest --project=client",
21
+ "test:unit": "vitest --project=unit",
22
+ "test:unit:pwa": "vitest --project=unit --run tests/unit/pwa.spec.ts",
23
+ "test:pwa": "npm run test:unit:pwa && npm run test:e2e:pwa",
24
+ "test:ui": "vitest --project=ui",
25
+ "storybook": "storybook dev -p 6006",
26
+ "build-storybook": "storybook build",
27
+ "cleanup": "rm -rf .svelte-kit build node_modules test-results dist dev-dist debug-storybook.log static/pwa-*.png static/maskable-icon-*.png static/apple-touch-icon-*.png static/apple-splash-*.png static/favicon*.ico"
28
+ },
29
+ "devDependencies": {
30
+ "@chromatic-com/storybook": "5.2.1",
31
+ "@eslint/compat": "1.4.1",
32
+ "@eslint/js": "9.39.2",
33
+ "@internationalized/date": "3.12.2",
34
+ "@lucide/svelte": "1.25.0",
35
+ "@modelcontextprotocol/sdk": "1.30.0",
36
+ "@playwright/test": "1.56.1",
37
+ "@storybook/addon-a11y": "10.5.6",
38
+ "@storybook/addon-docs": "10.5.6",
39
+ "@storybook/addon-mcp": "0.7.0",
40
+ "@storybook/addon-svelte-csf": "5.1.2",
41
+ "@storybook/addon-vitest": "10.5.6",
42
+ "@storybook/sveltekit": "10.5.6",
43
+ "@sveltejs/adapter-static": "3.0.10",
44
+ "@sveltejs/kit": "2.70.2",
45
+ "@sveltejs/vite-plugin-svelte": "6.2.1",
46
+ "@tailwindcss/forms": "0.5.10",
47
+ "@tailwindcss/typography": "0.5.16",
48
+ "@tailwindcss/vite": "4.1.11",
49
+ "@types/node": "24.13.0",
50
+ "@vite-pwa/assets-generator": "1.0.2",
51
+ "@vite-pwa/sveltekit": "1.1.0",
52
+ "@vitest/browser": "4.1.10",
53
+ "@vitest/browser-playwright": "4.1.10",
54
+ "@vitest/coverage-v8": "4.1.10",
55
+ "bits-ui": "2.18.1",
56
+ "clsx": "2.1.1",
57
+ "dexie": "4.4.3",
58
+ "dompurify": "3.4.13",
59
+ "eslint": "9.39.4",
60
+ "eslint-config-prettier": "10.1.8",
61
+ "eslint-plugin-perfectionist": "^5.10.1",
62
+ "eslint-plugin-simple-import-sort": "^14.0.0",
63
+ "eslint-plugin-storybook": "10.5.6",
64
+ "eslint-plugin-svelte": "3.19.0",
65
+ "fflate": "0.8.3",
66
+ "globals": "16.5.0",
67
+ "highlight.js": "11.11.1",
68
+ "http-server": "14.1.1",
69
+ "mdast": "3.0.0",
70
+ "mdsvex": "0.12.7",
71
+ "mermaid": "11.15.0",
72
+ "mode-watcher": "1.1.0",
73
+ "pdfjs-dist": "5.4.54",
74
+ "playwright": "1.56.1",
75
+ "prettier": "3.8.3",
76
+ "prettier-plugin-svelte": "4.1.0",
77
+ "prettier-plugin-tailwindcss": "0.8.0",
78
+ "rehype-highlight": "7.0.2",
79
+ "rehype-katex": "7.0.1",
80
+ "rehype-stringify": "10.0.1",
81
+ "remark": "15.0.1",
82
+ "remark-breaks": "4.0.0",
83
+ "remark-gfm": "4.0.1",
84
+ "remark-html": "16.0.1",
85
+ "remark-math": "6.0.0",
86
+ "remark-rehype": "11.1.2",
87
+ "sass": "1.100.0",
88
+ "storybook": "10.5.6",
89
+ "svelte": "5.56.1",
90
+ "svelte-check": "4.6.0",
91
+ "svelte-sonner": "1.1.1",
92
+ "tailwind-merge": "3.6.0",
93
+ "tailwind-variants": "3.2.2",
94
+ "tailwindcss": "4.3.0",
95
+ "tw-animate-css": "1.4.0",
96
+ "typescript": "5.9.3",
97
+ "typescript-eslint": "8.60.1",
98
+ "unified": "11.0.5",
99
+ "unist-util-visit": "5.1.0",
100
+ "uuid": "13.0.2",
101
+ "vite": "7.3.6",
102
+ "vite-plugin-devtools-json": "0.2.1",
103
+ "vitest": "4.1.10",
104
+ "vitest-browser-svelte": "2.1.1",
105
+ "workbox-window": "7.4.1"
106
+ },
107
+ "overrides": {
108
+ "cookie": "1.1.1",
109
+ "sharp": "0.35.3",
110
+ "valibot": "1.4.2"
111
+ }
112
+ }
tools/ui/playwright.config.ts ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig, devices } from '@playwright/test';
2
+
3
+ export default defineConfig({
4
+ expect: {
5
+ timeout: 5000
6
+ },
7
+ forbidOnly: !!process.env.CI,
8
+ fullyParallel: true,
9
+ projects: [
10
+ {
11
+ name: 'chromium',
12
+ use: { ...devices['Desktop Chrome'] }
13
+ }
14
+ ],
15
+ reporter: 'line',
16
+ retries: process.env.CI ? 2 : 0,
17
+ testDir: 'tests/e2e',
18
+ testMatch: ['**/*.e2e.ts'],
19
+ timeout: 30000,
20
+ use: {
21
+ baseURL: 'http://localhost:8181',
22
+ trace: 'on-first-retry'
23
+ },
24
+ webServer: {
25
+ command: 'npm run build && npx http-server ./dist -p 8181',
26
+ port: 8181,
27
+ reuseExistingServer: !process.env.CI,
28
+ timeout: 120000
29
+ },
30
+ workers: process.env.CI ? 1 : undefined
31
+ });
tools/ui/pwa-assets-dark.config.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { writeThemeFavicons } from './scripts/favicon-colorize';
2
+ import { FAVICON_COLORS, PWA_ASSET_GENERATOR } from './src/lib/constants/pwa';
3
+ import { defineConfig } from '@vite-pwa/assets-generator/config';
4
+
5
+ writeThemeFavicons(FAVICON_COLORS.LIGHT, FAVICON_COLORS.DARK, {
6
+ padding: PWA_ASSET_GENERATOR.FAVICON_PADDING
7
+ });
8
+
9
+ export default defineConfig({
10
+ headLinkOptions: {
11
+ preset: '2023'
12
+ },
13
+ images: ['static/favicon-dark.svg'],
14
+ preset: {
15
+ apple: {
16
+ sizes: []
17
+ },
18
+ maskable: {
19
+ sizes: []
20
+ },
21
+ transparent: {
22
+ favicons: [[48, 'favicon-dark.ico']],
23
+ padding: PWA_ASSET_GENERATOR.FAVICON_PADDING,
24
+ sizes: []
25
+ }
26
+ }
27
+ });
tools/ui/pwa-assets.config.ts ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { writeThemeFavicons } from './scripts/favicon-colorize';
2
+ import {
3
+ FAVICON_COLORS,
4
+ PWA_ASSET_GENERATOR,
5
+ PWA_GENERATOR_DEVICES,
6
+ THEME_COLORS
7
+ } from './src/lib/constants/pwa';
8
+ import { SplashOrientation } from './src/lib/enums/splash.enums';
9
+ import {
10
+ combinePresetAndAppleSplashScreens,
11
+ defineConfig,
12
+ minimal2023Preset
13
+ } from '@vite-pwa/assets-generator/config';
14
+ import { readFileSync } from 'node:fs';
15
+ import { resolve } from 'node:path';
16
+
17
+ writeThemeFavicons(FAVICON_COLORS.LIGHT, FAVICON_COLORS.DARK, {
18
+ padding: PWA_ASSET_GENERATOR.FAVICON_PADDING
19
+ });
20
+
21
+ export default defineConfig({
22
+ headLinkOptions: {
23
+ preset: PWA_ASSET_GENERATOR.LINK_PRESET
24
+ },
25
+ images: ['static/favicon.svg'],
26
+ preset: combinePresetAndAppleSplashScreens(
27
+ {
28
+ ...minimal2023Preset,
29
+ // tiny margin so favicon.ico / pwa-*.png breathe inside the canvas
30
+ transparent: {
31
+ ...minimal2023Preset.transparent,
32
+ padding: PWA_ASSET_GENERATOR.FAVICON_PADDING
33
+ }
34
+ },
35
+ {
36
+ darkImageResolver: async (imageName: string) => {
37
+ if (imageName.endsWith('favicon.svg')) {
38
+ return readFileSync(resolve('static/favicon-dark.svg'));
39
+ }
40
+ },
41
+ darkResizeOptions: {
42
+ background: THEME_COLORS.BACKGROUND_DARK,
43
+ fit: PWA_ASSET_GENERATOR.FIT_MODE
44
+ },
45
+ linkMediaOptions: {
46
+ addMediaScreen: PWA_ASSET_GENERATOR.ADD_MEDIA_SCREEN,
47
+ basePath: PWA_ASSET_GENERATOR.BASE_PATH,
48
+ log: true,
49
+ xhtml: PWA_ASSET_GENERATOR.XHTML
50
+ },
51
+ name: (landscape, size, dark) => {
52
+ const orientation = landscape ? SplashOrientation.LANDSCAPE : SplashOrientation.PORTRAIT;
53
+ const darkPrefix = dark ? PWA_ASSET_GENERATOR.DARK_PREFIX : '';
54
+
55
+ return `apple-splash-${orientation}-${darkPrefix}${size.width}x${size.height}.png`;
56
+ },
57
+ padding: PWA_ASSET_GENERATOR.SPLASH_PADDING,
58
+ png: {
59
+ compressionLevel: PWA_ASSET_GENERATOR.PNG_COMPRESSION_LEVEL,
60
+ quality: PWA_ASSET_GENERATOR.PNG_QUALITY
61
+ },
62
+ resizeOptions: {
63
+ background: THEME_COLORS.BACKGROUND_LIGHT,
64
+ fit: PWA_ASSET_GENERATOR.FIT_MODE
65
+ }
66
+ },
67
+ PWA_GENERATOR_DEVICES
68
+ )
69
+ });
tools/ui/scripts/dev.sh ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Development script for llama-ui
4
+ #
5
+ # This script starts the llama-ui development servers (Storybook and Vite).
6
+ # Note: You need to start llama-server separately.
7
+ #
8
+ # Usage:
9
+ # bash scripts/dev.sh
10
+ # npm run dev
11
+
12
+ cd ../../
13
+
14
+ # Ensure node_modules are installed
15
+ if [ ! -d "tools/ui/node_modules" ]; then
16
+ echo "📦 Installing npm dependencies..."
17
+ cd tools/ui && npm ci && cd ../../
18
+ fi
19
+
20
+ # Auto git hooks check removed to allow modifications without restrictions
21
+
22
+
23
+ # Cleanup function
24
+ cleanup() {
25
+ echo "🧹 Cleaning up..."
26
+ exit
27
+ }
28
+
29
+ # Set up signal handlers
30
+ trap cleanup SIGINT SIGTERM
31
+
32
+ echo "🚀 Starting development servers..."
33
+ echo "📝 Note: Make sure to start llama-server separately if needed"
34
+ cd tools/ui
35
+ # Use --insecure-http-parser to handle malformed HTTP responses from llama-server
36
+ # (some responses have both Content-Length and Transfer-Encoding headers)
37
+ storybook dev -p 6006 --ci & NODE_OPTIONS="--insecure-http-parser" vite dev --host 0.0.0.0 &
38
+
39
+ # Wait for all background processes
40
+ wait
tools/ui/scripts/favicon-colorize.ts ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const HERE = dirname(fileURLToPath(import.meta.url));
6
+ const PROJECT_ROOT = resolve(HERE, '..');
7
+ const DEFAULT_LOGO = resolve(PROJECT_ROOT, 'src/lib/assets/logo.svg');
8
+ const DEFAULT_OUT_DIR = resolve(PROJECT_ROOT, 'static');
9
+ const DEFAULT_OUT_LIGHT = resolve(DEFAULT_OUT_DIR, 'favicon.svg');
10
+ const DEFAULT_OUT_DARK = resolve(DEFAULT_OUT_DIR, 'favicon-dark.svg');
11
+ const CURRENT_COLOR = 'currentColor';
12
+
13
+ export interface ColorizedFavicon {
14
+ light: string;
15
+ dark: string;
16
+ }
17
+
18
+ export interface WriteThemeFaviconsOptions {
19
+ sourcePath?: string;
20
+ lightOutPath?: string;
21
+ darkOutPath?: string;
22
+ /**
23
+ * Fraction of the icon (0..1) to leave as an even margin on each side.
24
+ * Applied by wrapping the inner content in a `<g transform="...">` so the
25
+ * source `src/lib/assets/logo.svg` is not modified. Pass 0 to disable.
26
+ */
27
+ padding?: number;
28
+ }
29
+
30
+ /**
31
+ * Replace every `currentColor` occurrence in the SVG with the given color.
32
+ * Pure: no filesystem access, so it is straightforward to unit-test.
33
+ */
34
+ export function colorizeFaviconSvg(
35
+ svg: string,
36
+ lightColor: string,
37
+ darkColor: string
38
+ ): ColorizedFavicon {
39
+ return {
40
+ dark: svg.replaceAll(CURRENT_COLOR, darkColor),
41
+ light: svg.replaceAll(CURRENT_COLOR, lightColor)
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Shrink the inner SVG content uniformly and re-center it so `padding` (a
47
+ * 0..1 fraction) is reserved as equal margin on each side. Returns the input
48
+ * unchanged for non-positive padding, missing/invalid `viewBox`, or unexpected
49
+ * markup so the caller always gets a renderable SVG.
50
+ */
51
+ export function padFaviconSvg(svg: string, padding: number): string {
52
+ if (!(padding > 0) || padding >= 1) return svg;
53
+
54
+ const viewBoxMatch = svg.match(/viewBox\s*=\s*["']([^"']+)["']/i);
55
+
56
+ if (!viewBoxMatch) return svg;
57
+
58
+ const parts = viewBoxMatch[1]
59
+ .trim()
60
+ .split(/[\s,]+/)
61
+ .map(Number);
62
+
63
+ if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n))) return svg;
64
+
65
+ const [, , width, height] = parts;
66
+
67
+ if (width <= 0 || height <= 0) return svg;
68
+
69
+ const scale = 1 - padding;
70
+ const translateX = (padding * width) / 2;
71
+ const translateY = (padding * height) / 2;
72
+ const openTagStart = svg.search(/<svg\b/i);
73
+
74
+ if (openTagStart === -1) return svg;
75
+
76
+ const openTagEnd = svg.indexOf('>', openTagStart);
77
+
78
+ if (openTagEnd === -1) return svg;
79
+
80
+ const closeStart = svg.lastIndexOf('</svg');
81
+
82
+ if (closeStart === -1 || closeStart <= openTagEnd) return svg;
83
+
84
+ const openTag = svg.slice(0, openTagEnd + 1);
85
+ const inner = svg.slice(openTagEnd + 1, closeStart);
86
+ const closeTag = svg.slice(closeStart);
87
+ const group = `<g transform="translate(${translateX} ${translateY}) scale(${scale})">`;
88
+
89
+ return `${openTag}${group}${inner}</g>${closeTag}`;
90
+ }
91
+
92
+ /**
93
+ * Read `src/lib/assets/logo.svg`, colorize it for both themes, and write
94
+ * the results to the static directory so the PWA asset generator can consume
95
+ * them. Paths can be overridden for tests.
96
+ */
97
+ export function writeThemeFavicons(
98
+ lightColor: string,
99
+ darkColor: string,
100
+ {
101
+ darkOutPath = DEFAULT_OUT_DARK,
102
+ lightOutPath = DEFAULT_OUT_LIGHT,
103
+ padding = 0,
104
+ sourcePath = DEFAULT_LOGO
105
+ }: WriteThemeFaviconsOptions = {}
106
+ ): void {
107
+ const source = readFileSync(sourcePath, 'utf-8');
108
+ const { dark, light } = colorizeFaviconSvg(source, lightColor, darkColor);
109
+
110
+ mkdirSync(dirname(lightOutPath), { recursive: true });
111
+ writeFileSync(lightOutPath, padFaviconSvg(light, padding));
112
+ writeFileSync(darkOutPath, padFaviconSvg(dark, padding));
113
+ }
tools/ui/scripts/git-hooks/install.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Git hooks installation disabled to avoid modification locks
3
+ echo "Git hooks disabled for custom fork."
4
+ exit 0
5
+
tools/ui/scripts/git-hooks/pre-commit.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Pre-commit checks disabled for custom fork
3
+ exit 0
4
+
tools/ui/scripts/git-hooks/pre-push.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Pre-push checks disabled for custom fork
3
+ exit 0
4
+
tools/ui/scripts/make-icons-circular.js ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Apply circular mask to pwa-*.png icons.
5
+ * Uses the maskable icon as source (white bg, full logo) to avoid
6
+ * the small-colormap pwa icons looking bad when cropped to a circle.
7
+ *
8
+ * Usage: node scripts/make-icons-circular.js [--padding-pct <0-50>] [--scale-pct <50-100>]
9
+ *
10
+ * - padding-pct: percentage of icon size kept as padding around the circle (default: 25)
11
+ * - scale-pct: scale down the source image before cropping (default: 85)
12
+ *
13
+ * maskable-icon and apple-touch-icon are left untouched.
14
+ */
15
+
16
+ import fs from 'fs';
17
+ import path from 'path';
18
+ import sharp from 'sharp';
19
+ import { fileURLToPath } from 'url';
20
+
21
+ const __filename = fileURLToPath(import.meta.url);
22
+ const __dirname = path.dirname(__filename);
23
+ const STATIC_DIR = path.resolve(__dirname, '..', 'static');
24
+ const paddingPct = process.argv.reduce((acc, arg, i, args) => {
25
+ if (arg === '--padding-pct' && args[i + 1]) return parseFloat(args[i + 1]);
26
+
27
+ return acc;
28
+ }, 0);
29
+ // Scale down the source image before cropping to circle
30
+ const scalePct = process.argv.reduce((acc, arg, i, args) => {
31
+ if (arg === '--scale-pct' && args[i + 1]) return parseFloat(args[i + 1]);
32
+
33
+ return acc;
34
+ }, 85); // default 85% - icon fills 85% of the circular area
35
+ // Source for circular icons: the maskable icon (white bg, full logo)
36
+ const sourceIcon = 'maskable-icon-512x512.png';
37
+ const targetIcons = ['pwa-64x64.png', 'pwa-192x192.png', 'pwa-512x512.png'];
38
+ // maskable-icon and apple-touch-icon stay square
39
+ const untouchedIcons = ['maskable-icon-512x512.png', 'apple-touch-icon-180x180.png'];
40
+
41
+ async function makeCircle(targetFilename) {
42
+ const targetPath = path.join(STATIC_DIR, targetFilename);
43
+ const sourcePath = path.join(STATIC_DIR, sourceIcon);
44
+
45
+ if (!fs.existsSync(sourcePath)) {
46
+ console.log(`⏭️ ${sourceIcon} not found, skipping`);
47
+
48
+ return;
49
+ }
50
+
51
+ if (!fs.existsSync(targetPath)) {
52
+ console.log(`⏭️ ${targetFilename} not found, skipping`);
53
+
54
+ return;
55
+ }
56
+
57
+ const metadata = await sharp(targetPath).metadata();
58
+ const size = Math.max(metadata.width, metadata.height);
59
+ const radius = Math.floor((size * (1 - paddingPct / 100)) / 2);
60
+ const center = Math.floor(size / 2);
61
+ // Build circular mask as RGBA buffer: white opaque circle on transparent bg
62
+ const maskBuf = Buffer.alloc(size * size * 4, 0);
63
+
64
+ for (let y = 0; y < size; y++) {
65
+ for (let x = 0; x < size; x++) {
66
+ const dx = x - center;
67
+ const dy = y - center;
68
+ const dist = Math.sqrt(dx * dx + dy * dy);
69
+
70
+ if (dist < radius) {
71
+ const i = (y * size + x) * 4;
72
+
73
+ maskBuf[i] = 255;
74
+ maskBuf[i + 1] = 255;
75
+ maskBuf[i + 2] = 255;
76
+ maskBuf[i + 3] = 255;
77
+ }
78
+ }
79
+ }
80
+
81
+ const tmpMask = path.join(STATIC_DIR, '.mask-tmp.png');
82
+
83
+ await sharp(maskBuf, {
84
+ raw: { channels: 4, height: size, width: size }
85
+ })
86
+ .png()
87
+ .toFile(tmpMask);
88
+
89
+ // Step 1: Scale source relative to circle diameter (not full icon), composite centered onto white canvas of full size
90
+ const circleDiameter = Math.floor(size * (1 - paddingPct / 100));
91
+ const scaledSize = Math.floor((circleDiameter * scalePct) / 100);
92
+ const offset = Math.floor((size - scaledSize) / 2);
93
+ const scaledBuf = await sharp(sourcePath)
94
+ .resize(scaledSize, scaledSize, {
95
+ background: { alpha: 1, b: 255, g: 255, r: 255 },
96
+ fit: 'cover'
97
+ })
98
+ .ensureAlpha()
99
+ .png()
100
+ .toBuffer();
101
+ // Step 2: Composite scaled image onto white background, then apply circular mask
102
+ const output = await sharp({
103
+ create: {
104
+ background: { alpha: 1, b: 255, g: 255, r: 255 },
105
+ channels: 4,
106
+ height: size,
107
+ width: size
108
+ }
109
+ })
110
+ .composite([
111
+ { input: scaledBuf, left: offset, top: offset },
112
+ { blend: 'dest-in', input: tmpMask, left: 0, top: 0 }
113
+ ])
114
+ .png()
115
+ .toBuffer();
116
+
117
+ fs.writeFileSync(targetPath, output);
118
+ fs.unlinkSync(tmpMask);
119
+
120
+ console.log(
121
+ `✓ ${targetFilename} → circle from ${sourceIcon}, ${paddingPct}% padding (size=${size}, r=${radius}, scale=${scalePct}%, circleDiameter=${circleDiameter})`
122
+ );
123
+ }
124
+
125
+ async function main() {
126
+ console.log(`Circular mask: ${paddingPct}% padding, ${scalePct}% scale, source=${sourceIcon}\n`);
127
+ for (const icon of targetIcons) {
128
+ await makeCircle(icon);
129
+ }
130
+
131
+ console.log('\nUnchanged:');
132
+ for (const icon of untouchedIcons) {
133
+ const fp = path.join(STATIC_DIR, icon);
134
+
135
+ console.log(` ${icon} (${fs.existsSync(fp) ? fs.statSync(fp).size + ' bytes' : 'missing'})`);
136
+ }
137
+ }
138
+
139
+ main();
tools/ui/scripts/vite-plugin-build-info.ts ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { BUILD_CONFIG } from '../src/lib/constants/pwa';
2
+ import { existsSync, writeFileSync } from 'node:fs';
3
+ import { resolve } from 'path';
4
+ import type { Plugin } from 'vite';
5
+
6
+ let processed = false;
7
+
8
+ const OUTPUT_DIR = process.env.LLAMA_UI_OUT_DIR ?? BUILD_CONFIG.OUTPUT_DIR;
9
+
10
+ /**
11
+ * Write build.json with the llama.cpp release build number.
12
+ *
13
+ * LLAMA_BUILD_NUMBER is passed from CMake -> npm -> vite via env var.
14
+ * Used for display of the current llama-server release (e.g. "b1234").
15
+ */
16
+ export function buildInfoPlugin(): Plugin {
17
+ return {
18
+ apply: 'build',
19
+ closeBundle() {
20
+ setTimeout(() => {
21
+ try {
22
+ if (processed) return;
23
+
24
+ processed = true;
25
+
26
+ const buildNumber = process.env.LLAMA_BUILD_NUMBER || 'b0000';
27
+ const outDir = resolve(OUTPUT_DIR);
28
+ const indexPath = resolve(outDir, 'index.html');
29
+
30
+ if (!existsSync(indexPath)) return;
31
+
32
+ const buildJsonPath = resolve(outDir, 'build.json');
33
+
34
+ writeFileSync(buildJsonPath, JSON.stringify({ version: buildNumber }), 'utf-8');
35
+ console.log(`Created build.json (version: ${buildNumber})`);
36
+ } catch (error) {
37
+ console.error('Failed to write build.json:', error);
38
+ }
39
+ }, 100);
40
+ },
41
+ name: 'llamacpp:build-info'
42
+ };
43
+ }
tools/ui/scripts/vite-plugin-nerdamer.ts ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { build } from 'esbuild';
2
+ import { dirname, resolve } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import type { Plugin } from 'vite';
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const VENDORS_DIR = resolve(__dirname, '../src/lib/vendors');
8
+ const VIRTUAL_ID = 'virtual:nerdamer';
9
+ const RESOLVED_ID = '\0' + VIRTUAL_ID;
10
+
11
+ /**
12
+ * Bundle the vendored nerdamer-prime source into a minified IIFE string,
13
+ * exposed as the `virtual:nerdamer` module. Flags mirror the upstream
14
+ * build (esbuild --bundle --minify --format=iife --global-name=nerdamer),
15
+ * so only human readable source lives in the repo and minification is a
16
+ * build artifact. Vendored under src/lib/vendors/, upstream snapshot:
17
+ * https://github.com/together-science/nerdamer-prime/commit/1936145f8af306ec0d883b9bfd7730aedd175c24
18
+ */
19
+ export function nerdamerPlugin(): Plugin {
20
+ let bundled: string | null = null;
21
+
22
+ return {
23
+ async load(id) {
24
+ if (id !== RESOLVED_ID) return undefined;
25
+
26
+ if (bundled === null) {
27
+ const result = await build({
28
+ alias: {
29
+ 'big-integer': resolve(VENDORS_DIR, 'big-integer/BigInteger.js'),
30
+ 'decimal.js': resolve(VENDORS_DIR, 'decimal.js/decimal.js')
31
+ },
32
+ bundle: true,
33
+ entryPoints: [resolve(VENDORS_DIR, 'nerdamer-prime/all.js')],
34
+ format: 'iife',
35
+ globalName: 'nerdamer',
36
+ logLevel: 'silent',
37
+ minify: true,
38
+ write: false
39
+ });
40
+
41
+ bundled = result.outputFiles[0].text;
42
+ }
43
+
44
+ return `export default ${JSON.stringify(bundled)};`;
45
+ },
46
+ name: 'llamacpp:nerdamer',
47
+ resolveId(id) {
48
+ return id === VIRTUAL_ID ? RESOLVED_ID : undefined;
49
+ }
50
+ };
51
+ }
tools/ui/scripts/vite-plugin-relativize-base.ts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { BUILD_CONFIG } from '../src/lib/constants/pwa';
2
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { resolve } from 'path';
4
+ import type { Plugin } from 'vite';
5
+
6
+ let processed = false;
7
+
8
+ const OUTPUT_DIR = process.env.LLAMA_UI_OUT_DIR ?? BUILD_CONFIG.OUTPUT_DIR;
9
+
10
+ function rewrite(path: string, pairs: [string, string][]): void {
11
+ if (!existsSync(path)) {
12
+ return;
13
+ }
14
+
15
+ const text = readFileSync(path, 'utf-8');
16
+
17
+ let out = text;
18
+
19
+ for (const [from, to] of pairs) {
20
+ out = out.split(from).join(to);
21
+ }
22
+
23
+ if (out !== text) {
24
+ writeFileSync(path, out, 'utf-8');
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Relativize SvelteKit absolute base refs so the build is relocatable under any subpath.
30
+ *
31
+ * SvelteKit bakes root absolute /_app/ paths into the SPA fallback because paths.relative
32
+ * does not apply to a depth agnostic fallback page. Rewriting to ./_app/ lets a plain
33
+ * recursive copy of the output into /any/subdir/ resolve assets against the document URL.
34
+ * Runs after adapter-static writes index.html and the PWA plugin writes sw.js, deferred the
35
+ * same way as buildInfoPlugin so the emitted files exist.
36
+ */
37
+ export function relativizeBasePlugin(): Plugin {
38
+ return {
39
+ apply: 'build',
40
+ closeBundle() {
41
+ setTimeout(() => {
42
+ try {
43
+ if (processed) return;
44
+
45
+ processed = true;
46
+
47
+ const outDir = resolve(OUTPUT_DIR);
48
+
49
+ // index.html: modulepreload, stylesheet and bootstrap import reference "/_app/
50
+ rewrite(resolve(outDir, 'index.html'), [['"/_app/', '"./_app/']]);
51
+
52
+ // sw.js: the only absolute entries are the navigate fallback precache key and handler
53
+ rewrite(resolve(outDir, 'sw.js'), [
54
+ ['{url:"/"', '{url:"./"'],
55
+ ['createHandlerBoundToURL("/"', 'createHandlerBoundToURL("./"']
56
+ ]);
57
+
58
+ console.log('Relativized base refs in index.html and sw.js');
59
+ } catch (error) {
60
+ console.error('Failed to relativize base refs:', error);
61
+ }
62
+ }, 100);
63
+ },
64
+ name: 'llamacpp:relativize-base'
65
+ };
66
+ }
tools/ui/scripts/vite-plugin-splash-screen.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { NEWLINE, TAB } from '../src/lib/constants/code';
2
+ import { APPLE_DEVICES, BUILD_CONFIG, REGEX_PATTERNS, SPLASH_LINK } from '../src/lib/constants/pwa';
3
+ import { SplashOrientation } from '../src/lib/enums/splash.enums';
4
+ import type { SplashDimensions } from '../src/lib/types';
5
+ import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import { resolve } from 'path';
7
+ import type { Plugin } from 'vite';
8
+
9
+ let processed = false;
10
+
11
+ const OUTPUT_DIR = process.env.LLAMA_UI_OUT_DIR ?? BUILD_CONFIG.OUTPUT_DIR;
12
+
13
+ /**
14
+ * Generate iOS splash screen <link> tags from generated apple-splash-*.png files.
15
+ * Returns an array of HTML link strings to be injected into the page head.
16
+ */
17
+ export function generateSplashScreenLinks(outDir: string): string[] {
18
+ const files = readdirSync(outDir).filter((f) => f.match(REGEX_PATTERNS.SPLASH_FILE));
19
+
20
+ if (files.length === 0) return [];
21
+
22
+ const dimMap = new Map<string, SplashDimensions>();
23
+
24
+ for (const [dims, spec] of Object.entries(APPLE_DEVICES)) {
25
+ const [w, h] = dims.split('x').map(Number);
26
+
27
+ // logical-point dimensions
28
+ dimMap.set(`${w}x${h}`, { deviceH: spec.height, deviceW: spec.width, dpr: spec.dpr });
29
+ dimMap.set(`${h}x${w}`, { deviceH: spec.height, deviceW: spec.width, dpr: spec.dpr });
30
+ // pixel dimensions (used by actual generated splash files)
31
+ dimMap.set(`${w * spec.dpr}x${h * spec.dpr}`, {
32
+ deviceH: spec.height,
33
+ deviceW: spec.width,
34
+ dpr: spec.dpr
35
+ });
36
+ dimMap.set(`${h * spec.dpr}x${w * spec.dpr}`, {
37
+ deviceH: spec.height,
38
+ deviceW: spec.width,
39
+ dpr: spec.dpr
40
+ });
41
+ }
42
+
43
+ const lightLinks: string[] = [];
44
+ const darkLinks: string[] = [];
45
+
46
+ for (const file of files) {
47
+ const match = file.match(REGEX_PATTERNS.SPLASH_FILE);
48
+
49
+ if (!match) continue;
50
+
51
+ const orientation = match[1] as SplashOrientation;
52
+ const isDark = !!match[2];
53
+ const pixelW = parseInt(match[3]);
54
+ const pixelH = parseInt(match[4]);
55
+ const key = `${pixelW}x${pixelH}`;
56
+ const spec = dimMap.get(key);
57
+
58
+ if (!spec) {
59
+ console.warn(`Unknown splash screen dimensions: ${key} (${file})`);
60
+
61
+ continue;
62
+ }
63
+
64
+ const { deviceH, deviceW, dpr } = spec;
65
+ const media = `screen and (device-width: ${deviceW}px) and (device-height: ${deviceH}px) and (-webkit-device-pixel-ratio: ${dpr}) and (orientation: ${orientation})`;
66
+ const href = `./${file}`;
67
+
68
+ if (isDark) {
69
+ darkLinks.push(
70
+ `${SPLASH_LINK.HTML} media="${media}${SPLASH_LINK.DARK_MEDIA_SUFFIX}" href="${href}">`
71
+ );
72
+ } else {
73
+ lightLinks.push(`${SPLASH_LINK.HTML} media="${media}" href="${href}">`);
74
+ }
75
+ }
76
+
77
+ return [...lightLinks, ...darkLinks];
78
+ }
79
+
80
+ export function splashScreenPlugin(): Plugin {
81
+ return {
82
+ apply: 'build',
83
+ closeBundle() {
84
+ setTimeout(() => {
85
+ try {
86
+ if (processed) return;
87
+
88
+ processed = true;
89
+
90
+ const outDir = resolve(OUTPUT_DIR);
91
+ const indexPath = resolve(outDir, 'index.html');
92
+
93
+ if (!existsSync(indexPath)) return;
94
+
95
+ let content = readFileSync(indexPath, 'utf-8');
96
+
97
+ // Inject iOS splash screen <link> tags into <head>.
98
+ // The @vite-pwa/assets-generator generates apple-splash-*.png files;
99
+ // this scans them and creates the <link> tags SvelteKit needs.
100
+ const splashLinks = generateSplashScreenLinks(outDir);
101
+
102
+ if (splashLinks.length > 0) {
103
+ console.log(`Generated ${splashLinks.length} apple-splash link tags`);
104
+ const splashHtml = splashLinks.map((l) => TAB + TAB + l).join(NEWLINE);
105
+
106
+ content = content.replace(
107
+ REGEX_PATTERNS.HEAD_CLOSE,
108
+ splashHtml + NEWLINE + TAB + TAB + '</head>'
109
+ );
110
+ }
111
+
112
+ // Remove trailing \r from Windows line endings
113
+ content = content.replace(/\r/g, '');
114
+ content = BUILD_CONFIG.GUIDE_COMMENT + NEWLINE + content;
115
+
116
+ writeFileSync(indexPath, content, 'utf-8');
117
+ console.log('Updated index.html');
118
+ } catch (error) {
119
+ console.error('Failed to process build output:', error);
120
+ }
121
+ }, 100);
122
+ },
123
+ name: 'llamacpp:splash-screen'
124
+ };
125
+ }
tools/ui/sources.cmake ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inputs used to decide whether the npm build output is up-to-date.
2
+
3
+ set(UI_SOURCE_GLOBS
4
+ src/*
5
+ static/*
6
+ )
7
+
8
+ set(UI_SOURCE_FILES
9
+ package.json
10
+ package-lock.json
11
+ src/.gitignore
12
+ vite.config.ts
13
+ svelte.config.js
14
+ tsconfig.json
15
+ scripts/vite-plugin-llama-cpp-build.ts
16
+ )
tools/ui/src/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ !*
tools/ui/src/app.css ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import 'tailwindcss';
2
+ @source '.';
3
+ @plugin '@tailwindcss/forms';
4
+ @plugin '@tailwindcss/typography';
5
+ @import 'tw-animate-css';
6
+ @custom-variant dark (&:is(.dark *));
7
+
8
+ /* =========================================================
9
+ ΩFFFΣLLIa • llama.cpp • AlgMor24
10
+ Tema Cyberpunk "Fogo Neon" — vermelho/laranja incandescente,
11
+ dourado de chama e ciano dos olhos brilhantes. ᚠ Ω Σ
12
+ ========================================================= */
13
+
14
+ :root {
15
+ --radius: 0.625rem;
16
+
17
+ /* ===== Identidade da foto: nomes & símbolos ===== */
18
+ --brand-omega: 'ΩFFFΣLLIa';
19
+ --brand-llama: 'llama.cpp';
20
+ --brand-algmor: 'AlgMor24';
21
+ --rune-omega: 'Ω';
22
+ --rune-sigma: 'Σ';
23
+ --rune-fehu: 'ᚠ'; /* runa de fogo da foto */
24
+ --rune-perthro: 'ᛈ'; /* runa dos cards flamejantes */
25
+
26
+ /* Fire Neon Palette - Light Theme */
27
+ --background: oklch(0.96 0.02 80);
28
+ --foreground: oklch(0.2 0.06 25);
29
+ --card: oklch(0.98 0.015 80);
30
+ --card-foreground: oklch(0.2 0.06 25);
31
+ --popover: oklch(0.98 0.015 80);
32
+ --popover-foreground: oklch(0.2 0.06 25);
33
+ /* Primary - Flame Orange Neon */
34
+ --primary: oklch(0.62 0.22 45);
35
+ --primary-foreground: oklch(0.98 0.02 80);
36
+ /* Secondary - Ember Red */
37
+ --secondary: oklch(0.55 0.24 25);
38
+ --secondary-foreground: oklch(0.98 0.02 80);
39
+ --muted: oklch(0.9 0.03 80);
40
+ --muted-foreground: oklch(0.5 0.08 25);
41
+ /* Accent - Molten Gold */
42
+ --accent: oklch(0.6 0.2 80);
43
+ --accent-foreground: oklch(0.98 0.02 80);
44
+ --destructive: oklch(0.55 0.26 25);
45
+ --border: oklch(0.82 0.06 45);
46
+ --input: oklch(0.86 0.05 45);
47
+ --ring: oklch(0.62 0.22 45);
48
+ /* Símbolos de chama (cores da foto) */
49
+ --flame: oklch(0.62 0.22 45); /* laranja neon */
50
+ --ember: oklch(0.55 0.24 25); /* vermelho brasa */
51
+ --gold: oklch(0.7 0.16 85); /* dourado de chama */
52
+ --eye: oklch(0.6 0.12 220); /* ciano dos olhos */
53
+ /* Chart Colors - Fire Spectrum */
54
+ --chart-1: oklch(0.62 0.22 45); /* Flame */
55
+ --chart-2: oklch(0.55 0.24 25); /* Ember */
56
+ --chart-3: oklch(0.7 0.16 85); /* Gold */
57
+ --chart-4: oklch(0.6 0.12 220); /* Eye Cyan */
58
+ --chart-5: oklch(0.45 0.2 25); /* Deep Red */
59
+ --sidebar: oklch(0.97 0.015 80);
60
+ --sidebar-foreground: oklch(0.2 0.06 25);
61
+ --sidebar-primary: oklch(0.62 0.22 45);
62
+ --sidebar-primary-foreground: oklch(0.98 0.02 80);
63
+ --sidebar-accent: oklch(0.92 0.04 80);
64
+ --sidebar-accent-foreground: oklch(0.2 0.06 25);
65
+ --sidebar-border: oklch(0.85 0.05 45);
66
+ --sidebar-ring: oklch(0.62 0.22 45);
67
+ /* Code Block - carvão com texto flamejante */
68
+ --code-background: oklch(0.14 0.03 25);
69
+ --code-foreground: oklch(0.8 0.2 80);
70
+ --font-mono:
71
+ ui-monospace, SFMono-Regular, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas,
72
+ 'Liberation Mono', Menlo, monospace;
73
+ --layer-popover: 1000000;
74
+ --chat-form-area-height: 8rem;
75
+ --chat-form-area-offset: 2rem;
76
+ --chat-form-padding-top: 6rem;
77
+ --max-message-height: max(24rem, min(80dvh, calc(100dvh - var(--chat-form-area-height) - 12rem)));
78
+ }
79
+
80
+ @media (min-width: 640px) {
81
+ :root {
82
+ --chat-form-area-height: 24rem;
83
+ --chat-form-area-offset: 12rem;
84
+ --chat-form-padding-top: 6rem;
85
+ }
86
+ }
87
+
88
+ .dark {
89
+ /* ===== Cyberpunk Fogo Neon - Dark Theme (Principal) ===== */
90
+ --background: oklch(0.13 0.03 25);
91
+ --foreground: oklch(0.96 0.02 80);
92
+ --card: oklch(0.17 0.04 25);
93
+ --card-foreground: oklch(0.96 0.02 80);
94
+ --popover: oklch(0.17 0.04 25);
95
+ --popover-foreground: oklch(0.96 0.02 80);
96
+ /* Primary - Flame Orange Neon (#FF6A00 eq.) */
97
+ --primary: oklch(0.72 0.28 45);
98
+ --primary-foreground: oklch(0.12 0.03 25);
99
+ /* Secondary - Ember Red (#FF2A00 eq.) */
100
+ --secondary: oklch(0.62 0.28 25);
101
+ --secondary-foreground: oklch(0.98 0.02 80);
102
+ --muted: oklch(0.26 0.05 25);
103
+ --muted-foreground: oklch(0.7 0.08 45);
104
+ /* Accent - Molten Gold */
105
+ --accent: oklch(0.8 0.22 85);
106
+ --accent-foreground: oklch(0.15 0.04 80);
107
+ --destructive: oklch(0.65 0.28 25);
108
+ --border: oklch(0.38 0.1 25);
109
+ --input: oklch(0.22 0.05 25);
110
+ --ring: oklch(0.72 0.28 45);
111
+ /* Símbolos de chama (cores da foto) */
112
+ --flame: oklch(0.72 0.28 45);
113
+ --ember: oklch(0.62 0.28 25);
114
+ --gold: oklch(0.85 0.2 90);
115
+ --eye: oklch(0.78 0.18 220); /* olhos ciano incandescentes */
116
+ /* Chart Colors - Fire Spectrum + Eye Cyan */
117
+ --chart-1: oklch(0.72 0.28 45); /* Flame Neon */
118
+ --chart-2: oklch(0.62 0.28 25); /* Ember Red */
119
+ --chart-3: oklch(0.85 0.2 90); /* Molten Gold */
120
+ --chart-4: oklch(0.78 0.18 220); /* Eye Cyan */
121
+ --chart-5: oklch(0.5 0.25 25); /* Deep Blood Red */
122
+ --sidebar: oklch(0.11 0.03 25);
123
+ --sidebar-foreground: oklch(0.96 0.02 80);
124
+ --sidebar-primary: oklch(0.72 0.28 45);
125
+ --sidebar-primary-foreground: oklch(0.12 0.03 25);
126
+ --sidebar-accent: oklch(0.24 0.07 25);
127
+ --sidebar-accent-foreground: oklch(0.96 0.02 80);
128
+ --sidebar-border: oklch(0.3 0.08 25);
129
+ --sidebar-ring: oklch(0.72 0.28 45);
130
+ /* Code Block - carvão com brasas douradas */
131
+ --code-background: oklch(0.11 0.03 25);
132
+ --code-foreground: oklch(0.85 0.2 90);
133
+ }
134
+
135
+ @theme inline {
136
+ --radius-sm: calc(var(--radius) - 4px);
137
+ --radius-md: calc(var(--radius) - 2px);
138
+ --radius-lg: var(--radius);
139
+ --radius-xl: calc(var(--radius) + 4px);
140
+ --color-background: var(--background);
141
+ --color-foreground: var(--foreground);
142
+ --color-card: var(--card);
143
+ --color-card-foreground: var(--card-foreground);
144
+ --color-popover: var(--popover);
145
+ --color-popover-foreground: var(--popover-foreground);
146
+ --color-primary: var(--primary);
147
+ --color-primary-foreground: var(--primary-foreground);
148
+ --color-secondary: var(--secondary);
149
+ --color-secondary-foreground: var(--secondary-foreground);
150
+ --color-muted: var(--muted);
151
+ --color-muted-foreground: var(--muted-foreground);
152
+ --color-accent: var(--accent);
153
+ --color-accent-foreground: var(--accent-foreground);
154
+ --color-destructive: var(--destructive);
155
+ --color-border: var(--border);
156
+ --color-input: var(--input);
157
+ --color-ring: var(--ring);
158
+ --color-chart-1: var(--chart-1);
159
+ --color-chart-2: var(--chart-2);
160
+ --color-chart-3: var(--chart-3);
161
+ --color-chart-4: var(--chart-4);
162
+ --color-chart-5: var(--chart-5);
163
+ --color-sidebar: var(--sidebar);
164
+ --color-sidebar-foreground: var(--sidebar-foreground);
165
+ --color-sidebar-primary: var(--sidebar-primary);
166
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
167
+ --color-sidebar-accent: var(--sidebar-accent);
168
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
169
+ --color-sidebar-border: var(--sidebar-border);
170
+ --color-sidebar-ring: var(--sidebar-ring);
171
+ /* Cores-símbolo da foto como utilitários Tailwind (text-flame, bg-ember...) */
172
+ --color-flame: var(--flame);
173
+ --color-ember: var(--ember);
174
+ --color-gold: var(--gold);
175
+ --color-eye: var(--eye);
176
+ /* Animações nativas do tema */
177
+ --animate-flicker: flicker 3s linear infinite;
178
+ --animate-ember-rise: ember-rise 7s linear infinite;
179
+ --animate-pulse-fire: pulse-fire 2.2s ease-in-out infinite;
180
+ --animate-gradient-x: gradient-x 6s ease infinite;
181
+ }
182
+
183
+ /* ================= KEYFRAMES DOS EFEITOS ================= */
184
+
185
+ @keyframes flicker {
186
+ 0%, 100% { opacity: 1; }
187
+ 6% { opacity: 0.85; }
188
+ 9% { opacity: 1; }
189
+ 38% { opacity: 1; }
190
+ 40% { opacity: 0.5; }
191
+ 42% { opacity: 1; }
192
+ 71% { opacity: 0.75; }
193
+ 73% { opacity: 1; }
194
+ }
195
+
196
+ @keyframes ember-rise {
197
+ 0% { transform: translateY(0) scale(1); opacity: 0; }
198
+ 8% { opacity: 1; }
199
+ 100% { transform: translateY(-90vh) scale(0.3); opacity: 0; }
200
+ }
201
+
202
+ @keyframes gradient-x {
203
+ 0%, 100% { background-position: 0% 50%; }
204
+ 50% { background-position: 100% 50%; }
205
+ }
206
+
207
+ @keyframes pulse-fire {
208
+ 0%, 100% {
209
+ box-shadow: 0 0 6px var(--ember), 0 0 14px var(--flame), 0 0 28px var(--flame);
210
+ }
211
+ 50% {
212
+ box-shadow: 0 0 12px var(--gold), 0 0 26px var(--flame), 0 0 48px var(--ember);
213
+ }
214
+ }
215
+
216
+ @keyframes scan {
217
+ 0% { transform: translateY(-100%); }
218
+ 100% { transform: translateY(100vh); }
219
+ }
220
+
221
+ @layer base {
222
+ * {
223
+ @apply border-border outline-ring/50;
224
+ }
225
+ body {
226
+ @apply bg-background text-foreground;
227
+ scrollbar-width: thin;
228
+ scrollbar-gutter: stable;
229
+ /* Fundo com brasas ambientes + grade sutil */
230
+ background-image:
231
+ radial-gradient(ellipse at 50% 115%, oklch(0.3 0.12 25 / 0.35), transparent 60%),
232
+ radial-gradient(ellipse at 85% -10%, oklch(0.25 0.06 220 / 0.18), transparent 55%);
233
+ }
234
+ /* Scanlines CRT + vinheta (overlay global da foto) */
235
+ body::before {
236
+ content: '';
237
+ position: fixed;
238
+ inset: 0;
239
+ pointer-events: none;
240
+ z-index: 999990;
241
+ background:
242
+ repeating-linear-gradient(0deg, oklch(0 0 0 / 0.22) 0 1px, transparent 1px 3px),
243
+ radial-gradient(ellipse at center, transparent 55%, oklch(0.08 0.03 25 / 0.55) 100%);
244
+ opacity: 0.35;
245
+ }
246
+ /* Brilho de fogo inferior + reflexo ciano dos olhos */
247
+ body::after {
248
+ content: '';
249
+ position: fixed;
250
+ inset: 0;
251
+ pointer-events: none;
252
+ z-index: 999990;
253
+ background:
254
+ radial-gradient(circle at 50% 120%, var(--ember), transparent 70%),
255
+ radial-gradient(circle at 12% 8%, oklch(0.78 0.18 220 / 0.12), transparent 40%);
256
+ opacity: 0.22;
257
+ mix-blend-mode: screen;
258
+ }
259
+ ::selection {
260
+ background: var(--flame);
261
+ color: var(--background);
262
+ text-shadow: 0 0 8px var(--gold);
263
+ }
264
+ /* Scrollbar cor de fogo */
265
+ * {
266
+ scrollbar-width: thin;
267
+ scrollbar-color: transparent transparent;
268
+ }
269
+ *:hover {
270
+ scrollbar-color: var(--flame) transparent;
271
+ }
272
+ *::-webkit-scrollbar {
273
+ width: 6px;
274
+ height: 6px;
275
+ }
276
+ *::-webkit-scrollbar-track {
277
+ background: transparent;
278
+ }
279
+ *::-webkit-scrollbar-thumb {
280
+ background: transparent;
281
+ border-radius: 3px;
282
+ transition: background 0.2s ease;
283
+ }
284
+ *:hover::-webkit-scrollbar-thumb {
285
+ background: var(--flame);
286
+ }
287
+ *::-webkit-scrollbar-thumb:hover {
288
+ background: var(--gold);
289
+ }
290
+ :where(code, pre, kbd, samp) {
291
+ font-family: var(--font-mono);
292
+ }
293
+ }
294
+
295
+ @layer utilities {
296
+ .scrollbar-hide {
297
+ &::-webkit-scrollbar {
298
+ display: none;
299
+ }
300
+ -ms-overflow-style: none;
301
+ scrollbar-width: none;
302
+ }
303
+
304
+ /* ===== Neon Glow Effects (fogo da foto) ===== */
305
+ .neon-flame {
306
+ box-shadow: 0 0 5px var(--flame), 0 0 10px var(--flame), 0 0 20px var(--ember),
307
+ 0 0 40px var(--ember);
308
+ }
309
+ .neon-ember {
310
+ box-shadow: 0 0 5px var(--ember), 0 0 10px var(--ember), 0 0 20px var(--ember);
311
+ }
312
+ .neon-gold {
313
+ box-shadow: 0 0 5px var(--gold), 0 0 10px var(--gold), 0 0 20px var(--flame);
314
+ }
315
+ .neon-eye {
316
+ box-shadow: 0 0 5px var(--eye), 0 0 10px var(--eye), 0 0 20px var(--eye);
317
+ }
318
+ /* Legado (remapeado p/ fogo) */
319
+ .neon-cyan { box-shadow: 0 0 5px var(--flame), 0 0 10px var(--flame), 0 0 20px var(--flame); }
320
+ .neon-magenta { box-shadow: 0 0 5px var(--ember), 0 0 10px var(--ember), 0 0 20px var(--ember); }
321
+ .neon-purple { box-shadow: 0 0 5px var(--gold), 0 0 10px var(--gold), 0 0 20px var(--gold); }
322
+
323
+ .text-glow-fire {
324
+ text-shadow: 0 0 10px var(--flame), 0 0 20px var(--ember), 0 0 40px var(--ember);
325
+ }
326
+ .text-glow-gold {
327
+ text-shadow: 0 0 10px var(--gold), 0 0 20px var(--flame);
328
+ }
329
+ .text-glow-eye {
330
+ text-shadow: 0 0 10px var(--eye), 0 0 20px var(--eye);
331
+ }
332
+ .text-glow-cyan { text-shadow: 0 0 10px var(--flame), 0 0 20px var(--flame); }
333
+ .text-glow-magenta { text-shadow: 0 0 10px var(--ember), 0 0 20px var(--ember); }
334
+
335
+ /* Texto em chamas com gradiente animado */
336
+ .fire-text {
337
+ background-image: linear-gradient(90deg, var(--gold), var(--flame), var(--ember), var(--gold));
338
+ background-size: 200% auto;
339
+ background-clip: text;
340
+ -webkit-background-clip: text;
341
+ color: transparent;
342
+ animation: gradient-x 4s linear infinite;
343
+ filter: drop-shadow(0 0 8px var(--flame));
344
+ }
345
+
346
+ /* Grade ciberpunk vermelha */
347
+ .cyber-grid {
348
+ background-image:
349
+ linear-gradient(oklch(0.62 0.28 25 / 0.12) 1px, transparent 1px),
350
+ linear-gradient(90deg, oklch(0.62 0.28 25 / 0.12) 1px, transparent 1px);
351
+ background-size: 32px 32px;
352
+ }
353
+
354
+ /* Card-runas flutuantes (como os cards ᚠ da foto) */
355
+ .rune-card {
356
+ border: 1px solid oklch(0.72 0.28 45 / 0.6);
357
+ background: oklch(0.17 0.05 25 / 0.6);
358
+ backdrop-filter: blur(8px);
359
+ box-shadow: 0 0 12px oklch(0.62 0.28 25 / 0.5), inset 0 0 12px oklch(0.72 0.28 45 / 0.25);
360
+ animation: flicker 4s linear infinite;
361
+ }
362
+
363
+ /* ===== Símbolos da foto (Ω Σ ᚠ ᛈ) ===== */
364
+ .sym-omega::before,
365
+ .sym-sigma::before,
366
+ .sym-fehu::before,
367
+ .sym-perthro::before {
368
+ display: inline-block;
369
+ margin-right: 0.4em;
370
+ color: var(--flame);
371
+ text-shadow: 0 0 8px var(--ember), 0 0 16px var(--flame);
372
+ animation: flicker 3.5s linear infinite;
373
+ }
374
+ .sym-omega::before { content: var(--rune-omega); }
375
+ .sym-sigma::before { content: var(--rune-sigma); }
376
+ .sym-fehu::before { content: var(--rune-fehu); }
377
+ .sym-perthro::before { content: var(--rune-perthro); }
378
+
379
+ /* ===== Nomes da foto como marcas d'água/tags ===== */
380
+ .brand-omega::before { content: var(--brand-omega); }
381
+ .brand-llama::after { content: var(--brand-llama); }
382
+ .brand-algmor::after { content: var(--brand-algmor); }
383
+ .brand-omega::before,
384
+ .brand-llama::after,
385
+ .brand-algmor::after {
386
+ font-family: var(--font-mono);
387
+ letter-spacing: 0.15em;
388
+ color: var(--gold);
389
+ text-shadow: 0 0 6px var(--flame), 0 0 18px var(--ember);
390
+ }
391
+
392
+ /* Glitch ciberpunk (vermelho + ciano dos olhos) — usar com data-text */
393
+ .glitch {
394
+ position: relative;
395
+ }
396
+ .glitch::before,
397
+ .glitch::after {
398
+ content: attr(data-text);
399
+ position: absolute;
400
+ inset: 0;
401
+ pointer-events: none;
402
+ }
403
+ .glitch::before {
404
+ color: var(--ember);
405
+ clip-path: inset(0 0 55% 0);
406
+ transform: translate(-2px, -1px);
407
+ opacity: 0.8;
408
+ animation: flicker 2.7s linear infinite;
409
+ }
410
+ .glitch::after {
411
+ color: var(--eye);
412
+ clip-path: inset(45% 0 0 0);
413
+ transform: translate(2px, 1px);
414
+ opacity: 0.8;
415
+ animation: flicker 3.3s linear infinite reverse;
416
+ }
417
+ }
418
+
419
+ .mermaidTooltip {
420
+ display: none !important;
421
+ }
tools/ui/src/app.d.ts ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // See https://svelte.dev/docs/kit/types#app.d.ts
2
+ // for information about these interfaces
3
+
4
+ import 'vite-plugin-pwa/pwa-assets';
5
+ import 'vite-plugin-pwa/svelte';
6
+ import { ModelModality, ServerModelStatus, ServerRole } from '$lib/enums';
7
+ // Import chat types from dedicated module
8
+ import type {
9
+ // API types
10
+ ApiChatCompletionRequest,
11
+ ApiChatCompletionResponse,
12
+ ApiChatCompletionStreamChunk,
13
+ ApiChatCompletionToolCall,
14
+ ApiChatCompletionToolCallDelta,
15
+ ApiChatMessageContentPart,
16
+ ApiChatMessageData,
17
+ ApiContextSizeError,
18
+ ApiErrorResponse,
19
+ ApiLlamaCppServerProps,
20
+ ApiModelDataEntry,
21
+ ApiModelListResponse,
22
+ ApiModelLoadStage,
23
+ ApiModelsSseData,
24
+ ApiModelsSseEvent,
25
+ ApiModelsSseProgress,
26
+ ApiProcessingState,
27
+ ApiRouterModelMeta,
28
+ ApiRouterModelsListResponse,
29
+ ApiRouterModelsLoadRequest,
30
+ ApiRouterModelsLoadResponse,
31
+ ApiRouterModelsStatusRequest,
32
+ ApiRouterModelsStatusResponse,
33
+ ApiRouterModelsUnloadRequest,
34
+ ApiRouterModelsUnloadResponse,
35
+ // Chat types
36
+ ChatAttachmentDisplayItem,
37
+ ChatMessagePromptProgress,
38
+ ChatMessageSiblingInfo,
39
+ ChatMessageTimings,
40
+ ChatMessageType,
41
+ ChatRole,
42
+ ChatUploadedFile,
43
+ // Database types
44
+ DatabaseConversation,
45
+ DatabaseMessage,
46
+ DatabaseMessageExtra,
47
+ DatabaseMessageExtraAudioFile,
48
+ DatabaseMessageExtraImageFile,
49
+ DatabaseMessageExtraLegacyContext,
50
+ DatabaseMessageExtraPdfFile,
51
+ DatabaseMessageExtraTextFile,
52
+ DatabaseMessageExtraVideoFile,
53
+ ExportedConversation,
54
+ ExportedConversations,
55
+ ModelLoadProgress,
56
+ // Model types
57
+ ModelModalities,
58
+ ModelOption,
59
+ // Settings types
60
+ SettingsChatServiceOptions,
61
+ SettingsConfigType,
62
+ SettingsConfigValue,
63
+ SettingsFieldConfig
64
+ } from '$lib/types';
65
+
66
+ declare global {
67
+ // namespace App {
68
+ // interface Error {}
69
+ // interface Locals {}
70
+ // interface PageData {}
71
+ // interface PageState {}
72
+ // interface Platform {}
73
+ // }
74
+
75
+ export {
76
+ // API types
77
+ ApiChatCompletionRequest,
78
+ ApiChatCompletionResponse,
79
+ ApiChatCompletionStreamChunk,
80
+ ApiChatCompletionToolCall,
81
+ ApiChatCompletionToolCallDelta,
82
+ ApiChatMessageData,
83
+ ApiChatMessageContentPart,
84
+ ApiContextSizeError,
85
+ ApiErrorResponse,
86
+ ApiLlamaCppServerProps,
87
+ ApiModelDataEntry,
88
+ ApiModelLoadStage,
89
+ ApiModelsSseProgress,
90
+ ApiModelsSseData,
91
+ ApiModelsSseEvent,
92
+ ApiModelListResponse,
93
+ ApiProcessingState,
94
+ ApiRouterModelMeta,
95
+ ApiRouterModelsLoadRequest,
96
+ ApiRouterModelsLoadResponse,
97
+ ApiRouterModelsStatusRequest,
98
+ ApiRouterModelsStatusResponse,
99
+ ApiRouterModelsListResponse,
100
+ ApiRouterModelsUnloadRequest,
101
+ ApiRouterModelsUnloadResponse,
102
+ // Chat types
103
+ ChatAttachmentDisplayItem,
104
+ ChatMessagePromptProgress,
105
+ ChatMessageSiblingInfo,
106
+ ChatMessageTimings,
107
+ ChatMessageType,
108
+ ChatRole,
109
+ ChatUploadedFile,
110
+ // Database types
111
+ DatabaseConversation,
112
+ DatabaseMessage,
113
+ DatabaseMessageExtra,
114
+ DatabaseMessageExtraAudioFile,
115
+ DatabaseMessageExtraVideoFile,
116
+ DatabaseMessageExtraImageFile,
117
+ DatabaseMessageExtraTextFile,
118
+ DatabaseMessageExtraPdfFile,
119
+ DatabaseMessageExtraLegacyContext,
120
+ ExportedConversation,
121
+ ExportedConversations,
122
+ // Enum types
123
+ ModelModality,
124
+ ServerRole,
125
+ ServerModelStatus,
126
+ // Model types
127
+ ModelModalities,
128
+ ModelOption,
129
+ ModelLoadProgress,
130
+ // Settings types
131
+ SettingsChatServiceOptions,
132
+ SettingsConfigValue,
133
+ SettingsFieldConfig,
134
+ SettingsConfigType
135
+ };
136
+ }
137
+
138
+ declare global {
139
+ interface Window {
140
+ idxThemeStyle?: number;
141
+ idxCodeBlock?: number;
142
+
143
+ // File System Access API - not in the DOM lib and unavailable in some browsers
144
+ showDirectoryPicker?: (options?: {
145
+ id?: string;
146
+ mode?: 'read' | 'readwrite';
147
+ startIn?: FileSystemHandle | string;
148
+ }) => Promise<FileSystemDirectoryHandle>;
149
+ }
150
+ }
tools/ui/src/app.html ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="favicon.ico" sizes="48x48" />
6
+ <link rel="icon" href="favicon.svg" sizes="any" type="image/svg+xml" />
7
+
8
+ <link rel="apple-touch-icon" href="apple-touch-icon-180x180.png" />
9
+
10
+ <link rel="manifest" href="./manifest.webmanifest" />
11
+
12
+ <meta
13
+ name="viewport"
14
+ content="width=device-width, initial-scale=1, interactive-widget=resizes-content"
15
+ />
16
+ %sveltekit.head%
17
+ </head>
18
+
19
+ <body data-sveltekit-preload-data="hover">
20
+ <div style="display: contents">%sveltekit.body%</div>
21
+ </body>
22
+ </html>
tools/ui/src/lib/assets/logo.svg ADDED
tools/ui/src/lib/components/app/SKILL.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: app
3
+ description: Opinionated app components building on top of ./ui primitives
4
+ ---
5
+
6
+ - Can include business logic and state management
7
+ - Can include data fetching and caching logic
8
+ - Should use original spelling for HTML-native events and `camelCase` for custom events
9
+ - Props and markup attributes should be listed alphabetically
10
+ - Use JS Objects and Arrays for CSS classes and styles when they are dynamic
11
+ - Whenever there can be repetition in the component's markup, if it's too small to be decoupled as a separate component — use Svelte 5's `{#snippet}` + `{@render}`
tools/ui/src/lib/components/app/actions/ActionIcon.svelte ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Button, type ButtonSize, type ButtonVariant } from '$lib/components/ui/button';
3
+ import * as Tooltip from '$lib/components/ui/tooltip';
4
+ import { TooltipSide } from '$lib/enums';
5
+ import type { Component } from 'svelte';
6
+
7
+ interface Props {
8
+ ariaLabel?: string;
9
+ class?: string;
10
+ disabled?: boolean;
11
+ href?: string;
12
+ icon: Component;
13
+ iconSize?: string;
14
+ onclick?: (e?: MouseEvent) => void;
15
+ size?: ButtonSize;
16
+ stopPropagationOnClick?: boolean;
17
+ tooltip?: string;
18
+ variant?: ButtonVariant;
19
+ tooltipSide?: TooltipSide;
20
+ }
21
+
22
+ let {
23
+ ariaLabel,
24
+ class: className = '',
25
+ disabled = false,
26
+ href = '',
27
+ icon,
28
+ iconSize = 'h-3 w-3',
29
+ onclick,
30
+ size = 'sm',
31
+ stopPropagationOnClick = false,
32
+ tooltip,
33
+ tooltipSide = TooltipSide.TOP,
34
+ variant = 'ghost'
35
+ }: Props = $props();
36
+
37
+ let innerWidth = $state(0);
38
+ const showTooltip = $derived(!!tooltip && innerWidth > 768);
39
+ </script>
40
+
41
+ {#snippet button(props = {})}
42
+ <Button
43
+ {...props}
44
+ {href}
45
+ {variant}
46
+ {size}
47
+ {disabled}
48
+ onclick={(e: MouseEvent) => {
49
+ if (stopPropagationOnClick) e.stopPropagation();
50
+
51
+ onclick?.(e);
52
+ }}
53
+ class="h-6 w-6 p-0 {className} flex hover:bg-transparent data-[state=open]:bg-transparent!"
54
+ aria-label={ariaLabel || tooltip}
55
+ >
56
+ {#if icon}
57
+ {@const IconComponent = icon}
58
+
59
+ <IconComponent class={iconSize} />
60
+ {/if}
61
+ </Button>
62
+ {/snippet}
63
+
64
+ {#if showTooltip}
65
+ <Tooltip.Root>
66
+ <Tooltip.Trigger>
67
+ <!-- prevent another nested button element -->
68
+ {#snippet child({ props })}
69
+ {#if disabled}
70
+ <!-- disabled buttons have pointer-events:none; wrap in a span so the tooltip hover surface stays alive -->
71
+ <span {...props}>
72
+ {@render button({})}
73
+ </span>
74
+ {:else}
75
+ {@render button(props)}
76
+ {/if}
77
+ {/snippet}
78
+ </Tooltip.Trigger>
79
+
80
+ <Tooltip.Content side={tooltipSide}>
81
+ <p>{tooltip}</p>
82
+ </Tooltip.Content>
83
+ </Tooltip.Root>
84
+ {:else}
85
+ {@render button({ href })}
86
+ {/if}
87
+
88
+ <svelte:window bind:innerWidth />
tools/ui/src/lib/components/app/actions/ActionIconCopyToClipboard.svelte ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import ActionIcon from './ActionIcon.svelte';
3
+ import { Copy } from '@lucide/svelte';
4
+ import { ICON_CLASS_DEFAULT } from '$lib/constants/css-classes';
5
+ import { copyToClipboard } from '$lib/utils';
6
+
7
+ export let ariaLabel: string = 'Copy to clipboard';
8
+ export let canCopy: boolean = true;
9
+ export let text: string;
10
+ </script>
11
+
12
+ <ActionIcon
13
+ icon={Copy}
14
+ tooltip={ariaLabel}
15
+ iconSize={ICON_CLASS_DEFAULT}
16
+ disabled={!canCopy}
17
+ onclick={() => canCopy && copyToClipboard(text)}
18
+ />
tools/ui/src/lib/components/app/actions/index.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * ACTIONS
4
+ *
5
+ * Small interactive components for user actions.
6
+ *
7
+ */
8
+
9
+ /** Styled icon button for action triggers with tooltip. */
10
+ export { default as ActionIcon } from './ActionIcon.svelte';
11
+
12
+ /** Copy-to-clipboard icon button with clipboard logic. */
13
+ export { default as ActionIconCopyToClipboard } from './ActionIconCopyToClipboard.svelte';
tools/ui/src/lib/components/app/agents/AgentsHub.svelte ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import {
3
+ Bot,
4
+ Check,
5
+ ChevronRight,
6
+ Code,
7
+ Cpu,
8
+ Database,
9
+ FileCode,
10
+ FolderGit2,
11
+ Globe,
12
+ Layers,
13
+ Play,
14
+ Power,
15
+ RotateCcw,
16
+ Settings,
17
+ ShieldCheck,
18
+ Sparkles,
19
+ Terminal,
20
+ Wrench,
21
+ Zap
22
+ } from '@lucide/svelte';
23
+ import { browser } from '$app/environment';
24
+ import { goto } from '$app/navigation';
25
+ import { Button } from '$lib/components/ui/button';
26
+ import { Badge } from '$lib/components/ui/badge';
27
+ import { Switch } from '$lib/components/ui/switch';
28
+ import { Input } from '$lib/components/ui/input';
29
+ import { Textarea } from '$lib/components/ui/textarea';
30
+ import { ROUTES } from '$lib/constants';
31
+ import { BuiltInTool } from '$lib/enums';
32
+ import { agentsStore, type AgentProfile } from '$lib/stores/agents.svelte';
33
+ import { config, updateConfig } from '$lib/stores/settings.svelte';
34
+ import { toolsStore } from '$lib/stores/tools.svelte';
35
+ import { mcpStore } from '$lib/stores/mcp.svelte';
36
+ import { fade } from 'svelte/transition';
37
+
38
+ interface Props {
39
+ class?: string;
40
+ }
41
+
42
+ let { class: className = '' }: Props = $props();
43
+
44
+ let activeProfile = $derived(agentsStore.activeAgent);
45
+ let allProfiles = $derived(agentsStore.profiles);
46
+ let autoApprove = $derived(agentsStore.autoApprove);
47
+ let maxTurns = $derived(config().agenticMaxTurns ?? 20);
48
+ let jsSandbox = $derived(config().jsSandboxEnabled ?? true);
49
+ let symbolicMath = $derived(config().symbolicMathEnabled ?? true);
50
+
51
+ let editingPromptId = $state<string | null>(null);
52
+ let customPromptText = $state<string>('');
53
+
54
+ function selectAgent(profile: AgentProfile) {
55
+ agentsStore.setActiveAgent(profile.id);
56
+ }
57
+
58
+ function handleLaunchAgent(profile: AgentProfile) {
59
+ agentsStore.launchChatWithAgent(profile);
60
+ }
61
+
62
+ function handleToggleTool(toolKey: string) {
63
+ toolsStore.toggleTool(toolKey);
64
+ }
65
+
66
+ function handleMaxTurnsChange(val: number) {
67
+ updateConfig('agenticMaxTurns', val);
68
+ }
69
+
70
+ function handleToggleAutoApprove(checked: boolean) {
71
+ agentsStore.setAutoApprove(checked);
72
+ }
73
+
74
+ function handleToggleJsSandbox(checked: boolean) {
75
+ updateConfig('jsSandboxEnabled', checked);
76
+ }
77
+
78
+ function handleToggleSymbolicMath(checked: boolean) {
79
+ updateConfig('symbolicMathEnabled', checked);
80
+ }
81
+ </script>
82
+
83
+ <div in:fade={{ duration: 150 }} class="mx-auto w-full max-w-7xl px-4 py-6 md:px-8 {className}">
84
+ <!-- Top Header -->
85
+ <div class="mb-8 flex flex-col gap-4 border-b border-border/40 pb-6 md:flex-row md:items-center md:justify-between">
86
+ <div class="flex items-center gap-3">
87
+ <div class="flex h-12 w-12 items-center justify-center rounded-xl bg-flame/10 border border-flame/30 text-flame shadow-lg shadow-flame/10">
88
+ <Bot class="h-7 w-7" />
89
+ </div>
90
+ <div>
91
+ <div class="flex items-center gap-2">
92
+ <h1 class="text-2xl font-bold tracking-tight text-foreground md:text-3xl">
93
+ Centro de Controle Agêntico
94
+ </h1>
95
+ <Badge variant="outline" class="border-flame/50 bg-flame/10 text-flame text-xs font-semibold px-2.5 py-0.5">
96
+ UNLOCKED • 100% ATIVO
97
+ </Badge>
98
+ </div>
99
+ <p class="text-sm text-muted-foreground mt-0.5">
100
+ Orquestração autônoma, perfis especializados, execução livre de ferramentas e parametrização direta.
101
+ </p>
102
+ </div>
103
+ </div>
104
+
105
+ <!-- Quick Launch Active Agent -->
106
+ <div class="flex items-center gap-3">
107
+ <Button
108
+ variant="default"
109
+ size="lg"
110
+ class="gap-2 bg-gradient-to-r from-flame to-ember text-white font-semibold shadow-md hover:opacity-90 transition-all cursor-pointer"
111
+ onclick={() => handleLaunchAgent(activeProfile)}
112
+ >
113
+ <Play class="h-4 w-4 fill-white" />
114
+ Iniciar Chat com {activeProfile.name}
115
+ </Button>
116
+ </div>
117
+ </div>
118
+
119
+ <!-- Agent Profiles Grid -->
120
+ <div class="mb-10">
121
+ <div class="mb-4 flex items-center justify-between">
122
+ <div class="flex items-center gap-2">
123
+ <Sparkles class="h-5 w-5 text-flame" />
124
+ <h2 class="text-lg font-semibold text-foreground">Perfis de Agentes Autônomos</h2>
125
+ </div>
126
+ <span class="text-xs text-muted-foreground">Clique para selecionar e ativar</span>
127
+ </div>
128
+
129
+ <div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
130
+ {#each allProfiles as profile (profile.id)}
131
+ {@const isActive = activeProfile.id === profile.id}
132
+ <div
133
+ class="relative flex flex-col justify-between rounded-xl border p-5 transition-all duration-200 cursor-pointer {isActive
134
+ ? 'border-flame bg-flame/5 shadow-lg shadow-flame/10 ring-1 ring-flame'
135
+ : 'border-border/60 bg-card/60 hover:border-flame/40 hover:bg-card/90'}"
136
+ onclick={() => selectAgent(profile)}
137
+ role="button"
138
+ tabindex="0"
139
+ onkeydown={(e) => e.key === 'Enter' && selectAgent(profile)}
140
+ >
141
+ <div>
142
+ <!-- Card Header -->
143
+ <div class="mb-3 flex items-start justify-between">
144
+ <div class="flex items-center gap-2.5">
145
+ <div
146
+ class="flex h-10 w-10 items-center justify-center rounded-lg border text-lg font-bold"
147
+ style="background-color: color-mix(in srgb, {profile.color} 15%, transparent); border-color: color-mix(in srgb, {profile.color} 40%, transparent); color: {profile.color};"
148
+ >
149
+ {#if profile.id === 'coder'}
150
+ <Code class="h-5 w-5" />
151
+ {:else if profile.id === 'devops'}
152
+ <Terminal class="h-5 w-5" />
153
+ {:else if profile.id === 'researcher'}
154
+ <Globe class="h-5 w-5" />
155
+ {:else if profile.id === 'math-data'}
156
+ <Cpu class="h-5 w-5" />
157
+ {:else}
158
+ <Sparkles class="h-5 w-5" />
159
+ {/if}
160
+ </div>
161
+ <div>
162
+ <h3 class="font-bold text-foreground flex items-center gap-1.5">
163
+ {profile.name}
164
+ {#if isActive}
165
+ <Badge class="bg-flame text-white text-[10px] px-1.5 py-0 h-4">ATIVO</Badge>
166
+ {/if}
167
+ </h3>
168
+ <p class="text-xs text-muted-foreground line-clamp-1">{profile.title}</p>
169
+ </div>
170
+ </div>
171
+ <Badge
172
+ variant="secondary"
173
+ class="text-[10px] uppercase font-mono tracking-wider"
174
+ style="color: {profile.color}; border-color: color-mix(in srgb, {profile.color} 30%, transparent);"
175
+ >
176
+ {profile.badge}
177
+ </Badge>
178
+ </div>
179
+
180
+ <!-- Description -->
181
+ <p class="mb-4 text-xs text-muted-foreground leading-relaxed">
182
+ {profile.description}
183
+ </p>
184
+
185
+ <!-- Tools Count & System Preset -->
186
+ <div class="mb-4 flex flex-wrap items-center gap-1.5">
187
+ {#each profile.tools.slice(0, 4) as tool}
188
+ <span class="rounded bg-muted/80 px-2 py-0.5 text-[11px] font-mono text-muted-foreground">
189
+ {tool}
190
+ </span>
191
+ {/each}
192
+ {#if profile.tools.length > 4}
193
+ <span class="rounded bg-muted/80 px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground">
194
+ +{profile.tools.length - 4} mais
195
+ </span>
196
+ {/if}
197
+ </div>
198
+ </div>
199
+
200
+ <!-- Card Footer Actions -->
201
+ <div class="flex items-center justify-between border-t border-border/40 pt-3 mt-2">
202
+ <div class="text-[11px] text-muted-foreground">
203
+ Temp: <span class="font-mono text-foreground font-semibold">{profile.temperature}</span> • Max: <span class="font-mono text-foreground font-semibold">{profile.maxTurns} turns</span>
204
+ </div>
205
+
206
+ <div class="flex items-center gap-2">
207
+ <Button
208
+ variant={isActive ? 'default' : 'outline'}
209
+ size="sm"
210
+ class="h-8 gap-1.5 text-xs font-semibold {isActive ? 'bg-flame hover:bg-flame/90 text-white' : ''}"
211
+ onclick={(e) => {
212
+ e.stopPropagation();
213
+ handleLaunchAgent(profile);
214
+ }}
215
+ >
216
+ <Play class="h-3 w-3" />
217
+ Iniciar
218
+ </Button>
219
+ </div>
220
+ </div>
221
+ </div>
222
+ {/each}
223
+ </div>
224
+ </div>
225
+
226
+ <!-- Master Agentic Settings & Fast Controls -->
227
+ <div class="grid grid-cols-1 gap-6 lg:grid-cols-3 mb-10">
228
+ <!-- Left: Core Execution Parameters -->
229
+ <div class="rounded-xl border border-border/60 bg-card p-5 lg:col-span-2">
230
+ <div class="mb-4 flex items-center justify-between border-b border-border/40 pb-3">
231
+ <div class="flex items-center gap-2">
232
+ <Settings class="h-5 w-5 text-flame" />
233
+ <h3 class="font-semibold text-foreground">Parâmetros de Execução Agêntica</h3>
234
+ </div>
235
+ <Badge variant="outline" class="text-[11px] text-muted-foreground font-mono">
236
+ Loop Multi-Turno
237
+ </Badge>
238
+ </div>
239
+
240
+ <div class="grid grid-cols-1 gap-5 md:grid-cols-2">
241
+ <!-- Auto Execution Switch -->
242
+ <div class="flex items-start justify-between gap-3 rounded-lg border border-border/40 bg-muted/20 p-3.5">
243
+ <div class="space-y-1">
244
+ <div class="flex items-center gap-2">
245
+ <ShieldCheck class="h-4 w-4 text-flame" />
246
+ <span class="text-sm font-semibold text-foreground">Execução Livre (Sem Trava)</span>
247
+ </div>
248
+ <p class="text-xs text-muted-foreground leading-relaxed">
249
+ Executa chamadas de ferramentas instantaneamente sem pausar para pedir confirmações.
250
+ </p>
251
+ </div>
252
+ <Switch checked={autoApprove} onCheckedChange={handleToggleAutoApprove} />
253
+ </div>
254
+
255
+ <!-- JS Sandbox Switch -->
256
+ <div class="flex items-start justify-between gap-3 rounded-lg border border-border/40 bg-muted/20 p-3.5">
257
+ <div class="space-y-1">
258
+ <div class="flex items-center gap-2">
259
+ <Code class="h-4 w-4 text-eye" />
260
+ <span class="text-sm font-semibold text-foreground">Sandbox JavaScript & Nerdamer</span>
261
+ </div>
262
+ <p class="text-xs text-muted-foreground leading-relaxed">
263
+ Permite ao agente rodar scripts e cálculos matemáticos exatos no navegador.
264
+ </p>
265
+ </div>
266
+ <Switch checked={jsSandbox} onCheckedChange={handleToggleJsSandbox} />
267
+ </div>
268
+
269
+ <!-- Max Turns Quick Selector -->
270
+ <div class="space-y-2 md:col-span-2 rounded-lg border border-border/40 bg-muted/20 p-3.5">
271
+ <div class="flex items-center justify-between">
272
+ <div class="flex items-center gap-2">
273
+ <RotateCcw class="h-4 w-4 text-gold" />
274
+ <span class="text-sm font-semibold text-foreground">Limite de Ciclos por Pergunta (Max Turns)</span>
275
+ </div>
276
+ <span class="font-mono text-sm font-bold text-flame">{maxTurns} ciclos</span>
277
+ </div>
278
+ <div class="flex flex-wrap gap-2 pt-1">
279
+ {#each [5, 10, 15, 20, 30, 50] as val}
280
+ <Button
281
+ variant={maxTurns === val ? 'default' : 'outline'}
282
+ size="sm"
283
+ class="h-7 text-xs font-mono {maxTurns === val ? 'bg-flame hover:bg-flame/90 text-white' : ''}"
284
+ onclick={() => handleMaxTurnsChange(val)}
285
+ >
286
+ {val} turns
287
+ </Button>
288
+ {/each}
289
+ </div>
290
+ </div>
291
+ </div>
292
+ </div>
293
+
294
+ <!-- Right: Active Agent System Prompt -->
295
+ <div class="rounded-xl border border-border/60 bg-card p-5 flex flex-col justify-between">
296
+ <div>
297
+ <div class="mb-3 flex items-center justify-between border-b border-border/40 pb-3">
298
+ <div class="flex items-center gap-2">
299
+ <FileCode class="h-5 w-5 text-flame" />
300
+ <h3 class="font-semibold text-foreground">Prompt de Sistema do Agente</h3>
301
+ </div>
302
+ <Badge variant="secondary" class="text-[10px] font-mono">
303
+ {activeProfile.name}
304
+ </Badge>
305
+ </div>
306
+ <p class="text-xs text-muted-foreground mb-3">
307
+ Instruções fundamentais injetadas nas mensagens de sistema para guiar as ferramentas.
308
+ </p>
309
+ <div class="rounded-lg bg-muted/60 p-3 font-mono text-xs text-foreground/90 border border-border/40 max-h-48 overflow-y-auto leading-relaxed">
310
+ {activeProfile.systemPrompt}
311
+ </div>
312
+ </div>
313
+
314
+ <div class="mt-4 pt-3 border-t border-border/40">
315
+ <Button
316
+ variant="outline"
317
+ size="sm"
318
+ class="w-full text-xs gap-1.5"
319
+ onclick={() => goto(`${ROUTES.SETTINGS}/general`)}
320
+ >
321
+ <Settings class="h-3.5 w-3.5" />
322
+ Configurações Avançadas do Sistema
323
+ </Button>
324
+ </div>
325
+ </div>
326
+ </div>
327
+
328
+ <!-- Live Tools Control Matrix -->
329
+ <div class="rounded-xl border border-border/60 bg-card p-5">
330
+ <div class="mb-4 flex flex-col md:flex-row md:items-center md:justify-between gap-2 border-b border-border/40 pb-3">
331
+ <div class="flex items-center gap-2">
332
+ <Wrench class="h-5 w-5 text-flame" />
333
+ <h3 class="font-semibold text-foreground">Matriz de Ferramentas Ativas no Backend e Frontend</h3>
334
+ </div>
335
+ <span class="text-xs text-muted-foreground font-mono">Todas as ferramentas liberadas offline</span>
336
+ </div>
337
+
338
+ <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
339
+ {#each toolsStore.allTools as tool (tool.key)}
340
+ {@const isEnabled = toolsStore.isToolEnabled(tool.key)}
341
+ <div
342
+ class="flex items-center justify-between rounded-lg border p-3 transition-all cursor-pointer {isEnabled
343
+ ? 'border-flame/30 bg-flame/5'
344
+ : 'border-border/40 bg-muted/10 opacity-60'}"
345
+ onclick={() => handleToggleTool(tool.key)}
346
+ role="button"
347
+ tabindex="0"
348
+ onkeydown={(e) => e.key === 'Enter' && handleToggleTool(tool.key)}
349
+ >
350
+ <div class="flex items-center gap-2.5 overflow-hidden">
351
+ <div
352
+ class="flex h-7 w-7 shrink-0 items-center justify-center rounded border text-xs font-mono {isEnabled
353
+ ? 'border-flame/40 bg-flame/10 text-flame'
354
+ : 'border-border bg-muted text-muted-foreground'}"
355
+ >
356
+ {#if tool.definition.function.name === BuiltInTool.EXEC_SHELL_COMMAND}
357
+ <Terminal class="h-3.5 w-3.5" />
358
+ {:else if tool.definition.function.name === BuiltInTool.RUN_JAVASCRIPT}
359
+ <Code class="h-3.5 w-3.5" />
360
+ {:else if tool.definition.function.name.includes('file')}
361
+ <FileCode class="h-3.5 w-3.5" />
362
+ {:else}
363
+ <Zap class="h-3.5 w-3.5" />
364
+ {/if}
365
+ </div>
366
+ <div class="truncate">
367
+ <span class="block truncate text-xs font-semibold text-foreground">
368
+ {tool.definition.function.name}
369
+ </span>
370
+ <span class="block truncate text-[10px] text-muted-foreground">
371
+ {tool.source.toUpperCase()}
372
+ </span>
373
+ </div>
374
+ </div>
375
+ <Switch checked={isEnabled} onCheckedChange={() => handleToggleTool(tool.key)} />
376
+ </div>
377
+ {/each}
378
+ </div>
379
+ </div>
380
+ </div>
tools/ui/src/lib/components/app/agents/index.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export { default as AgentsHub } from './AgentsHub.svelte';
tools/ui/src/lib/components/app/badges/BadgeInfo.svelte ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLButtonAttributes } from 'svelte/elements';
4
+
5
+ interface Props extends HTMLButtonAttributes {
6
+ children: Snippet;
7
+ class?: string;
8
+ icon?: Snippet;
9
+ }
10
+
11
+ let { children, class: className = '', icon, ...rest }: Props = $props();
12
+ </script>
13
+
14
+ <button
15
+ {...rest}
16
+ class={[
17
+ 'inline-flex cursor-pointer items-center gap-1 rounded-sm bg-muted-foreground/15 px-1.5 py-0.75',
18
+ className
19
+ ]}
20
+ >
21
+ {#if icon}
22
+ {@render icon()}
23
+ {/if}
24
+
25
+ {@render children()}
26
+ </button>
tools/ui/src/lib/components/app/badges/BadgesModality.svelte ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Eye, Mic, Video } from '@lucide/svelte';
3
+ import { ModelModality } from '$lib/enums';
4
+
5
+ interface Props {
6
+ modalities: ModelModality[];
7
+ class?: string;
8
+ }
9
+
10
+ let { class: className = '', modalities }: Props = $props();
11
+ </script>
12
+
13
+ {#each modalities as modality (modality)}
14
+ {#if modality === ModelModality.VISION || modality === ModelModality.AUDIO || modality === ModelModality.VIDEO}
15
+ <span
16
+ class={[
17
+ 'inline-flex items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs font-medium',
18
+ className
19
+ ]}
20
+ >
21
+ {#if modality === ModelModality.VISION}
22
+ <Eye class="h-3 w-3" />
23
+
24
+ Vision (Image)
25
+ {:else if modality === ModelModality.VIDEO}
26
+ <Video class="h-3 w-3" />
27
+
28
+ Vision (Video)
29
+ {:else}
30
+ <Mic class="h-3 w-3" />
31
+
32
+ Audio
33
+ {/if}
34
+ </span>
35
+ {/if}
36
+ {/each}
tools/ui/src/lib/components/app/badges/index.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * BADGES & INDICATORS
4
+ *
5
+ * Small visual indicators for status and metadata.
6
+ *
7
+ */
8
+
9
+ /** Generic info badge with optional tooltip and click handler. */
10
+ export { default as BadgeInfo } from './BadgeInfo.svelte';
11
+
12
+ /** Badge indicating model modality (vision, audio, tools). */
13
+ export { default as BadgesModality } from './BadgesModality.svelte';
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import {
3
+ ChatAttachmentsListItem,
4
+ DialogChatAttachmentsPreview,
5
+ DialogMcpResourcePreview,
6
+ HorizontalScrollCarousel
7
+ } from '$lib/components/app';
8
+ import type { DatabaseMessageExtraMcpResource } from '$lib/types';
9
+ import { getAttachmentDisplayItems, isMcpPrompt, isMcpResource } from '$lib/utils';
10
+
11
+ interface Props {
12
+ class?: string;
13
+ style?: string;
14
+ // For ChatMessage - stored attachments
15
+ attachments?: DatabaseMessageExtra[];
16
+ readonly?: boolean;
17
+ // For ChatForm - pending uploads
18
+ onFileRemove?: (fileId: string) => void;
19
+ uploadedFiles?: ChatUploadedFile[];
20
+ // Image size customization
21
+ imageClass?: string;
22
+ imageHeight?: string;
23
+ imageWidth?: string;
24
+ // Limit display to single row with "+ X more" button
25
+ limitToSingleRow?: boolean;
26
+ // For vision modality check
27
+ activeModelId?: string;
28
+ }
29
+
30
+ let {
31
+ activeModelId,
32
+ attachments = [],
33
+ class: className = '',
34
+ // Default to small size for form previews
35
+ imageClass = '',
36
+ imageHeight = 'h-24',
37
+ imageWidth = 'w-auto',
38
+ limitToSingleRow = false,
39
+ onFileRemove,
40
+ readonly = false,
41
+ style = '',
42
+ uploadedFiles = $bindable([])
43
+ }: Props = $props();
44
+
45
+ let carouselRef: HorizontalScrollCarousel | undefined = $state();
46
+ let mcpResourcePreviewOpen = $state(false);
47
+ let mcpResourcePreviewExtra = $state<DatabaseMessageExtraMcpResource | null>(null);
48
+ let previewFocusIndex = $state(0);
49
+ let viewAllDialogOpen = $state(false);
50
+
51
+ let displayItems = $derived(getAttachmentDisplayItems({ attachments, uploadedFiles }));
52
+
53
+ function openPreview(item: ChatAttachmentDisplayItem, event?: MouseEvent) {
54
+ event?.stopPropagation();
55
+ event?.preventDefault();
56
+
57
+ // Find the index of the clicked item among non-MCP attachments
58
+ const nonMcpItems = displayItems.filter((i) => !isMcpPrompt(i) && !isMcpResource(i));
59
+ const index = nonMcpItems.findIndex((i) => i.id === item.id);
60
+
61
+ previewFocusIndex = index >= 0 ? index : 0;
62
+ viewAllDialogOpen = true;
63
+ }
64
+
65
+ function openMcpResourcePreview(extra: DatabaseMessageExtraMcpResource) {
66
+ mcpResourcePreviewExtra = extra;
67
+ mcpResourcePreviewOpen = true;
68
+ }
69
+
70
+ $effect(() => {
71
+ if (carouselRef && displayItems.length) {
72
+ carouselRef.resetScroll();
73
+ }
74
+ });
75
+ </script>
76
+
77
+ {#snippet attachmentitem(item: ChatAttachmentDisplayItem)}
78
+ <ChatAttachmentsListItem
79
+ {imageClass}
80
+ {imageHeight}
81
+ {imageWidth}
82
+ {item}
83
+ {limitToSingleRow}
84
+ {onFileRemove}
85
+ onMcpResourcePreview={openMcpResourcePreview}
86
+ onPreview={(i: ChatAttachmentDisplayItem, event?: MouseEvent) => openPreview(i, event)}
87
+ {readonly}
88
+ />
89
+ {/snippet}
90
+
91
+ {#if displayItems.length > 0}
92
+ <div class={className} {style}>
93
+ {#if limitToSingleRow}
94
+ <HorizontalScrollCarousel bind:this={carouselRef}>
95
+ {#each displayItems as item (item.id)}
96
+ {@render attachmentitem(item)}
97
+ {/each}
98
+ </HorizontalScrollCarousel>
99
+ {:else}
100
+ <div class="flex flex-wrap items-start justify-end gap-3">
101
+ {#each displayItems as item (item.id)}
102
+ {@render attachmentitem(item)}
103
+ {/each}
104
+ </div>
105
+ {/if}
106
+ </div>
107
+ {/if}
108
+
109
+ <DialogChatAttachmentsPreview
110
+ {activeModelId}
111
+ {attachments}
112
+ bind:open={viewAllDialogOpen}
113
+ {previewFocusIndex}
114
+ {uploadedFiles}
115
+ />
116
+
117
+ {#if mcpResourcePreviewExtra}
118
+ <DialogMcpResourcePreview extra={mcpResourcePreviewExtra} bind:open={mcpResourcePreviewOpen} />
119
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import {
3
+ ChatAttachmentsListItemMcpPrompt,
4
+ ChatAttachmentsListItemMcpResource,
5
+ ChatAttachmentsListItemThumbnailFile,
6
+ ChatAttachmentsListItemThumbnailImage
7
+ } from '$lib/components/app';
8
+ import { AttachmentType } from '$lib/enums';
9
+ import type {
10
+ ChatAttachmentDisplayItem,
11
+ DatabaseMessageExtraMcpPrompt,
12
+ DatabaseMessageExtraMcpResource,
13
+ MCPResourceAttachment
14
+ } from '$lib/types';
15
+ import { isMcpPrompt, isMcpResource, isPdfFile } from '$lib/utils';
16
+
17
+ interface Props {
18
+ class?: string;
19
+ imageClass?: string;
20
+ imageHeight?: string;
21
+ imageWidth?: string;
22
+ item: ChatAttachmentDisplayItem;
23
+ limitToSingleRow?: boolean;
24
+ onFileRemove?: (fileId: string) => void;
25
+ onMcpResourcePreview?: (extra: DatabaseMessageExtraMcpResource) => void;
26
+ onPreview?: (item: ChatAttachmentDisplayItem) => void;
27
+ readonly?: boolean;
28
+ }
29
+
30
+ let {
31
+ class: className = '',
32
+ imageClass = '',
33
+ imageHeight = 'h-24',
34
+ imageWidth = 'w-auto',
35
+ item,
36
+ limitToSingleRow = false,
37
+ onFileRemove,
38
+ onMcpResourcePreview,
39
+ onPreview,
40
+ readonly = false
41
+ }: Props = $props();
42
+
43
+ const scrollClasses = $derived(limitToSingleRow ? 'first:ml-4 last:mr-4' : '');
44
+
45
+ function toMcpResourceAttachment(
46
+ extra: DatabaseMessageExtraMcpResource,
47
+ id: string
48
+ ): MCPResourceAttachment {
49
+ return {
50
+ id,
51
+ resource: {
52
+ name: extra.name,
53
+ serverName: extra.serverName,
54
+ title: extra.name,
55
+ uri: extra.uri
56
+ }
57
+ };
58
+ }
59
+ </script>
60
+
61
+ {#if isMcpPrompt(item)}
62
+ {@const mcpPrompt =
63
+ item.attachment?.type === AttachmentType.MCP_PROMPT
64
+ ? (item.attachment as DatabaseMessageExtraMcpPrompt)
65
+ : item.uploadedFile?.mcpPrompt
66
+ ? {
67
+ arguments: item.uploadedFile.mcpPrompt.arguments,
68
+ content: item.textContent ?? '',
69
+ name: item.name,
70
+ promptName: item.uploadedFile.mcpPrompt.promptName,
71
+ serverName: item.uploadedFile.mcpPrompt.serverName,
72
+ type: AttachmentType.MCP_PROMPT as const
73
+ }
74
+ : null}
75
+ {#if mcpPrompt}
76
+ <ChatAttachmentsListItemMcpPrompt
77
+ class="max-w-[300px] min-w-[200px] flex-shrink-0 {className} {scrollClasses}"
78
+ prompt={mcpPrompt}
79
+ {readonly}
80
+ isLoading={item.isLoading}
81
+ loadError={item.loadError}
82
+ onRemove={onFileRemove ? () => onFileRemove(item.id) : undefined}
83
+ />
84
+ {/if}
85
+ {:else if isMcpResource(item)}
86
+ {@const mcpResource = item.attachment as DatabaseMessageExtraMcpResource}
87
+
88
+ <ChatAttachmentsListItemMcpResource
89
+ class="flex-shrink-0 {className} {scrollClasses}"
90
+ attachment={toMcpResourceAttachment(mcpResource, item.id)}
91
+ onclick={() => onMcpResourcePreview?.(mcpResource)}
92
+ />
93
+ {:else if item.isImage && item.preview}
94
+ <ChatAttachmentsListItemThumbnailImage
95
+ class="flex-shrink-0 cursor-pointer {className} {scrollClasses}"
96
+ id={item.id}
97
+ name={item.name}
98
+ preview={item.preview}
99
+ {readonly}
100
+ onRemove={onFileRemove}
101
+ height={imageHeight}
102
+ width={imageWidth}
103
+ {imageClass}
104
+ onclick={() => onPreview?.(item)}
105
+ />
106
+ {:else if isPdfFile(item.attachment, item.uploadedFile)}
107
+ <ChatAttachmentsListItemThumbnailFile
108
+ class="flex-shrink-0 cursor-pointer {className} {scrollClasses}"
109
+ id={item.id}
110
+ name={item.name}
111
+ size={item.size}
112
+ {readonly}
113
+ onRemove={onFileRemove}
114
+ textContent={item.textContent}
115
+ attachment={item.attachment}
116
+ uploadedFile={item.uploadedFile}
117
+ onclick={() => onPreview?.(item)}
118
+ />
119
+ {:else}
120
+ <ChatAttachmentsListItemThumbnailFile
121
+ class="flex-shrink-0 cursor-pointer {className} {scrollClasses}"
122
+ id={item.id}
123
+ name={item.name}
124
+ size={item.size}
125
+ {readonly}
126
+ onRemove={onFileRemove}
127
+ textContent={item.textContent}
128
+ attachment={item.attachment}
129
+ uploadedFile={item.uploadedFile}
130
+ onclick={() => onPreview?.(item)}
131
+ />
132
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemMcpPrompt.svelte ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { X } from '@lucide/svelte';
3
+ import { ActionIcon, ChatMessageMcpPromptContent } from '$lib/components/app';
4
+ import { McpPromptVariant } from '$lib/enums';
5
+ import type { DatabaseMessageExtraMcpPrompt } from '$lib/types';
6
+
7
+ interface Props {
8
+ class?: string;
9
+ isLoading?: boolean;
10
+ loadError?: string;
11
+ onRemove?: () => void;
12
+ prompt: DatabaseMessageExtraMcpPrompt;
13
+ readonly?: boolean;
14
+ }
15
+
16
+ let {
17
+ class: className = '',
18
+ isLoading = false,
19
+ loadError,
20
+ onRemove,
21
+ prompt,
22
+ readonly = false
23
+ }: Props = $props();
24
+ </script>
25
+
26
+ <div class="group relative {className}">
27
+ <ChatMessageMcpPromptContent
28
+ {isLoading}
29
+ {loadError}
30
+ {prompt}
31
+ variant={McpPromptVariant.ATTACHMENT}
32
+ />
33
+
34
+ {#if !readonly && onRemove}
35
+ <div
36
+ class="absolute top-10 right-2 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100"
37
+ >
38
+ <ActionIcon icon={X} tooltip="Remove" stopPropagationOnClick onclick={() => onRemove?.()} />
39
+ </div>
40
+ {/if}
41
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemMcpResource.svelte ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { AlertCircle, Loader2 } from '@lucide/svelte';
3
+ import { X } from '@lucide/svelte';
4
+ import { ActionIcon } from '$lib/components/app';
5
+ import * as Tooltip from '$lib/components/ui/tooltip';
6
+ import { mcpStore } from '$lib/stores/mcp.svelte';
7
+ import type { MCPResourceAttachment } from '$lib/types';
8
+ import { getResourceDisplayName, getResourceIcon } from '$lib/utils';
9
+
10
+ interface Props {
11
+ attachment: MCPResourceAttachment;
12
+ class?: string;
13
+ onclick?: () => void;
14
+ onRemove?: (attachmentId: string) => void;
15
+ }
16
+
17
+ let { attachment, class: className, onclick, onRemove }: Props = $props();
18
+
19
+ const ResourceIcon = $derived(
20
+ getResourceIcon(attachment.resource.mimeType, attachment.resource.uri)
21
+ );
22
+ const serverName = $derived(mcpStore.getServerDisplayName(attachment.resource.serverName));
23
+ const favicon = $derived(mcpStore.getServerFavicon(attachment.resource.serverName));
24
+
25
+ function getStatusClass(attachment: MCPResourceAttachment): string {
26
+ if (attachment.error) return 'border-red-500/50 bg-red-500/10';
27
+
28
+ if (attachment.loading) return 'border-border/50 bg-muted/30';
29
+
30
+ return 'border-border/50 bg-muted/30';
31
+ }
32
+ </script>
33
+
34
+ <Tooltip.Root>
35
+ <Tooltip.Trigger>
36
+ <button
37
+ class={[
38
+ 'flex flex-shrink-0 items-center gap-1.5 rounded-md border px-2 py-0.75 text-sm transition-colors',
39
+ getStatusClass(attachment),
40
+ onclick && 'cursor-pointer hover:bg-muted/50',
41
+ className
42
+ ]}
43
+ disabled={!onclick}
44
+ {onclick}
45
+ type="button"
46
+ >
47
+ {#if attachment.loading}
48
+ <Loader2 class="h-3 w-3 animate-spin text-muted-foreground" />
49
+ {:else if attachment.error}
50
+ <AlertCircle class="h-3 w-3 text-red-500" />
51
+ {:else}
52
+ <ResourceIcon class="h-3 w-3 text-muted-foreground" />
53
+ {/if}
54
+
55
+ <span class="max-w-[150px] truncate text-xs">
56
+ {getResourceDisplayName(attachment.resource)}
57
+ </span>
58
+
59
+ {#if onRemove}
60
+ <ActionIcon
61
+ class="-my-2 -mr-1.5 bg-transparent"
62
+ icon={X}
63
+ iconSize="h-2 w-2"
64
+ onclick={() => onRemove?.(attachment.id)}
65
+ stopPropagationOnClick
66
+ tooltip="Remove"
67
+ />
68
+ {/if}
69
+ </button>
70
+ </Tooltip.Trigger>
71
+
72
+ <Tooltip.Content>
73
+ <div class="flex items-center gap-1 text-xs">
74
+ {#if favicon}
75
+ <img
76
+ alt={attachment.resource.serverName}
77
+ class="h-3 w-3 shrink-0 rounded-sm"
78
+ onerror={(e) => {
79
+ (e.currentTarget as HTMLImageElement).style.display = 'none';
80
+ }}
81
+ src={favicon}
82
+ />
83
+ {/if}
84
+
85
+ <span class="truncate">
86
+ {serverName}
87
+ </span>
88
+ </div>
89
+ </Tooltip.Content>
90
+ </Tooltip.Root>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemThumbnailFile.svelte ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Music, Video, X } from '@lucide/svelte';
3
+ import { ActionIcon } from '$lib/components/app';
4
+ import { ICON_CLASS_DEFAULT } from '$lib/constants/css-classes';
5
+ import { AttachmentType } from '$lib/enums';
6
+ import {
7
+ formatFileSize,
8
+ getFileTypeLabel,
9
+ getPreviewText,
10
+ isAudioFile,
11
+ isPdfFile,
12
+ isTextFile,
13
+ isVideoFile
14
+ } from '$lib/utils';
15
+
16
+ interface Props {
17
+ attachment?: DatabaseMessageExtra;
18
+ class?: string;
19
+ id: string;
20
+ onclick?: (event: MouseEvent) => void;
21
+ onRemove?: (id: string) => void;
22
+ name: string;
23
+ readonly?: boolean;
24
+ size?: number;
25
+ textContent?: string;
26
+ // Either uploaded file or stored attachment
27
+ uploadedFile?: ChatUploadedFile;
28
+ }
29
+
30
+ let {
31
+ attachment,
32
+ class: className = '',
33
+ id,
34
+ name,
35
+ onclick,
36
+ onRemove,
37
+ readonly = false,
38
+ size,
39
+ textContent,
40
+ uploadedFile
41
+ }: Props = $props();
42
+
43
+ let isPdf = $derived(isPdfFile(attachment, uploadedFile));
44
+ let isAudio = $derived(isAudioFile(attachment, uploadedFile));
45
+ let isVideo = $derived(isVideoFile(attachment, uploadedFile));
46
+ let isPdfWithContent = $derived(isPdf && !!textContent);
47
+
48
+ let isText = $derived(isTextFile(attachment, uploadedFile));
49
+ let isTextWithContent = $derived(isText && !!textContent);
50
+
51
+ let fileTypeLabel = $derived.by(() => {
52
+ if (uploadedFile?.type) {
53
+ return getFileTypeLabel(uploadedFile.type);
54
+ }
55
+
56
+ if (attachment) {
57
+ if ('mimeType' in attachment && attachment.mimeType) {
58
+ return getFileTypeLabel(attachment.mimeType);
59
+ }
60
+
61
+ if (attachment.type) {
62
+ return getFileTypeLabel(attachment.type);
63
+ }
64
+ }
65
+
66
+ return getFileTypeLabel(name);
67
+ });
68
+
69
+ let pdfProcessingMode = $derived.by(() => {
70
+ if (attachment?.type === AttachmentType.PDF) {
71
+ const pdfAttachment = attachment as DatabaseMessageExtraPdfFile;
72
+
73
+ return pdfAttachment.processedAsImages ? 'Sent as Image' : 'Sent as Text';
74
+ }
75
+
76
+ return null;
77
+ });
78
+ </script>
79
+
80
+ {#snippet textPreview(content: string)}
81
+ <div class="relative">
82
+ <div
83
+ class="font-mono text-xs leading-relaxed break-words whitespace-pre-wrap text-muted-foreground {!readonly
84
+ ? 'max-h-3rem line-height-1.2'
85
+ : ''}"
86
+ >
87
+ {getPreviewText(content)}
88
+ </div>
89
+
90
+ {#if content.length > 150}
91
+ <div
92
+ class="pointer-events-none absolute right-0 bottom-0 left-0 h-4 bg-gradient-to-t from-muted to-transparent {readonly
93
+ ? 'h-6'
94
+ : ''}"
95
+ ></div>
96
+ {/if}
97
+ </div>
98
+ {/snippet}
99
+
100
+ {#snippet removeButton()}
101
+ <div
102
+ class="absolute top-2 right-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100"
103
+ >
104
+ <ActionIcon icon={X} tooltip="Remove" stopPropagationOnClick onclick={() => onRemove?.(id)} />
105
+ </div>
106
+ {/snippet}
107
+
108
+ {#snippet fileIcon()}
109
+ <div
110
+ class="flex h-8 w-8 items-center justify-center rounded bg-primary/10 text-xs font-medium text-primary"
111
+ >
112
+ {#if isAudio}
113
+ <Music class="{ICON_CLASS_DEFAULT} text-white/70" />
114
+ {:else if isVideo}
115
+ <Video class="{ICON_CLASS_DEFAULT} text-white/70" />
116
+ {:else}
117
+ {fileTypeLabel}
118
+ {/if}
119
+ </div>
120
+ {/snippet}
121
+
122
+ {#snippet info(text: string | undefined)}
123
+ {#if text}
124
+ <span class="text-xs text-muted-foreground">{text}</span>
125
+ {/if}
126
+ {/snippet}
127
+
128
+ {#if isTextWithContent || isPdfWithContent}
129
+ <button
130
+ aria-label={readonly ? `Preview ${name}` : undefined}
131
+ class="rounded-lg border border-border bg-muted p-3 {className} cursor-pointer {readonly
132
+ ? 'w-full max-w-2xl transition-shadow hover:shadow-md'
133
+ : `group relative text-left ${textContent ? 'max-h-24 max-w-72' : 'max-w-36'}`} overflow-hidden"
134
+ {onclick}
135
+ type="button"
136
+ >
137
+ {#if !readonly}
138
+ {@render removeButton()}
139
+ {/if}
140
+
141
+ <div class={[!readonly && 'pr-8', 'overflow-hidden']}>
142
+ {#if readonly}
143
+ <div class="flex items-start gap-3">
144
+ <div class="flex min-w-0 flex-1 flex-col items-start text-left">
145
+ <span class="w-full truncate text-sm font-medium text-foreground">{name}</span>
146
+
147
+ {@render info(pdfProcessingMode || (size ? formatFileSize(size) : undefined))}
148
+
149
+ {#if textContent}
150
+ {@render textPreview(textContent)}
151
+ {/if}
152
+ </div>
153
+ </div>
154
+ {:else}
155
+ <span class="mb-3 block truncate text-sm font-medium text-foreground">{name}</span>
156
+
157
+ {#if textContent}
158
+ {@render textPreview(textContent)}
159
+ {/if}
160
+ {/if}
161
+ </div>
162
+ </button>
163
+ {:else}
164
+ <button
165
+ class="group flex items-center gap-3 rounded-lg border border-border bg-muted p-3 {className} relative"
166
+ {onclick}
167
+ type="button"
168
+ >
169
+ {@render fileIcon()}
170
+
171
+ <div class="flex flex-col items-start gap-0.5">
172
+ <span
173
+ class="max-w-24 truncate text-sm font-medium text-foreground {readonly
174
+ ? ''
175
+ : 'group-hover:pr-6'} md:max-w-32"
176
+ >
177
+ {name}
178
+ </span>
179
+
180
+ {@render info(pdfProcessingMode || (size ? formatFileSize(size) : undefined))}
181
+ </div>
182
+
183
+ {#if !readonly}
184
+ {@render removeButton()}
185
+ {/if}
186
+ </button>
187
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemThumbnailImage.svelte ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { X } from '@lucide/svelte';
3
+ import { ActionIcon } from '$lib/components/app';
4
+
5
+ interface Props {
6
+ class?: string;
7
+ height?: string;
8
+ id: string;
9
+ imageClass?: string;
10
+ onclick?: (event?: MouseEvent) => void;
11
+ onRemove?: (id: string) => void;
12
+ name: string;
13
+ preview: string;
14
+ readonly?: boolean;
15
+ width?: string;
16
+ }
17
+
18
+ let {
19
+ class: className = '',
20
+ height = 'h-16',
21
+ id,
22
+ imageClass = '',
23
+ name,
24
+ onclick,
25
+ onRemove,
26
+ preview,
27
+ readonly = false,
28
+ width = 'w-auto'
29
+ }: Props = $props();
30
+ </script>
31
+
32
+ {#snippet image()}
33
+ <img src={preview} alt={name} class="{height} {width} cursor-pointer object-cover {imageClass}" />
34
+ {/snippet}
35
+
36
+ <div
37
+ class="group relative overflow-hidden rounded-lg bg-muted shadow-lg dark:border dark:border-muted {className}"
38
+ >
39
+ {#if onclick}
40
+ <button
41
+ aria-label="Preview {name}"
42
+ class="block h-full w-full rounded-lg focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none"
43
+ {onclick}
44
+ type="button"
45
+ >
46
+ {@render image()}
47
+ </button>
48
+ {:else}
49
+ {@render image()}
50
+ {/if}
51
+
52
+ {#if !readonly}
53
+ <div
54
+ class="absolute top-1 right-1 flex items-center justify-center opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100"
55
+ >
56
+ <ActionIcon
57
+ class="text-white"
58
+ icon={X}
59
+ onclick={() => onRemove?.(id)}
60
+ stopPropagationOnClick
61
+ tooltip="Remove"
62
+ />
63
+ </div>
64
+ {/if}
65
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview.svelte ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import {
3
+ ChatAttachmentsPreviewCurrentItem,
4
+ ChatAttachmentsPreviewFileInfo,
5
+ ChatAttachmentsPreviewNavButtons,
6
+ ChatAttachmentsPreviewThumbnailStrip
7
+ } from '$lib/components/app';
8
+ import { modelsStore } from '$lib/stores/models.svelte';
9
+ import {
10
+ createBase64DataUrl,
11
+ formatFileSize,
12
+ getAttachmentDisplayItems,
13
+ getLanguageFromFilename,
14
+ isAudioFile,
15
+ isImageFile,
16
+ isMcpPrompt,
17
+ isMcpResource,
18
+ isPdfFile,
19
+ isTextFile,
20
+ isVideoFile
21
+ } from '$lib/utils';
22
+
23
+ interface PreviewItem {
24
+ id: string;
25
+ name: string;
26
+ size?: number;
27
+ preview?: string;
28
+ uploadedFile?: ChatUploadedFile;
29
+ attachment?: DatabaseMessageExtra;
30
+ textContent?: string;
31
+ isImage: boolean;
32
+ isAudio: boolean;
33
+ isVideo: boolean;
34
+ }
35
+
36
+ interface Props {
37
+ uploadedFiles?: ChatUploadedFile[];
38
+ attachments?: DatabaseMessageExtra[];
39
+ activeModelId?: string;
40
+ class?: string;
41
+ previewFocusIndex?: number;
42
+ }
43
+
44
+ let {
45
+ activeModelId,
46
+ attachments = [],
47
+ class: className = '',
48
+ previewFocusIndex = 0,
49
+ uploadedFiles = []
50
+ }: Props = $props();
51
+
52
+ let allItems = $derived(
53
+ getAttachmentDisplayItems({ attachments, uploadedFiles })
54
+ .filter((item) => !isMcpPrompt(item) && !isMcpResource(item))
55
+ .map(
56
+ (item): PreviewItem => ({
57
+ ...item,
58
+ isAudio: isAudioFile(item.attachment, item.uploadedFile),
59
+ isImage: isImageFile(item.attachment, item.uploadedFile),
60
+ isVideo: isVideoFile(item.attachment, item.uploadedFile)
61
+ })
62
+ )
63
+ );
64
+
65
+ let currentIndex = $state(0);
66
+
67
+ $effect(() => {
68
+ if (previewFocusIndex >= 0 && previewFocusIndex < allItems.length) {
69
+ currentIndex = previewFocusIndex;
70
+ }
71
+ });
72
+
73
+ $effect(() => {
74
+ const handler = (e: Event) => {
75
+ const delta = (e as CustomEvent).detail;
76
+
77
+ if (delta < 0) {
78
+ currentIndex = currentIndex > 0 ? currentIndex - 1 : allItems.length - 1;
79
+ } else {
80
+ currentIndex = currentIndex < allItems.length - 1 ? currentIndex + 1 : 0;
81
+ }
82
+ };
83
+
84
+ document.addEventListener('chat-attachments-nav', handler);
85
+
86
+ return () => document.removeEventListener('chat-attachments-nav', handler);
87
+ });
88
+
89
+ $effect(() => {
90
+ const index = currentIndex;
91
+
92
+ setTimeout(() => {
93
+ const thumbnail = document.querySelector(`[data-thumbnail-index="${index}"]`);
94
+
95
+ thumbnail?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
96
+ }, 0);
97
+ });
98
+
99
+ let currentItem = $derived(allItems[currentIndex] ?? null);
100
+ let displayName = $derived(
101
+ currentItem?.name ||
102
+ currentItem?.uploadedFile?.name ||
103
+ currentItem?.attachment?.name ||
104
+ 'Unknown File'
105
+ );
106
+ let isAudio = $derived(
107
+ currentItem ? isAudioFile(currentItem.attachment, currentItem.uploadedFile) : false
108
+ );
109
+ let isVideo = $derived(
110
+ currentItem ? isVideoFile(currentItem.attachment, currentItem.uploadedFile) : false
111
+ );
112
+ let isImage = $derived(
113
+ currentItem ? isImageFile(currentItem.attachment, currentItem.uploadedFile) : false
114
+ );
115
+ let isPdf = $derived(
116
+ currentItem ? isPdfFile(currentItem.attachment, currentItem.uploadedFile) : false
117
+ );
118
+ let isText = $derived(
119
+ currentItem ? isTextFile(currentItem.attachment, currentItem.uploadedFile) : false
120
+ );
121
+
122
+ let displayPreview = $derived(
123
+ currentItem?.uploadedFile?.preview ||
124
+ (isImage && currentItem?.attachment && 'base64Url' in currentItem.attachment
125
+ ? currentItem.attachment.base64Url
126
+ : currentItem?.preview)
127
+ );
128
+
129
+ let displayTextContent = $derived(
130
+ currentItem?.uploadedFile?.textContent ||
131
+ (currentItem?.attachment && 'content' in currentItem.attachment
132
+ ? currentItem.attachment.content
133
+ : currentItem?.textContent)
134
+ );
135
+
136
+ let language = $derived(getLanguageFromFilename(displayName));
137
+
138
+ let fileSize = $derived(currentItem?.size ? formatFileSize(currentItem.size) : '');
139
+
140
+ let hasVisionModality = $derived(
141
+ currentItem && activeModelId ? modelsStore.modelSupportsVision(activeModelId) : false
142
+ );
143
+
144
+ let audioSrc = $derived(
145
+ isAudio && currentItem
146
+ ? (currentItem.uploadedFile?.preview ??
147
+ (currentItem.attachment &&
148
+ 'mimeType' in currentItem.attachment &&
149
+ 'base64Data' in currentItem.attachment
150
+ ? createBase64DataUrl(
151
+ currentItem.attachment.mimeType,
152
+ currentItem.attachment.base64Data
153
+ )
154
+ : null))
155
+ : null
156
+ );
157
+
158
+ let videoSrc = $derived(
159
+ isVideo && currentItem
160
+ ? (currentItem.uploadedFile?.preview ??
161
+ (currentItem.attachment &&
162
+ 'mimeType' in currentItem.attachment &&
163
+ 'base64Data' in currentItem.attachment
164
+ ? createBase64DataUrl(
165
+ currentItem.attachment.mimeType,
166
+ currentItem.attachment.base64Data
167
+ )
168
+ : null))
169
+ : null
170
+ );
171
+
172
+ export function prev() {
173
+ currentIndex = currentIndex > 0 ? currentIndex - 1 : allItems.length - 1;
174
+ }
175
+
176
+ export function next() {
177
+ currentIndex = currentIndex < allItems.length - 1 ? currentIndex + 1 : 0;
178
+ }
179
+
180
+ function onNavigate(index: number) {
181
+ currentIndex = index;
182
+ }
183
+ </script>
184
+
185
+ <div class="{className} flex flex-col text-white">
186
+ <div class="relative flex min-h-0 flex-1 items-center justify-center overflow-hidden">
187
+ <ChatAttachmentsPreviewNavButtons onPrev={prev} onNext={next} show={allItems.length > 1} />
188
+
189
+ <div class="flex h-full w-full flex-col items-center justify-start overflow-auto py-4">
190
+ {#if currentItem}
191
+ <ChatAttachmentsPreviewFileInfo {displayName} {fileSize} />
192
+
193
+ <ChatAttachmentsPreviewCurrentItem
194
+ {currentItem}
195
+ {isImage}
196
+ {isAudio}
197
+ {isVideo}
198
+ {isPdf}
199
+ {isText}
200
+ {displayPreview}
201
+ {displayTextContent}
202
+ {audioSrc}
203
+ {videoSrc}
204
+ {language}
205
+ {hasVisionModality}
206
+ {activeModelId}
207
+ />
208
+ {/if}
209
+
210
+ <ChatAttachmentsPreviewThumbnailStrip items={allItems} {currentIndex} {onNavigate} />
211
+ </div>
212
+ </div>
213
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItem.svelte ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import ChatAttachmentsPreviewCurrentItemAudio from './ChatAttachmentsPreviewCurrentItemAudio.svelte';
3
+ import ChatAttachmentsPreviewCurrentItemImage from './ChatAttachmentsPreviewCurrentItemImage.svelte';
4
+ import ChatAttachmentsPreviewCurrentItemPdf from './ChatAttachmentsPreviewCurrentItemPdf.svelte';
5
+ import ChatAttachmentsPreviewCurrentItemText from './ChatAttachmentsPreviewCurrentItemText.svelte';
6
+ import ChatAttachmentsPreviewCurrentItemUnavailable from './ChatAttachmentsPreviewCurrentItemUnavailable.svelte';
7
+ import ChatAttachmentsPreviewCurrentItemVideo from './ChatAttachmentsPreviewCurrentItemVideo.svelte';
8
+ import { FileIcon, FileText, Image, Music, Video } from '@lucide/svelte';
9
+ import type { ChatAttachmentDisplayItem } from '$lib/types';
10
+
11
+ interface Props {
12
+ currentItem: ChatAttachmentDisplayItem | null;
13
+ isImage: boolean;
14
+ isAudio: boolean;
15
+ isVideo: boolean;
16
+ isPdf: boolean;
17
+ isText: boolean;
18
+ displayPreview: string | undefined;
19
+ displayTextContent: string | undefined;
20
+ audioSrc: string | null;
21
+ videoSrc: string | null;
22
+ language: string;
23
+ hasVisionModality: boolean;
24
+ activeModelId?: string;
25
+ }
26
+
27
+ let {
28
+ activeModelId,
29
+ audioSrc,
30
+ currentItem,
31
+ displayPreview,
32
+ displayTextContent,
33
+ hasVisionModality,
34
+ isAudio,
35
+ isImage,
36
+ isPdf,
37
+ isText,
38
+ isVideo,
39
+ language,
40
+ videoSrc
41
+ }: Props = $props();
42
+
43
+ let IconComponent = $derived(
44
+ isImage ? Image : isText || isPdf ? FileText : isAudio ? Music : isVideo ? Video : FileIcon
45
+ );
46
+
47
+ let isUnavailable = $derived(
48
+ !isPdf && !isImage && !(isText && displayTextContent) && !isAudio && !isVideo
49
+ );
50
+ </script>
51
+
52
+ {#if currentItem}
53
+ {#key currentItem.id}
54
+ {#if isPdf}
55
+ <ChatAttachmentsPreviewCurrentItemPdf
56
+ {currentItem}
57
+ displayName={currentItem.name}
58
+ {displayTextContent}
59
+ {hasVisionModality}
60
+ {activeModelId}
61
+ />
62
+ {:else if isImage}
63
+ <ChatAttachmentsPreviewCurrentItemImage {currentItem} {displayPreview} />
64
+ {:else if isText && displayTextContent}
65
+ <ChatAttachmentsPreviewCurrentItemText {displayTextContent} {language} />
66
+ {:else if isAudio}
67
+ <ChatAttachmentsPreviewCurrentItemAudio {currentItem} {audioSrc} />
68
+ {:else if isVideo}
69
+ <ChatAttachmentsPreviewCurrentItemVideo {currentItem} {videoSrc} />
70
+ {:else if isUnavailable}
71
+ <ChatAttachmentsPreviewCurrentItemUnavailable {IconComponent} />
72
+ {/if}
73
+ {/key}
74
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemAudio.svelte ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Music } from '@lucide/svelte';
3
+
4
+ interface Props {
5
+ currentItem: { name?: string } | null;
6
+ audioSrc: string | null;
7
+ }
8
+
9
+ let { audioSrc, currentItem }: Props = $props();
10
+ </script>
11
+
12
+ <div class="flex flex-1 items-center justify-center p-8">
13
+ <div class="w-full max-w-md text-center">
14
+ <Music class="mx-auto mb-4 h-16 w-16 text-white/50" />
15
+
16
+ {#if audioSrc}
17
+ <audio controls class="mb-4 w-full" src={audioSrc}>
18
+ Your browser does not support the audio element.
19
+ </audio>
20
+ {:else}
21
+ <p class="mb-4 text-white/70">Audio preview not available</p>
22
+ {/if}
23
+
24
+ <p class="text-sm text-white/50">{currentItem?.name || 'Audio'}</p>
25
+ </div>
26
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemImage.svelte ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ interface Props {
3
+ currentItem: { name?: string } | null;
4
+ displayPreview: string | undefined;
5
+ }
6
+
7
+ let { currentItem, displayPreview }: Props = $props();
8
+ </script>
9
+
10
+ {#if displayPreview}
11
+ <div class="flex flex-1 items-center justify-center">
12
+ <img
13
+ src={displayPreview}
14
+ alt={currentItem?.name || 'preview'}
15
+ class="max-h-[80vh] max-w-[80vw] rounded-lg object-contain shadow-lg"
16
+ />
17
+ </div>
18
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemPdf.svelte ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Eye, FileText, Info } from '@lucide/svelte';
3
+ import { SyntaxHighlightedCode } from '$lib/components/app';
4
+ import * as Alert from '$lib/components/ui/alert';
5
+ import { Button } from '$lib/components/ui/button';
6
+ import { ICON_CLASS_DEFAULT } from '$lib/constants/css-classes';
7
+ import { PdfViewMode } from '$lib/enums';
8
+ import type { ChatAttachmentDisplayItem } from '$lib/types';
9
+ import { getLanguageFromFilename } from '$lib/utils';
10
+ import { convertPDFToImage } from '$lib/utils/browser-only';
11
+
12
+ interface Props {
13
+ currentItem: ChatAttachmentDisplayItem | null;
14
+ displayName: string;
15
+ displayTextContent: string | undefined;
16
+ hasVisionModality: boolean;
17
+ activeModelId?: string;
18
+ }
19
+
20
+ let { activeModelId, currentItem, displayName, displayTextContent, hasVisionModality }: Props =
21
+ $props();
22
+
23
+ let pdfViewMode = $state<PdfViewMode>(PdfViewMode.PAGES);
24
+ let pdfImages = $state<string[]>([]);
25
+ let pdfImagesLoading = $state(false);
26
+ let pdfImagesError = $state<string | null>(null);
27
+
28
+ let language = $derived(getLanguageFromFilename(displayName));
29
+
30
+ async function loadPdfImages() {
31
+ if (pdfImages.length > 0 || pdfImagesLoading || !currentItem) return;
32
+
33
+ pdfImagesLoading = true;
34
+ pdfImagesError = null;
35
+
36
+ try {
37
+ let file: File | null = null;
38
+
39
+ if (currentItem.uploadedFile?.file) {
40
+ file = currentItem.uploadedFile.file;
41
+ } else if (currentItem.attachment) {
42
+ // Check if we have pre-processed images
43
+ if (
44
+ 'images' in currentItem.attachment &&
45
+ currentItem.attachment.images &&
46
+ Array.isArray(currentItem.attachment.images) &&
47
+ currentItem.attachment.images.length > 0
48
+ ) {
49
+ pdfImages = currentItem.attachment.images;
50
+
51
+ return;
52
+ }
53
+
54
+ // Convert base64 back to File for processing
55
+ if ('base64Data' in currentItem.attachment && currentItem.attachment.base64Data) {
56
+ const base64Data = currentItem.attachment.base64Data;
57
+ const byteCharacters = atob(base64Data);
58
+ const byteNumbers = new Array(byteCharacters.length);
59
+
60
+ for (let i = 0; i < byteCharacters.length; i++) {
61
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
62
+ }
63
+ const byteArray = new Uint8Array(byteNumbers);
64
+
65
+ file = new File([byteArray], displayName, { type: 'application/pdf' });
66
+ }
67
+ }
68
+
69
+ if (file) {
70
+ pdfImages = await convertPDFToImage(file);
71
+ } else {
72
+ throw new Error('No PDF file available for conversion');
73
+ }
74
+ } catch (error) {
75
+ pdfImagesError = error instanceof Error ? error.message : 'Failed to load PDF images';
76
+ } finally {
77
+ pdfImagesLoading = false;
78
+ }
79
+ }
80
+
81
+ $effect(() => {
82
+ if (pdfViewMode === PdfViewMode.PAGES) {
83
+ loadPdfImages();
84
+ }
85
+ });
86
+ </script>
87
+
88
+ <div class="mb-4 flex items-center justify-end gap-2">
89
+ <Button
90
+ variant={pdfViewMode === PdfViewMode.TEXT ? 'default' : 'outline'}
91
+ size="sm"
92
+ onclick={() => (pdfViewMode = PdfViewMode.TEXT)}
93
+ disabled={pdfImagesLoading}
94
+ >
95
+ <FileText class="mr-1 {ICON_CLASS_DEFAULT}" />
96
+ Text
97
+ </Button>
98
+
99
+ <Button
100
+ variant={pdfViewMode === PdfViewMode.PAGES ? 'default' : 'outline'}
101
+ size="sm"
102
+ onclick={() => (pdfViewMode = PdfViewMode.PAGES)}
103
+ disabled={pdfImagesLoading}
104
+ >
105
+ {#if pdfImagesLoading}
106
+ <div
107
+ class="mr-1 {ICON_CLASS_DEFAULT} animate-spin rounded-full border-2 border-current border-t-transparent"
108
+ ></div>
109
+ {:else}
110
+ <Eye class="mr-1 {ICON_CLASS_DEFAULT}" />
111
+ {/if}
112
+ Pages
113
+ </Button>
114
+ </div>
115
+
116
+ {#if !hasVisionModality && activeModelId && currentItem}
117
+ <Alert.Root class="mb-4 max-w-4xl">
118
+ <Info class={ICON_CLASS_DEFAULT} />
119
+ <Alert.Title>Preview only</Alert.Title>
120
+ <Alert.Description>
121
+ <span class="inline-flex">
122
+ The selected model does not support vision. Only the extracted
123
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
124
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
125
+ <span
126
+ class="mx-1 cursor-pointer underline"
127
+ onclick={() => (pdfViewMode = PdfViewMode.TEXT)}
128
+ >
129
+ text
130
+ </span>
131
+ will be sent to the model.
132
+ </span>
133
+ </Alert.Description>
134
+ </Alert.Root>
135
+ {/if}
136
+
137
+ {#if pdfImagesLoading}
138
+ <div class="flex flex-1 items-center justify-center p-8">
139
+ <div class="text-center">
140
+ <div
141
+ class="mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"
142
+ ></div>
143
+ <p class="text-white/70">Converting PDF to images...</p>
144
+ </div>
145
+ </div>
146
+ {:else if pdfImagesError}
147
+ <div class="flex flex-1 items-center justify-center p-8">
148
+ <div class="text-center">
149
+ <FileText class="mx-auto mb-4 h-16 w-16 text-white/50" />
150
+ <p class="mb-4 text-white/70">Failed to load PDF images</p>
151
+ <p class="text-sm text-white/50">{pdfImagesError}</p>
152
+ </div>
153
+ </div>
154
+ {:else if pdfImages.length > 0}
155
+ {#each pdfImages as image, index (image)}
156
+ <p class="mb-2 text-sm text-white/50">Page {index + 1}</p>
157
+ <img src={image} alt="PDF Page {index + 1}" class="mx-auto max-w-[85vw] rounded-lg shadow-lg" />
158
+ <div class="h-4"></div>
159
+ {/each}
160
+ {:else}
161
+ <div class="flex flex-1 items-center justify-center p-8">
162
+ <div class="text-center">
163
+ <FileText class="mx-auto mb-4 h-16 w-16 text-white/50" />
164
+ <p class="text-white/70">No PDF pages available</p>
165
+ </div>
166
+ </div>
167
+ {/if}
168
+
169
+ {#if pdfViewMode === PdfViewMode.TEXT && displayTextContent}
170
+ <div class="px-4 pb-4">
171
+ <SyntaxHighlightedCode
172
+ class="max-w-4xl"
173
+ code={displayTextContent}
174
+ {language}
175
+ maxHeight="none"
176
+ />
177
+ </div>
178
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemText.svelte ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { SyntaxHighlightedCode } from '$lib/components/app';
3
+
4
+ interface Props {
5
+ displayTextContent: string | undefined;
6
+ language: string;
7
+ }
8
+
9
+ let { displayTextContent, language }: Props = $props();
10
+ </script>
11
+
12
+ {#if displayTextContent}
13
+ <div class="px-4 pb-4">
14
+ <SyntaxHighlightedCode
15
+ class="max-w-4xl"
16
+ code={displayTextContent}
17
+ {language}
18
+ maxHeight="none"
19
+ />
20
+ </div>
21
+ {/if}
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemUnavailable.svelte ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { Component } from 'svelte';
3
+
4
+ interface Props {
5
+ IconComponent: Component;
6
+ }
7
+
8
+ let { IconComponent }: Props = $props();
9
+ </script>
10
+
11
+ <div class="flex flex-1 items-center justify-center p-8">
12
+ <div class="text-center">
13
+ <IconComponent class="mx-auto mb-4 h-16 w-16 text-white/50" />
14
+
15
+ <p class="text-white/70">Preview not available for this file type</p>
16
+ </div>
17
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewCurrentItem/ChatAttachmentsPreviewCurrentItemVideo.svelte ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { Video } from '@lucide/svelte';
3
+
4
+ interface Props {
5
+ currentItem: { name?: string } | null;
6
+ videoSrc: string | null;
7
+ }
8
+
9
+ let { currentItem, videoSrc }: Props = $props();
10
+ </script>
11
+
12
+ <div class="flex flex-1 items-center justify-center p-8">
13
+ <div class="w-full max-w-md text-center">
14
+ <Video class="mx-auto mb-4 h-16 w-16 text-white/50" />
15
+
16
+ {#if videoSrc}
17
+ <video controls class="mb-4 w-full" src={videoSrc}>
18
+ <track kind="captions" src="" />
19
+ Your browser does not support the video element.
20
+ </video>
21
+ {:else}
22
+ <p class="mb-4 text-white/70">Video preview not available</p>
23
+ {/if}
24
+
25
+ <p class="text-sm text-white/50">{currentItem?.name || 'Video'}</p>
26
+ </div>
27
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewFileInfo.svelte ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ interface Props {
3
+ displayName: string;
4
+ fileSize: string;
5
+ }
6
+
7
+ let { displayName, fileSize }: Props = $props();
8
+ </script>
9
+
10
+ <div class="sticky top-0 z-[20] mb-4 rounded-lg bg-black/5 px-4 py-2 text-center backdrop-blur-md">
11
+ <p class="font-medium text-white">{displayName}</p>
12
+
13
+ {#if fileSize}
14
+ <p class="text-xs text-white/60">{fileSize}</p>
15
+ {/if}
16
+ </div>
tools/ui/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsPreview/ChatAttachmentsPreviewNavButtons.svelte ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { ChevronLeft, ChevronRight } from '@lucide/svelte';
3
+ import { Button } from '$lib/components/ui/button';
4
+
5
+ interface Props {
6
+ onPrev: () => void;
7
+ onNext: () => void;
8
+ show: boolean;
9
+ }
10
+
11
+ let { onNext, onPrev, show }: Props = $props();
12
+ </script>
13
+
14
+ {#if show}
15
+ <Button
16
+ variant="secondary"
17
+ size="icon"
18
+ class="absolute top-1/2 left-4 z-10 h-8 w-8 -translate-y-1/2 rounded-full bg-background/5 p-0 text-white!"
19
+ onclick={onPrev}
20
+ aria-label="Previous"
21
+ >
22
+ <ChevronLeft class="size-4" />
23
+ </Button>
24
+
25
+ <Button
26
+ variant="secondary"
27
+ size="icon"
28
+ class="absolute top-1/2 right-4 z-10 h-8 w-8 -translate-y-1/2 rounded-full bg-background/5 p-0 text-white!"
29
+ onclick={onNext}
30
+ aria-label="Next"
31
+ >
32
+ <ChevronRight class="size-4" />
33
+ </Button>
34
+ {/if}