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/common/arg.cpp b/common/arg.cpp
index 192f70607f1e..4503b19bc7d4 100644
--- a/common/arg.cpp
+++ b/common/arg.cpp
@@ -3426,6 +3426,22 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
params.ui_mcp_proxy = value;
}
).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_UI_MCP_PROXY"));
+ add_opt(common_arg(
+ {"--ui-storage"},
+ {"--no-ui-storage"},
+ "experimental: keep UI conversations and settings on disk instead of only in the browser - anyone who can reach the server can read them (default: disabled)",
+ [](common_params & params, bool value) {
+ params.ui_storage = value;
+ }
+ ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_UI_STORAGE"));
+ add_opt(common_arg(
+ {"--ui-storage-dir"}, "PATH",
+ "directory for UI storage, implies --ui-storage (default: llama.cpp/ui in the user data directory)",
+ [](common_params & params, const std::string & value) {
+ params.ui_storage = true;
+ params.ui_storage_dir = value;
+ }
+ ).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_UI_STORAGE_DIR"));
add_opt(common_arg(
{"--tools"}, "TOOL1,TOOL2,...",
"experimental: whether to enable built-in tools for AI agents - do not enable in untrusted environments (default: no tools)\n"
diff --git a/common/common.cpp b/common/common.cpp
index b009d460d697..80cf1f157a88 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -1014,6 +1014,24 @@ std::filesystem::path fs_get_config_directory() {
return config_directory / "llama.cpp";
}
+std::filesystem::path fs_get_data_directory() {
+ std::filesystem::path data_directory;
+#if defined(_WIN32)
+ data_directory = common_get_path_from_env("APPDATA");
+ if (data_directory.empty()) {
+ throw std::runtime_error("Failed to find %APPDATA% directory");
+ }
+#elif defined(__APPLE__)
+ data_directory = get_home_directory() / "Library/Application Support";
+#else
+ data_directory = common_get_path_from_env("XDG_DATA_HOME");
+ if (data_directory.empty()) {
+ data_directory = get_home_directory() / ".local/share";
+ }
+#endif
+ return data_directory / "llama.cpp";
+}
+
std::filesystem::path fs_get_cache_file(const std::string & filename) {
GGML_ASSERT(filename.find(DIRECTORY_SEPARATOR) == std::string::npos);
const std::filesystem::path cache_directory = fs_get_cache_directory();
diff --git a/common/common.h b/common/common.h
index e16bee7c1629..48f9ef99572a 100644
--- a/common/common.h
+++ b/common/common.h
@@ -703,6 +703,8 @@ struct common_params {
bool ui = true;
bool ui_mcp_proxy = false;
std::string ui_config_json;
+ bool ui_storage = false; // keep UI conversations and settings on disk
+ std::string ui_storage_dir; // empty: fs_get_data_directory() / "ui"
// "advanced" endpoints are disabled by default for better security
bool endpoint_slots = true;
@@ -960,6 +962,7 @@ inline bool common_create_directories(const std::filesystem::path & path, std::e
std::filesystem::path fs_get_cache_directory();
std::filesystem::path fs_get_cache_file(const std::string & filename);
std::filesystem::path fs_get_config_directory();
+std::filesystem::path fs_get_data_directory();
void fs_write_atomic(const std::filesystem::path & path, const std::string & data);
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/CMakeLists.txt b/tools/server/CMakeLists.txt
index 9f9393f98384..7403ce5aa0cd 100644
--- a/tools/server/CMakeLists.txt
+++ b/tools/server/CMakeLists.txt
@@ -23,6 +23,8 @@ add_library(${TARGET} STATIC
server-stream.h
server-tools.cpp
server-tools.h
+ server-storage.cpp
+ server-storage.h
server-mcp.cpp
server-mcp.h
server-schema.cpp
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..abb425cf3b57 100644
--- a/tools/server/README.md
+++ b/tools/server/README.md
@@ -203,6 +203,8 @@ For the full list of features, please refer to [server's changelog](https://gith
| `--ui-config, --webui-config JSON` | JSON that provides default UI settings (overrides UI defaults) (env: LLAMA_ARG_UI_CONFIG) |
| `--ui-config-file, --webui-config-file PATH` | JSON file that provides default UI settings (overrides UI defaults) (env: LLAMA_ARG_UI_CONFIG_FILE) |
| `--ui-mcp-proxy, --webui-mcp-proxy, --no-ui-mcp-proxy, --no-webui-mcp-proxy` | experimental: whether to enable MCP CORS proxy, for Llama Chat to reach public MCP servers without CORS headers; local and private addresses are refused - do not enable in untrusted environments (default: disabled) note: for security reasons, this will limit --cors-origins to localhost by default (env: LLAMA_ARG_UI_MCP_PROXY) |
+| `--ui-storage, --no-ui-storage` | experimental: keep UI conversations and settings on disk instead of only in the browser - anyone who can reach the server can read them (default: disabled) (env: LLAMA_ARG_UI_STORAGE) |
+| `--ui-storage-dir PATH` | directory for UI storage, implies --ui-storage (default: llama.cpp/ui in the user data directory) (env: LLAMA_ARG_UI_STORAGE_DIR) |
| `--tools TOOL1,TOOL2,...` | experimental: whether to enable built-in tools for AI agents - do not enable in untrusted environments (default: no tools) specify "all" to enable all tools available tools: read_file, file_glob_search, grep_search, exec_shell_command, write_file, edit_file, get_info note: for security reasons, this will limit --cors-origins to localhost by default (env: LLAMA_ARG_TOOLS) |
| `--tools-runtime OPTION` | experimental: run tools in a separate runtime environment (default: none, use host environment) available options: 'docker:', 'podman:': spin up a new container and reuse it for all invocations, clean up on server exit 'docker-container:', 'podman-container:': use an existing container by ID, won't stop on server exit 'ssh:': run tools on a remote POSIX host over SSH, key-based auth and a trusted host key are required
(env: LLAMA_ARG_TOOLS_RUNTIME) |
| `--allow-unauthenticated-tools` | allow server tools, MCP servers or MCP proxy on a non-loopback address without an API key - only for trusted networks (default: disabled) (env: LLAMA_ARG_ALLOW_UNAUTHENTICATED_TOOLS) |
@@ -389,7 +391,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-context.cpp b/tools/server/server-context.cpp
index 36082df89d7a..e8c09724fa62 100644
--- a/tools/server/server-context.cpp
+++ b/tools/server/server-context.cpp
@@ -5663,6 +5663,7 @@ static json get_res_props(const server_context_meta & meta, const common_params
{ "build_info", meta.build_info },
{ "is_sleeping", is_sleeping },
{ "cors_proxy_enabled", params.ui_mcp_proxy },
+ { "ui_storage", params.ui_storage },
};
if (!params.server_connect_code.empty()) {
diff --git a/tools/server/server-models.cpp b/tools/server/server-models.cpp
index 5d5992c08d3a..60bd889b5539 100644
--- a/tools/server/server-models.cpp
+++ b/tools/server/server-models.cpp
@@ -296,6 +296,9 @@ static void unset_reserved_args(common_preset & preset, bool unset_model_args) {
preset.unset_option("LLAMA_ARG_CONNECT_CODE");
preset.unset_option("LLAMA_ARG_MCP_SERVERS_CONFIG");
preset.unset_option("LLAMA_ARG_MCP_SERVERS_JSON");
+ // UI storage is served by the router only
+ preset.unset_option("LLAMA_ARG_UI_STORAGE");
+ preset.unset_option("LLAMA_ARG_UI_STORAGE_DIR");
if (unset_model_args) {
preset.unset_option("LLAMA_ARG_MODEL");
preset.unset_option("LLAMA_ARG_SHARD");
@@ -2073,6 +2076,7 @@ void server_models_routes::init_routes() {
{"ui_settings", ui_settings},
{"build_info", std::string(llama_build_info())},
{"cors_proxy_enabled", params.ui_mcp_proxy},
+ {"ui_storage", params.ui_storage},
};
if (!params.server_connect_code.empty()) {
props["connect_code"] = params.server_connect_code;
diff --git a/tools/server/server-storage.cpp b/tools/server/server-storage.cpp
new file mode 100644
index 000000000000..2239e57c965a
--- /dev/null
+++ b/tools/server/server-storage.cpp
@@ -0,0 +1,227 @@
+#include "server-storage.h"
+
+#include
+#include
+
+namespace fs = std::filesystem;
+
+static json read_json_file(const fs::path & path) {
+ std::ifstream f(path, std::ios::binary);
+ if (!f) {
+ throw std::runtime_error("failed to open file: " + path.string());
+ }
+ std::stringstream ss;
+ ss << f.rdbuf();
+ return json::parse(ss.str());
+}
+
+// ids and record kinds come from the UI (uuids, table names), anything else could escape the storage directory
+static void validate_id(const std::string & id, const char * what = "conversation id") {
+ if (id.empty() || id.size() > 64) {
+ throw std::invalid_argument(std::string("invalid ") + what);
+ }
+ for (char c : id) {
+ if (!std::isalnum((unsigned char) c) && c != '-' && c != '_') {
+ throw std::invalid_argument(std::string("invalid ") + what);
+ }
+ }
+}
+
+static server_http_res_ptr res_json(int status, const json & data) {
+ auto res = std::make_unique();
+ res->status = status;
+ res->data = safe_json_to_str(data);
+ return res;
+}
+
+fs::path server_storage::conversation_path(const std::string & id) const {
+ return dir / "conversations" / fs::u8path(id + ".json");
+}
+
+fs::path server_storage::records_path(const std::string & kind) const {
+ return dir / "records" / fs::u8path(kind + ".json");
+}
+
+void server_storage::load_index() {
+ const fs::path index_path = dir / "index.json";
+
+ if (fs::exists(index_path)) {
+ try {
+ index = read_json_file(index_path);
+ if (index.is_object()) {
+ return;
+ }
+ } catch (const std::exception & e) {
+ SRV_WRN("failed to read %s, rebuilding it: %s\n", index_path.string().c_str(), e.what());
+ }
+ }
+
+ index = json::object();
+ for (const auto & entry : fs::directory_iterator(dir / "conversations")) {
+ if (!entry.is_regular_file() || entry.path().extension() != ".json") {
+ continue;
+ }
+ try {
+ const json doc = read_json_file(entry.path());
+ const std::string id = doc.at("conv").at("id").get();
+ index[id] = { { "rev", doc.value("rev", 0) }, { "conv", doc.at("conv") } };
+ } catch (const std::exception & e) {
+ SRV_WRN("skipping unreadable conversation %s: %s\n", entry.path().string().c_str(), e.what());
+ }
+ }
+ save_index();
+}
+
+void server_storage::save_index() const {
+ fs_write_atomic(dir / "index.json", safe_json_to_str(index));
+}
+
+void server_storage::setup(const fs::path & storage_dir) {
+ dir = storage_dir;
+
+ std::error_code ec;
+ common_create_directories(dir / "conversations", ec);
+ if (!ec) {
+ common_create_directories(dir / "records", ec);
+ }
+ if (ec) {
+ throw std::runtime_error("failed to create UI storage directory: " + dir.string());
+ }
+ load_index();
+
+ SRV_INF("UI storage in %s (%zu conversations)\n", dir.string().c_str(), index.size());
+
+ handle_list = [this](const server_http_req &) {
+ std::lock_guard lock(mtx);
+ json list = json::array();
+ for (const auto & [id, entry] : index.items()) {
+ list.push_back(entry);
+ }
+ return res_json(200, list);
+ };
+
+ handle_get = [this](const server_http_req & req) {
+ const std::string id = req.get_param("id");
+ validate_id(id);
+
+ std::lock_guard lock(mtx);
+ if (!index.contains(id)) {
+ return res_json(404, { { "error", format_error_response("conversation not found", ERROR_TYPE_NOT_FOUND) } });
+ }
+ return res_json(200, read_json_file(conversation_path(id)));
+ };
+
+ // the body carries the revision it was based on, 0 for a new conversation
+ handle_put = [this](const server_http_req & req) {
+ const std::string id = req.get_param("id");
+ validate_id(id);
+
+ const json body = json::parse(req.body);
+ const int rev = body.at("rev").get();
+ const json & conv = body.at("conv");
+ const json & messages = body.at("messages");
+ if (!conv.is_object() || conv.value("id", "") != id || !messages.is_array()) {
+ throw std::invalid_argument("expected { rev, conv, messages } with conv.id matching the path");
+ }
+
+ std::lock_guard lock(mtx);
+ const int current = index.contains(id) ? index[id].value("rev", 0) : 0;
+ if (rev != current) {
+ json error = { { "code", 409 }, { "message", "conversation was modified by another client" }, { "type", "conflict_error" } };
+ return res_json(409, { { "error", error }, { "rev", current } });
+ }
+
+ const json doc = { { "rev", current + 1 }, { "conv", conv }, { "messages", messages } };
+ fs_write_atomic(conversation_path(id), safe_json_to_str(doc));
+ index[id] = { { "rev", current + 1 }, { "conv", conv } };
+ save_index();
+
+ return res_json(200, { { "rev", current + 1 } });
+ };
+
+ handle_delete = [this](const server_http_req & req) {
+ const std::string id = req.get_param("id");
+ validate_id(id);
+
+ std::lock_guard lock(mtx);
+ std::error_code ec;
+ fs::remove(conversation_path(id), ec);
+ if (index.contains(id)) {
+ index.erase(id);
+ save_index();
+ }
+ return res_json(200, json::object());
+ };
+
+ handle_get_settings = [this](const server_http_req &) {
+ std::lock_guard lock(mtx);
+ const fs::path path = dir / "settings.json";
+ return res_json(200, fs::exists(path) ? read_json_file(path) : json::object());
+ };
+
+ // merges per key, so two clients changing different settings do not overwrite each other
+ handle_put_settings = [this](const server_http_req & req) {
+ const json body = json::parse(req.body);
+ const json set = body.value("set", json::object());
+ const json remove = body.value("remove", json::array());
+ if (!set.is_object() || !remove.is_array()) {
+ throw std::invalid_argument("expected { set: { key: value }, remove: [key] }");
+ }
+
+ std::lock_guard lock(mtx);
+ const fs::path path = dir / "settings.json";
+ json settings = fs::exists(path) ? read_json_file(path) : json::object();
+ for (const auto & [key, value] : set.items()) {
+ if (!value.is_string()) {
+ throw std::invalid_argument("setting values must be strings");
+ }
+ settings[key] = value;
+ }
+ for (const auto & key : remove) {
+ settings.erase(key.get());
+ }
+ fs_write_atomic(path, safe_json_to_str(settings));
+
+ return res_json(200, settings);
+ };
+
+ handle_get_records = [this](const server_http_req & req) {
+ const std::string kind = req.get_param("kind");
+ validate_id(kind, "record kind");
+
+ std::lock_guard lock(mtx);
+ const fs::path path = records_path(kind);
+ return res_json(200, fs::exists(path) ? read_json_file(path) : json::object());
+ };
+
+ // records are small and written whole, merged per id like settings
+ handle_put_records = [this](const server_http_req & req) {
+ const std::string kind = req.get_param("kind");
+ validate_id(kind, "record kind");
+
+ const json body = json::parse(req.body);
+ const json set = body.value("set", json::object());
+ const json remove = body.value("remove", json::array());
+ if (!set.is_object() || !remove.is_array()) {
+ throw std::invalid_argument("expected { set: { id: record }, remove: [id] }");
+ }
+ for (const auto & [id, record] : set.items()) {
+ if (!record.is_object() || record.value("id", "") != id) {
+ throw std::invalid_argument("records must be objects whose id matches their key");
+ }
+ }
+
+ std::lock_guard lock(mtx);
+ const fs::path path = records_path(kind);
+ json records = fs::exists(path) ? read_json_file(path) : json::object();
+ for (const auto & [id, record] : set.items()) {
+ records[id] = record;
+ }
+ for (const auto & id : remove) {
+ records.erase(id.get());
+ }
+ fs_write_atomic(path, safe_json_to_str(records));
+
+ return res_json(200, json::object());
+ };
+}
diff --git a/tools/server/server-storage.h b/tools/server/server-storage.h
new file mode 100644
index 000000000000..ee2c24bb1dd0
--- /dev/null
+++ b/tools/server/server-storage.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include "server-common.h"
+#include "server-http.h"
+
+#include
+#include
+
+// UI storage (--ui-storage): the Web UI's conversations and settings kept as JSON files on disk
+// the server does not interpret the documents, it only tracks a revision per conversation so
+// concurrent writers (tabs, browsers) get a 409 instead of silently overwriting each other
+//
+// layout:
+// /conversations/.json { "rev": n, "conv": {...}, "messages": [...] }
+// /index.json { "": { "rev": n, "conv": {...} } }, rebuilt when missing
+// /settings.json { "": "" }
+// /records/.json { "": {...} }, groups, projects, prompts, ...
+struct server_storage {
+ void setup(const std::filesystem::path & dir);
+
+ server_http_context::handler_t handle_list; // GET /storage/conversations
+ server_http_context::handler_t handle_get; // GET /storage/conversations/:id
+ server_http_context::handler_t handle_put; // POST /storage/conversations/:id
+ server_http_context::handler_t handle_delete; // DELETE /storage/conversations/:id
+ server_http_context::handler_t handle_get_settings; // GET /storage/settings
+ server_http_context::handler_t handle_put_settings; // POST /storage/settings
+ server_http_context::handler_t handle_get_records; // GET /storage/records/:kind
+ server_http_context::handler_t handle_put_records; // POST /storage/records/:kind
+
+private:
+ std::filesystem::path dir;
+ std::mutex mtx;
+ json index = json::object();
+
+ std::filesystem::path conversation_path(const std::string & id) const;
+ std::filesystem::path records_path(const std::string & kind) const;
+ void load_index();
+ void save_index() const;
+};
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/server.cpp b/tools/server/server.cpp
index d14978286224..1acdd56c7290 100644
--- a/tools/server/server.cpp
+++ b/tools/server/server.cpp
@@ -5,6 +5,7 @@
#include "server-cors-proxy.h"
#include "server-stream.h"
#include "server-tools.h"
+#include "server-storage.h"
#include "arg.h"
#include "build-info.h"
@@ -241,6 +242,7 @@ static bool server_setup_features(
const common_params & params,
server_mcp & mcp_mgr,
server_tools & tools,
+ server_storage & storage,
server_role_type role_type) {
// return 403 for disabled features
server_http_context::handler_t res_403 = [](const server_http_req &) {
@@ -319,6 +321,33 @@ static bool server_setup_features(
ctx_http.post("/tools", ex_wrapper(res_403));
}
+ if (params.ui_storage) {
+ try {
+ storage.setup(params.ui_storage_dir.empty() ? fs_get_data_directory() / "ui" : std::filesystem::u8path(params.ui_storage_dir));
+ } catch (const std::exception & e) {
+ SRV_ERR("UI storage setup failed: %s\n", e.what());
+ return false;
+ }
+ ctx_http.get ("/storage/conversations", ex_wrapper(storage.handle_list));
+ ctx_http.get ("/storage/conversations/:id", ex_wrapper(storage.handle_get));
+ ctx_http.post("/storage/conversations/:id", ex_wrapper(storage.handle_put));
+ ctx_http.del ("/storage/conversations/:id", ex_wrapper(storage.handle_delete));
+ ctx_http.get ("/storage/settings", ex_wrapper(storage.handle_get_settings));
+ ctx_http.post("/storage/settings", ex_wrapper(storage.handle_put_settings));
+ ctx_http.get ("/storage/records/:kind", ex_wrapper(storage.handle_get_records));
+ ctx_http.post("/storage/records/:kind", ex_wrapper(storage.handle_put_records));
+ warn_names.push_back("UI storage (experimental)");
+ } else {
+ ctx_http.get ("/storage/conversations", ex_wrapper(res_403));
+ ctx_http.get ("/storage/conversations/:id", ex_wrapper(res_403));
+ ctx_http.post("/storage/conversations/:id", ex_wrapper(res_403));
+ ctx_http.del ("/storage/conversations/:id", ex_wrapper(res_403));
+ ctx_http.get ("/storage/settings", ex_wrapper(res_403));
+ ctx_http.post("/storage/settings", ex_wrapper(res_403));
+ ctx_http.get ("/storage/records/:kind", ex_wrapper(res_403));
+ ctx_http.post("/storage/records/:kind", ex_wrapper(res_403));
+ }
+
if (!warn_names.empty()) {
std::string features;
for (const auto & name : warn_names) {
@@ -502,6 +531,7 @@ static int server_run_router(common_params & params, int argc, char ** argv, con
server_context ctx_server;
server_routes routes(params, ctx_server);
server_tools tools;
+ server_storage storage;
server_http_context ctx_http;
if (!ctx_http.init(params)) {
@@ -564,7 +594,7 @@ static int server_run_router(common_params & params, int argc, char ** argv, con
models_routes->router_streams_lookup,
models_routes->router_stream_delete);
- if (!server_setup_features(ctx_http, params, mcp_mgr, tools, SERVER_ROLE_ROUTER)) {
+ if (!server_setup_features(ctx_http, params, mcp_mgr, tools, storage, SERVER_ROLE_ROUTER)) {
return 1;
}
@@ -653,6 +683,7 @@ static int server_run_instance(common_params & params, server_role & role, commo
server_context ctx_server;
server_routes routes(params, ctx_server);
server_tools tools;
+ server_storage storage;
server_http_context ctx_http;
if (!ctx_http.init(params)) {
@@ -666,7 +697,7 @@ static int server_run_instance(common_params & params, server_role & role, commo
server_stream_make_lookup_handler(),
server_stream_make_delete_handler());
- if (!server_setup_features(ctx_http, params, mcp_mgr, tools, SERVER_ROLE_INSTANCE)) {
+ if (!server_setup_features(ctx_http, params, mcp_mgr, tools, storage, SERVER_ROLE_INSTANCE)) {
return 1;
}
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..2a6c5ac44b72 100644
--- a/ui/apps/chat/README.md
+++ b/ui/apps/chat/README.md
@@ -19,21 +19,22 @@ It works with a llama-server in either mode: **MODEL** (one model) or **ROUTER**
Llama Chat is published to npm as [`@ggml-org/llama-chat`](https://www.npmjs.com/package/@ggml-org/llama-chat), with [`llama-chat`](https://www.npmjs.com/package/llama-chat) as its short name. It serves the prebuilt app as static files on localhost, or writes them to a folder for any static file server (see [Self-hosting](#self-hosting)); it brings no server and no models of its own. It needs Node.js 20 or later.
```bash
-npx @ggml-org/llama-chat # serve it on http://127.0.0.1:3000 and open the browser
-npx llama-chat --host 0.0.0.0 --no-open # the same, by its short name, reachable from other devices
-npx llama-chat build # write the static app to ./llama-chat instead
+npx @ggml-org/llama-chat --server http://127.0.0.1:9931 # serve it on http://127.0.0.1:3000 with that server added
+npx llama-chat --host 0.0.0.0 --no-open # the same, by its short name, reachable from other devices
+npx llama-chat build --server https://llm.example.com # write the static app to ./llama-chat instead
```
| Flag | Default | What it does |
| --------------------------------- | ----------- | ------------------------------------------------------------------------------------------- |
+| `--server ` | | A llama-server the app adds on startup, once; repeatable. Its API key goes in the app |
| `--port ` | `3000` | Fixed, so the origin, and the chats the browser stores under it, stay the same between runs |
| `--host ` | `127.0.0.1` | `0.0.0.0` to open it to the LAN |
| `--open` / `--no-open` | open | Opens the default browser once it listens |
| `-v`, `--version`, `-h`, `--help` | | As usual |
-The bare command is the documented form; `start` is accepted as an alias for it. `build` takes `--out ` (default `./llama-chat`) and `--force`, which lets it write into a folder that is not empty.
+The bare command is the documented form; `start` is accepted as an alias for it. `build` takes `--out ` (default `./llama-chat`), `--force`, which lets it write into a folder that is not empty, and `--server`.
-How it works: the CLI only serves the files of `dist`, with llama-server's headers for the UI (`index.html` cross-origin isolated, the PWA files revalidated, hashed assets cached for good), and forwards nothing. The browser talks to each llama-server you add in the app by URL directly, so llama-server's own rules apply: start it with `--cors-origins http://127.0.0.1:3000` (the address you open) when it restricts origins, as it does with tools or MCP enabled, and with `--api-key` when it is reachable from the LAN. An `http://` page like this one can reach a plain `http://` llama-server on the LAN, which an `https://` page cannot.
+How it works: the CLI only serves the files of `dist`, with llama-server's headers for the UI (`index.html` cross-origin isolated, the PWA files revalidated, hashed assets cached for good), and forwards nothing. `--server` only puts the address in `llama-chat.json` next to `index.html`, which the app reads at startup to add the server; one you remove in the app stays removed. The CLI marks `index.html` with ``, and only a page with that tag asks for the file (`build --server` writes both). The browser talks to each llama-server directly, so llama-server's own rules apply: start it with `--cors-origins http://127.0.0.1:3000` (the address you open) when it restricts origins, as it does with tools or MCP enabled, and with `--api-key` when it is reachable from the LAN. An `http://` page like this one can reach a plain `http://` llama-server on the LAN, which an `https://` page cannot.
## Self-hosting
@@ -84,15 +85,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 +107,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
```
@@ -140,7 +144,32 @@ sequenceDiagram
- **Messages form a tree**: each message knows its parent and children, and a conversation points at the branch tip it shows, so editing or regenerating branches without losing history.
- **Server role**: one codebase serves MODEL and ROUTER mode; `serverStore` reads the role from `/props`, and ROUTER-only UI shows only there.
- **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.
+- **Storage**: conversations and messages in IndexedDB (idb), 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, message and attachment renderers, and prompts offered as system messages.
+
+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 |
+
+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
diff --git a/ui/apps/chat/cli/server.js b/ui/apps/chat/cli/server.js
index 8ef0f557c3a4..70a7a33c80cd 100644
--- a/ui/apps/chat/cli/server.js
+++ b/ui/apps/chat/cli/server.js
@@ -6,12 +6,15 @@
*
* It only serves files and forwards nothing: the browser calls each llama-server the app is
* pointed at directly, so llama-server's own rules (--cors-origins, --api-key) apply as they do
- * to any other page.
+ * to any other page. `--server` only tells the app which servers to add: the CLI serves them in
+ * `llama-chat.json` next to index.html, and `build` writes that file, which the app reads at
+ * startup. index.html carries a marker for it, so a page served any other way, such as by
+ * llama-server or the dev server, does not ask for a file that is not there.
*/
import { spawn } from 'node:child_process';
import { createReadStream, readFileSync } from 'node:fs';
-import { cp, readdir, stat } from 'node:fs/promises';
+import { cp, readdir, readFile, stat, writeFile } from 'node:fs/promises';
import http from 'node:http';
import { extname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -28,6 +31,15 @@ export const DEFAULTS = Object.freeze({
port: 3000
});
+/** The file next to index.html that lists the servers the app adds at startup. */
+export const PRESET_FILE = 'llama-chat.json';
+
+/**
+ * The marker in index.html that sends the app to `llama-chat.json`. It names the file rather
+ * than the servers: the service worker keeps index.html, so servers in it would outlive a run.
+ */
+export const PRESET_META = ``;
+
// The same caching llama-server applies to the UI it embeds (tools/server/server-http.cpp):
// index.html and the PWA's update checks are revalidated, hashed assets are cached for good.
const NO_CACHE = new Set([
@@ -36,7 +48,8 @@ const NO_CACHE = new Set([
'/sw.js',
'/manifest.webmanifest',
'/_app/version.json',
- '/build.json'
+ '/build.json',
+ `/${PRESET_FILE}`
]);
const CACHE_IMMUTABLE = 'public, max-age=31536000, immutable';
const CACHE_REVALIDATE = 'no-cache';
@@ -65,13 +78,15 @@ const SERVE_OPTIONS = ['host', 'open', 'port'];
const BUILD_OPTIONS = ['force', 'out'];
export const USAGE = `Usage: llama-chat [options]
- llama-chat build [--out ] [--force]
+ llama-chat build [--out ] [--force] [--server ]
Serves Llama Chat on localhost as static files, or, with build, writes them to
a folder for any HTTP server. The browser talks to llama-server directly: start
it with --cors-origins set to this page's address when it restricts origins.
Options:
+ --server a llama-server the app adds on startup, repeatable; the API
+ key, if it needs one, goes in the app
--port port to listen on (default: ${DEFAULTS.port})
--host address to listen on, 0.0.0.0 for the LAN (default: ${DEFAULTS.host})
--open open the browser once it listens (default)
@@ -82,11 +97,12 @@ Options:
Build options:
--out folder to write to (default: ./${DEFAULTS.out})
--force write into a folder that is not empty
+ --server as above, written to ${PRESET_FILE} in the folder
Examples:
- npx @ggml-org/llama-chat
+ npx @ggml-org/llama-chat --server http://127.0.0.1:9931
npx @ggml-org/llama-chat --host 0.0.0.0 --port 3000 --no-open
- npx @ggml-org/llama-chat build --out ./public`;
+ npx @ggml-org/llama-chat build --out ./public --server https://llm.example.com`;
/** The version in this package's package.json. */
export function packageVersion() {
@@ -97,7 +113,7 @@ export function packageVersion() {
* Reads the command line. No verb serves the app, `start` means the same, and `build` writes it
* to a folder.
* @param {string[]} argv the arguments after the command
- * @returns {{ command: 'build' | 'serve', force: boolean, help: boolean, host: string, open: boolean, out: string, port: number, version: boolean }}
+ * @returns {{ command: 'build' | 'serve', force: boolean, help: boolean, host: string, open: boolean, out: string, port: number, servers: string[], version: boolean }}
*/
export function parseCliArgs(argv) {
const { positionals, values } = parseArgs({
@@ -111,6 +127,7 @@ export function parseCliArgs(argv) {
open: { type: 'boolean' },
out: { type: 'string' },
port: { type: 'string' },
+ server: { multiple: true, type: 'string' },
version: { short: 'v', type: 'boolean' }
},
strict: true
@@ -146,10 +163,54 @@ export function parseCliArgs(argv) {
open: values.open ?? true,
out: values.out ?? DEFAULTS.out,
port,
+ servers: (values.server ?? []).map(parseServerUrl),
version: values.version ?? false
};
}
+/**
+ * A llama-server address for the app, with or without `http://`, as the app stores it: no
+ * trailing slash, a path kept (for `--api-prefix`).
+ * @param {string} value
+ */
+export function parseServerUrl(value) {
+ let url;
+
+ try {
+ url = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(value) ? value : `http://${value}`);
+ } catch {
+ throw new Error(`invalid --server: ${value}`);
+ }
+
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
+ throw new Error(`invalid --server: ${value} (use an http:// or https:// address)`);
+ }
+
+ if (url.search || url.hash || url.username || url.password) {
+ throw new Error(`invalid --server: ${value} (no query, fragment or credentials)`);
+ }
+
+ return url.href.replace(/\/+$/, '');
+}
+
+/**
+ * index.html with the marker for `llama-chat.json` at the end of its head, once.
+ * @param {string} html
+ */
+export function withPresetMeta(html) {
+ if (html.includes('name="llama-chat-servers"')) return html;
+
+ return html.replace('', `\t${PRESET_META}\n\t`);
+}
+
+/**
+ * The contents of `llama-chat.json`.
+ * @param {string[]} servers
+ */
+export function presetFile(servers) {
+ return `${JSON.stringify({ servers: servers.map((url) => ({ url })) }, null, '\t')}\n`;
+}
+
/**
* Maps a request path to a file under `root`, or null when it falls outside it.
* @param {string} root
@@ -181,7 +242,10 @@ function resolveStatic(root, pathname) {
*/
function sendFile(req, res, file, pathname, stats) {
const name = pathname === '/' ? '/index.html' : pathname;
- const etag = `W/"${stats.size.toString(16)}-${Math.floor(stats.mtimeMs).toString(16)}"`;
+ // index.html goes out with the marker for llama-chat.json, and an ETag of its own
+ const body =
+ name === '/index.html' ? Buffer.from(withPresetMeta(readFileSync(file, 'utf8'))) : null;
+ const etag = `W/"${(body?.length ?? stats.size).toString(16)}-${Math.floor(stats.mtimeMs).toString(16)}"`;
res.setHeader('ETag', etag);
res.setHeader('Cache-Control', NO_CACHE.has(name) ? CACHE_REVALIDATE : CACHE_IMMUTABLE);
@@ -201,7 +265,7 @@ function sendFile(req, res, file, pathname, stats) {
'Content-Type',
MIME_TYPES[extname(file).toLowerCase()] ?? 'application/octet-stream'
);
- res.setHeader('Content-Length', stats.size);
+ res.setHeader('Content-Length', body?.length ?? stats.size);
res.writeHead(200);
if (req.method === 'HEAD') {
@@ -210,6 +274,12 @@ function sendFile(req, res, file, pathname, stats) {
return;
}
+ if (body) {
+ res.end(body);
+
+ return;
+ }
+
createReadStream(file).pipe(res);
}
@@ -224,11 +294,13 @@ function sendError(res, status, message) {
}
/**
- * The HTTP server: the files of `dist`, read-only.
- * @param {{ distDir?: string }} [options]
+ * The HTTP server: the files of `dist`, read-only, and `llama-chat.json` with the servers given,
+ * if any: index.html always points the app at it.
+ * @param {{ distDir?: string, servers?: string[] }} [options]
*/
-export function createChatServer({ distDir = DIST_DIR } = {}) {
+export function createChatServer({ distDir = DIST_DIR, servers = [] } = {}) {
const root = normalize(distDir);
+ const preset = Buffer.from(presetFile(servers));
return http.createServer(async (req, res) => {
const { pathname } = new URL(req.url ?? '/', 'http://localhost');
@@ -240,6 +312,17 @@ export function createChatServer({ distDir = DIST_DIR } = {}) {
return;
}
+ if (pathname === `/${PRESET_FILE}`) {
+ res.writeHead(200, {
+ 'Cache-Control': CACHE_REVALIDATE,
+ 'Content-Length': preset.length,
+ 'Content-Type': MIME_TYPES['.json']
+ });
+ res.end(req.method === 'HEAD' ? undefined : preset);
+
+ return;
+ }
+
const file = resolveStatic(root, pathname);
const stats = file ? await stat(file).catch(() => null) : null;
@@ -255,11 +338,12 @@ export function createChatServer({ distDir = DIST_DIR } = {}) {
/**
* Writes the app to a folder: the files of `dist` without source maps, ready for any static
- * file server. Refuses a folder that is not empty unless `force` is set, and a folder in `dist`.
- * @param {{ distDir?: string, force?: boolean, out: string }} options
+ * file server, and `llama-chat.json` when servers are given, with the marker in index.html. Refuses a folder that is not empty
+ * unless `force` is set, and a folder in `dist`.
+ * @param {{ distDir?: string, force?: boolean, out: string, servers?: string[] }} options
* @returns {Promise} the absolute path of the folder
*/
-export async function buildStatic({ distDir = DIST_DIR, force = false, out }) {
+export async function buildStatic({ distDir = DIST_DIR, force = false, out, servers = [] }) {
const source = resolve(distDir);
const target = resolve(out);
const inside = relative(source, target);
@@ -276,6 +360,13 @@ export async function buildStatic({ distDir = DIST_DIR, force = false, out }) {
await cp(source, target, { filter: (file) => !file.endsWith('.map'), recursive: true });
+ if (servers.length > 0) {
+ const index = join(target, 'index.html');
+
+ await writeFile(join(target, PRESET_FILE), presetFile(servers));
+ await writeFile(index, withPresetMeta(await readFile(index, 'utf8')));
+ }
+
return target;
}
@@ -339,10 +430,17 @@ export async function main(argv) {
if (options.command === 'build') {
try {
- const target = await buildStatic({ force: options.force, out: options.out });
+ const target = await buildStatic({
+ force: options.force,
+ out: options.out,
+ servers: options.servers
+ });
const shown = relative(process.cwd(), target) || '.';
console.log(`Llama Chat ${packageVersion()} written to ${target}`);
+
+ for (const server of options.servers) console.log(`Adds the llama-server at ${server}`);
+
console.log(`Serve it with any static file server, e.g.: npx http-server ${shown}`);
} catch (error) {
console.error(`llama-chat: ${error instanceof Error ? error.message : error}`);
@@ -352,7 +450,7 @@ export async function main(argv) {
return;
}
- const server = createChatServer();
+ const server = createChatServer({ servers: options.servers });
return new Promise((resolve) => {
server.on('error', (error) => {
@@ -373,6 +471,9 @@ export async function main(argv) {
const url = `http://${shown.includes(':') ? `[${shown}]` : shown}:${address.port}/`;
console.log(`Llama Chat ${packageVersion()} on ${url}`);
+
+ for (const server of options.servers) console.log(`Adds the llama-server at ${server}`);
+
console.log(
`If llama-server restricts origins (tools or MCP on), start it with --cors-origins ${url.slice(0, -1)}`
);
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/docs/storage-adapters.md b/ui/apps/chat/docs/storage-adapters.md
new file mode 100644
index 000000000000..37e2e27fc0ab
--- /dev/null
+++ b/ui/apps/chat/docs/storage-adapters.md
@@ -0,0 +1,115 @@
+# Storage adapters
+
+By default the UI keeps conversations, groups, projects, prompts and settings in the browser (IndexedDB and localStorage). A storage adapter keeps them somewhere else instead. The built-in one is llama-server's own JSON document store (`llama-server --ui-storage`). You can add your own for Postgres (Supabase, Neon), PocketBase or any other database.
+
+```mermaid
+flowchart LR
+ stores[Stores] --> db[DatabaseService tree rules]
+ db --> backend{StorageBackend}
+ backend --> idb[IdbBackend this browser]
+ backend --> dsb[DocumentStoreBackend cache, batching, conflict replay]
+ dsb --> adapter{StorageAdapter}
+ adapter --> ls[llama-server /storage routes]
+ adapter --> pg[your adapter Postgres, PocketBase, ...]
+```
+
+## The contract
+
+An adapter stores one **document per conversation**: `{ rev, conv, messages }`. It doesn't need to understand the document. It only stores it as a whole and enforces one rule:
+
+- **Compare and swap on `rev`.** `putConversation(doc)` writes only if the store still holds revision `doc.rev`, where `0` means the document must not exist yet. It returns the new revision. Otherwise it throws `StorageConflictError` and writes nothing. This check and the write must be atomic.
+
+`DocumentStoreBackend` uses that rule to merge edits from two tabs or browsers: on a conflict it fetches the fresh document, replays its own edits and retries.
+
+Settings are plain string key/value pairs, merged per key: `updateSettings(set, remove)` must leave other keys untouched. The API key never reaches an adapter; it stays in the browser.
+
+Records are the small standalone objects next to conversations, one kind per table: `groups`, `projects` and `prompts`. Each has an `id`. `listRecords(kind)` returns all of a kind, and `updateRecords(kind, set, remove)` writes `set` whole and deletes `remove` by id, leaving the other records untouched. Last write wins per record. New kinds the UI adds later go through the same two methods, so a store keyed by kind and id needs no change for them.
+
+See `StorageAdapter` in `src/lib/types/storage.d.ts` for the full interface (eight methods).
+
+## Adding one
+
+1. Implement `StorageAdapter` in `src/lib/storage-adapters/.adapter.ts`, next to `llama-server.adapter.ts`.
+2. Export a `StorageAdapterDefinition` (`id`, `name`, `description`, `isAvailable`, `create`) and add it to `STORAGE_ADAPTERS` in `src/lib/storage-adapters/index.ts`.
+3. Build the UI. Settings → Import/Export → Storage then offers "Store on " wherever `isAvailable` returns true, and copies the browser's data over when the user picks it.
+
+Configuration such as a URL or a public key usually comes from build-time env vars (`import.meta.env.VITE_*`). Make `isAvailable` return false when they are missing.
+
+The in-memory adapter in `tests/unit/document-store-backend.test.ts` is the smallest working example.
+
+## Postgres: Supabase, Neon
+
+Store the document as JSON columns, and do the compare and swap in one SQL function:
+
+```sql
+create table llama_ui_conversations (
+ id text primary key,
+ rev integer not null,
+ conv jsonb not null,
+ messages jsonb not null
+);
+
+create table llama_ui_settings (
+ key text primary key,
+ value text not null
+);
+
+create table llama_ui_records (
+ kind text not null,
+ id text not null,
+ record jsonb not null,
+ primary key (kind, id)
+);
+
+-- returns the new revision, or null when `doc.rev` is stale
+create function llama_ui_put_conversation(doc jsonb) returns integer
+language plpgsql as $$
+declare
+ base integer := (doc->>'rev')::integer;
+ new_rev integer;
+begin
+ if base = 0 then
+ insert into llama_ui_conversations (id, rev, conv, messages)
+ values (doc->'conv'->>'id', 1, doc->'conv', doc->'messages')
+ on conflict (id) do nothing
+ returning rev into new_rev;
+ else
+ update llama_ui_conversations
+ set rev = rev + 1, conv = doc->'conv', messages = doc->'messages'
+ where id = doc->'conv'->>'id' and rev = base
+ returning rev into new_rev;
+ end if;
+ return new_rev;
+end $$;
+```
+
+Supabase and Neon (Data API) both expose this over PostgREST, so the adapter is a thin wrapper around `fetch`:
+
+| Method | Request |
+| -------------------- | --------------------------------------------------------------------------------------------------- |
+| `listConversations` | `GET /llama_ui_conversations?select=rev,conv` |
+| `getConversation` | `GET /llama_ui_conversations?id=eq.&select=rev,conv,messages`, first row or null |
+| `putConversation` | `POST /rpc/llama_ui_put_conversation` with `{ "doc": ... }`; a null result → `StorageConflictError` |
+| `deleteConversation` | `DELETE /llama_ui_conversations?id=eq.` |
+| `getSettings` | `GET /llama_ui_settings`, rows into an object |
+| `updateSettings` | upsert with `Prefer: resolution=merge-duplicates`, then `DELETE ?key=in.(...)` |
+| `listRecords` | `GET /llama_ui_records?kind=eq.&select=record` |
+| `updateRecords` | upsert `{ kind, id, record }` rows, then `DELETE ?kind=eq.&id=in.(...)` |
+
+Whatever key the adapter sends is in the built UI bundle, readable by anyone who loads the page. Protect the tables with row level security tied to a signed-in user (for example Supabase Auth), not with a key alone.
+
+Add a `user_id` column to every table if several people share the database.
+
+## PocketBase
+
+Create three collections:
+
+- `conversations`, with `conv_id` (text, unique), `rev` (number), `conv` (json) and `messages` (json).
+- `settings`, with `key` (text, unique) and `value` (text).
+- `records`, with `kind` (text), `record_id` (text) and `record` (json), unique on `kind` + `record_id`.
+
+PocketBase's record API has no conditional update, so do the compare and swap in a custom route in `pb_hooks`. Inside `$app.runInTransaction`, read the record, compare `rev`, then save it with `rev + 1`. Answer 409 on a mismatch, and have the adapter turn that 409 into `StorageConflictError`.
+
+## Going lower level
+
+If you'd rather store messages as rows, for example as normalized Postgres tables, implement `StorageBackend` (`src/lib/types/database.d.ts`) directly, the way `IdbBackend` does. Then pass it to `DatabaseService.useBackend`. Your backend then has to provide transactions across conversations, messages and records itself; the document model above exists to avoid that requirement.
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..d29105211fe6 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",
@@ -47,7 +49,6 @@
"@vitest/coverage-v8": "4.1.12",
"bits-ui": "2.18.1",
"clsx": "2.1.1",
- "dexie": "4.4.3",
"dompurify": "3.4.17",
"eslint": "10.14.0",
"eslint-config-prettier": "10.1.8",
@@ -59,6 +60,7 @@
"globals": "16.5.0",
"highlight.js": "11.11.1",
"http-server": "14.1.1",
+ "idb": "8.0.4",
"mdsvex": "0.12.7",
"mode-watcher": "1.1.0",
"pdfjs-dist": "5.4.54",
@@ -89,6 +91,7 @@
"typescript-eslint": "8.72.1",
"unified": "11.0.5",
"unist-util-visit": "5.1.0",
+ "uqr": "0.1.3",
"uuid": "13.0.2",
"vaul-svelte": "1.0.0-next.7",
"vite": "8.3.6",
@@ -1937,45 +1940,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 +5255,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 +5278,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 +5460,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 +5489,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 +5740,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 +5761,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 +5981,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",
@@ -6157,13 +6022,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/dexie": {
- "version": "4.4.3",
- "resolved": "https://registry.npmjs.org/dexie/-/dexie-4.4.3.tgz",
- "integrity": "sha512-N+3IGQ3HPlyO2YAkntGAwitm42BpBGV86MttzUMiRzWLa4NGh0pltVRcUVF4ybL/OnXjCrr9k7SDPIKkFYP2Lg==",
- "dev": true,
- "license": "Apache-2.0"
- },
"node_modules/dom-accessibility-api": {
"version": "0.5.16",
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
@@ -6196,27 +6054,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 +6176,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 +6554,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 +6594,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 +6622,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 +6657,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 +6714,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 +7129,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,22 +7179,12 @@
"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==",
+ "node_modules/idb": {
+ "version": "8.0.4",
+ "resolved": "https://registry.npmjs.org/idb/-/idb-8.0.4.tgz",
+ "integrity": "sha512-jd0ITCrN+Zah4J7R/Z2jnR3W7A4BXDAjmo62MwWuSjxCiueUAf7X5rbodEdidWzeknwXHmLpdZkoiiCppNi30Q==",
"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"
- }
+ "license": "ISC"
},
"node_modules/ignore": {
"version": "5.3.2",
@@ -7571,13 +7223,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 +7230,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 +7301,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 +7407,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 +8242,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 +8888,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 +9049,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 +9057,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 +9084,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 +9245,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 +9265,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 +9703,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 +9767,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 +10034,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 +10085,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 +10134,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 +10189,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 +10417,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 +11008,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 +11106,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 +11312,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",
@@ -12066,6 +11328,13 @@
"node": ">=18.12.0"
}
},
+ "node_modules/uqr": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/uqr/-/uqr-0.1.3.tgz",
+ "integrity": "sha512-0rjE8iEJe4YmT9TOhwsZtqCMRLc5DXZUI2UEYUUg63ikBkqqE5EYWaI0etFe/5KUcmcYwLih2RND1kq+hrUJXA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@@ -12136,16 +11405,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 +11884,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 +11952,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..223afabc19e2 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",
@@ -106,7 +108,7 @@
"@vitest/coverage-v8": "4.1.12",
"bits-ui": "2.18.1",
"clsx": "2.1.1",
- "dexie": "4.4.3",
+ "idb": "8.0.4",
"dompurify": "3.4.17",
"eslint": "10.14.0",
"eslint-config-prettier": "10.1.8",
@@ -149,6 +151,7 @@
"typescript-eslint": "8.72.1",
"unified": "11.0.5",
"unist-util-visit": "5.1.0",
+ "uqr": "0.1.3",
"uuid": "13.0.2",
"vaul-svelte": "1.0.0-next.7",
"vite": "8.3.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/app.css b/ui/apps/chat/src/app.css
index cca440844162..df5c707dd0d7 100644
--- a/ui/apps/chat/src/app.css
+++ b/ui/apps/chat/src/app.css
@@ -23,6 +23,11 @@
--safe-area-bottom: env(safe-area-inset-bottom, 0px);
/* where the phone's corner controls (menu toggle, context gauge, sidebar logo) sit */
--corner-control-top: calc(1rem + var(--safe-area-top));
+ /* where the phone's bottom corner actions (a page's floating key) sit: as far in from
+ the side as up from the bottom, which keeps a 56px key about concentric with an
+ iPhone's rounded screen corner */
+ --corner-control-side: 1.75rem;
+ --corner-control-bottom: calc(var(--corner-control-side) + var(--safe-area-bottom));
/* where a phone page's title starts: a row below the corner controls */
--page-top: calc(var(--corner-control-top) + 3.75rem);
/* expanded desktop sidebar width, overridden once the user drags its edge */
@@ -75,6 +80,9 @@
/* the installed app's status bar already sets them apart from the screen's edge */
:root {
--corner-control-top: calc(0.25rem + var(--safe-area-top));
+ /* the home indicator is a short bar in the middle, so the corners beside it are
+ free: a corner action ignores its inset and keeps the same gap as from the side */
+ --corner-control-bottom: var(--corner-control-side);
}
html {
@@ -295,11 +303,15 @@
}
/* While something is dragged, what it passes over takes no hover: only the
- sections themselves stay targets, for the drop */
+ sections themselves, and the projects in them, stay targets, for the drop */
body[data-sidebar-dragging] [data-sidebar-section] * {
pointer-events: none;
}
+ body[data-sidebar-dragging] [data-sidebar-section] [data-sidebar-section] {
+ pointer-events: auto;
+ }
+
.sidebar-drag-overlay {
position: fixed;
z-index: 1000;
@@ -354,6 +366,21 @@
animation: none;
}
}
+
+ /* A page's entrance, for pages that remount on every navigation into them:
+ * the whole page fades in at once. A plain ease over 350ms spreads the
+ * fade evenly instead of front-loading it, so it reads as a calm arrival.
+ * Opacity only, so it runs on the compositor and stays for reduced motion
+ * too: a fade does not move anything. */
+ .page-enter {
+ animation: page-enter 350ms ease;
+ }
+
+ @keyframes page-enter {
+ from {
+ opacity: 0;
+ }
+ }
}
/*
diff --git a/ui/apps/chat/src/app.d.ts b/ui/apps/chat/src/app.d.ts
index 006a37a8cfaa..7b9e60c457f0 100644
--- a/ui/apps/chat/src/app.d.ts
+++ b/ui/apps/chat/src/app.d.ts
@@ -10,6 +10,7 @@ import type {
ApiChatCompletionStreamChunk,
ApiChatCompletionToolCall,
ApiChatCompletionToolCallDelta,
+ ApiChatCompletionUsage,
ApiChatMessageContentPart,
ApiChatMessageData,
ApiContextSizeError,
@@ -72,6 +73,7 @@ declare global {
ApiChatCompletionResponse,
ApiChatCompletionStreamChunk,
ApiChatCompletionToolCall,
+ ApiChatCompletionUsage,
ApiChatCompletionToolCallDelta,
ApiChatMessageData,
ApiChatMessageContentPart,
diff --git a/ui/apps/chat/src/lib/components/app/actions/FloatingActionButton.svelte b/ui/apps/chat/src/lib/components/app/actions/FloatingActionButton.svelte
new file mode 100644
index 000000000000..0689c01a6dbe
--- /dev/null
+++ b/ui/apps/chat/src/lib/components/app/actions/FloatingActionButton.svelte
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/ui/apps/chat/src/lib/components/app/actions/index.ts b/ui/apps/chat/src/lib/components/app/actions/index.ts
index 8b0279d06216..7a1db73a293a 100644
--- a/ui/apps/chat/src/lib/components/app/actions/index.ts
+++ b/ui/apps/chat/src/lib/components/app/actions/index.ts
@@ -14,3 +14,6 @@ export { default as ActionIconCopyToClipboard } from './ActionIconCopyToClipboar
/** A round matte glass key: a phone's corner keys and the key back to a chat's bottom. */
export { default as GlassKey } from './GlassKey.svelte';
+
+/** A page's main action on a phone: a round key pinned to the bottom-right corner. */
+export { default as FloatingActionButton } from './FloatingActionButton.svelte';
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..d4a5f905477b 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,41 @@
ChatFormCurrentWorkingDirectory,
ChatFormInput,
ChatFormInputFileInputInvisible,
- ChatFormMcpResourcesList,
ChatFormPickers,
- DialogMcpResourcesBrowser
+ ChatFormProjectChip
} 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,
+ type SystemPromptEntry,
+ type SystemPromptSource
+ } 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,
+ projectsStore,
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,
@@ -93,6 +88,7 @@
onStop?: () => void;
onSubmit?: () => void;
onSystemPromptClick?: (draft: { message: string; files: ChatUploadedFile[] }) => void;
+ onSystemPromptWithContent?: (content: string, promptId: string, title: string) => void;
onUploadedFileRemove?: (fileId: string) => void;
onUploadedFilesChange?: (files: ChatUploadedFile[]) => void;
onValueChange?: (value: string) => void;
@@ -109,6 +105,7 @@
onStop,
onSubmit,
onSystemPromptClick,
+ onSystemPromptWithContent,
onUploadedFileRemove,
onUploadedFilesChange,
onValueChange,
@@ -146,6 +143,14 @@
conversationsStore.activeConversation?.cwd ?? conversationsStore.preferences.pendingCwd
);
+ // the project the chat is in, or the one picked for the chat about to start
+ let project = $derived.by(() => {
+ const active = conversationsStore.activeConversation;
+ const projectId = active ? active.projectId : conversationsStore.preferences.pendingProjectId;
+
+ return projectId ? projectsStore.get(projectId) : undefined;
+ });
+
let showWorkingDirectory = $derived(conversationsStore.preferences.hasEnabledCwdTools());
// On a desktop the chip under the form shows a directory once one is set, and the + menu
// sets one until then. A phone has no chip: a chat shows it in its header (see
@@ -155,27 +160,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 +222,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 +274,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 +303,7 @@
let isPickerOpen = $derived(
pickers.isCommandPickerOpen ||
pickers.isMentionPickerOpen ||
- pickers.isPromptPickerOpen ||
+ pickers.openPickerId !== null ||
pickers.isWorkingDirectoryPickerOpen
);
@@ -488,70 +498,9 @@
}
}
- 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);
+ /** A prompt of the System message list that needs arguments: its source asks for them in the form. */
+ function handlePromptArguments(source: SystemPromptSource, entry: SystemPromptEntry) {
+ source.openArguments(entry, composer);
}
// Deferred so the closing popover's focus scope tears down first -
@@ -656,20 +605,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 +712,9 @@
{placeholder}
/>
- {#if mcpStore.resources.hasAttachments}
- {
- preSelectedResourceUri = uri;
- isResourceDialogOpen = true;
- }}
- />
- {/if}
+ {#each contributedAttachments as source (source)}
+
+ {/each}
- {serverStore.props?.modalities?.audio ? 'Record audio, type a message ' : 'Type a message'} or upload
- files to get started
+ {serverStore.localProps?.modalities?.audio
+ ? 'Record audio, type a message '
+ : 'Type a message'} or upload files to get started
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreenServerError.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreenServerError.svelte
index 497c1efc2c14..4d8d60e8fb39 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreenServerError.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreenServerError.svelte
@@ -1,11 +1,18 @@
{#if hasError || isLoadingModel}
@@ -33,7 +40,19 @@
{#if !isLoadingModel}
- {serverStore.error}
+
+ {serverStore.error}
+
+
+
+
{/if}
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte
index c4a68a2dbfc8..bf9a4d586a06 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte
@@ -14,31 +14,45 @@
import { useScrollCarousel } from '#lib/hooks/use-scroll-carousel.svelte.ts';
import { chatStore, conversationsStore, tabsStore, uiStore } from '#lib/stores/index.ts';
import type { MenuAction } from '#lib/types/index.ts';
- import { resolveTabView } from '#lib/utils/index.ts';
+ import { projectNewChatTabId, projectOfNewChatTab, resolveTabView } from '#lib/utils/index.ts';
+ import { goto } from '$app/navigation';
import { page } from '$app/state';
- import { tick } from 'svelte';
+ import { type Snippet, tick } from 'svelte';
+
+ interface Props {
+ /** Sits before the tabs, e.g. the breadcrumb of a project view. */
+ leading?: Snippet;
+ }
+
+ let { leading }: Props = $props();
const carousel = useScrollCarousel();
- let view = $derived(resolveTabView(page, tabsStore.openTabs));
+ let view = $derived(resolveTabView(page, tabsStore.openTabs, conversationsStore.conversations));
let activeId = $derived(view.activeId);
let tabs = $derived(
- view.ids.map((id) =>
- id === NEW_CHAT_TAB_ID
- ? { href: view.hrefFor(id), icon: SquarePen, id, name: NEW_CHAT_LABEL }
- : {
- href: view.hrefFor(id),
- id,
- name:
- conversationsStore.conversations.find((c) => c.id === id)?.name ?? UNNAMED_CHAT_LABEL
- }
- )
+ view.ids.map((id) => {
+ if (id === NEW_CHAT_TAB_ID || projectOfNewChatTab(id)) {
+ return { href: view.hrefFor(id), icon: SquarePen, id, name: NEW_CHAT_LABEL };
+ }
+
+ return {
+ href: view.hrefFor(id),
+ id,
+ name: conversationsStore.conversations.find((c) => c.id === id)?.name ?? UNNAMED_CHAT_LABEL
+ };
+ })
);
- // hide the New chat button while a new-chat tab is already open
- let showNewChatButton = $derived(!view.ids.includes(NEW_CHAT_TAB_ID));
+ // the new-chat tab of the view: the regular one, or the project's own
+ let newChatTabId = $derived(
+ view.projectId ? projectNewChatTabId(view.projectId) : NEW_CHAT_TAB_ID
+ );
+
+ // hide the New chat button while that tab is already open
+ let showNewChatButton = $derived(!view.ids.includes(newChatTabId));
let loadingIds = $derived(new Set(chatStore.getAllLoadingChats()));
@@ -46,6 +60,11 @@
void tabsStore.close(id, id === activeId, view);
}
+ function openNewChat() {
+ void tabsStore.openInNewTab(newChatTabId);
+ void goto(view.hrefFor(newChatTabId));
+ }
+
function handleStop(id: string, event: MouseEvent) {
event.stopPropagation();
void chatStore.stopGenerationForChat(id);
@@ -135,44 +154,48 @@
: CHAT_TABS_MAX_WIDTH.COLLAPSED_SIDEBAR
]}
>
-
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/ChatTabs/ChatTabsNewChatButton.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte
index a3a8f1439bbb..35affb808ba1 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte
@@ -4,10 +4,11 @@
import { ICON_CLASS_DEFAULT } from '#lib/constants/index.ts';
interface Props {
+ label?: string;
onclick?: () => void;
}
- let { onclick }: Props = $props();
+ let { label = 'New chat', onclick }: Props = $props();
@@ -15,8 +16,8 @@
{#snippet child({ props })}
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..13dde519966f 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
*
@@ -219,6 +205,11 @@ export { default as ChatFormActionReasoning } from './ChatForm/ChatFormActions/C
*/
export { default as ChatFormActionAddToolsSubmenu } from './ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddToolsSubmenu.svelte';
+/**
+ * System message submenu of the add dropdown: prompts from the library, MCP prompts and a write-new entry.
+ */
+export { default as ChatFormActionAddSystemMessageSubmenu } from './ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddSystemMessageSubmenu.svelte';
+
/**
* Compact context-usage gauge with per-turn and cumulative breakdown in the tooltip.
*/
@@ -229,12 +220,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
@@ -254,63 +239,12 @@ 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
+ * **ChatFormProjectChip** - The chat's project under the chat form
*
- * @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.
+ * Shown beside the working directory. A click changes the project and the
+ * hover × takes the chat out of it.
*/
-export { default as ChatFormPromptPickerArgumentInput } from './ChatForm/ChatFormPickers/ChatFormPickerMcpPrompts/ChatFormPromptPickerArgumentInput.svelte';
+export { default as ChatFormProjectChip } from './ChatForm/ChatFormProjectChip/ChatFormProjectChip.svelte';
/**
* Shared popover wrapper for inline picker popovers (prompts, resources).
@@ -322,24 +256,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 +289,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 +455,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
@@ -543,6 +463,12 @@ export { default as ChatMessageMcpPrompt } from './ChatMessages/ChatMessage/Chat
*/
export { default as ChatMessageCwdChange } from './ChatMessages/ChatMessage/ChatMessageCwdChange.svelte';
+/**
+ * The `Set working directory to ` row itself, shared by the synthetic
+ * cwd message and by the project folder row.
+ */
+export { default as ChatMessageCwdChangeRow } from './ChatMessages/ChatMessage/ChatMessageCwdChangeRow.svelte';
+
/**
* Generic wrapper for UI-generated (synthetic) messages. Routes the
* working-directory change to ChatMessageCwdChange and renders a muted
@@ -559,11 +485,11 @@ 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.
+ * A system message made from a library prompt, laid out like the MCP prompt card:
+ * the prompt's name above, with an optional status (e.g. "Modified"), and its text
+ * in a card.
*/
-export { default as ChatMessageMcpPromptContent } from './ChatMessages/ChatMessage/ChatMessageMcpPrompt/ChatMessageMcpPromptContent.svelte';
+export { default as ChatMessagePromptContent } from './ChatMessages/ChatMessage/ChatMessagePrompt/ChatMessagePromptContent.svelte';
/**
* Assistant message display component. Renders assistant responses with left-aligned styling.
@@ -669,11 +595,13 @@ export { default as ChatScreen } from './ChatScreen/ChatScreen.svelte';
* **ChatTabs** - Browser-style tab bar for open conversations
*
* Horizontal strip of tabs rendered above ChatScreen in the chat layout,
- * one per conversation tracked by tabsStore. The active tab follows the
- * route's conversation id; clicking a tab navigates to it, middle-click or
- * the close button closes it (switching to the left neighbor when closing
- * the active tab), and a trailing "+" button starts a new chat. Shows a
- * spinner on tabs with a running generation. Desktop-only.
+ * showing the tabs of the route's view (see `resolveTabView`): every open
+ * tab in the regular view, or the chats of the open project in a project
+ * view, led by the project breadcrumb. The active tab follows the route;
+ * clicking a tab navigates to it, middle-click or the close button closes
+ * it (switching to the left neighbor when closing the active tab), and a
+ * trailing "+" button starts a new chat, inside the project in a project
+ * view. Shows a spinner on tabs with a running generation. Desktop-only.
*/
export { default as ChatTabs } from './ChatTabs/ChatTabs.svelte';
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogExportSettings.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogExportSettings.svelte
index 9afa1b17d6e6..35750c932e25 100644
--- a/ui/apps/chat/src/lib/components/app/dialogs/DialogExportSettings.svelte
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogExportSettings.svelte
@@ -38,14 +38,14 @@
{#if includeSensitiveData}
- Warning: This export will include sensitive data such as API keys and MCP server custom
- headers (e.g., authorization tokens). Do not share this file with anyone you don't
- trust.
+ Warning: This export will include sensitive data such as API keys, remote access codes
+ and MCP server custom headers (e.g., authorization tokens). Do not share this file with
+ anyone you don't trust.
{:else}
- Sensitive data (API keys, MCP server custom headers) will not be included in the export
- to protect your credentials.
+ Sensitive data (API keys, remote access codes, MCP server custom headers) will not be
+ included in the export to protect your credentials.
{/if}
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/DialogPrompt.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogPrompt.svelte
new file mode 100644
index 000000000000..64b80128c418
--- /dev/null
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogPrompt.svelte
@@ -0,0 +1,139 @@
+
+
+
+ {
+ event.preventDefault();
+ nameInput?.focus();
+ nameInput?.select();
+ }}
+ >
+
+
+ {prompt ? 'Edit prompt' : contentEditable ? 'New prompt' : 'Add to library'}
+
+
+ {#if !prompt && !contentEditable}
+
+ Save this system message as a prompt, to start other chats from it.
+
+ {/if}
+
+
+
+
+
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogPromptUpdate.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogPromptUpdate.svelte
new file mode 100644
index 000000000000..f20c8525a513
--- /dev/null
+++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogPromptUpdate.svelte
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+ Update prompt
+
+
+
+ {#if drift === PromptDrift.LIBRARY}
+ The prompt changed after this system message was written. Update the prompt with this
+ message's text, or sync this message from the prompt.
+ {:else}
+ Save this system message's text back to the prompt in your library.
+ {/if}
+
+
+
+
+
+
+ Cancel
+
+ {#if drift === PromptDrift.LIBRARY}
+
+ {/if}
+
+
+
+
+
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..d7a531dce1d3 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,14 @@
ICON_CLASS_DEFAULT,
ICON_CLASS_SM,
ICON_CLASS_XS,
- SIDEBAR_ACTIONS_ITEMS,
- SIDEBAR_FOOTER_ITEMS
+ PROJECT_ICON,
+ 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 { conversationsStore, deviceStore, projectsStore, uiStore } from '#lib/stores/index.ts';
+ import { formatRelativeTime, isIMEComposing, sidebarFooterItems } from '#lib/utils/index.ts';
import { goto } from '$app/navigation';
import type { Component } from 'svelte';
@@ -20,9 +21,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;
@@ -60,33 +63,57 @@
.filter((conversation) => matches(conversation.name))
.sort((a, b) => b.lastModified - a.lastModified)
.slice(0, limit)
- .map((conversation) => ({
- icon: MessageSquare,
- id: `chat-${conversation.id}`,
- label: conversation.name,
- meta: formatRelativeTime(conversation.lastModified),
- pinned: conversation.pinned,
- run: () => close(() => goto(RouterService.chat(conversation.id)))
+ .map((conversation) => {
+ const project = conversation.projectId
+ ? projectsStore.get(conversation.projectId)
+ : undefined;
+ const time = formatRelativeTime(conversation.lastModified);
+
+ return {
+ icon: MessageSquare,
+ id: `chat-${conversation.id}`,
+ label: conversation.name,
+ meta: project ? `${project.name} · ${time}` : time,
+ pinned: conversation.pinned,
+ run: () => close(() => goto(RouterService.conversation(conversation)))
+ };
+ })
+ );
+
+ const projectEntries = $derived.by((): SearchEntry[] =>
+ projectsStore.projects
+ .filter((project) => matches(project.name))
+ .slice(0, limit)
+ .map((project) => ({
+ icon: PROJECT_ICON,
+ id: `project-${project.id}`,
+ label: project.name,
+ meta: project.archived ? 'Archived' : undefined,
+ run: () => close(() => uiStore.openProjectDialog({ projectId: project.id }))
}))
);
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))
);
@@ -94,6 +121,7 @@
const sections = $derived(
[
{ entries: chatEntries, title: needle ? 'Chats' : 'Recents' },
+ { entries: projectEntries, title: 'Projects' },
{ entries: actionEntries, title: 'Actions' }
].filter((section) => section.entries.length > 0)
);
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..6d6ad0d2ab56 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
*
@@ -177,6 +161,23 @@ export { default as DialogConversationDelete } from './DialogConversationDelete.
*/
export { default as DialogConversationRename } from './DialogConversationRename.svelte';
+/**
+ * **DialogPromptUpdate** - Save a system message back to its library prompt
+ *
+ * Opened from the "Modified" link under a system message made from a prompt.
+ * Writes the message text to the prompt (with an optional rename), or syncs the
+ * message from the prompt when the library is the newer side.
+ */
+export { default as DialogPromptUpdate } from './DialogPromptUpdate.svelte';
+
+/**
+ * **DialogPrompt** - Name, describe and write a library prompt
+ *
+ * Adds a prompt to the library, from a system message (its text shown as is)
+ * or from scratch on the Library page, and edits an existing one.
+ */
+export { default as DialogPrompt } from './DialogPrompt.svelte';
+
/**
* **DialogGroup** - Name a new sidebar group, or rename one
*
@@ -447,60 +448,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..c6ff41dcb941 100644
--- a/ui/apps/chat/src/lib/components/app/index.ts
+++ b/ui/apps/chat/src/lib/components/app/index.ts
@@ -4,9 +4,10 @@ export * from './chat';
export * from './content';
export * from './dialogs';
export * from './forms';
-export * from './mcp';
+export * from './library';
export * from './misc';
export * from './settings';
export * from './models';
export * from './navigation';
export * from './servers';
+export * from './projects';
diff --git a/ui/apps/chat/src/lib/components/app/library/LibraryGrid.svelte b/ui/apps/chat/src/lib/components/app/library/LibraryGrid.svelte
new file mode 100644
index 000000000000..25158be0e135
--- /dev/null
+++ b/ui/apps/chat/src/lib/components/app/library/LibraryGrid.svelte
@@ -0,0 +1,43 @@
+
+
+
+
+ {#each PROMPT_CARD_SKELETONS as index (index)}
+
+ {/each}
+
+{:else if promptsStore.prompts.length === 0}
+
+
+
+
+
+
+ Save your first prompt
+
+
+ Keep system messages you reuse, and start chats from them. A system message in a chat can be
+ added here with its "Add to library" link.
+
+
+
+
+
+
+
+{:else if prompts.length === 0}
+
+
+
+
+
+
+ No prompts match
+
+ Try another search.
+
+
+{:else}
+