diff --git a/.devops/cann.Dockerfile b/.devops/cann.Dockerfile index 83df409506fd..d76bfa69978b 100644 --- a/.devops/cann.Dockerfile +++ b/.devops/cann.Dockerfile @@ -25,9 +25,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM ${CANN_BASE_IMAGE} AS build diff --git a/.devops/cpu.Dockerfile b/.devops/cpu.Dockerfile index e195b5ac8b53..19a6a93b78c0 100644 --- a/.devops/cpu.Dockerfile +++ b/.devops/cpu.Dockerfile @@ -15,9 +15,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM docker.io/ubuntu:$UBUNTU_VERSION AS build diff --git a/.devops/cuda.Dockerfile b/.devops/cuda.Dockerfile index 20501c1beac2..b4cad90c95c5 100644 --- a/.devops/cuda.Dockerfile +++ b/.devops/cuda.Dockerfile @@ -23,9 +23,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM ${BASE_CUDA_DEV_CONTAINER} AS build diff --git a/.devops/intel.Dockerfile b/.devops/intel.Dockerfile index 16326ebbdea5..9e0025920602 100644 --- a/.devops/intel.Dockerfile +++ b/.devops/intel.Dockerfile @@ -17,9 +17,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM docker.io/intel/deep-learning-essentials:$ONEAPI_VERSION AS build diff --git a/.devops/musa.Dockerfile b/.devops/musa.Dockerfile index dbf9e0b41122..dcfe3a22080f 100644 --- a/.devops/musa.Dockerfile +++ b/.devops/musa.Dockerfile @@ -21,9 +21,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM ${BASE_MUSA_DEV_CONTAINER} AS build diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix index 4ac844ff959d..887270fb23bd 100644 --- a/.devops/nix/package.nix +++ b/.devops/nix/package.nix @@ -182,7 +182,7 @@ effectiveStdenv.mkDerivation (finalAttrs: { webui = stdenvNoCC.mkDerivation { pname = "webui"; version = llamaVersion; - # the app compiles Llama UI from its source in ../../lib/ui, so the source is ui/ as a whole + # the app compiles Llama UI and the harness from their sources in ../../lib, so the source is ui/ as a whole src = lib.cleanSource ../../ui; sourceRoot = "source/apps/chat"; diff --git a/.devops/openvino.Dockerfile b/.devops/openvino.Dockerfile index c88cc2bbb5f9..f7461f2eee7f 100644 --- a/.devops/openvino.Dockerfile +++ b/.devops/openvino.Dockerfile @@ -34,9 +34,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build ## Build Image diff --git a/.devops/rocm.Dockerfile b/.devops/rocm.Dockerfile index 9e667660f00e..78a30ef47ae4 100644 --- a/.devops/rocm.Dockerfile +++ b/.devops/rocm.Dockerfile @@ -23,9 +23,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build ### Build image diff --git a/.devops/vulkan.Dockerfile b/.devops/vulkan.Dockerfile index dc8a87667205..740cd3b9cced 100644 --- a/.devops/vulkan.Dockerfile +++ b/.devops/vulkan.Dockerfile @@ -15,9 +15,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM docker.io/ubuntu:$UBUNTU_VERSION AS build diff --git a/.devops/zendnn.Dockerfile b/.devops/zendnn.Dockerfile index cbc3696ed643..75b2da5a4dd5 100644 --- a/.devops/zendnn.Dockerfile +++ b/.devops/zendnn.Dockerfile @@ -15,9 +15,10 @@ COPY ui/apps/chat/package.json ui/apps/chat/package-lock.json ./ RUN npm ci COPY ui/apps/chat/ ./ -# the app compiles Llama UI from its source next to it +# the app compiles Llama UI and the harness from their sources next to it COPY ui/lib/ui/package.json /app/ui/lib/ui/package.json COPY ui/lib/ui/src/lib/ /app/ui/lib/ui/src/lib/ +COPY ui/lib/harness/src/ /app/ui/lib/harness/src/ RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build FROM docker.io/ubuntu:$UBUNTU_VERSION AS build diff --git a/.github/workflows/ui-self-hosted.yml b/.github/workflows/ui-self-hosted.yml index 346f1cfb4b12..e19c4234b827 100644 --- a/.github/workflows/ui-self-hosted.yml +++ b/.github/workflows/ui-self-hosted.yml @@ -19,6 +19,7 @@ on: '.github/workflows/ui-build-self-hosted.yml', 'ui/apps/chat/**.*', 'ui/lib/ui/**.*', + 'ui/lib/harness/**.*', 'tools/server/tests/**.*' ] pull_request: @@ -28,6 +29,7 @@ on: '.github/workflows/ui-build-self-hosted.yml', 'ui/apps/chat/**.*', 'ui/lib/ui/**.*', + 'ui/lib/harness/**.*', 'tools/server/tests/**.*' ] diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index 10d7ed0ed5e4..11875ba53c5c 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -150,6 +150,37 @@ jobs: run: npm run prepack working-directory: ui/lib/ui + harness-checks: + name: Harness checks + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }} + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: "24" + package-manager-cache: false + + - name: Install dependencies + run: npm ci + working-directory: ui/lib/harness + + - name: Run type checking + run: npm run check + working-directory: ui/lib/harness + + - name: Run tests + run: npm test + working-directory: ui/lib/harness + + - name: Build the package + run: npm run prepack + working-directory: ui/lib/harness + e2e-tests: name: E2E Tests needs: ui-build diff --git a/scripts/ui-assets.cmake b/scripts/ui-assets.cmake index 90d0bdf338b8..12b5f068d513 100644 --- a/scripts/ui-assets.cmake +++ b/scripts/ui-assets.cmake @@ -20,10 +20,12 @@ set(LLAMA_UI_GZIP "" CACHE STRING "Apply gzip compress to assets to save ban set(DIST_DIR "${UI_BINARY_DIR}/dist") set(SRC_DIST_DIR "${UI_SOURCE_DIR}/dist") # The stage keeps the layout of ui/: the app in apps/chat, with the sources of -# Llama UI that it compiles next to it in lib/ui (see ui/apps/chat/scripts/llama-ui.js). +# Llama UI and the harness that it compiles next to it in lib/ (see +# ui/apps/chat/scripts/llama-ui.js and svelte.config.js). set(STAGE_DIR "${UI_BINARY_DIR}/ui-src") set(WORK_DIR "${STAGE_DIR}/apps/chat") set(UI_LIB_DIR "${UI_SOURCE_DIR}/../../lib/ui") +set(HARNESS_DIR "${UI_SOURCE_DIR}/../../lib/harness") set(STAMP_FILE "${UI_BINARY_DIR}/.ui-stamp") set(EMBED_STAMP "${UI_BINARY_DIR}/.ui-embed.sha256") set(UI_CPP "${UI_BINARY_DIR}/ui.cpp") @@ -323,7 +325,7 @@ function(npm_build_should_skip out_var) endfunction() function(stage_sources) - # everything but the app goes: the library, restaged below, and what a stage + # everything but the app goes: the packages, restaged below, and what a stage # from before this layout left at the top, its node_modules included if(EXISTS "${STAGE_DIR}") file(GLOB staged RELATIVE "${STAGE_DIR}" "${STAGE_DIR}/*") @@ -347,7 +349,8 @@ function(stage_sources) PATTERN "node_modules" EXCLUDE ) - # what the app reads of the library: its sources and the dependency list + # what the app reads of the packages: Llama UI's sources and dependency list, + # and the harness's sources file(COPY "${UI_LIB_DIR}/package.json" DESTINATION "${STAGE_DIR}/lib/ui" NO_SOURCE_PERMISSIONS @@ -356,6 +359,10 @@ function(stage_sources) DESTINATION "${STAGE_DIR}/lib/ui/src" NO_SOURCE_PERMISSIONS ) + file(COPY "${HARNESS_DIR}/src" + DESTINATION "${STAGE_DIR}/lib/harness" + NO_SOURCE_PERMISSIONS + ) endfunction() function(npm_build out_var) diff --git a/tools/server/README-dev.md b/tools/server/README-dev.md index 997b8137d61f..f7ec63b7f44f 100644 --- a/tools/server/README-dev.md +++ b/tools/server/README-dev.md @@ -190,6 +190,7 @@ Get a list of tools, each tool has these fields: - `tool` (string): the ID name of the tool, to be used in POST call. Example: `read_file` - `display_name` (string): the name to be displayed on UI. Example: `Read file` - `type` (string): `"server"` for a server tool, or `"mcp"` for a tool exposed by an MCP server +- `mcp_server` (string, only when `type` is `"mcp"`): the name of the MCP server the tool comes from, as declared in `--mcp-servers-config`. Example: `imcp` - `permissions` (object): a mapping string --> boolean that indicates the permission required by this tool. This is useful for the UI to ask the user before calling the tool. For now, the only permission supported is `"write"` - `definition` (object): the OAI-compat definition of this tool diff --git a/tools/server/README.md b/tools/server/README.md index 278518dce75c..ef32b2c51513 100644 --- a/tools/server/README.md +++ b/tools/server/README.md @@ -389,7 +389,7 @@ The same JSON can be passed inline with `--mcp-servers-json`. Each entry under ` | `cwd` | working directory of the child process | | `timeout_ms` | per-tool-call timeout (default: 30000) | -Every server is spawned once at startup to list its tools, then stopped, and respawned on demand when one of its tools is called. Tools are exposed as `_` alongside the built-in ones: they show up in Llama Chat and in `GET /tools`, and the model calls them like any other tool. A name colliding with an already registered tool is skipped. This is independent of `--tools`, MCP servers can be the only tools available. +Every server is spawned once at startup to list its tools, then stopped, and respawned on demand when one of its tools is called. Tools are exposed as `_` alongside the built-in ones: they show up in Llama Chat, which lists each of these servers on its MCP servers page, and in `GET /tools`, with `"type": "mcp"` and the server's name in `mcp_server`. The model calls them like any other tool. A name colliding with an already registered tool is skipped. This is independent of `--tools`, MCP servers can be the only tools available. The child process runs with the same privileges as the server, so only declare commands you trust. As with `--tools`, `--cors-origins` then defaults to `localhost`. diff --git a/tools/server/server-tools.cpp b/tools/server/server-tools.cpp index 63626ddcc3df..633d0a5a51e6 100644 --- a/tools/server/server-tools.cpp +++ b/tools/server/server-tools.cpp @@ -89,7 +89,7 @@ static std::string console_output_to_utf8(const std::string & text) { } json server_tool::to_json() const { - return { + json res = { {"display_name", display_name}, {"tool", name}, {"type", type()}, @@ -99,6 +99,10 @@ json server_tool::to_json() const { {"uses_cwd", uses_cwd}, {"definition", get_definition()}, }; + if (!mcp_server.empty()) { + res["mcp_server"] = mcp_server; + } + return res; } static constexpr size_t SERVER_TOOL_GIT_LS_FILES_MAX_OUTPUT = 8 * 1024 * 1024; // 8 MB @@ -1814,6 +1818,7 @@ struct server_mcp_tool : server_tool { { name = server_name + "_" + tool_name; display_name = name; + mcp_server = server_name; permission_write = false; support_stream = false; } diff --git a/tools/server/server-tools.h b/tools/server/server-tools.h index 5a63ee973bef..1dc1d6e1e60b 100644 --- a/tools/server/server-tools.h +++ b/tools/server/server-tools.h @@ -15,6 +15,7 @@ struct server_tool { bool permission_write = false; bool support_stream = false; // if true, output can be streamed bool uses_cwd = false; // if true, the tool resolves paths and runs against the working directory + std::string mcp_server; // the MCP server the tool comes from, empty for a built-in tool virtual ~server_tool() = default; virtual json get_definition() const = 0; diff --git a/tools/server/tests/unit/test_mcp_servers.py b/tools/server/tests/unit/test_mcp_servers.py index 7a9f0bea57b3..6500d432485e 100644 --- a/tools/server/tests/unit/test_mcp_servers.py +++ b/tools/server/tests/unit/test_mcp_servers.py @@ -77,6 +77,9 @@ def get_tool_name(t): # Verify tool structure echo_tool = next(t for t in mcp_tools if get_tool_name(t) == "echo_echo") assert "description" in echo_tool or "definition" in echo_tool + assert echo_tool["type"] == "mcp" + assert echo_tool["mcp_server"] == "echo" + assert all("mcp_server" not in t for t in tools if t["type"] != "mcp") finally: server.stop() diff --git a/ui/README.md b/ui/README.md index b70228d0de7c..55fab208f41d 100644 --- a/ui/README.md +++ b/ui/README.md @@ -5,20 +5,27 @@ The UI of llama.cpp: the packages in `lib` and the apps built on them. ```text ui/ ├── lib/ -│ └── ui/ @ggml-org/llama-ui: design tokens, fonts, surfaces and components +│ ├── ui/ @ggml-org/llama-ui: design tokens, fonts, surfaces and components +│ └── harness/ @ggml-org/llama-harness: the agentic loop, headless └── apps/ - └── chat/ Llama Chat, the chat app that llama-server serves + └── chat/ Llama Chat, the chat app that llama-server serves ``` - [`lib/ui`](lib/ui/README.md) draws the parts and handles interaction, with no business logic. It is built with `@sveltejs/package` and published to npm as `@ggml-org/llama-ui`. Apps in this repo skip the package: they compile its sources as part of their own build, so they hold no copy of a component, a token or a font. -- [`apps/chat`](apps/chat/README.md) talks to llama-server, stores conversations and runs the agentic loop. CMake - builds it into llama-server (see `scripts/ui-assets.cmake`), and it is published to npm as `@ggml-org/llama-chat` - (with `llama-chat` as its short name), so `npx llama-chat` runs it against any llama-server. +- [`lib/harness`](lib/harness/README.md) is the agentic loop: plain TypeScript with no UI and no dependencies. An app + gives it an inference client and tools, and reads its events. +- [`apps/chat`](apps/chat/README.md) talks to llama-server, stores conversations and runs the agentic loop through the + harness. CMake builds it into llama-server (see `scripts/ui-assets.cmake`), and it is published to npm as + `@ggml-org/llama-chat` (with `llama-chat` as its short name), so `npx llama-chat` runs it against any llama-server. Each folder is its own npm package with its own `package-lock.json`: run `npm ci` in the one you work on. Building, -checking and testing `apps/chat` needs no install in `lib/ui`. +checking and testing `apps/chat` needs no install in `lib/ui` or `lib/harness`. + +The split between library and app is not finished. Llama Chat takes its tokens, fonts, surfaces and base components +from `lib/ui`, but still has its own versions of what the library holds above those (ActionIcon, SearchInput, Logo, +SyntaxHighlightedCode and the Model UI), and `DESIGN.md`, `BRAND.md` and the full Storybook still sit beside the app. ## Releases diff --git a/ui/apps/chat/.storybook/preview.ts b/ui/apps/chat/.storybook/preview.ts index 7e7a58d167a8..035a5d097f12 100644 --- a/ui/apps/chat/.storybook/preview.ts +++ b/ui/apps/chat/.storybook/preview.ts @@ -4,6 +4,7 @@ import { SurfaceTheme } from '#lib/enums/ui.enums.ts'; import { applySurfaceTheme } from '#lib/utils/css.ts'; // the docs pages' styles, shared with the library's Storybook import '../../../lib/ui/.storybook/docs.css'; +import { activateBuiltInExtensions } from '../tests/stories/helpers/extensions'; import { applyColorScheme } from './color-scheme'; import ModeWatcherDecorator from './decorators/ModeWatcherDecorator.svelte'; import TooltipProviderDecorator from './decorators/TooltipProviderDecorator.svelte'; @@ -13,6 +14,8 @@ applyColorScheme(); window.matchMedia(MEDIA_QUERIES.PREFERS_DARK).addEventListener('change', applyColorScheme); const preview: Preview = { + // the app switches its extensions on at startup; the stories get them the same way, once + beforeAll: activateBuiltInExtensions, parameters: { controls: { matchers: { diff --git a/ui/apps/chat/AGENTS.md b/ui/apps/chat/AGENTS.md index 32e6a009a2c9..0b4884de3167 100644 --- a/ui/apps/chat/AGENTS.md +++ b/ui/apps/chat/AGENTS.md @@ -1,6 +1,6 @@ # Instructions for ui/apps/chat -These add to the repository's [AGENTS.md](../../../AGENTS.md) for work in `ui/apps/chat`: **Llama Chat**, the chat client that llama-server bundles. **Llama UI**, the library, is `ui/lib/ui` (`@ggml-org/llama-ui`): Chat imports its tokens, fonts and base components from there (`@ggml-org/llama-ui/ui/`) and keeps no copy of them. `DESIGN.md` and the Storybook live here; the brand book, `BRAND.md`, and the brand and communications pages are in [ggml-org/llama-brand](https://github.com/ggml-org/llama-brand), with their own Storybook. +These add to the repository's [AGENTS.md](../../../AGENTS.md) for work in `ui/apps/chat`: **Llama Chat**, the chat client that llama-server bundles. **Llama UI**, the library, is `ui/lib/ui` (`@ggml-org/llama-ui`): Chat imports its tokens, fonts and base components from there (`@ggml-org/llama-ui/ui/`) and keeps no copy of them. `DESIGN.md` and the Storybook live here; the brand book, `BRAND.md`, and the brand and communications pages are in [ggml-org/llama-brand](https://github.com/ggml-org/llama-brand), with their own Storybook. The agentic loop is `ui/lib/harness` (`@ggml-org/llama-harness`). - **Design:** [DESIGN.md](DESIGN.md) holds the tokens, roles and rules, written for agents. Follow it for anything visual. Its token sections (`colors`, `typography`, `rounded`) are generated from the CSS with `npm run design:tokens`, and CI checks they are current; the rest is written by hand, and when it and the CSS disagree, the CSS wins and DESIGN.md is updated. - **Stories:** a story lives with the code it shows. Llama UI's (its foundations, base components, app components and Model UI) are in `ui/lib/ui/tests/stories`, titled `Llama UI/...`, and run as the library's tests; this app's Storybook shows them too. Llama Chat's are in `tests/stories/`, one folder per `src/lib/components/app/` (`chat/` has one per Chat folder), titled `Llama Chat//`. An accessibility story sits next to its component's, as `.a11y.stories.svelte`, titled `...//Accessibility`. The story helpers both Storybooks use (the Editorial the prose pages are set in, `StateGallery`) live with the library's stories and are imported here as `$llama-ui-stories/...`; reuse them rather than copying them here. diff --git a/ui/apps/chat/README.md b/ui/apps/chat/README.md index 5fa37286aadf..b6c46b5605ed 100644 --- a/ui/apps/chat/README.md +++ b/ui/apps/chat/README.md @@ -84,15 +84,17 @@ Llama Chat is the first app on Llama UI, and the reference for the line between The app imports the library as `@ggml-org/llama-ui/ui/` and compiles its sources in its own build, with no install of the library (see `scripts/vite-plugin-llama-ui.ts`). Data flows one way, through these layers: -| Layer | Lives in | What it holds | -| -------------- | ------------------------- | --------------------------------------------------------------------------------------------------- | -| Routes | `src/routes` | `/`, `/chat/[id]`, `/models`, `/mcp-servers`, `/settings`, `/search` | -| App components | `src/lib/components/app` | Chat, navigation, models, MCP, settings and dialogs, grouped by area | -| UI components | `ui/lib/ui` | shadcn-svelte on bits-ui, from Llama UI | -| Hooks | `src/lib/hooks` | View logic between components and stores: scroll, drag and drop, pickers, keyboard | -| Stores | `src/lib/stores` | Application state as Svelte 5 runes: chat, conversations, the agentic loop, tools, models, settings | -| Services | `src/lib/services` | Stateless I/O: the llama-server API, IndexedDB, MCP, the Hugging Face Hub, the tool sandbox | -| Storage + API | the browser, llama-server | IndexedDB and localStorage; llama-server's `/v1`, `/props`, `/models`, `/tools`, `/slots` | +| Layer | Lives in | What it holds | +| -------------- | ------------------------- | ---------------------------------------------------------------------------------------------------- | +| Routes | `src/routes` | `/`, `/chat/[id]`, `/models`, `/mcp-servers`, `/settings`, `/search` | +| App components | `src/lib/components/app` | Chat, navigation, models, settings and dialogs, grouped by area | +| UI components | `ui/lib/ui` | shadcn-svelte on bits-ui, from Llama UI | +| Hooks | `src/lib/hooks` | View logic between components and stores: scroll, drag and drop, pickers, keyboard | +| Stores | `src/lib/stores` | Application state as Svelte 5 runes: chat, conversations, the agentic loop, tools, models, settings | +| Agentic loop | `ui/lib/harness` | Llama Harness: streams a turn, runs the tools the model called, repeats until it answers without one | +| Services | `src/lib/services` | Stateless I/O: the llama-server API, IndexedDB, the Hugging Face Hub, the tool sandbox | +| Extensions | `src/lib/extensions` | Features that can be switched off, MCP first: what they add to the app's extension points | +| Storage + API | the browser, llama-server | IndexedDB and localStorage; llama-server's `/v1`, `/props`, `/models`, `/tools`, `/slots` | ```mermaid flowchart LR @@ -104,6 +106,7 @@ flowchart LR Services --> DB[("IndexedDB, localStorage")] Services --> API["llama-server"] Components -. "imports" .-> UI["Llama UI"] + Ext["Extensions, such as MCP"] -. "extension points" .-> Stores Stores -. "reactive state" .-> Components ``` @@ -142,6 +145,33 @@ sequenceDiagram - **Modalities**: attachments a model cannot read (images for a text-only model, say) are refused before sending, from the model's `/props`. - **Storage**: conversations and messages in IndexedDB (Dexie), settings and model preferences in localStorage, server state and Hub details in memory only. +### Extensions (`src/lib/extensions/`) + +An extension is a feature the app is composed with and that can be switched off. The registry (`registry.svelte.ts`) knows the built-in extensions (`builtin.ts`), activates the ones that are on at startup, and holds what they add to each extension point (`points/`): tools, flow hooks, sidebar entries, pages, slash commands, pickers, pending attachments, and message and attachment renderers. + +The core never imports an extension's own code; an extension may import the core. ESLint enforces this: a file outside `src/lib/extensions//` cannot import from that folder. + +Extensions are switched on and off in Settings, in the Extensions section. A switch takes effect at once: the extension's contributions go away and its cleanups run (MCP closes its connections). The choice is kept in localStorage and read at startup. + +MCP is the first extension. All of its code is in `src/lib/extensions/mcp/`: + +| Part | Responsibility | +| -------------------------- | ------------------------------------------------------------------------------------------------- | +| `index.ts` and glue | The extension: what MCP adds to each extension point (`tools.ts`, `composer.ts`, `pages.ts`, ...) | +| `stores/` (`mcpStore`) | MCP host role: multi-server lifecycle, tool routing, server icons; composes `health`, `resources` | +| `services/` (`MCPService`) | MCP protocol: transports, connect, list/execute tools, prompts, resources | +| `components/` | Server cards and forms, resource browser, dialogs, the prompt picker and the chat renderers | + +A server that answers 401 and publishes an OAuth authorization server shows **Sign in** on its card: the browser registers the app with it (dynamic client registration, or the client ID of an app the user registered there by hand), opens the authorization page in a popup, and keeps the tokens per server in localStorage (`oauth/`), apart from the settings, so a settings export never carries them. An Authorization header set on the server wins over a sign-in. With **Use llama-server proxy** on, the discovery, registration and token requests go through the proxy too. + +MCP's shared data stays in the core: types, enums, constants, `utils/mcp.ts`, settings keys and the stored message formats. + +MCP servers come two ways. A remote server (Streamable HTTP, SSE or WebSocket) is one the browser connects to by URL, added on the MCP servers page. A local server that runs as a command (stdio) is one llama-server starts from `--mcp-servers-config`, since a page cannot start a process: llama-server lists its tools in `/tools` with the type `mcp` and the server's name in `mcp_server`, and runs them on `POST /tools`. The MCP extension takes those tools over from the core's server tools (`serverToolType` on its tool provider, see `llama-server.ts`), so both kinds show up the same way, one group per server, on the MCP servers page and in the tools menu. With the extension off, the core lists them as server tools again. + +A setting can name the extension it belongs to (`extension` in `SETTINGS_REGISTRY`): its field shows only while that extension is on, and the stored value stays either way. + +llama-server embeds the app as a single bundle, so an extension's code ships whether it is on or off; nothing of it runs while it is off. + ### Cross-origin isolation llama-server serves the UI with `Cross-Origin-Embedder-Policy: require-corp` and `Cross-Origin-Opener-Policy: same-origin`, so every cross-origin asset needs the other origin's consent. Hugging Face Hub avatars and metadata are requested in CORS mode, which the Hub allows. MCP server icons and search-result favicons go through llama-server's `/cors-proxy` when it runs with `--ui-mcp-proxy`, and fall back to a bundled icon otherwise. diff --git a/ui/apps/chat/demo/fixtures/mcp-servers.ts b/ui/apps/chat/demo/fixtures/mcp-servers.ts index 15529e4a314e..46b637c670da 100644 --- a/ui/apps/chat/demo/fixtures/mcp-servers.ts +++ b/ui/apps/chat/demo/fixtures/mcp-servers.ts @@ -8,8 +8,8 @@ */ import { DEMO_MCP_PORT, DEMO_MCP_SERVERS, type DemoMcpServer } from './demo-config.ts'; -import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; -import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; +import { NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/node'; +import { McpServer } from '@modelcontextprotocol/server'; import { createServer, type IncomingMessage, type ServerResponse } from 'node:http'; import { z } from 'zod'; @@ -19,7 +19,7 @@ function buildServer(fixture: DemoMcpServer): McpServer { for (const tool of fixture.tools) { server.registerTool( tool.name, - { description: tool.description, inputSchema: { query: z.string().optional() } }, + { description: tool.description, inputSchema: z.object({ query: z.string().optional() }) }, async () => ({ content: [{ text: tool.result, type: 'text' }] }) ); } @@ -72,7 +72,7 @@ const httpServer = createServer(async (req, res) => { } const server = buildServer(fixture); - const transport = new StreamableHTTPServerTransport({ + const transport = new NodeStreamableHTTPServerTransport({ enableJsonResponse: true, sessionIdGenerator: undefined }); diff --git a/ui/apps/chat/eslint.config.js b/ui/apps/chat/eslint.config.js index 330551d9d8d1..8b03c8098097 100644 --- a/ui/apps/chat/eslint.config.js +++ b/ui/apps/chat/eslint.config.js @@ -8,6 +8,7 @@ import simpleImportSort from 'eslint-plugin-simple-import-sort'; import storybook from 'eslint-plugin-storybook'; import svelte from 'eslint-plugin-svelte'; import globals from 'globals'; +import path from 'node:path'; import { fileURLToPath } from 'node:url'; import ts from 'typescript-eslint'; @@ -157,6 +158,86 @@ const blankLineBetweenAccessors = { type: 'layout' } }; +// The core never imports an extension's own code; an extension may import the +// core. A module under src/lib/extensions// can only be imported by a file +// in that same folder. The registry's own files (the index, builtin, +// registry.svelte, types and points/*) stay importable from anywhere, and +// builtin.ts loads each extension's entry with a dynamic import. +const LIB_DIR = fileURLToPath(new URL('./src/lib', import.meta.url)); +const EXTENSIONS_DIR = path.join(LIB_DIR, 'extensions'); +const EXTENSIONS_PUBLIC_FILES = new Set(['builtin', 'index', 'registry.svelte', 'types']); +const noExtensionInternals = { + create(context) { + // path of a file inside src/lib/extensions as segments, or null for a file outside it + function extensionSegments(file) { + const relative = path.relative(EXTENSIONS_DIR, file); + + if (relative.startsWith('..') || path.isAbsolute(relative)) return null; + + return relative === '' ? [] : relative.split(path.sep); + } + + function check(node, source, isDynamic) { + if (typeof source !== 'string') return; + + let target; + + if (source.startsWith('#lib/')) { + target = path.join(LIB_DIR, source.slice('#lib'.length)); + } else if (source.startsWith('.')) { + target = path.resolve(path.dirname(context.filename), source); + } else { + return; + } + + const segments = extensionSegments(target); + + if (!segments || segments.length === 0 || segments[0] === 'points') return; + + const id = segments[0]; + + if (segments.length === 1 && EXTENSIONS_PUBLIC_FILES.has(id.replace(/\.[jt]s$/, ''))) return; + + const importer = extensionSegments(context.filename); + + if (importer && importer.length > 1 && importer[0] === id) return; + + const isEntry = + segments.length === 1 || (segments.length === 2 && /^index(\.[jt]s)?$/.test(segments[1])); + + // the one place that names the extensions: it loads the entry of each, lazily + if (isDynamic && isEntry && importer?.length === 1 && importer[0] === 'builtin.ts') return; + + context.report({ data: { id, source }, messageId: 'internal', node }); + } + + return { + ExportAllDeclaration(node) { + check(node, node.source.value, false); + }, + ExportNamedDeclaration(node) { + if (node.source) check(node, node.source.value, false); + }, + ImportDeclaration(node) { + check(node, node.source.value, false); + }, + ImportExpression(node) { + if (node.source.type === 'Literal') check(node, node.source.value, true); + } + }; + }, + meta: { + docs: { + description: "Keep an extension's own code out of the rest of the app." + }, + messages: { + internal: + '"{{source}}" is the own code of the "{{id}}" extension. Only files in src/lib/extensions/{{id}}/ can import it; the rest of the app uses the extension points.' + }, + schema: [], + type: 'problem' + } +}; export default ts.config( includeIgnoreFile(gitignorePath), @@ -171,6 +252,7 @@ export default ts.config( local: { rules: { 'blank-line-between-accessors': blankLineBetweenAccessors, + 'no-extension-internals': noExtensionInternals, 'padding-line-between-elements': paddingLineBetweenElements } }, @@ -189,6 +271,8 @@ export default ts.config( 'eol-last': 'error', // Enforce a blank line between consecutive get/set accessors 'local/blank-line-between-accessors': 'error', + // The core does not import an extension's own code + 'local/no-extension-internals': 'error', // Require a blank line between sibling elements in a Svelte template 'local/padding-line-between-elements': 'error', // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects. @@ -266,7 +350,6 @@ export default ts.config( 'simple-import-sort/imports': ['error', { groups: [['.*']] }], 'svelte/no-at-html-tags': 'off', // This app uses hash-based routing (#/) where resolve() from $app/paths does not apply - 'svelte/no-navigation-without-resolve': 'off', // Sort HTML attributes alphabetically in the markup. The Svelte directives // (bind:/use:/animate:/style:/in:/out:/transition:/class:) sort first, @@ -321,6 +404,17 @@ export default ts.config( } } }, + { + // type information for the app's own modules too, so svelte/no-navigation-without-resolve + // accepts a URL typed as ResolvedPathname, such as RouterService.chat(id) + files: ['src/**/*.ts'], + languageOptions: { parserOptions: { projectService: true } } + }, + { + // Tests and stories exercise an extension's code directly + files: ['tests/**'], + rules: { 'local/no-extension-internals': 'off' } + }, { // Exclude generated build output and Storybook files from ESLint ignores: [ diff --git a/ui/apps/chat/package-lock.json b/ui/apps/chat/package-lock.json index ef7891ba3e38..d5eadbd7e48d 100644 --- a/ui/apps/chat/package-lock.json +++ b/ui/apps/chat/package-lock.json @@ -24,7 +24,9 @@ "@internationalized/date": "3.12.2", "@lezer/highlight": "1.2.5", "@lucide/svelte": "1.46.0", - "@modelcontextprotocol/sdk": "1.32.1", + "@modelcontextprotocol/client": "2.4.0", + "@modelcontextprotocol/node": "2.1.2", + "@modelcontextprotocol/server": "2.4.0", "@playwright/test": "1.56.1", "@storybook/addon-a11y": "10.6.6", "@storybook/addon-docs": "10.6.6", @@ -1937,45 +1939,67 @@ "react": ">=16" } }, - "node_modules/@modelcontextprotocol/sdk": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.32.1.tgz", - "integrity": "sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw==", + "node_modules/@modelcontextprotocol/client": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.4.0.tgz", + "integrity": "sha512-LgrD2OphHuG12vfKFKz6SOnq7bKHQmhGJIAYdD+MZBn2npHEyry6uD8zvktodtl5CQM85MO0anUyD9JwmUmxww==", "dev": true, - "license": "MIT", + "license": "Apache-2.0", "dependencies": { - "@hono/node-server": "^1.19.9 || ^2.0.5", - "ajv": "^8.17.1", - "ajv-formats": "^3.0.1", - "content-type": "^1.0.5", - "cors": "^2.8.5", + "@modelcontextprotocol/core": "2.4.0", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", - "eventsource-parser": "^3.0.0", - "express": "^5.2.1", - "express-rate-limit": "^8.2.1", - "hono": "^4.11.4", + "eventsource-parser": "^3.0.8", "jose": "^6.1.3", - "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", - "raw-body": "^3.0.0", - "zod": "^3.25 || ^4.0", - "zod-to-json-schema": "^3.25.1" + "zod": "^4.2.0" }, "engines": { - "node": ">=18" + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/core": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.4.0.tgz", + "integrity": "sha512-z8QBKqdfXLPzkLQuG4xp8hrVEMm1PZ1IgxMN2sMbJiFiAKOWXnAzogXn2W4aqIBlP1ea6U5yiqVquvUNM1Cj6Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/node": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/node/-/node-2.1.2.tgz", + "integrity": "sha512-IIcIqBpr6NCQQs5DgJTgvbSOAw+3iaR/uquqg+e0nXCdudfjPg/80x0TseUnQx14AUAtE4fsJCEpJKPyb6WPVA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@hono/node-server": "^1.19.9 || ^2.1.3", + "hono": "^4.11.4" + }, + "engines": { + "node": ">=20" }, "peerDependencies": { - "@cfworker/json-schema": "^4.1.1", - "zod": "^3.25 || ^4.0" + "@modelcontextprotocol/server": "^2.4.0" + } + }, + "node_modules/@modelcontextprotocol/server": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.4.0.tgz", + "integrity": "sha512-rgR9yxSaAJ+bcsi/XroT/S2AfPiIWloXAnrdfYSCms9ivVju0ishu/wW0J21Ho6+ZOR1r7RyeRbjiRuF87ix5Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/core": "2.4.0", + "zod": "^4.2.0" }, - "peerDependenciesMeta": { - "@cfworker/json-schema": { - "optional": true - }, - "zod": { - "optional": false - } + "engines": { + "node": ">=20" } }, "node_modules/@napi-rs/canvas": { @@ -5230,20 +5254,6 @@ "dev": true, "license": "MIT" }, - "node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "dev": true, - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/acorn": { "version": "8.19.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", @@ -5267,41 +5277,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/ajv": { - "version": "8.20.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", - "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", - "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -5484,45 +5459,6 @@ } } }, - "node_modules/body-parser": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", - "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^2.1.0", - "debug": "^4.4.3", - "http-errors": "^2.0.1", - "iconv-lite": "^0.7.3", - "on-finished": "^2.4.1", - "qs": "^6.16.1", - "raw-body": "^3.0.2", - "type-is": "^2.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/body-parser/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/brace-expansion": { "version": "5.0.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", @@ -5552,16 +5488,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -5813,30 +5739,6 @@ "node": "^14.18.0 || >=16.10.0" } }, - "node_modules/content-disposition": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-2.0.1.tgz", - "integrity": "sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -5858,34 +5760,6 @@ "url": "https://opencollective.com/express" } }, - "node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "node_modules/cors": { - "version": "2.8.6", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", - "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", - "dev": true, - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/corser": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz", @@ -6106,16 +5980,6 @@ "dev": true, "license": "MIT" }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -6196,27 +6060,6 @@ "node": ">= 0.4" } }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "dev": true, - "license": "MIT" - }, - "node_modules/encodeurl": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz", - "integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/enhanced-resolve": { "version": "5.26.1", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.26.1.tgz", @@ -6339,13 +6182,6 @@ "@esbuild/win32-x64": "0.28.2" } }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "dev": true, - "license": "MIT" - }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -6724,16 +6560,6 @@ "node": ">=0.10.0" } }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", @@ -6774,84 +6600,6 @@ "node": ">=12.0.0" } }, - "node_modules/express": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/express/-/express-5.3.0.tgz", - "integrity": "sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==", - "dev": true, - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.3.0", - "content-disposition": "^2.0.1", - "content-type": "^2.0.0", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "depd": "^2.0.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.8", - "qs": "^6.16.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.1.0", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/express-rate-limit": { - "version": "8.7.3", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.3.tgz", - "integrity": "sha512-zPLqDI2f0gV2WmGnacLf9XSSqn4VldRyP5LCzOwx0BKH40mO6+2PCFkoSsRO2jePx87/Kf6NUF6P2QOTKXHbQA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "ip-address": "^10.2.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/express-rate-limit" - }, - "peerDependencies": { - "express": ">= 4.11" - } - }, - "node_modules/express/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -6880,23 +6628,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fast-uri": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", - "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "BSD-3-Clause" - }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -6932,28 +6663,6 @@ "flat-cache": "^6.1.23" } }, - "node_modules/finalhandler": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", - "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -7011,26 +6720,6 @@ } } }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -7446,27 +7135,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/http-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", - "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "depd": "~2.0.0", - "inherits": "~2.0.4", - "setprototypeof": "~1.2.0", - "statuses": "~2.0.2", - "toidentifier": "~1.0.1" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/http-proxy": { "version": "1.18.1", "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", @@ -7517,27 +7185,10 @@ "dev": true, "license": "MPL-2.0" }, - "node_modules/iconv-lite": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", - "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/ignore": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", - "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "license": "MIT", "engines": { @@ -7571,13 +7222,6 @@ "node": ">=8" } }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "license": "ISC" - }, "node_modules/inline-style-parser": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.7.tgz", @@ -7585,26 +7229,6 @@ "dev": true, "license": "MIT" }, - "node_modules/ip-address": { - "version": "10.7.6", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz", - "integrity": "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, "node_modules/is-docker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", @@ -7676,13 +7300,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", - "dev": true, - "license": "MIT" - }, "node_modules/is-reference": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", @@ -7789,20 +7406,6 @@ "dev": true, "license": "MIT" }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-schema-typed": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz", - "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==", - "dev": true, - "license": "BSD-2-Clause" - }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -8638,33 +8241,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/media-typer": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", - "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/micromark": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.3.tgz", @@ -9311,33 +8887,6 @@ "node": ">=4" } }, - "node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", - "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -9499,37 +9048,6 @@ "node": ">=18" } }, - "node_modules/negotiator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", - "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", - "dev": true, - "license": "MIT", - "dependencies": { - "content-type": "^2.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/negotiator/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/node-addon-api": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", @@ -9538,16 +9056,6 @@ "license": "MIT", "optional": true }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-inspect": { "version": "1.13.4", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", @@ -9575,33 +9083,6 @@ "node": ">=12.20.0" } }, - "node_modules/on-finished": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz", - "integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, "node_modules/open": { "version": "10.2.0", "resolved": "https://registry.npmjs.org/open/-/open-10.2.0.tgz", @@ -9763,16 +9244,6 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -9793,17 +9264,6 @@ "node": ">=8" } }, - "node_modules/path-to-regexp": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", - "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", - "dev": true, - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -10242,24 +9702,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/proxy-addr": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", - "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -10324,36 +9766,6 @@ ], "license": "MIT" }, - "node_modules/range-parser": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", - "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/raw-body": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", - "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", - "dev": true, - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "http-errors": "~2.0.1", - "iconv-lite": "~0.7.0", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/react": { "version": "19.3.1", "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", @@ -10621,16 +10033,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -10682,23 +10084,6 @@ "url": "https://github.com/sponsors/oxc-project" } }, - "node_modules/router": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", - "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "depd": "^2.0.0", - "is-promise": "^4.0.0", - "parseurl": "^1.3.3", - "path-to-regexp": "^8.0.0" - }, - "engines": { - "node": ">= 18" - } - }, "node_modules/run-applescript": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", @@ -10748,13 +10133,6 @@ "dev": true, "license": "MIT" }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, - "license": "MIT" - }, "node_modules/sass": { "version": "1.100.0", "resolved": "https://registry.npmjs.org/sass/-/sass-1.100.0.tgz", @@ -10810,60 +10188,6 @@ "node": ">=10" } }, - "node_modules/send": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", - "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.1", - "mime-types": "^3.0.2", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/serve-static": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", - "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", - "dev": true, - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "dev": true, - "license": "ISC" - }, "node_modules/sharp": { "version": "0.35.5", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", @@ -11092,16 +10416,6 @@ "dev": true, "license": "MIT" }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/std-env": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", @@ -11693,16 +11007,6 @@ "dev": true, "license": "MIT" }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, "node_modules/totalist": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", @@ -11801,39 +11105,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/type-is": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", - "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", - "dev": true, - "license": "MIT", - "dependencies": { - "content-type": "^2.0.0", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/type-is/node_modules/content-type": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", - "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/typescript": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", @@ -12040,16 +11311,6 @@ "node": ">= 10.0.0" } }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/unplugin": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-2.3.11.tgz", @@ -12136,16 +11397,6 @@ } } }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/vaul-svelte": { "version": "1.0.0-next.7", "resolved": "https://registry.npmjs.org/vaul-svelte/-/vaul-svelte-1.0.0-next.7.tgz", @@ -12625,13 +11876,6 @@ "node": ">=0.10.0" } }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, - "license": "ISC" - }, "node_modules/ws": { "version": "8.22.2", "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.2.tgz", @@ -12700,16 +11944,6 @@ "url": "https://github.com/sponsors/colinhacks" } }, - "node_modules/zod-to-json-schema": { - "version": "3.25.2", - "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", - "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", - "dev": true, - "license": "ISC", - "peerDependencies": { - "zod": "^3.25.28 || ^4" - } - }, "node_modules/zwitch": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", diff --git a/ui/apps/chat/package.json b/ui/apps/chat/package.json index bc3f0d3315d1..b39c3c179b90 100644 --- a/ui/apps/chat/package.json +++ b/ui/apps/chat/package.json @@ -83,7 +83,9 @@ "@internationalized/date": "3.12.2", "@lezer/highlight": "1.2.5", "@lucide/svelte": "1.46.0", - "@modelcontextprotocol/sdk": "1.32.1", + "@modelcontextprotocol/client": "2.4.0", + "@modelcontextprotocol/node": "2.1.2", + "@modelcontextprotocol/server": "2.4.0", "@playwright/test": "1.56.1", "@storybook/addon-a11y": "10.6.6", "@storybook/addon-docs": "10.6.6", diff --git a/ui/apps/chat/sources.cmake b/ui/apps/chat/sources.cmake index 7e506c0eccf9..817bb9a22918 100644 --- a/ui/apps/chat/sources.cmake +++ b/ui/apps/chat/sources.cmake @@ -3,8 +3,9 @@ set(UI_SOURCE_GLOBS src/* static/* - # Llama UI, which the app compiles from source + # Llama UI and the harness, which the app compiles from source ../../lib/ui/src/lib/* + ../../lib/harness/src/* ) set(UI_SOURCE_FILES diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte index cc9b940df6de..aafbd3ad47bc 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte @@ -2,12 +2,11 @@ import { ChatAttachmentsListItem, DialogChatAttachmentsPreview, - DialogMcpResourcePreview, ScrollCarousel } from '#lib/components/app/index.ts'; import { ScrollCarouselVariant } from '#lib/enums/index.ts'; - import type { DatabaseMessageExtraMcpResource } from '#lib/types/index.ts'; - import { getAttachmentDisplayItems, isMcpPrompt, isMcpResource } from '#lib/utils/index.ts'; + import { extensions, findAttachmentRenderer } from '#lib/extensions/index.ts'; + import { getAttachmentDisplayItems } from '#lib/utils/index.ts'; interface Props { class?: string; @@ -44,8 +43,6 @@ }: Props = $props(); let carouselRef: ScrollCarousel | undefined = $state(); - let mcpResourcePreviewOpen = $state(false); - let mcpResourcePreviewExtra = $state(null); let previewFocusIndex = $state(0); let viewAllDialogOpen = $state(false); @@ -55,19 +52,15 @@ event?.stopPropagation(); event?.preventDefault(); - // Find the index of the clicked item among non-MCP attachments - const nonMcpItems = displayItems.filter((i) => !isMcpPrompt(i) && !isMcpResource(i)); - const index = nonMcpItems.findIndex((i) => i.id === item.id); + // items an extension draws stay out of the built-in preview, so they do not count + const renderers = extensions.contributions('attachmentRenderers'); + const previewItems = displayItems.filter((i) => !findAttachmentRenderer(renderers, i)); + const index = previewItems.findIndex((i) => i.id === item.id); previewFocusIndex = index >= 0 ? index : 0; viewAllDialogOpen = true; } - function openMcpResourcePreview(extra: DatabaseMessageExtraMcpResource) { - mcpResourcePreviewExtra = extra; - mcpResourcePreviewOpen = true; - } - $effect(() => { if (carouselRef && displayItems.length) { carouselRef.resetScroll(); @@ -83,7 +76,6 @@ {item} {limitToSingleRow} {onFileRemove} - onMcpResourcePreview={openMcpResourcePreview} onPreview={(i: ChatAttachmentDisplayItem, event?: MouseEvent) => openPreview(i, event)} {readonly} /> @@ -114,7 +106,3 @@ {previewFocusIndex} {uploadedFiles} /> - -{#if mcpResourcePreviewExtra} - -{/if} diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte index 5bb7a47d71ea..e405100199e4 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte @@ -1,18 +1,12 @@ -{#if isMcpPrompt(item)} - {@const mcpPrompt = - item.attachment?.type === AttachmentType.MCP_PROMPT - ? (item.attachment as DatabaseMessageExtraMcpPrompt) - : item.uploadedFile?.mcpPrompt - ? { - arguments: item.uploadedFile.mcpPrompt.arguments, - content: item.textContent ?? '', - name: item.name, - promptName: item.uploadedFile.mcpPrompt.promptName, - serverName: item.uploadedFile.mcpPrompt.serverName, - type: AttachmentType.MCP_PROMPT as const - } - : null} - {#if mcpPrompt} - onFileRemove(item.id) : undefined} - prompt={mcpPrompt} - {readonly} - /> - {/if} -{:else if isMcpResource(item)} - {@const mcpResource = item.attachment as DatabaseMessageExtraMcpResource} - - onMcpResourcePreview?.(mcpResource)} +{#if renderer} + onFileRemove(item.id) : undefined} + {readonly} /> {:else if item.isImage && item.preview} !isMcpPrompt(item) && !isMcpResource(item)) + .filter((item) => !findAttachmentRenderer(attachmentRenderers, item)) .map( (item): PreviewItem => ({ ...item, diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte index 0c44d125fb9c..5c4cfc69d82e 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte @@ -8,46 +8,34 @@ ChatFormCurrentWorkingDirectory, ChatFormInput, ChatFormInputFileInputInvisible, - ChatFormMcpResourcesList, - ChatFormPickers, - DialogMcpResourcesBrowser + ChatFormPickers } from '#lib/components/app/index.ts'; import { CHAT_FORM_SINGLE_ROW_MAX_TEXT_PX, CLIPBOARD_CONTENT_QUOTE_PREFIX, ICON_CLASS_DEFAULT, - INITIAL_FILE_SIZE, - PROMPT_CONTENT_SEPARATOR, SETTING_CONFIG_DEFAULT } from '#lib/constants/index.ts'; import { - ContentPartType, FileExtensionText, KeyboardKey, MimeTypeText, - SpecialFileType, - ToolSource + SpecialFileType } from '#lib/enums/index.ts'; + import { type ComposerHandle, extensions } from '#lib/extensions/index.ts'; import { useChatFormExpansion } from '#lib/hooks/use-chat-form-expansion.svelte.ts'; import { useChatFormPickers } from '#lib/hooks/use-chat-form-pickers.svelte.ts'; import { chatStore, conversationsStore, deviceStore, - mcpStore, modelsStore, serverStore, settingsStore, toolsStore, uiStore } from '#lib/stores/index.ts'; - import type { - FileMentionEntry, - GetPromptResult, - MCPPromptInfo, - MCPResourceInfo, - PromptMessage - } from '#lib/types/index.ts'; + import type { FileMentionEntry } from '#lib/types/index.ts'; import { AudioRecorder, convertToWav, @@ -155,27 +143,38 @@ showWorkingDirectory && (deviceStore.isMobile ? !conversationsStore.activeConversation : !cwd) ); + // what extensions add to the form: slash commands, the pickers they open, and + // attachments that wait outside the form's files + let contributedCommands = $derived(extensions.contributions('composerCommands')); + let contributedPickers = $derived(extensions.contributions('composerPickers')); + let contributedAttachments = $derived(extensions.contributions('composerAttachments')); + + const composer: ComposerHandle = { + addUploadedFile(file) { + uploadedFiles = [...uploadedFiles, file]; + onUploadedFilesChange?.(uploadedFiles); + }, + closePicker: () => pickers.closePicker(), + focusInput: () => inputRef?.focus(), + openPicker: (id, query) => pickers.openPicker(id, query), + updateUploadedFile(id, update) { + uploadedFiles = uploadedFiles.map((f) => (f.id === id ? update(f) : f)); + onUploadedFilesChange?.(uploadedFiles); + } + }; + const pickers = useChatFormPickers({ canCompact: () => chatStore.canCompact(conversationsStore.activeMessages), focusInput: refocusInput, getCaretOffset: () => inputRef?.getCaretOffset(), + getComposer: () => composer, + getContributedCommands: () => contributedCommands, getCwd: () => cwd, getPickersRef: () => pickersRef, getServerHome: () => toolsStore.serverHome ?? null, getShowModelSelector: () => showModelSelector, getValue: () => value, hasCwdTools: () => conversationsStore.preferences.hasEnabledCwdTools(), - // policy-aware, same rule as the agentic flow: MCP category on and at - // least one globally-enabled server whose group key is not disabled - hasPrompts: () => { - const prefs = conversationsStore.preferences; - - if (!prefs.isCategoryEnabled(ToolSource.MCP)) return false; - - return mcpStore - .getServers() - .some((s) => s.enabled && prefs.isServerToolsEnabled(s.id) && s.url.trim()); - }, onCompact: () => chatStore.compactConversation(), openModelSelector: () => chatFormActionsRef?.openModelSelector(), // TODO: no typed pickers with an on-screen keyboard for now: each mobile browser moves @@ -206,12 +205,6 @@ } } - // Resource Dialog State - let isResourceDialogOpen = $state(false); - let preSelectedResourceUri = $state(undefined); - - // MCP Servers Dialog State - let currentConfig = $derived(settingsStore.config); let pasteLongTextToFileLength = $derived.by(() => { @@ -264,7 +257,7 @@ !deviceStore.isMobile && !isExpanded && !hasAttachments && - !mcpStore.resources.hasAttachments && + !contributedAttachments.some((source) => source.hasPending()) && !value.includes('\n') ); // starts as it will settle, so a phone never draws a frame of the single row @@ -293,7 +286,7 @@ let isPickerOpen = $derived( pickers.isCommandPickerOpen || pickers.isMentionPickerOpen || - pickers.isPromptPickerOpen || + pickers.openPickerId !== null || pickers.isWorkingDirectoryPickerOpen ); @@ -488,72 +481,6 @@ } } - function handlePromptLoadStart( - placeholderId: string, - promptInfo: MCPPromptInfo, - args?: Record - ) { - pickers.closePromptPicker(); - - const promptName = promptInfo.title || promptInfo.name; - const placeholder: ChatUploadedFile = { - file: new File([], 'loading'), - id: placeholderId, - isLoading: true, - mcpPrompt: { - arguments: args ? { ...args } : undefined, - promptName: promptInfo.name, - serverName: promptInfo.serverName - }, - name: promptName, - size: INITIAL_FILE_SIZE, - type: SpecialFileType.MCP_PROMPT - }; - - uploadedFiles = [...uploadedFiles, placeholder]; - onUploadedFilesChange?.(uploadedFiles); - inputRef?.focus(); - } - - function handlePromptLoadComplete(placeholderId: string, result: GetPromptResult) { - const promptText = result.messages - ?.map((msg: PromptMessage) => { - if (typeof msg.content === 'string') { - return msg.content; - } - - if (msg.content.type === ContentPartType.TEXT) { - return msg.content.text; - } - - return ''; - }) - .filter(Boolean) - .join(PROMPT_CONTENT_SEPARATOR); - - uploadedFiles = uploadedFiles.map((f) => - f.id === placeholderId - ? { - ...f, - file: new File([promptText], `${f.name}${FileExtensionText.TXT}`, { - type: MimeTypeText.PLAIN - }), - isLoading: false, - size: promptText.length, - textContent: promptText - } - : f - ); - onUploadedFilesChange?.(uploadedFiles); - } - - function handlePromptLoadError(placeholderId: string, error: string) { - uploadedFiles = uploadedFiles.map((f) => - f.id === placeholderId ? { ...f, isLoading: false, loadError: error } : f - ); - onUploadedFilesChange?.(uploadedFiles); - } - // Deferred so the closing popover's focus scope tears down first - // bits-ui yanks a synchronous focus() back into the still-mounted popover. function refocusInput() { @@ -656,20 +583,19 @@ anchor={activePickerAnchor} commandQuery={pickers.commandQuery} commands={pickers.availableCommands} + {composer} isCommandPickerOpen={pickers.isCommandPickerOpen} isMentionPickerOpen={pickers.isMentionPickerOpen} - isPromptPickerOpen={pickers.isPromptPickerOpen} mentionQuery={pickers.mentionQuery} onCommandPickerClose={pickers.handleCommandPickerClose} onCommandSelect={pickers.handleCommandSelect} onMentionOpened={() => inputRef?.focus()} onMentionPickerClose={pickers.handleMentionPickerClose} onMentionSelect={handleMentionSelect} - onPromptLoadComplete={handlePromptLoadComplete} - onPromptLoadError={handlePromptLoadError} - onPromptLoadStart={handlePromptLoadStart} - onPromptPickerClose={pickers.handlePromptPickerClose} - promptSearchQuery={pickers.promptSearchQuery} + onPickerClose={pickers.handlePickerClose} + openPickerId={pickers.openPickerId} + pickerQuery={pickers.pickerQuery} + pickers={contributedPickers} scopePath={pickers.mentionScopePath} /> @@ -764,15 +690,9 @@ {placeholder} /> - {#if mcpStore.resources.hasAttachments} - { - preSelectedResourceUri = uri; - isResourceDialogOpen = true; - }} - /> - {/if} + {#each contributedAttachments as source (source)} + + {/each}
@@ -833,16 +753,3 @@ /> {/if} - - { - mcpStore.attachResource(resource.uri); - }} - onOpenChange={(newOpen: boolean) => { - if (!newOpen) { - preSelectedResourceUri = undefined; - } - }} - preSelectedUri={preSelectedResourceUri} -/> diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDrawer.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDrawer.svelte index b777b7c00117..63a1a933395b 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDrawer.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDrawer.svelte @@ -171,7 +171,7 @@ {@render groupRow(group)} {/each} - {#each toolsPanel.mcpGroups as group (group.key)} + {#each toolsPanel.providerGroups as group (group.key)} {@render groupRow(group)} {/each}
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte index ce32bdf3113e..a55c259a8f11 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte @@ -6,11 +6,10 @@ import { Check, ChevronDown, ChevronRight, Info, Loader2, PencilRuler } from '@lucide/svelte'; import { ATTACHMENT_MENU_TEXT, CLI_FLAGS, ICON_CLASS_DEFAULT } from '#lib/constants/index.ts'; import { useToolsPanel } from '#lib/hooks/use-tools-panel.svelte.ts'; - import { mcpStore, toolsStore, uiStore } from '#lib/stores/index.ts'; + import { toolsStore } from '#lib/stores/index.ts'; import type { ToolGroup } from '#lib/types/index.ts'; const toolsPanel = useToolsPanel(); - const hasMcpServersAvailable = $derived(mcpStore.getServers().length > 0); open && toolsPanel.handleOpen()}> @@ -40,18 +39,17 @@ - - {#if uiStore.isMcpShown} + {#each toolsPanel.providerHints as hint (hint.toolsLabel)} - {hasMcpServersAvailable ? 'Enable' : 'Add'} MCP Server(s) to access + {hint.action} - MCP Tools. + {hint.toolsLabel}. - {/if} + {/each} {:else if toolsStore.error}
Failed to load tools
@@ -70,7 +68,7 @@ {@render groupRow(group)} {/each} - {#each toolsPanel.mcpGroups as group (group.key)} + {#each toolsPanel.providerGroups as group (group.key)} {@render groupRow(group)} {/each} diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormPickers/ChatFormPickerCommand.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormPickers/ChatFormPickerCommand.svelte index 299ebf682592..3fdcfc6c9d9e 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormPickers/ChatFormPickerCommand.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormPickers/ChatFormPickerCommand.svelte @@ -121,7 +121,7 @@ showSearchInput={false} > {#snippet item(command, index, isSelected)} - {@const Icon = CHAT_FORM_COMMAND_ICONS[command.action]} + {@const Icon = 'action' in command ? CHAT_FORM_COMMAND_ICONS[command.action] : command.icon} import ChatFormPickerCommand from './ChatFormPickerCommand.svelte'; - import ChatFormPickerMcpPrompts from './ChatFormPickerMcpPrompts/ChatFormPickerMcpPrompts.svelte'; import ChatFormPickerMention from './ChatFormPickerMention.svelte'; import type { - ChatFormCommand, - FileMentionEntry, - GetPromptResult, - MCPPromptInfo - } from '#lib/types/index.ts'; + ComposerHandle, + ComposerPicker, + ComposerPickerExports + } from '#lib/extensions/index.ts'; + import type { ChatFormCommand, FileMentionEntry } from '#lib/types/index.ts'; interface Props { /** What every picker's popover floats by. */ @@ -15,49 +14,46 @@ isCommandPickerOpen?: boolean; commandQuery?: string; commands?: ChatFormCommand[]; - isPromptPickerOpen?: boolean; - promptSearchQuery?: string; + /** Handed to the pickers extensions contribute. */ + composer: ComposerHandle; + /** The pickers extensions contribute. */ + pickers?: ComposerPicker[]; + /** The contributed picker that is open, if any. */ + openPickerId?: string | null; + pickerQuery?: string; isMentionPickerOpen?: boolean; mentionQuery?: string; scopePath?: string | null; onCommandPickerClose?: () => void; onCommandSelect?: (command: ChatFormCommand) => void; - onPromptPickerClose?: () => void; + onPickerClose?: () => void; onMentionPickerClose?: () => void; onMentionOpened?: () => void; onMentionSelect?: (entry: FileMentionEntry) => void; - onPromptLoadStart?: ( - placeholderId: string, - promptInfo: MCPPromptInfo, - args?: Record - ) => void; - onPromptLoadComplete?: (placeholderId: string, result: GetPromptResult) => void; - onPromptLoadError?: (placeholderId: string, error: string) => void; } let { anchor, commandQuery, commands = [], + composer, isCommandPickerOpen, isMentionPickerOpen, - isPromptPickerOpen, mentionQuery, onCommandPickerClose, onCommandSelect, onMentionOpened, onMentionPickerClose, onMentionSelect, - onPromptLoadComplete, - onPromptLoadError, - onPromptLoadStart, - onPromptPickerClose, - promptSearchQuery, + onPickerClose, + openPickerId = null, + pickerQuery, + pickers = [], scopePath }: Props = $props(); let commandPickerRef: ChatFormPickerCommand | undefined = $state(undefined); - let promptPickerRef: ChatFormPickerMcpPrompts | undefined = $state(undefined); + let contributedPickerRefs: Record = $state({}); let mentionPickerRef: ChatFormPickerMention | undefined = $state(undefined); /** Delegate keyboard events to the active picker child; true if handled. */ @@ -66,7 +62,7 @@ return true; } - if (isPromptPickerOpen && promptPickerRef?.handleKeydown(event)) { + if (openPickerId !== null && contributedPickerRefs[openPickerId]?.handleKeydown(event)) { return true; } @@ -88,16 +84,18 @@ query={commandQuery ?? ''} /> - +{#each pickers as picker (picker.id)} + {@const isOpen = openPickerId === picker.id} + + {})} + query={isOpen ? (pickerQuery ?? '') : ''} + /> +{/each} { - if (message.role !== MessageRole.USER) return null; - - if (message.content.trim()) return null; - - if (!message.extra || message.extra.length !== 1) return null; - - const extra = message.extra[0]; - - if (extra.type === AttachmentType.MCP_PROMPT) { - return extra as DatabaseMessageExtraMcpPrompt; - } - - return null; - }); + // an extension can claim a message and draw it in place of the default + let messageRenderer = $derived( + findMessageRenderer(extensions.contributions('messageRenderers'), message) + ); $effect(() => { const pendingId = chatStore.pendingEditMessageId; @@ -241,7 +223,7 @@ const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id); if (conversationDeleted) { - goto(ROUTES.START); + goto(resolve(ROUTES.START)); } return; @@ -282,7 +264,7 @@ const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id); if (conversationDeleted) { - goto(ROUTES.START); + goto(resolve(ROUTES.START)); } } else { chatActions.delete(message); @@ -362,7 +344,7 @@ isEditing = false; if (conversationDeleted) { - goto(ROUTES.START); + goto(resolve(ROUTES.START)); } else { focusMainChatForm(); } @@ -425,8 +407,8 @@
{#if message.role === MessageRole.SYSTEM} - {:else if mcpPromptExtra} - + {:else if messageRenderer} + {:else if isCompaction} {:else if isSynthetic} diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte index 2ed631a4f4ae..9f2c601c3dfd 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte @@ -4,7 +4,7 @@ import { CollapsibleContentBlock } from '#lib/components/app/index.ts'; import { ICON_CLASS_DEFAULT, ICON_CLASS_SPIN } from '#lib/constants/index.ts'; import { AgenticSectionType } from '#lib/enums/index.ts'; - import { mcpStore } from '#lib/stores/index.ts'; + import { serverStore, toolsStore } from '#lib/stores/index.ts'; import type { AgenticSection, SearchResult } from '#lib/types/index.ts'; import { buildProxiedIconUrl, @@ -33,7 +33,9 @@ // Same icon-resolution chain as ChatMessageToolCallBlockDefault so // MCP-server branding is consistent across both views. Spinner wins // while the call is in flight so the user sees execution status. - const iconUrl = $derived(showSpinner ? null : mcpStore.getServerFaviconForTool(section.toolName)); + const iconUrl = $derived(showSpinner ? null : toolsStore.getToolIcon(section.toolName)); + // favicons of the results go through the server's CORS proxy when it has one + const isProxyAvailable = $derived(serverStore.props?.cors_proxy_enabled ?? false); const icon = $derived(showSpinner ? Loader2 : undefined); const iconClass = $derived(showSpinner ? ICON_CLASS_SPIN : ICON_CLASS_DEFAULT); @@ -83,7 +85,7 @@ {#snippet pill(result: SearchResult)} - {@const faviconUrl = buildProxiedIconUrl(faviconForUrl(result.url), mcpStore.isProxyAvailable)} + {@const faviconUrl = buildProxiedIconUrl(faviconForUrl(result.url), isProxyAvailable)} {@const safeUrl = sanitizeExternalUrl(result.url)} {@const showHoverCard = safeUrl !== null && hasDetails(result)} {#if safeUrl} @@ -91,7 +93,7 @@ {#if faviconUrl} @@ -116,7 +118,7 @@ {result.title} diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ToolCallBlock.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ToolCallBlock.svelte index cafb077e5366..278eef10ff23 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ToolCallBlock.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ToolCallBlock.svelte @@ -4,7 +4,7 @@ // - the collapsible wrapper (defaults to CollapsibleContentBlock; // `exec_shell_command` swaps in CollapsibleTerminalBlock via the // `wrapper` prop); - // - the icon, spinner state, and MCP favicon fallback chain; + // - the icon, spinner state, and tool provider icon fallback chain; // - the status subtitle pill. // Components supply only their `meta`, a title snippet, and a body // snippet - everything around them is this single source of truth. @@ -13,7 +13,7 @@ import { CollapsibleContentBlock } from '#lib/components/app/index.ts'; import { ICON_CLASS_DEFAULT, ICON_CLASS_SPIN } from '#lib/constants/index.ts'; import { AgenticSectionType } from '#lib/enums/index.ts'; - import { mcpStore } from '#lib/stores/index.ts'; + import { toolsStore } from '#lib/stores/index.ts'; import type { AgenticSection, ToolUiEntry } from '#lib/types/index.ts'; import { getToolUi } from '#lib/utils/index.ts'; import type { Component, Snippet } from 'svelte'; @@ -104,13 +104,11 @@ const toolIconClass = $derived( spinIconWhenActive && showSpinner ? ICON_CLASS_SPIN : ICON_CLASS_DEFAULT ); - // Drop the MCP favicon while the spinner is on so the title row + // Drop the provider's icon while the spinner is on so the title row // signals "in flight" without being overwritten by server branding. - const mcpServerFavicon = $derived( - showSpinner ? null : mcpStore.getServerFaviconForTool(section.toolName) - ); + const providerIcon = $derived(showSpinner ? null : toolsStore.getToolIcon(section.toolName)); const iconUrl = $derived( - showSpinner || (toolUi?.icon ?? null) || !mcpServerFavicon ? null : mcpServerFavicon + showSpinner || (toolUi?.icon ?? null) || !providerIcon ? null : providerIcon ); // No subtitle while the call is in flight - the spinner already diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte index c01af20d6f4b..d5c5509568c2 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte @@ -10,10 +10,11 @@ TAB_SURFACE_IDLE_CLASS, UI_DATA_ATTRS } from '#lib/constants/index.ts'; + import type { ResolvedPathname } from '$app/types'; import type { Component } from 'svelte'; interface Tab { - href: string; + href: ResolvedPathname; /** Marks the new-chat tab. */ icon?: Component; id: string; diff --git a/ui/apps/chat/src/lib/components/app/chat/index.ts b/ui/apps/chat/src/lib/components/app/chat/index.ts index fce3962c4fe4..6e9aa7ae970e 100644 --- a/ui/apps/chat/src/lib/components/app/chat/index.ts +++ b/ui/apps/chat/src/lib/components/app/chat/index.ts @@ -52,26 +52,12 @@ export { default as ChatAttachmentsList } from './ChatAttachments/ChatAttachmentsList/ChatAttachmentsList.svelte'; /** - * Renders a single attachment item based on its type (image, file, MCP prompt, or MCP resource). - * Delegates to specialized sub-components: ChatAttachmentsListItemThumbnailImage, ChatAttachmentsListItemThumbnailFile, - * ChatAttachmentsListItemMcpPrompt, or ChatAttachmentsListItemMcpResource. + * Renders a single attachment item based on its type (image or file). + * Delegates to specialized sub-components: ChatAttachmentsListItemThumbnailImage or ChatAttachmentsListItemThumbnailFile. + * An item an extension claims (an MCP prompt or resource) is drawn by that extension's attachment renderer. */ export { default as ChatAttachmentsListItem } from './ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItem.svelte'; -/** - * Displays MCP Prompt attachment with expandable content preview. - * Shows server name, prompt name, and allows expanding to view full prompt arguments - * and content. Used when user selects a prompt from ChatFormPickerMcpPrompts. - */ -export { default as ChatAttachmentsListItemMcpPrompt } from './ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemMcpPrompt.svelte'; - -/** - * Displays a single MCP Resource attachment with icon, name, and server info. - * Shows loading/error states and supports remove action. - * Used within ChatAttachmentMcpResources for individual resource display. - */ -export { default as ChatAttachmentsListItemMcpResource } from './ChatAttachments/ChatAttachmentsList/ChatAttachmentsListItem/ChatAttachmentsListItemMcpResource.svelte'; - /** * Thumbnail for non-image file attachments. Displays file type icon based on extension, * file name (truncated), and file size. @@ -102,10 +88,9 @@ export { default as ChatAttachmentsPreviewCurrentItem } from './ChatAttachments/ * FORM * * Components for the chat input area. The form handles user input, file attachments, - * audio recording, and MCP prompts & resources selection. It integrates with multiple stores: + * audio recording, and what extensions add (MCP prompts & resources selection). It integrates with multiple stores: * - `chatStore` for message submission and generation control * - `modelsStore` for model selection and validation - * - `mcpStore` for MCP prompt browsing and loading * * The form exposes a public API for programmatic control from parent components * (focus, height reset, model selector, validation). @@ -116,12 +101,13 @@ export { default as ChatAttachmentsPreviewCurrentItem } from './ChatAttachments/ * **ChatForm** - Main chat input component with rich features * * The primary input interface for composing and sending chat messages. - * Orchestrates text input, file attachments, audio recording, and MCP prompts. + * Orchestrates text input, file attachments, audio recording, and what extensions + * add to it: slash commands, pickers and pending attachments (see `#lib/extensions/points/composer.ts`). * Used by ChatScreenForm and ChatMessageEditForm for both new conversations and message editing. * * **Architecture:** * - Composes ChatFormInput (a live-preview markdown editor), ChatFormActions, - * and ChatFormPickerMcpPrompts + * and ChatFormPickers * - Manages file upload state via `uploadedFiles` bindable prop * - Integrates with ModelsSelectorDropdown for model selection in router mode * - Communicates with parent via callbacks (onSubmit, onFilesAdd, onStop, etc.) @@ -130,14 +116,14 @@ export { default as ChatAttachmentsPreviewCurrentItem } from './ChatAttachments/ * - IME-safe Enter key handling (waits for composition end) * - Shift+Enter for newline, Enter for submit * - Paste handler for files and long text (> {pasteLongTextToFileLen} chars → file conversion) - * - Keyboard shortcut `/` triggers MCP prompt picker + * - Typing `/` opens the slash-command picker * * **Features:** * - Auto-growing live-preview markdown editor with placeholder * - File upload via button dropdown (images/text/PDF), drag-drop, or paste * - Audio recording with WAV conversion (when model supports audio) - * - MCP prompt picker with search and argument forms - * - MCP reource picker with component to list attached resources at the bottom of Chat Form + * - Slash commands, pickers and pending attachments contributed by extensions: the MCP + * prompt picker and the list of attached MCP resources come from the MCP extension * - Model selector integration (router mode) * - Loading state with stop button, disabled state for errors * @@ -229,12 +215,6 @@ export { default as ChatFormContextGauge } from './ChatForm/ChatFormContextGauge */ export { default as ChatFormInputFileInputInvisible } from './ChatForm/ChatFormInput/ChatFormInputFileInputInvisible.svelte'; -/** - * Displays MCP Resource attachments as a horizontal carousel. - * Shows resource name, URI, and allows clicking to view resource content. - */ -export { default as ChatFormMcpResourcesList } from './ChatForm/ChatFormMcpResourcesList.svelte'; - /** * The message editor: a live-preview MarkdownEditor. Plain text reads like a * textarea; markdown blocks render as in chat messages until the cursor enters @@ -253,65 +233,6 @@ export { default as ChatFormInput } from './ChatForm/ChatFormInput/ChatFormInput */ export { default as ChatFormCurrentWorkingDirectory } from './ChatForm/ChatFormCurrentWorkingDirectory/ChatFormCurrentWorkingDirectory.svelte'; -/** - * **ChatFormPickerMcpPrompts** - MCP prompt selection interface - * - * Floating picker for browsing and selecting MCP Server Prompts. - * Triggered by typing `/` in the chat input or choosing `MCP Prompt` option in ChatFormActionAddDropdown. - * Loads prompts from connected MCP servers and allows users to select and configure them. - * - * **Architecture:** - * - Fetches available prompts from mcpStore - * - Manages selection state and keyboard navigation internally - * - Delegates argument input to ChatFormPromptPickerArgumentForm - * - Communicates prompt loading lifecycle via callbacks - * - * **Prompt Loading Flow:** - * 1. User selects prompt → `onPromptLoadStart` called with placeholder ID - * 2. Prompt content fetched from MCP server asynchronously - * 3. On success → `onPromptLoadComplete` with full prompt data - * 4. On failure → `onPromptLoadError` with error details - * - * **Features:** - * - Search/filter prompts by name across all connected servers - * - Keyboard navigation (↑/↓ to navigate, Enter to select, Esc to close) - * - Argument input forms for prompts with required parameters - * - Autocomplete suggestions for argument values - * - Loading states with skeleton placeholders - * - Server information header per prompt for visual identification - * - * **Exported API:** - * - `handleKeydown(event): boolean` - Process keyboard events, returns true if handled - * - * @example - * ```svelte - * showPicker = false} - * onPromptLoadStart={(id, info) => addPlaceholder(id, info)} - * onPromptLoadComplete={(id, result) => replacePlaceholder(id, result)} - * onPromptLoadError={(id, error) => handleError(id, error)} - * /> - * ``` - */ -export { default as ChatFormPickerMcpPrompts } from './ChatForm/ChatFormPickers/ChatFormPickerMcpPrompts/ChatFormPickerMcpPrompts.svelte'; - -/** - * Form for entering MCP prompt arguments. Displays input fields for each - * required argument defined by the prompt. Validates input and submits - * when all required fields are filled. Shows argument descriptions as hints. - */ -export { default as ChatFormPromptPickerArgumentForm } from './ChatForm/ChatFormPickers/ChatFormPickerMcpPrompts/ChatFormPromptPickerArgumentForm.svelte'; - -/** - * Single argument input field with autocomplete suggestions. Fetches suggestions - * from MCP server based on argument type. Supports keyboard navigation through - * suggestions list. Used within ChatFormPromptPickerArgumentForm. - */ -export { default as ChatFormPromptPickerArgumentInput } from './ChatForm/ChatFormPickers/ChatFormPickerMcpPrompts/ChatFormPromptPickerArgumentInput.svelte'; - /** * Shared popover wrapper for inline picker popovers (prompts, resources). * Provides consistent positioning, styling, and open/close behavior. @@ -322,24 +243,17 @@ export { default as ChatFormPickerPopover } from './ChatForm/ChatFormPickers/Cha * Generic scrollable list for picker popovers. Provides search input, * scroll-into-view for keyboard navigation, loading skeletons, empty state, * and optional footer. Uses Svelte 5 snippets for item/skeleton/footer rendering. - * Shared by ChatFormPickerMcpPrompts and ChatFormPickerMention. + * Shared by ChatFormPickerMention and the MCP extension's prompt picker. */ export { default as ChatFormPickerList } from './ChatForm/ChatFormPickers/ChatFormPicker/ChatFormPickerList.svelte'; /** * Generic button wrapper for picker list items. Provides consistent styling, * hover/selected states, and data-picker-index attribute for scroll-into-view. - * Shared by ChatFormPickerMcpPrompts and ChatFormPickerMention. + * Shared by ChatFormPickerMention and the MCP extension's prompt picker. */ export { default as ChatFormPickerListItem } from './ChatForm/ChatFormPickers/ChatFormPicker/ChatFormPickerListItem.svelte'; -/** - * Generic header for picker items displaying server favicon, label, item title, - * and optional description. Accepts `titleExtra` and `subtitle` snippets for - * custom content like badges or URIs. Shared by both pickers. - */ -export { default as ChatFormPickerItemHeader } from './ChatForm/ChatFormPickers/ChatFormPicker/ChatFormPickerItemHeader.svelte'; - /** * Generic skeleton loading placeholder for picker list items. Configurable * title width and optional badge skeleton. Shared by both pickers. @@ -362,8 +276,8 @@ export { default as ChatFormPickerMention } from './ChatForm/ChatFormPickers/Cha export { default as ChatFormPickerCommand } from './ChatForm/ChatFormPickers/ChatFormPickerCommand.svelte'; /** - * Hosts the chat-form pickers (slash-command, MCP prompt, file mention) - * and delegates keyboard events to the active one. + * Hosts the chat-form pickers (slash-command, file mention and the ones + * extensions contribute) and delegates keyboard events to the active one. */ export { default as ChatFormPickers } from './ChatForm/ChatFormPickers/ChatFormPickers.svelte'; @@ -528,13 +442,6 @@ export { default as ChatMessageContextMenu } from './ChatMessages/ChatMessageAct export { default as ChatMessageStatistics } from './ChatMessages/ChatMessageStatistics/ChatMessageStatistics.svelte'; export { default as ChatMessageStatisticsBadge } from './ChatMessages/ChatMessageStatistics/ChatMessageStatisticsBadge.svelte'; -/** - * MCP prompt display in user messages. Shows when user selected an MCP prompt - * via ChatFormPickerMcpPrompts. Displays server name, prompt name, and expandable - * content preview. Stored in message.extra as DatabaseMessageExtraMcpPrompt. - */ -export { default as ChatMessageMcpPrompt } from './ChatMessages/ChatMessage/ChatMessageMcpPrompt/ChatMessageMcpPrompt.svelte'; - /** * Synthetic working-directory-change message. Rendered in place of a user * bubble when the message content parses as a cwd message (see @@ -558,13 +465,6 @@ export { default as ChatMessageSynthetic } from './ChatMessages/ChatMessage/Chat */ export { default as ChatMessageCompaction } from './ChatMessages/ChatMessage/ChatMessageCompaction.svelte'; -/** - * Formatted content display for MCP prompt messages. Renders the full prompt - * content with arguments in a readable format. Used within ChatMessageMcpPrompt - * for the expanded view. - */ -export { default as ChatMessageMcpPromptContent } from './ChatMessages/ChatMessage/ChatMessageMcpPrompt/ChatMessageMcpPromptContent.svelte'; - /** * Assistant message display component. Renders assistant responses with left-aligned styling. * Supports both plain markdown content (via MarkdownContent) and agentic content with tool calls diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte index 6d5115a6c067..541db9bec157 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte +++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte @@ -26,6 +26,7 @@ url.searchParams.set(URL_PARAMS.MODEL, model); handleOpenChange(false); + // eslint-disable-next-line svelte/no-navigation-without-resolve -- the current page's own URL with its query changed, not a link to resolve goto(url.toString()); } diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte index 2b4e0b71dad3..b8c227945455 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte +++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte @@ -6,13 +6,13 @@ ICON_CLASS_DEFAULT, ICON_CLASS_SM, ICON_CLASS_XS, - SIDEBAR_ACTIONS_ITEMS, - SIDEBAR_FOOTER_ITEMS + SIDEBAR_ACTIONS_ITEMS } from '#lib/constants/index.ts'; import { KeyboardKey, SidebarAction } from '#lib/enums/index.ts'; + import { extensions, type NavigationItem } from '#lib/extensions/index.ts'; import { RouterService } from '#lib/services/router.service.ts'; import { conversationsStore, deviceStore, uiStore } from '#lib/stores/index.ts'; - import { formatRelativeTime, isIMEComposing } from '#lib/utils/index.ts'; + import { formatRelativeTime, isIMEComposing, sidebarFooterItems } from '#lib/utils/index.ts'; import { goto } from '$app/navigation'; import type { Component } from 'svelte'; @@ -20,9 +20,11 @@ open: boolean; /** Runs a sidebar action picked from the actions section. */ onAction?: (action: SidebarAction) => void; + /** Opens an extension's item picked from the actions section. */ + onContributed?: (item: NavigationItem) => void; } - let { onAction, open = $bindable() }: Props = $props(); + let { onAction, onContributed, open = $bindable() }: Props = $props(); interface SearchEntry { icon: Component; @@ -71,22 +73,26 @@ ); const actionEntries = $derived.by((): SearchEntry[] => - // every sidebar action the sidebar shows but Search itself, which is what opened this - // dialog, and the models manager on a phone, which picks its models in the selector - [...SIDEBAR_ACTIONS_ITEMS, ...SIDEBAR_FOOTER_ITEMS] + // every sidebar action the sidebar shows but Search itself, which is what opened this dialog, and the + // models manager on a phone, which picks its models in the selector; extensions' items among them + [...SIDEBAR_ACTIONS_ITEMS, ...sidebarFooterItems(extensions.contributions('navigation'))] .filter( (item) => - item.action && + (item.action || item.contributed) && item.action !== SidebarAction.SEARCH && uiStore.isSidebarActionShown(item.action) && (item.action !== SidebarAction.MANAGE_MODELS || !deviceStore.isMobile) ) - .map((item) => ({ - icon: item.icon, - id: `action-${item.action}`, - keys: item.keys, - label: item.tooltip, - run: () => close(() => onAction?.(item.action!)) + .map(({ action, contributed, icon, keys, tooltip }) => ({ + icon, + id: `action-${action ?? contributed?.id}`, + keys, + label: tooltip, + run: () => + close(() => { + if (action) onAction?.(action); + else if (contributed) onContributed?.(contributed); + }) })) .filter((entry) => matches(entry.label)) ); diff --git a/ui/apps/chat/src/lib/components/app/dialogs/index.ts b/ui/apps/chat/src/lib/components/app/dialogs/index.ts index 5b3ca761d6f4..c7c5db37a183 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/index.ts +++ b/ui/apps/chat/src/lib/components/app/dialogs/index.ts @@ -10,22 +10,6 @@ * */ -/** - * **DialogMcpServerAddNew** - Add new MCP server dialog - * - * Modal dialog for adding a new MCP server with URL and optional headers. - * Validates URL format and integrates with mcpStore and conversationsStore. - */ -export { default as DialogMcpServerAddNew } from './DialogMcpServerAddNew.svelte'; - -/** - * **DialogMcpServers** - MCP servers dialog shown from the chat form - * - * Shows the same MCP server list as the `/mcp-servers` route inside a modal - * dialog. - */ -export { default as DialogMcpServers } from './DialogMcpServers.svelte'; - /** * **DialogSettingsChat** - Chat settings shown in a modal dialog * @@ -447,60 +431,6 @@ export { default as DialogModelNotAvailable } from './DialogModelNotAvailable.sv */ export { default as DialogConversationSelection } from './DialogConversationSelection.svelte'; -/** - * **DialogMcpResourcesBrowser** - MCP resources browser dialog - * - * Dialog for browsing and attaching MCP resources to chat context. - * Displays resources from connected MCP servers in a tree structure - * with preview panel and multi-select support. - * - * **Architecture:** - * - Uses ShadCN Dialog with two-panel layout - * - Left panel: McpResourcesBrowser with tree navigation - * - Right panel: McpResourcePreview for selected resource - * - Integrates with mcpStore for resource fetching and attachment - * - * **Features:** - * - Tree-based resource navigation by server and path - * - Single and multi-select with shift+click - * - Resource preview with content display - * - Quick attach button per resource - * - Batch attach for multiple selections - * - * @example - * ```svelte - * - * ``` - */ -export { default as DialogMcpResourcesBrowser } from './DialogMcpResourcesBrowser.svelte'; - -/** - * **DialogMcpResourcePreview** - MCP resource content preview - * - * Dialog for previewing the content of a stored MCP resource attachment. - * Displays the resource content with syntax highlighting for code, - * image rendering for images, and plain text for other content. - * - * **Features:** - * - Syntax highlighted code preview - * - Image rendering for image resources - * - Copy to clipboard and download actions - * - Server name and favicon display - * - MIME type badge - * - * @example - * ```svelte - * - * ``` - */ -export { default as DialogMcpResourcePreview } from './DialogMcpResourcePreview.svelte'; - /** * **DialogMermaidPreview** - Full-screen Mermaid diagram preview with zoom and pan * diff --git a/ui/apps/chat/src/lib/components/app/index.ts b/ui/apps/chat/src/lib/components/app/index.ts index a0a14c6173af..a1ea03a74b8d 100644 --- a/ui/apps/chat/src/lib/components/app/index.ts +++ b/ui/apps/chat/src/lib/components/app/index.ts @@ -4,7 +4,6 @@ export * from './chat'; export * from './content'; export * from './dialogs'; export * from './forms'; -export * from './mcp'; export * from './misc'; export * from './settings'; export * from './models'; diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte index 136acf32e204..ca6b922920fe 100644 --- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte +++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte @@ -73,7 +73,7 @@ aria-label="View base model on HuggingFace" class="shrink-0 text-muted-foreground transition-colors hover:text-foreground" href={HuggingFaceService.getModelUrl(baseModels[0])} - rel="noopener noreferrer" + rel="external noopener noreferrer" target="_blank" > @@ -86,7 +86,7 @@
@@ -758,9 +773,18 @@ - + - + +{#each navigationItems as item (item.id)} + {#if item.dialog} + dialogItem === item, (open) => setItemDialogOpen(item, open)} /> + {/if} +{/each} @@ -770,6 +794,8 @@ + +