From 4df6165fa93c7caeea86385312415e312de4d11f Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期二, 05 五月 2026 01:10:39 +0800
Subject: [PATCH] 暂存

---
 src/Moli.Desktop/Llm/LlmModels.cs                                  |  101 +
 src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs            |   54 
 src/Moli.Desktop/Management/ManagementWindow.xaml                  |   16 
 src/Moli.Desktop/Windows/RuntimeSurfaceController.cs               |   77 +
 docs/product/llm-command-palette-plugin-prd.md                     |  200 ++
 src/Moli.Desktop/Interop/Win32InteropService.cs                    |   20 
 src/Moli.Desktop/Llm/LlmGatewayService.cs                          |  117 +
 src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs      |   97 +
 src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs                |   13 
 docs/ops/user-manual.md                                            |    3 
 src/Moli.Desktop/WebView/PluginBridgeScript.cs                     |    7 
 src/Moli.Desktop/Host/DefaultContentInstaller.cs                   |   12 
 docs/README.md                                                     |    2 
 docs/architecture/runtime-architecture.md                          |    4 
 scripts/publish-to-apps.ps1                                        |   80 +
 src/Moli.Desktop/Diagnostics/DailyFileLoggerProvider.cs            |   79 +
 docs/architecture/detailed-design.md                               |    2 
 src/Moli.Desktop/Runtime/RuntimeState.cs                           |    9 
 src/Moli.Desktop/Host/DesktopPaths.cs                              |    2 
 src/Moli.Desktop/Layout/LayoutManager.cs                           |   16 
 samples/plugins/sample.llm-command-palette/index.html              |  486 ++++++
 src/Moli.Desktop.Tests/Llm/AiChatClientTests.cs                    |  165 ++
 docs/ops/user-manual/plugins/sample.llm-command-palette.md         |  145 ++
 src/Moli.Desktop/Windows/WidgetWindow.cs                           |   21 
 src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs                 |  200 ++
 docs/product/desktop-enhancement-prd.md                            |    2 
 samples/plugins/sample.llm-command-palette/plugin.json             |   82 +
 docs/development/llm-command-palette-aichat-mode-task-breakdown.md |  156 ++
 docs/data/configuration-and-storage.md                             |    6 
 src/Moli.Desktop/Host/DesktopHostBuilder.cs                        |    4 
 src/Moli.Desktop/Interop/NativeMethods.cs                          |    5 
 src/Moli.Desktop/Management/ManagementWindow.xaml.cs               |  127 +
 docs/qa/display-layer-acceptance-2026-05-03.md                     |    2 
 docs/architecture/llm-command-palette-architecture.md              |  297 ++++
 samples/plugins/sample.llm-command-palette/demo.html               |  491 +++++++
 src/Moli.Desktop/Llm/ILlmServices.cs                               |   72 +
 docs/ops/user-manual/moli-desktop.md                               |    8 
 docs/qa/llm-command-palette-aichat-mode-acceptance-2026-05-04.md   |   57 
 src/Moli.Desktop/Diagnostics/DiagnosticsService.cs                 |    9 
 src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs               |   76 +
 src/Moli.Desktop/Llm/AiChatClient.cs                               |  621 +++++++++
 41 files changed, 3,821 insertions(+), 122 deletions(-)

diff --git a/docs/README.md b/docs/README.md
index 8d5b594..ca08da6 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -27,6 +27,7 @@
 ## 褰撳墠寮�鍙戞枃妗�
 
 - [Moli.Desktop MVP 寮�鍙戜换鍔℃媶鍒哴(development/mvp-dev-task-breakdown.md)
+- [LLM 妗岄潰杈撳叆鎻掍欢 AiChat 妯″紡寮�鍙戜换鍔℃媶鍒哴(development/llm-command-palette-aichat-mode-task-breakdown.md)
 
 ## 褰撳墠 API 鏂囨。
 
@@ -41,6 +42,7 @@
 - [Moli.Desktop MVP 闆嗘垚绉讳氦璁板綍](qa/mvp-integration-handoff.md)
 - [Moli.Desktop MVP QA 娴嬭瘯璁″垝涓庢姤鍛奭(qa/mvp-qa-report-2026-05-02.md)
 - [LLM 妗岄潰杈撳叆鎻掍欢楠屾敹璁板綍](qa/llm-command-palette-acceptance-2026-05-04.md)
+- [LLM 妗岄潰杈撳叆鎻掍欢 AiChat 妯″紡楠屾敹璁板綍](qa/llm-command-palette-aichat-mode-acceptance-2026-05-04.md)
 
 ## 褰撳墠杩愮淮鏂囨。
 
diff --git a/docs/architecture/detailed-design.md b/docs/architecture/detailed-design.md
index 2825e70..db2a37f 100644
--- a/docs/architecture/detailed-design.md
+++ b/docs/architecture/detailed-design.md
@@ -462,7 +462,7 @@
 
 绛栫暐椤哄簭锛�
 
-1. `WorkerWDesktopLayerStrategy`锛氬皾璇曞皢澹佺焊绐楀彛鍜� `desktop` 灞傜粍浠舵寕鍒� Explorer WorkerW锛屼娇妗岄潰鎻掍欢鍦� Win+D 鍚庝粛鐒舵樉绀恒��
+1. `WorkerWDesktopLayerStrategy`锛氬皾璇曞皢澹佺焊绐楀彛鍜� `desktop` 灞傜粍浠舵寕鍒� Explorer WorkerW锛涘綋褰撳墠 Explorer 娌℃湁鐙珛 WorkerW 鏃跺洖閫�鍒� Progman 妗岄潰瀹夸富銆傛寕杞芥椂绐楀彛蹇呴』鍒囨崲涓� `WS_CHILD` 骞剁Щ闄� `WS_POPUP`锛屼娇妗岄潰鎻掍欢鍦� Win+D 鍚庝粛鐒舵樉绀恒��
 2. `BottomDesktopLayerStrategy`锛氶檷绾т负瑕嗙洊鐩爣鍖哄煙鐨勫簳灞傜獥鍙o紝骞跺紑鍚偣鍑荤┛閫忋��
 
 閫夋嫨绛栫暐鍚庡啓鍏ヨ瘖鏂細
diff --git a/docs/architecture/llm-command-palette-architecture.md b/docs/architecture/llm-command-palette-architecture.md
index d4b445b..2c8f425 100644
--- a/docs/architecture/llm-command-palette-architecture.md
+++ b/docs/architecture/llm-command-palette-architecture.md
@@ -9,15 +9,22 @@
 鏍稿績鏋舵瀯鍐崇瓥锛�
 
 - 鎻掍欢鍓嶇鍙礋璐h緭鍏ャ�佹ā鍨嬮�夋嫨鍜屾祦寮忔覆鏌撱��
-- 鎻掍欢鍓嶇鍙紶 `modelId`銆乣messages` 鍜岃姹傚弬鏁帮紝涓嶇洿鎺ヤ紶 provider銆乪ndpoint 鎴� API key銆�
+- 鎻掍欢鍓嶇鍙紶 `mode`銆乣projectId`銆乣modelId`銆乣messages` 鍜岃姹傚弬鏁帮紝涓嶇洿鎺ヤ紶 provider銆乪ndpoint銆丄PI key銆丄iChat 瀵嗙爜鎴� Session Token銆�
 - 瀹夸富缁存姢 LLM 妯″瀷娉ㄥ唽琛紝姣忎釜妯″瀷鍙嫭绔嬮厤缃� `provider`銆乣endpoint`銆乣authRef` 鍜� `apiModel`銆�
 - 瀹夸富鎸� `modelId` 閫夋嫨 provider adapter锛屽苟鎶婁笉鍚屼緵搴斿晢鐨勬祦寮忓搷搴旂粺涓�杞崲鎴愭彃浠跺彲娑堣垂鐨勪簨浠躲��
 - API key 涓嶈繘鍏ユ彃浠跺墠绔祫婧愩�乵anifest 绀轰緥鎴栨櫘閫氭棩蹇椼��
+- 鎻掍欢杩愯妯″紡鐢遍厤缃喅瀹氾細
+  - `provider-direct`锛氭部鐢ㄥ綋鍓嶄緵搴斿晢鐩磋繛閾捐矾锛屽苟鍙皟鐢� AiChat 璁板繂鎺ュ彛绠$悊/鍙洖璁板繂銆�
+  - `aichat-api`锛氶�氳繃鑷湁 AiChat API 鐧诲綍銆佽鍙栭」鐩�佸彂閫佽亰澶╁拰璁㈤槄 SSE锛涙彃浠朵晶涓嶅鐞嗚蹇嗐��
+- AiChat 缁熶竴 Host 榛樿鍥哄畾涓� `http://192.168.1.111:13000`锛屼笉浠� AiChat 鎺ュ彛鏂囨。鐨勭幆澧冭〃鎺ㄥ銆�
 
 ## Goals
 
 - 鏀寔涓�涓《閮ㄥ眳涓殑 LLM 杈撳叆灏忕粍浠讹紝榛樿浣滀负 `widget` 鎻掍欢杩愯銆�
 - 鏀寔澶氫緵搴斿晢銆佸 endpoint銆佸妯″瀷鍏卞瓨銆�
+- 鏀寔閫氳繃閰嶇疆鍒囨崲渚涘簲鍟嗙洿杩炲拰 AiChat 鑷湁 API 涓ょ妯″紡銆�
+- 鏀寔杈撳叆妗嗗乏渚� AiChat 椤圭洰涓嬫媺銆�
+- 鏀寔渚涘簲鍟嗙洿杩炴ā寮忎笅澶嶇敤 AiChat 璁板繂绠$悊鑳藉姏銆�
 - 鏀寔 OpenAI-compatible銆丏eepSeek銆佹湰鍦� OpenAI-compatible 鏈嶅姟锛屽悗缁彲鎵╁睍 Anthropic銆丱llama 绛夐�傞厤鍣ㄣ��
 - 鏀寔娴佸紡杈撳嚭锛屽苟灏嗕緵搴斿晢宸紓灞忚斀鍦ㄥ涓讳晶銆�
 - 淇濇寔鎻掍欢绯荤粺杈圭晫锛歐ebView 椤甸潰鍙闂櫧鍚嶅崟妗ユ帴 API銆�
@@ -28,6 +35,9 @@
 - 涓嶅疄鐜板畬鏁磋亰澶╀細璇濈郴缁熴��
 - 涓嶅疄鐜颁簯绔悓姝ャ�佸洟闃熷叡浜ā鍨嬮厤缃垨璁¤垂绯荤粺銆�
 - 涓嶅湪鎻掍欢鍓嶇鐩存帴淇濆瓨鎴栫鐞� API key銆�
+- 涓嶅湪鎻掍欢鍓嶇淇濆瓨 AiChat 瀵嗙爜鎴� Session Token銆�
+- 涓嶅鍒� AiChat 鏈嶅姟绔殑椤圭洰銆佸鎵广�佹潈闄愩�侀厤棰濆拰璁板繂绛栫暐銆�
+- 涓嶅湪 `aichat-api` 妯″紡涓澶栬皟鐢ㄨ蹇嗗彫鍥炴嫾瑁� Prompt銆�
 - 涓嶅湪 MVP 涓疄鐜版枃浠朵笂浼犮�佸妯℃�佽緭鍏ユ垨闀挎湡鍘嗗彶璁板綍銆�
 - 涓嶈姹傛妸 LLM 浠g悊鏆撮湶鎴愬叕缃� API銆�
 
@@ -41,6 +51,10 @@
   Bridge["PluginBridgeScript / WebViewHost"]
   Runtime["DesktopRuntimeCoordinator"]
   LlmService["LlmGatewayService"]
+  ModeRouter["LlmModeRouter"]
+  AiChat["AiChatClient"]
+  AiChatSession["AiChatSessionService"]
+  AiChatMemory["AiChatMemoryService"]
   Registry["LlmModelRegistry"]
   SecretStore["CredentialStore"]
   AdapterFactory["LlmProviderAdapterFactory"]
@@ -54,6 +68,10 @@
   Plugin --> Bridge
   Bridge --> Runtime
   Runtime --> LlmService
+  LlmService --> ModeRouter
+  ModeRouter --> AiChat
+  AiChat --> AiChatSession
+  AiChat --> AiChatMemory
   LlmService --> Registry
   Registry --> Config
   LlmService --> SecretStore
@@ -73,7 +91,11 @@
 | `sample.llm-command-palette` | 杈撳叆銆佹ā鍨嬩笅鎷夈�丒nter 鎻愪氦銆佹祦寮忔枃鏈覆鏌撱�侀敊璇睍绀� | 渚涘簲鍟� API 閫傞厤銆佸瘑閽ヨ鍙� |
 | `PluginBridgeScript` | 鍚� WebView 娉ㄥ叆 `window.moliDesktop.llm` API锛屽鐞� Promise 涓庝簨浠舵淳鍙� | 鐩存帴鍙戣捣澶栭儴 HTTP 璇锋眰 |
 | `DesktopRuntimeCoordinator` | 缁熶竴鎺ユ敹鎻掍欢妗ユ帴鍛戒护锛屾牎楠屾彃浠跺疄渚嬪拰鏉冮檺锛岃皟鐢� LLM 鏈嶅姟 | 瑙f瀽渚涘簲鍟嗘祦寮忓崗璁� |
-| `LlmGatewayService` | LLM 璇锋眰鍏ュ彛銆佹ā鍨嬭矾鐢便�佸彇娑堛�佽秴鏃躲�佷簨浠跺綊涓�鍖� | 鎸佷箙鍖栧竷灞�鎴栫獥鍙g姸鎬� |
+| `LlmGatewayService` | LLM 璇锋眰鍏ュ彛銆佽繍琛屾ā寮忓垎鍙戙�佹ā鍨嬭矾鐢便�佸彇娑堛�佽秴鏃躲�佷簨浠跺綊涓�鍖� | 鎸佷箙鍖栧竷灞�鎴栫獥鍙g姸鎬� |
+| `LlmModeRouter` | 鎸� `provider-direct` / `aichat-api` 閫夋嫨渚涘簲鍟嗛�傞厤鍣ㄦ垨 AiChat 瀹㈡埛绔� | 澶勭悊鍏蜂綋 SSE 鍗忚 |
+| `AiChatClient` | 灏佽 AiChat 鐧诲綍銆侀」鐩�佹ā鍨嬨�佽亰澶┿�丼SE 鍜岄敊璇爜鏄犲皠 | 淇濆瓨鐢ㄦ埛瀵嗙爜鏄庢枃 |
+| `AiChatSessionService` | 瑙f瀽瀵嗙爜鐜鍙橀噺銆佺櫥褰曘�佺紦瀛樺唴瀛樻�� sessionToken銆�401 閲嶇櫥 | 鏆撮湶 sessionToken 缁欐彃浠堕〉闈� |
+| `AiChatMemoryService` | 渚涘簲鍟嗙洿杩炴ā寮忎笅灏佽璁板繂鏌ヨ銆佸垱寤恒�佸垹闄ゃ�佸彫鍥� | 鍦ㄨ嚜鏈� API 妯″紡涓噸澶嶅鐞嗚蹇� |
 | `LlmModelRegistry` | 鍔犺浇鍜屾牎楠屾ā鍨嬮厤缃紝鎸� `modelId` 鏌ユ壘妯″瀷 | 淇濆瓨 API key 鏄庢枃 |
 | `CredentialStore` | 鎸� `authRef` 鎻愪緵瀵嗛挜锛岄殣钘忕湡瀹� key | 淇濆瓨鏅�氭彃浠堕厤缃� |
 | `LlmProviderAdapter` | 鎸� provider 閫傞厤璇锋眰鍜屾祦寮忓搷搴� | 鍐冲畾鎻掍欢 UI 琛屼负 |
@@ -85,6 +107,7 @@
 - 鎻掍欢 UI 鍙兘渚濊禆 `window.moliDesktop.llm`銆�
 - 妗ユ帴灞傚彧渚濊禆杩愯鏃舵帴鍙o紝涓嶇洿鎺ヤ緷璧栧叿浣� provider adapter銆�
 - Provider adapter 鍙敱 `LlmGatewayService` 閫氳繃宸ュ巶鍒涘缓鎴栧彇寰椼��
+- AiChat API 璁块棶鍙敱瀹夸富渚� `AiChatClient` 鎵ц锛屾彃浠堕〉闈笉鑳界洿鎺ユ寔鏈夊瘑鐮佹垨 token銆�
 - 閰嶇疆璇诲啓浠嶇粡 `ConfigurationService`锛屼笉鍏佽鎻掍欢鎴� adapter 鐩存帴鍐� JSON銆�
 
 ## Runtime Flow
@@ -125,6 +148,58 @@
 
 榛樿涓嶈繑鍥� `endpoint`銆乣authRef`銆丄PI key 鎴栧叾浠栨晱鎰熼厤缃�傜鐞嗙獥鍙e彲浠ュ湪鍙楁帶 UI 涓睍绀哄拰缂栬緫 endpoint锛屼絾鎻掍欢鍓嶇涓嶉渶瑕佺煡閬撱��
 
+`aichat-api` 妯″紡涓嬫ā鍨嬪垪琛ㄦ潵鑷� AiChat `GET /api/chat/models`锛岃繑鍥炲悓鏍风殑瀹夊叏鎽樿缁撴瀯锛�
+
+```json
+[
+  {
+    "id": "deepseek-v4-flash",
+    "label": "deepseek-v4-flash",
+    "provider": "aichat",
+    "supportsStreaming": true,
+    "enabled": true
+  }
+]
+```
+
+### AiChat Login and Project Load
+
+```mermaid
+sequenceDiagram
+  participant Plugin
+  participant Bridge
+  participant Runtime
+  participant AiChat as AiChatClient
+  participant Session as AiChatSessionService
+  participant Api as AiChat API
+
+  Plugin->>Bridge: getProjects()
+  Bridge->>Runtime: GetAiChatProjects(pluginId, instanceId)
+  Runtime->>AiChat: GetProjectsAsync()
+  AiChat->>Session: EnsureSessionAsync()
+  Session->>Session: Resolve passwordEnv before password
+  Session->>Api: POST /api/auth/login
+  Api-->>Session: sessionToken
+  AiChat->>Api: GET /api/projects with x-session-token
+  Api-->>AiChat: projects
+  AiChat-->>Runtime: safe project summaries
+  Runtime-->>Bridge: project summaries
+  Bridge-->>Plugin: Promise resolve
+```
+
+椤圭洰鎽樿寤鸿鍙繑鍥炴彃浠� UI 闇�瑕佺殑瀛楁锛�
+
+```json
+[
+  {
+    "id": "project_id",
+    "name": "浜у搧闂瓟",
+    "projectType": "CHAT",
+    "memoryMode": "ISOLATED"
+  }
+]
+```
+
 ### Stream Chat
 
 ```mermaid
@@ -138,11 +213,11 @@
   participant Adapter as ProviderAdapter
   participant Upstream as LLM Provider
 
-  Plugin->>Bridge: streamChat(modelId, messages, options)
+  Plugin->>Bridge: streamChat(mode, projectId, modelId, messages, options)
   Bridge->>Runtime: StreamLlmChat(request)
   Runtime->>Runtime: Validate plugin permission llm.stream
   Runtime->>Llm: StreamChatAsync(request)
-  Llm->>Registry: Get model by modelId
+  Llm->>Registry: Get model by modelId when provider-direct
   Registry-->>Llm: provider, endpoint, authRef, apiModel
   Llm->>Secret: Resolve authRef
   Secret-->>Llm: credential or null
@@ -154,6 +229,75 @@
   Runtime-->>Bridge: llm.delta / completed / error
   Bridge-->>Plugin: DOM event or callback
 ```
+
+### AiChat API Chat Flow
+
+```mermaid
+sequenceDiagram
+  participant Plugin
+  participant Bridge
+  participant Runtime
+  participant Llm as LlmGatewayService
+  participant AiChat as AiChatClient
+  participant Api as AiChat API
+
+  Plugin->>Bridge: streamChat(mode=aichat-api, projectId, modelId, message)
+  Bridge->>Runtime: StreamLlmChat(request)
+  Runtime->>Runtime: Validate plugin permission llm.stream
+  Runtime->>Llm: StreamChatAsync(request)
+  Llm->>AiChat: SendChatAsync(projectId, modelName, message)
+  AiChat->>Api: POST /api/chat/send
+  Api-->>AiChat: generationId, streamToken, conversationId
+  AiChat->>Api: GET /api/chat/generations/{id}/stream?token={streamToken}
+  Api-->>AiChat: snapshot/chunk/processing/done/failed/aborted
+  AiChat-->>Llm: normalized deltas/completed/error
+  Llm-->>Runtime: LlmStreamEvent
+  Runtime-->>Bridge: llm.delta / completed / error
+  Bridge-->>Plugin: DOM event or callback
+```
+
+AiChat SSE 浜嬩欢鏄犲皠锛�
+
+| AiChat event | 褰掍竴鍖栦簨浠� | 澶勭悊 |
+| --- | --- | --- |
+| `snapshot` | `llm.delta` 鎴栧拷鐣� | 濡傛灉 snapshot content 闈炵┖锛屼綔涓哄綋鍓嶅唴瀹瑰揩鐓ф覆鏌� |
+| `chunk` | `llm.delta` | 浣跨敤 `delta` 杩藉姞 |
+| `processing` | `llm.processing` | UI 鍙樉绀衡�滃鐞嗕腑鈥� |
+| `done` | `llm.completed` | 缁撴潫璇锋眰 |
+| `failed` | `llm.error` | 鏄剧ず閿欒骞剁粨鏉熻姹� |
+| `aborted` | `llm.error` 鎴� `llm.aborted` | 鏄剧ず宸茬粓姝㈠苟缁撴潫璇锋眰 |
+
+### Provider Direct Memory Flow
+
+渚涘簲鍟嗙洿杩炴ā寮忎笅锛岃蹇嗙鐞嗚蛋 AiChat API锛屼絾鑱婂ぉ鐢熸垚浠嶈蛋渚涘簲鍟嗛�傞厤鍣細
+
+```mermaid
+sequenceDiagram
+  participant Plugin
+  participant Bridge
+  participant Runtime
+  participant Memory as AiChatMemoryService
+  participant Api as AiChat API
+  participant Llm as LlmGatewayService
+  participant Provider as ProviderAdapter
+
+  Plugin->>Bridge: recallMemories(query, projectId, scope=ALL)
+  Bridge->>Runtime: RecallMemories(request)
+  Runtime->>Memory: RecallAsync(request)
+  Memory->>Api: POST /api/memories/recall
+  Api-->>Memory: memory items
+  Memory-->>Plugin: safe memory summaries
+  Plugin->>Bridge: streamChat(mode=provider-direct, messages with selected memory context)
+  Bridge->>Llm: StreamChatAsync(request)
+  Llm->>Provider: StreamAsync(normalized request)
+```
+
+鏉冮檺瑙勫垯锛�
+
+- `GET /api/auth/me` 杩斿洖 `canUseMemory`銆乣canViewMemory`銆乣canManageMemory` 鍚庯紝瀹夸富搴旀妸鍙敤鑳藉姏鎽樿杩斿洖缁欐彃浠躲��
+- `canViewMemory=false` 鏃朵笉灞曠ず璁板繂鍒楄〃銆�
+- `canManageMemory=false` 鏃朵笉鍏佽鍒涘缓鎴栧垹闄ゃ��
+- `canUseMemory=false` 鏃朵笉鍏佽鍙洖骞舵敞鍏ヤ笂涓嬫枃銆�
 
 ### Cancellation
 
@@ -236,6 +380,51 @@
 }
 ```
 
+### Plugin Runtime Mode Config
+
+寤鸿鍦ㄦ彃浠堕厤缃垨鍚庣画鐙珛杩愯閰嶇疆涓鍔� AiChat 瀵规帴閰嶇疆銆備负浜嗗吋瀹圭幇鏈� `plugin.json`锛岀己澶卞瓧娈垫椂浣跨敤榛樿鍊笺��
+
+```json
+{
+  "schemaVersion": 1,
+  "mode": "provider-direct",
+  "aichat": {
+    "baseUrl": "http://192.168.1.111:13000",
+    "account": {
+      "email": "user@example.com",
+      "password": null,
+      "passwordEnv": "MOLI_AICHAT_PASSWORD"
+    },
+    "defaultProjectId": "",
+    "memory": {
+      "enabledInProviderDirect": true,
+      "defaultScope": "PROJECT",
+      "recallLimit": 8
+    }
+  }
+}
+```
+
+鏍¢獙瑙勫垯锛�
+
+| 瀛楁 | 瑙勫垯 |
+| --- | --- |
+| `mode` | `provider-direct` 鎴� `aichat-api`锛岀己澶辨椂榛樿涓� `provider-direct` |
+| `aichat.baseUrl` | `http` 鎴� `https` 缁濆 URL锛岄粯璁� `http://192.168.1.111:13000` |
+| `aichat.account.email` | 鍙负绌猴紱璋冪敤 AiChat API 鍓嶅繀椤诲瓨鍦� |
+| `aichat.account.passwordEnv` | 鍙负绌猴紱瀛樺湪鏃朵紭鍏堣鍙栫幆澧冨彉閲� |
+| `aichat.account.password` | 鍙负绌猴紱鍙綔涓烘湰鍦版祴璇� fallback |
+| `aichat.defaultProjectId` | 鍙负绌猴紱涓嶄负绌烘椂搴斿瓨鍦ㄤ簬椤圭洰鍒楄〃 |
+| `aichat.memory.recallLimit` | `1..20` |
+
+瀵嗙爜瑙f瀽椤哄簭锛�
+
+1. `passwordEnv` 鎸囧悜鐨勭幆澧冨彉閲忓�笺��
+2. `password` 鏄庢枃瀛楁銆�
+3. 閮戒笉瀛樺湪鏃惰繑鍥� `AiChatCredentialMissing`銆�
+
+Session Token 浠呬繚瀛樺湪 `AiChatSessionService` 鍐呭瓨鎬侊紝涓嶅啓鍏� JSON銆�
+
 ### Model Validation Rules
 
 | 瀛楁 | 瑙勫垯 |
@@ -315,6 +504,8 @@
     public required string RequestId { get; init; }
     public required string PluginId { get; init; }
     public required string InstanceId { get; init; }
+    public string Mode { get; init; } = "provider-direct";
+    public string? ProjectId { get; init; }
     public required string ModelId { get; init; }
     public required IReadOnlyList<LlmMessage> Messages { get; init; }
     public LlmRequestOptions Options { get; init; } = new();
@@ -371,6 +562,8 @@
 };
 
 type LlmStreamRequest = {
+  mode?: "provider-direct" | "aichat-api";
+  projectId?: string;
   modelId: string;
   messages: Array<{ role: "system" | "user" | "assistant"; content: string }>;
   options?: {
@@ -381,9 +574,26 @@
 };
 
 window.moliDesktop.llm = {
+  getConnectionMode(): Promise<"provider-direct" | "aichat-api">;
+  setConnectionMode(mode: "provider-direct" | "aichat-api"): Promise<void>;
+  getProjects(): Promise<Array<{
+    id: string;
+    name: string;
+    projectType: "CHAT" | "REMOTE";
+    memoryMode: "ISOLATED" | "SHARED";
+  }>>;
   getModels(): Promise<LlmModelSummary[]>;
   streamChat(request: LlmStreamRequest): Promise<{ requestId: string }>;
   cancel(requestId: string): Promise<void>;
+  getMemoryCapabilities(): Promise<{
+    canUseMemory: boolean;
+    canViewMemory: boolean;
+    canManageMemory: boolean;
+  }>;
+  getMemories(options: { scope?: "GLOBAL" | "PROJECT"; projectId?: string }): Promise<object>;
+  createMemory(input: { scope: "GLOBAL" | "PROJECT"; projectId?: string; content: string }): Promise<object>;
+  deleteMemory(memoryId: string): Promise<void>;
+  recallMemories(input: { query: string; scope?: "GLOBAL" | "PROJECT" | "ALL"; projectId?: string; limit?: number }): Promise<object>;
   onDelta(handler: (event: { requestId: string; delta: string }) => void): () => void;
   onCompleted(handler: (event: { requestId: string; usage?: object }) => void): () => void;
   onError(handler: (event: { requestId: string; code: string; message: string }) => void): () => void;
@@ -432,11 +642,18 @@
 | `LlmRateLimited` | 429 | 杈撳嚭鍖烘彁绀虹◢鍚庨噸璇� | Warning |
 | `LlmTimeout` | 瓒呮椂 | 杈撳嚭鍖烘彁绀鸿姹傝秴鏃� | Warning |
 | `LlmStreamParseFailed` | 渚涘簲鍟嗘祦鏍煎紡寮傚父 | 淇濈暀宸茶緭鍑哄唴瀹瑰苟鎻愮ず瑙f瀽澶辫触 | Error |
+| `AiChatCredentialMissing` | 鏈厤缃� AiChat 璐﹀彿鎴栧瘑鐮� | 鎻愮ず妫�鏌ヨ处鍙峰拰瀵嗙爜鐜鍙橀噺 | Error锛屼笉璁板綍瀵嗙爜 |
+| `AiChatLoginFailed` | 鐧诲綍澶辫触鎴栬处鍙风姸鎬佸紓甯� | 鏄剧ず鐧诲綍澶辫触銆佸緟瀹℃壒鎴栨潈闄愰敊璇� | Warning |
+| `AiChatProjectLoadFailed` | 椤圭洰鍒楄〃涓嶅彲鐢� | 椤圭洰涓嬫媺鏄剧ず涓嶅彲鐢� | Warning |
+| `AiChatQuotaExceeded` | Token 閰嶉鑰楀敖 | 杈撳嚭鍖烘彁绀洪厤棰濊�楀敖 | Warning |
+| `AiChatMemoryPermissionDenied` | 璁板繂鏉冮檺涓嶈冻 | 绂佺敤瀵瑰簲璁板繂鎿嶄綔 | Warning |
+| `AiChatSseInterrupted` | AiChat SSE 涓柇 | 淇濈暀宸茶緭鍑哄唴瀹瑰苟鎻愮ず杩炴帴涓柇 | Warning |
 
 鏃ュ織瑙勫垯锛�
 
 - 鍙互璁板綍 `requestId`銆乣modelId`銆乣provider`銆乪ndpoint host銆丠TTP status銆�
 - 涓嶈褰曞畬鏁� API key銆�
+- 涓嶈褰� AiChat 瀵嗙爜銆丼ession Token 鎴栧畬鏁� `x-session-token` 璇锋眰澶淬��
 - 榛樿涓嶈褰曞畬鏁� prompt锛涘鍚庣画闇�瑕佽皟璇曞紑鍏筹紝蹇呴』鐢辩敤鎴锋樉寮忓惎鐢ㄣ��
 
 ## Security Boundaries
@@ -444,6 +661,7 @@
 - `llm.stream` 蹇呴』浣滀负鎻掍欢鏉冮檺澹版槑锛屾湭澹版槑鏃舵ˉ鎺ュ眰鎷掔粷璋冪敤銆�
 - 鎻掍欢鍙兘鐪嬪埌 enabled 妯″瀷鎽樿銆�
 - 鎻掍欢涓嶈兘瑕嗙洊 endpoint銆乸rovider銆乤uthRef 鎴� apiModel銆�
+- 鎻掍欢涓嶈兘璇诲彇 AiChat 鏄庢枃瀵嗙爜鍜� Session Token銆�
 - `setConfig` 涓嶅厑璁稿啓鍏ュ涓荤骇 LLM 妯″瀷娉ㄥ唽琛ㄣ��
 - 鏈湴 HTTP API 濡傚悗缁毚闇� LLM 璋冪敤锛屼篃蹇呴』榛樿缁戝畾 `127.0.0.1`锛屽苟澶嶇敤鍚屼竴 `ILlmGatewayService`銆�
 - 杩滅▼ endpoint 蹇呴』缁忚繃 URL 鏍¢獙锛岀姝� `file://`銆佺浉瀵硅矾寰勫拰闈� HTTP 鍗忚銆�
@@ -458,6 +676,9 @@
 | 鍙疄鐜� OpenAI-compatible adapter | MVP 鍙綔涓虹涓�闃舵 | 蹇�熻鐩栧鏁颁緵搴斿晢锛屼絾淇濈暀 provider adapter 鎵╁睍鐐� |
 | 鎶婃ā鍨嬮厤缃斁杩涙彃浠� manifest | 浠呬綔涓� fallback | manifest 灞炰簬鎻掍欢鍖咃紝涓嶉�傚悎淇濆瓨鐢ㄦ埛鐪熷疄 endpoint 鍜屽瘑閽ュ紩鐢� |
 | 鎶婃ā鍨嬮厤缃斁杩� `appsettings.json` | 鍙浣嗕笉鎺ㄨ崘 | LLM 閰嶇疆浼氬闀匡紝鐙珛鏂囦欢鏇村埄浜庣鐞嗗拰杩佺Щ |
+| 鑷湁 API 妯″紡鐩存帴璁╂彃浠� fetch AiChat | 涓嶉噰鐢� | 浼氭妸瀵嗙爜銆乼oken銆侀敊璇鐞嗗拰 SSE 鍏煎閫昏緫鎵╂暎鍒板墠绔� |
+| 瀹夸富灏佽 AiChatClient | 閲囩敤 | 缁熶竴閴存潈銆丼ession銆侀」鐩�佹ā鍨嬨�佽亰澶╁拰璁板繂閿欒鏄犲皠 |
+| 鑷湁 API 妯″紡涔熸墜鍔ㄥ彫鍥炶蹇� | 涓嶉噰鐢� | AiChat 鏈嶅姟鑷韩璐熻矗椤圭洰鍜岃蹇嗙瓥鐣ワ紝鎻掍欢閲嶅澶勭悊浼氱牬鍧忎竴鑷存�� |
 
 ## Implementation Tasks
 
@@ -578,6 +799,67 @@
 - LLM 閰嶇疆鍜� adapter 鍗曞厓娴嬭瘯閫氳繃銆�
 - 浣跨敤涓や釜涓嶅悓 endpoint 鐨勬ā鍨嬪彲鍒嗗埆璺敱銆�
 
+### A09 AiChat Client and Session
+
+杈撳嚭锛�
+
+- `AiChatClient`
+- `AiChatSessionService`
+- 鐧诲綍銆侀噸鐧汇�乣x-session-token` 娉ㄥ叆
+- `GET /api/projects`銆乣GET /api/chat/models`
+
+楠屾敹锛�
+
+- `passwordEnv` 浼樺厛浜庢槑鏂囧瘑鐮併��
+- 鐧诲綍鎴愬姛鍚� token 鍙繚瀛樺湪鍐呭瓨鎬併��
+- 401 鍚庤嚜鍔ㄩ噸鐧讳竴娆°��
+- 椤圭洰鍒楄〃澶辫触鏃� UI 鍙檷绾ц�屼笉褰卞搷渚涘簲鍟嗙洿杩炶亰澶┿��
+
+### A10 AiChat API Chat Mode
+
+杈撳嚭锛�
+
+- `mode=aichat-api` 鐨� `StreamChatAsync` 鍒嗘敮銆�
+- `POST /api/chat/send` 璋冪敤銆�
+- AiChat SSE 瑙f瀽鍜屼簨浠跺綊涓�鍖栥��
+
+楠屾敹锛�
+
+- 鎵�閫� `projectId` 浼氫紶缁� AiChat銆�
+- `chunk` 鑳借浆鎹负 `llm.delta`銆�
+- `done` 鑳借浆鎹负 `llm.completed`銆�
+- `failed` / `aborted` 鑳借浆鎹负鍙閿欒銆�
+
+### A11 Provider Direct Memory Management
+
+杈撳嚭锛�
+
+- `AiChatMemoryService`
+- 璁板繂鑳藉姏鏌ヨ銆�
+- 鏌ヨ銆佸垱寤恒�佸垹闄ゃ�佸彫鍥炴帴鍙c��
+- 鐩磋繛妯″紡涓嬪彲閫夋妸鍙洖鍐呭娉ㄥ叆涓婁笅鏂囥��
+
+楠屾敹锛�
+
+- `canViewMemory`銆乣canManageMemory`銆乣canUseMemory` 鍒嗗埆鎺у埗 UI 鑳藉姏銆�
+- 椤圭洰璁板繂璇锋眰蹇呴』鎼哄甫 `projectId`銆�
+- 鑷湁 API 妯″紡涓嬩笉璋冪敤璁板繂鍙洖銆�
+
+### A12 Sample Plugin UI Update
+
+杈撳嚭锛�
+
+- 杈撳叆妗嗗乏渚ч」鐩笅鎷夈��
+- 杩愯妯″紡閰嶇疆璇诲彇銆�
+- 妯″瀷鍒楄〃鎸夋ā寮忓垏鎹€��
+- 璁板繂绠$悊鍏ュ彛鍜屾潈闄愰檷绾х姸鎬併��
+
+楠屾敹锛�
+
+- 涓ょ妯″紡鍒囨崲鍚庯紝涓嬫媺鍜屾彁浜よ矾寰勬纭埛鏂般��
+- 椤圭洰涓嬫媺闀垮悕绉颁笉鎾戝紑杈撳叆鏉°��
+- AiChat 涓嶅彲鐢ㄦ椂鏈夌煭閿欒涓斾笉鐮村潖鐩磋繛妯″紡銆�
+
 ## Verification Plan
 
 ### Unit Tests
@@ -596,6 +878,9 @@
 ### Manual QA
 
 - 閰嶇疆涓や釜妯″瀷锛屽垎鍒寚鍚戜笉鍚� endpoint锛岄�夋嫨涓嶅悓妯″瀷鎻愪氦鍚庢鏌ヨ矾鐢辨棩蹇椼��
+- 閰嶇疆 `mode=aichat-api`銆丄iChat 璐﹀彿鍜� `MOLI_AICHAT_PASSWORD`锛岀‘璁よ兘鐧诲綍 `http://192.168.1.111:13000` 骞跺姞杞介」鐩��
+- 鍦ㄨ嚜鏈� API 妯″紡涓嬮�夋嫨椤圭洰骞舵彁浜わ紝纭 AiChat SSE 鑳芥祦寮忚緭鍑恒��
+- 鍦ㄤ緵搴斿晢鐩磋繛妯″紡涓嬫煡璇€�佸垱寤恒�佸垹闄ゅ拰鍙洖 AiChat 椤圭洰璁板繂銆�
 - 閰嶇疆缂哄け `authRef`锛岀‘璁よ緭鍑哄尯鏄剧ず閴存潈閰嶇疆閿欒銆�
 - 閰嶇疆鏈湴 OpenAI-compatible 鏈嶅姟锛岀‘璁ゆ棤 key 妯″瀷鍙祦寮忚緭鍑恒��
 - 鏂綉鎴栧叧闂湰鍦� endpoint锛岀‘璁ゆ彃浠惰緭鍑哄尯鏄剧ず endpoint 涓嶅彲杈俱��
@@ -610,4 +895,6 @@
 | DeepSeek 鏄惁鐙珛 adapter | 鏆備笉寮哄埗 | 濡傛灉瀹為檯鎺ュ彛涓� OpenAI-compatible 宸紓鏄庢樉鍐嶆媶 |
 | 鏄惁鏆撮湶鏈湴 HTTP LLM API | 鏆備笉鏆撮湶 | 鎻掍欢妗ユ帴鍏堟弧瓒抽渶姹傦紱澶栭儴鑷姩鍖栭渶瑕佹椂鍐嶈璁� |
 | 鏄惁淇濆瓨 prompt 鍘嗗彶 | 榛樿涓嶄繚瀛� | 鐢ㄦ埛鏄庣‘闇�瑕佸巻鍙叉垨璋冭瘯瀹¤鏃跺啀璇勪及 |
-
+| AiChat 閰嶇疆浣嶇疆 | 鍏堟斁鎻掍欢閰嶇疆锛屽悗缁彲杩佺Щ涓虹嫭绔� `llm-runtime.json` | 绠$悊 UI 闇�瑕佽法鎻掍欢鍏变韩 AiChat 璐﹀彿鏃� |
+| AiChat 浼氳瘽涓嬫媺 | MVP 涓嶅仛 | 鐢ㄦ埛瑕佹眰鍥哄畾浼氳瘽鎴栨煡鐪嬪巻鍙叉椂 |
+| 鐩磋繛妯″紡鍙洖鍐呭娉ㄥ叆鏂瑰紡 | 鍏堜綔涓虹郴缁熶笂涓嬫枃鍓嶇紑娉ㄥ叆 | 鍚庣画鍙仛鐢ㄦ埛纭鍜屽紩鐢ㄥ紑鍏� |
diff --git a/docs/architecture/runtime-architecture.md b/docs/architecture/runtime-architecture.md
index 5b38c64..2e925d4 100644
--- a/docs/architecture/runtime-architecture.md
+++ b/docs/architecture/runtime-architecture.md
@@ -404,7 +404,7 @@
 - 鏁版嵁濂戠害缁熶竴浣跨敤 `displayLayer`锛屽彇鍊间粎鍏佽 `desktop`銆乣normal`銆乣app-top`銆乣global-top`銆�
 - `LayoutManager` 鍙礋璐d繚瀛樸�佹牎楠屽拰骞挎挱灞傜骇鎰忓浘锛屼笉鐩存帴鎿嶄綔 Win32銆�
 - `DesktopRuntimeCoordinator` 灏嗘洿鏂板悗鐨勫竷灞�閫氳繃 `IRuntimeSurfaceController` 涓嬪彂锛屼繚璇佺鐞嗙獥鍙c�丄PI 鍜屾墭鐩樺懡浠よ蛋鍚屼竴杩愯鏃惰矾寰勩��
-- `WidgetWindow` 鏄渶缁堢獥鍙h涓烘墽琛岀偣锛歚desktop` 浼樺厛鎸傝浇鍒� Explorer WorkerW 妗岄潰灞備互閬垮厤 Win+D 鏈�灏忓寲锛屽け璐ユ椂闄嶇骇鍒板簳灞傛櫘閫氱獥鍙o紱`normal` 浣跨敤鏅�� WPF 绐楀彛灞傜骇锛宍app-top` 淇濇寔鏈簲鐢ㄥ唴鐨勬櫘閫氱獥鍙f彁鍗囪涔夛紝`global-top` 鎵嶈缃叏灞� `Topmost`銆�
+- `WidgetWindow` 鏄渶缁堢獥鍙h涓烘墽琛岀偣锛歚desktop` 浼樺厛鎸傝浇鍒� Explorer WorkerW/Progman 妗岄潰瀹夸富骞跺垏鎹负 child 绐楀彛鏍峰紡锛屼互閬垮厤 Win+D 鏈�灏忓寲锛屽け璐ユ椂闄嶇骇鍒板簳灞傛櫘閫氱獥鍙o紱`normal` 浣跨敤鏅�� WPF 绐楀彛灞傜骇锛宍app-top` 淇濇寔鏈簲鐢ㄥ唴鐨勬櫘閫氱獥鍙f彁鍗囪涔夛紝`global-top` 鎵嶈缃叏灞� `Topmost`銆�
 - 濡傛灉鏌愬眰绾у彈 Windows 妗岄潰鐜闄愬埗鏃犳硶瀹屽叏绮剧‘琛ㄨ揪锛岀獥鍙f帶鍒跺櫒蹇呴』閫夋嫨鏇村畨鍏ㄧ殑闈炲叏灞�缃《琛屼负锛屽苟璁板綍璇婃柇銆�
 
 绾︽潫瑙勫垯锛�
@@ -415,7 +415,7 @@
 - `locked = true` 鏃舵嫆缁濇嫋鎷藉拰缂╂斁銆�
 - `visible = false` 鏃剁獥鍙i殣钘忎絾甯冨眬淇濈暀銆�
 - `clickThrough = true` 鏃剁敱 Win32 鎵╁睍鏍峰紡閫忎紶榧犳爣杈撳叆銆�
-- `displayLayer` 鏀寔 `desktop`銆乣normal`銆乣app-top`銆乣global-top`锛歚desktop` 鎸傚埌 WorkerW 妗岄潰灞傚苟鍦� Win+D 鍚庣户缁樉绀猴紝`normal` 閬靛惊鏅�氱獥鍙e眰绾э紝`app-top` 鍙湪鏈簲鐢ㄧ獥鍙h寖鍥村唴鎻愬崌锛宍global-top` 浣跨敤鍏ㄥ眬缃《骞惰姹傛墭鐩�/绠$悊绐楀彛鍙揩閫熸挙閿�銆�
+- `displayLayer` 鏀寔 `desktop`銆乣normal`銆乣app-top`銆乣global-top`锛歚desktop` 鎸傚埌 WorkerW/Progman 妗岄潰瀹夸富骞跺湪 Win+D 鍚庣户缁樉绀猴紝`normal` 閬靛惊鏅�氱獥鍙e眰绾э紝`app-top` 鍙湪鏈簲鐢ㄧ獥鍙h寖鍥村唴鎻愬崌锛宍global-top` 浣跨敤鍏ㄥ眬缃《骞惰姹傛墭鐩�/绠$悊绐楀彛鍙揩閫熸挙閿�銆�
 
 ### Audio Visualizer Plugin
 
diff --git a/docs/data/configuration-and-storage.md b/docs/data/configuration-and-storage.md
index cb884fc..16476cc 100644
--- a/docs/data/configuration-and-storage.md
+++ b/docs/data/configuration-and-storage.md
@@ -15,7 +15,7 @@
 | 搴旂敤鏁版嵁鏍圭洰褰� | `%AppData%\DesktopEnhancer` |
 | 閰嶇疆鐩綍 | `%AppData%\DesktopEnhancer\config` |
 | 鎻掍欢鐩綍 | `%AppData%\DesktopEnhancer\plugins` |
-| 鏃ュ織鐩綍 | `%LocalAppData%\DesktopEnhancer\logs` |
+| 鏃ュ織鐩綍 | 绋嬪簭鐩綍涓嬬殑 `logs` |
 | WebView2 鏁版嵁鐩綍 | `%LocalAppData%\DesktopEnhancer\WebView2` |
 | 婧愮爜鏍蜂緥鎻掍欢鐩綍 | `samples\plugins` |
 | 渚挎惡鍖呮牱渚嬫彃浠剁洰褰� | `samples\plugins` |
@@ -92,7 +92,7 @@
 | `plugins[].state` | enum | 鎻掍欢鎸佷箙鐘舵�侊紝甯哥敤鍊间负 `enabled` / `disabled` |
 | `plugins[].updatedAt` | string | 鐘舵�佹洿鏂版椂闂达紝浣跨敤 `DateTimeOffset` JSON 琛ㄨ揪 |
 
-鎻掍欢鎵弿鏃讹紝`IPluginManager` 浼氬皢纾佺洏涓婄殑 `plugin.json` 涓庢敞鍐岃〃鐘舵�佸悎骞躲�傛棤鏁� manifest 涓嶄細璁╁簲鐢ㄥ穿婧冿紝浼氳繘鍏ラ敊璇姸鎬佸苟鍐欏叆璇婃柇銆�
+鎻掍欢鎵弿鏃讹紝`IPluginManager` 浼氬皢纾佺洏涓婄殑 `plugin.json` 涓庢敞鍐岃〃鐘舵�佸悎骞躲�傛棤鏁� manifest 涓嶄細璁╁簲鐢ㄥ穿婧冿紝浼氳繘鍏ラ敊璇姸鎬佸苟鍐欏叆璇婃柇銆傞粯璁ゆ牱渚嬫彃浠跺畨瑁呭拰鍙戝竷鏇存柊涓嶄細瑕嗙洊宸叉湁 `plugin.json`锛涘綋鐩爣鎻掍欢鐩綍宸茬粡瀛樺湪閰嶇疆鏃讹紝鏂扮増鏈� manifest 浼氬啓鍏� `plugin.template.json`锛屼緵鐢ㄦ埛瀵圭収杩佺Щ銆�
 
 ## layout.json
 
@@ -213,7 +213,7 @@
 - 淇濆瓨鏃朵娇鐢ㄤ复鏃舵枃浠跺拰澶囦唤鏂囦欢锛岄伩鍏嶇洿鎺ヨ鐩栧鑷撮厤缃崯鍧忋��
 - 閰嶇疆璇诲啓寮傚父搴旇褰曡瘖鏂紝涓嶅簲闈欓粯鍚炴帀銆�
 
-QA 鍙�氳繃鎵嬪伐鐮村潖閰嶇疆鏂囦欢楠岃瘉鎭㈠璺緞锛屽苟妫�鏌� `%LocalAppData%\DesktopEnhancer\logs` 涓庤繍琛屾椂璇婃柇鍒楄〃銆�
+QA 鍙�氳繃鎵嬪伐鐮村潖閰嶇疆鏂囦欢楠岃瘉鎭㈠璺緞锛屽苟妫�鏌ョ▼搴忕洰褰曚笅鐨� `logs` 涓庤繍琛屾椂璇婃柇鍒楄〃銆�
 
 ## 鍚庣画杩佺Щ棰勭暀
 
diff --git a/docs/development/llm-command-palette-aichat-mode-task-breakdown.md b/docs/development/llm-command-palette-aichat-mode-task-breakdown.md
new file mode 100644
index 0000000..704e9be
--- /dev/null
+++ b/docs/development/llm-command-palette-aichat-mode-task-breakdown.md
@@ -0,0 +1,156 @@
+# LLM 妗岄潰杈撳叆鎻掍欢 AiChat 妯″紡寮�鍙戜换鍔℃媶鍒�
+
+鏃ユ湡锛�2026-05-04
+
+## 鑼冨洿
+
+鏈换鍔″寘鎵挎帴 `docs/product/llm-command-palette-plugin-prd.md` 鍜� `docs/architecture/llm-command-palette-architecture.md`锛岀洰鏍囨槸鍦ㄧ幇鏈� `sample.llm-command-palette` 涓庡涓� LLM 浠g悊鍩虹涓婂畬鎴愪袱绉嶆ā寮忓寮猴細
+
+- 渚涘簲鍟嗙洿杩炴ā寮忥細淇濈暀褰撳墠鑳藉姏锛屽苟鎺ュ叆 AiChat 璁板繂绠$悊銆�
+- 鑷湁 API 妯″紡锛氶�氳繃 AiChat 鐧诲綍銆侀」鐩�佹ā鍨嬨�佽亰澶╁拰 SSE 鎺ュ彛瀹屾垚鍥炲銆�
+
+AiChat Host 榛樿浣跨敤锛�
+
+```text
+http://192.168.1.111:13000
+```
+
+## D01 閰嶇疆妯″瀷涓庡吋瀹硅縼绉�
+
+浜や粯锛�
+
+- 鎻掍欢閰嶇疆鏀寔 `mode`銆乣aichat.baseUrl`銆乣aichat.account`銆乣aichat.defaultProjectId`銆乣aichat.memory`銆�
+- 缂哄け `mode` 鏃舵寜 `provider-direct` 澶勭悊銆�
+- 缂哄け `aichat` 鏃朵笉褰卞搷鍘熶緵搴斿晢鐩磋繛鑱婂ぉ銆�
+- JSON 璇诲啓淇濇寔 UTF-8銆�
+
+楠屾敹锛�
+
+- 鏃х増 `plugin.json` 鍙寘鍚� `defaultModel` / `models` 鏃朵粛鍙姞杞姐��
+- 鏂扮増鏍蜂緥 `plugin.json` 榛樿 `mode=provider-direct`銆�
+- 瀵嗙爜鐜鍙橀噺浼樺厛浜庢槑鏂囧瘑鐮併��
+
+渚濊禆锛氭棤銆�
+
+## D02 AiChat Session 涓庡熀纭�瀹㈡埛绔�
+
+浜や粯锛�
+
+- `AiChatSessionService`锛氱櫥褰曘�乼oken 鍐呭瓨缂撳瓨銆�401 閲嶇櫥涓�娆°��
+- `AiChatClient`锛氱粺涓�灏佽璇锋眰澶淬�侀敊璇爜銆丣SON 鍝嶅簲瑙f瀽銆�
+- 鏀寔 `POST /api/auth/login`銆乣GET /api/auth/me`銆�
+
+楠屾敹锛�
+
+- 鐧诲綍鎴愬姛鍚庡彧鍦ㄥ唴瀛樹繚瀛� `sessionToken`銆�
+- 鏃ュ織涓嶈緭鍑哄瘑鐮佸拰 `x-session-token`銆�
+- 鐧诲綍澶辫触銆佸緟瀹℃壒銆佸仠鐢ㄨ处鍙疯兘鏄犲皠涓烘彃浠跺彲璇婚敊璇��
+
+渚濊禆锛欴01銆�
+
+## D03 椤圭洰涓庢ā鍨嬪垪琛�
+
+浜や粯锛�
+
+- `GET /api/projects` 椤圭洰鍒楄〃鍔犺浇銆�
+- `GET /api/chat/models` 妯″瀷鍒楄〃鍔犺浇銆�
+- 鎻掍欢妗ユ帴鏂板 `getProjects()`銆�
+- 妯″瀷涓嬫媺鏍规嵁妯″紡閫夋嫨瀹夸富妯″瀷娉ㄥ唽琛ㄦ垨 AiChat 妯″瀷鎺ュ彛銆�
+
+楠屾敹锛�
+
+- 杈撳叆妗嗗乏渚ф樉绀� AiChat 椤圭洰涓嬫媺銆�
+- 椤圭洰鍚嶇О杩囬暱涓嶆拺寮�杈撳叆鏉°��
+- AiChat 涓嶅彲鐢ㄦ椂椤圭洰涓嬫媺闄嶇骇涓� `No project`锛屼緵搴斿晢鐩磋繛浠嶅彲鐢ㄣ��
+
+渚濊禆锛欴02銆�
+
+## D04 鑷湁 API 妯″紡鑱婂ぉ
+
+浜や粯锛�
+
+- `mode=aichat-api` 鍒嗘敮銆�
+- 璋冪敤 `POST /api/chat/send`銆�
+- 浣跨敤 `generationId` 鍜� `streamToken` 璁㈤槄 SSE銆�
+- 瑙f瀽 `snapshot`銆乣chunk`銆乣processing`銆乣done`銆乣failed`銆乣aborted`銆�
+
+楠屾敹锛�
+
+- 閫夋嫨椤圭洰鍚庢彁浜わ紝璇锋眰鎼哄甫 `projectId`銆�
+- `chunk.delta` 鑳芥祦寮忔樉绀哄埌杈撳嚭鍖恒��
+- `done` 鍚庣姸鎬佸洖鍒扮┖闂层��
+- `USER_PENDING_APPROVAL`銆乣TOKEN_TOTAL_LIMIT_REACHED`銆乣INVALID_MODEL` 绛夐敊璇樉绀虹煭閿欒銆�
+
+渚濊禆锛欴02銆丏03銆�
+
+## D05 渚涘簲鍟嗙洿杩炴ā寮忚蹇嗙鐞�
+
+浜や粯锛�
+
+- `GET /api/memories` 鏌ヨ鍏ㄥ眬/椤圭洰璁板繂銆�
+- `POST /api/memories` 鍒涘缓璁板繂銆�
+- `DELETE /api/memories/{memoryId}` 鍒犻櫎璁板繂銆�
+- `POST /api/memories/recall` 鍙洖璁板繂銆�
+- `GET /api/auth/me` 鑳藉姏鎽樿椹卞姩 UI锛歚canUseMemory`銆乣canViewMemory`銆乣canManageMemory`銆�
+
+楠屾敹锛�
+
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅鍙寜閫変腑椤圭洰鏌ヨ銆佸垱寤恒�佸垹闄ゅ拰鍙洖璁板繂銆�
+- 鏉冮檺涓嶈冻鏃跺搴旀搷浣滅鐢ㄣ��
+- 鑷湁 API 妯″紡涓嬩笉鎵ц鎻掍欢渚ц蹇嗗彫鍥炪��
+
+渚濊禆锛欴02銆丏03銆�
+
+## D06 鎻掍欢 UI 鏇存柊
+
+浜や粯锛�
+
+- 杈撳叆妗嗗乏渚ч」鐩笅鎷夈��
+- 鍙充晶妯″瀷涓嬫媺鎸夋ā寮忓埛鏂般��
+- 璁板繂绠$悊鍏ュ彛鍜屾潈闄愰檷绾х姸鎬併��
+- 妯″紡鍒囨崲鍚庡埛鏂伴」鐩�佹ā鍨嬪拰鎻愪氦閾捐矾銆�
+
+楠屾敹锛�
+
+- Enter 鎻愪氦銆丼hift+Enter 鎹㈣銆丒scape 鏀惰捣缁х画鍙敤銆�
+- 闀块」鐩悕銆侀暱妯″瀷鍚嶄笉浼氬鑷磋緭鍏ユ潯璺冲姩銆�
+- AiChat 椤圭洰/妯″瀷鍔犺浇澶辫触鏃舵樉绀虹煭鐘舵�侊紝涓嶅脊绯荤粺妯℃�佹銆�
+
+渚濊禆锛欴03銆丏04銆丏05銆�
+
+## D07 绠$悊绐楀彛涓庢墜鍐屽悓姝�
+
+浜や粯锛�
+
+- 绠$悊绐楀彛鎴栨彃浠堕厤缃叆鍙e睍绀鸿繍琛屾ā寮忓拰 AiChat 閰嶇疆銆�
+- 瀵嗙爜瀛楁鏀寔鐜鍙橀噺璇存槑锛屼笉鏄剧ず鏄庢枃 token銆�
+- 鍚屾鏇存柊 `docs/ops/user-manual/plugins/sample.llm-command-palette.md`銆�
+
+楠屾敹锛�
+
+- 鐢ㄦ埛鑳芥壘鍒颁袱绉嶆ā寮忋�丄iChat Host銆佽处鍙枫�佸瘑鐮佺幆澧冨彉閲忋�侀」鐩笅鎷夈�佽蹇嗛檺鍒跺拰鏁呴殰鎺掓煡璇存槑銆�
+- 鍚庣画 QA 鍓嶆搷浣滄墜鍐屼繚鎸佹渶鏂般��
+
+渚濊禆锛欴01銆丏06銆�
+
+## D08 娴嬭瘯涓庨獙鏀�
+
+浜や粯锛�
+
+- 閰嶇疆瑙f瀽鍗曞厓娴嬭瘯銆�
+- AiChat 瀹㈡埛绔� fake HTTP 娴嬭瘯銆�
+- AiChat SSE 瑙f瀽娴嬭瘯銆�
+- 璁板繂鏉冮檺鎺у埗娴嬭瘯銆�
+- 鏍蜂緥鎻掍欢闈欐�佹覆鏌撴鏌ャ��
+- QA 楠屾敹璁板綍鏇存柊銆�
+
+楠屾敹锛�
+
+- `dotnet build .\Moli.Desktop.slnx` 閫氳繃銆�
+- `dotnet test .\Moli.Desktop.slnx` 閫氳繃銆�
+- 鍙敤 AiChat 璐﹀彿涓嬪畬鎴愪竴娆� `aichat-api` 妯″紡娴佸紡鍥炲銆�
+- `provider-direct` 妯″紡鍘熸湁渚涘簲鍟嗙洿杩炶兘鍔涗笉鍥炲綊銆�
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅璁板繂鏌ヨ銆佸垱寤恒�佸垹闄ゃ�佸彫鍥炶嚦灏戝畬鎴愪竴杞墜宸ラ獙鏀躲��
+
+渚濊禆锛欴01-D07銆�
+
diff --git a/docs/ops/user-manual.md b/docs/ops/user-manual.md
index fec2686..e6cc162 100644
--- a/docs/ops/user-manual.md
+++ b/docs/ops/user-manual.md
@@ -21,6 +21,5 @@
 
 - 閰嶇疆鏂囦欢鐩綍锛歚%AppData%\DesktopEnhancer\config`
 - 鎻掍欢鐩綍锛歚%AppData%\DesktopEnhancer\plugins`
-- 鏃ュ織鐩綍锛歚%LocalAppData%\DesktopEnhancer\logs`
+- 鏃ュ織鐩綍锛氱▼搴忕洰褰曚笅鐨� `logs`
 - WebView2 鏁版嵁鐩綍锛歚%LocalAppData%\DesktopEnhancer\WebView2`
-
diff --git a/docs/ops/user-manual/moli-desktop.md b/docs/ops/user-manual/moli-desktop.md
index e3a3d29..d7951e4 100644
--- a/docs/ops/user-manual/moli-desktop.md
+++ b/docs/ops/user-manual/moli-desktop.md
@@ -32,7 +32,7 @@
 | --- | --- |
 | 閰嶇疆鏂囦欢 | `%AppData%\DesktopEnhancer\config` |
 | 鎻掍欢鐩綍 | `%AppData%\DesktopEnhancer\plugins` |
-| 鏃ュ織鐩綍 | `%LocalAppData%\DesktopEnhancer\logs` |
+| 鏃ュ織鐩綍 | 绋嬪簭鐩綍涓嬬殑 `logs` |
 | WebView2 鏁版嵁 | `%LocalAppData%\DesktopEnhancer\WebView2` |
 
 ## 瀹夎涓庡惎鍔�
@@ -114,6 +114,7 @@
 | 缁勪欢 | 灏忕粍浠跺疄渚嬪垪琛紝鍙�夋嫨缁勪欢骞舵樉绀�/闅愯棌鎴栭攣瀹�/瑙i攣 |
 | 鎻掍欢 | 宸叉壂鎻忔彃浠剁殑鍚嶇О銆佺被鍨嬨�佺姸鎬併�佸叆鍙e拰閿欒鐮� |
 | 璇婃柇 | 璇婃柇璁板綍鍜屾彃浠� manifest 閿欒鎽樿 |
+| Log | 鍔犺浇褰撳ぉ鏃ュ織锛屽苟闅忕鐞嗙獥鍙e埛鏂板懆鏈熸樉绀烘柊澧炴棩蹇� |
 
 ## 閫氱敤缁勪欢鎿嶄綔
 
@@ -155,6 +156,8 @@
 ```text
 %AppData%\DesktopEnhancer\plugins\<pluginId>
 ```
+
+鍙戝竷鎴栭粯璁ゆ牱渚嬫洿鏂版椂锛屽鏋滄彃浠剁洰褰曚腑宸茬粡瀛樺湪 `plugin.json`锛屽簲鐢ㄤ細淇濈暀鐜版湁閰嶇疆锛屽苟鎶婃柊鐗堟湰鏍蜂緥閰嶇疆鍐欏叆 `plugin.template.json`銆傞娆′笉瀛樺湪閰嶇疆鏃舵墠浼氬垵濮嬪寲 `plugin.json`銆�
 
 娣诲姞鏈湴鎻掍欢鐨勪竴鑸祦绋嬶細
 
@@ -275,7 +278,7 @@
 
 - 妫�鏌� Windows 鎵樼洏闅愯棌鍖哄煙銆�
 - 纭 `Moli.Desktop.exe` 杩涚▼鏄惁浠嶅湪杩愯銆�
-- 鏌ョ湅 `%LocalAppData%\DesktopEnhancer\logs`銆�
+- 鏌ョ湅绋嬪簭鐩綍涓嬬殑 `logs`锛屾垨鎵撳紑绠$悊绐楀彛鐨� 鈥淟og鈥� 椤甸潰銆�
 - 濡傛灉浠庢簮鐮佽繍琛岋紝鍏堢‘璁� `dotnet build Moli.Desktop.slnx` 鎴愬姛銆�
 
 ### 澹佺焊鎴栫粍浠舵病鏈夋樉绀�
@@ -320,4 +323,3 @@
 - 寮�鏈哄惎鍔ㄩ�氳繃褰撳墠鐢ㄦ埛 HKCU Run 娉ㄥ唽琛ㄥ疄鐜般��
 - 绠$悊绐楀彛鐨勨�滈噸缃竷灞�鈥濇槸杞噸缃紝涓嶄細閲嶆柊鍒涘缓缁勪欢瀹炰緥銆�
 - WebView2 Runtime 缂哄け銆佹闈㈠眰绾у拰鐐瑰嚮绌块�忚涓洪渶瑕佸湪鐪熷疄 Windows 妗岄潰鐜涓獙璇併��
-
diff --git a/docs/ops/user-manual/plugins/sample.llm-command-palette.md b/docs/ops/user-manual/plugins/sample.llm-command-palette.md
index ace5c2b..69182c5 100644
--- a/docs/ops/user-manual/plugins/sample.llm-command-palette.md
+++ b/docs/ops/user-manual/plugins/sample.llm-command-palette.md
@@ -8,19 +8,89 @@
 
 ## 浣跨敤鍓嶅噯澶�
 
-浣跨敤璇ユ彃浠跺墠锛岄渶瑕佸噯澶囪嚦灏戜竴涓彲璁块棶鐨� LLM 鎺ュ彛銆傚綋鍓嶇増鏈紭鍏堟敮鎸� OpenAI-compatible 娴佸紡鎺ュ彛锛屼篃鍙互閰嶇疆 DeepSeek銆佹湰鍦� Ollama/LM Studio 绛夊吋瀹规帴鍙c��
+浣跨敤璇ユ彃浠跺墠锛岄渶瑕佹牴鎹繍琛屾ā寮忓噯澶囦笉鍚屾湇鍔★細
+
+| 妯″紡 | 闇�瑕佸噯澶� |
+| --- | --- |
+| 渚涘簲鍟嗙洿杩炴ā寮� | 鑷冲皯涓�涓彲璁块棶鐨� LLM 鎺ュ彛锛屼緥濡� OpenAI-compatible銆丏eepSeek銆佹湰鍦� Ollama/LM Studio 绛夊吋瀹规帴鍙� |
+| 鑷湁 API 妯″紡 | 鍙闂殑 AiChat 鏈嶅姟銆佸凡瀹℃壒璐﹀彿銆佸瘑鐮佹垨瀵嗙爜鐜鍙橀噺 |
+
+AiChat 榛樿鏈嶅姟鍦板潃锛�
+
+```text
+http://192.168.1.111:13000
+```
 
 ## 榛樿琛屼负
 
 | 椤圭洰 | 榛樿琛屼负 |
 | --- | --- |
 | 浣嶇疆 | 涓诲睆椤堕儴灞呬腑锛岄《閮ㄤ繚鐣欑害 `32px` 绌洪殭 |
+| 榛樿妯″紡 | 渚涘簲鍟嗙洿杩炴ā寮� |
+| 宸︿晶涓嬫媺 | AiChat 椤圭洰鍒楄〃 |
 | 鏄剧ず灞傜骇 | `desktop` |
 | 鐐瑰嚮绌块�� | 鍏抽棴锛屼究浜庢帴鏀堕敭鐩樺拰榧犳爣杈撳叆 |
 | 閿佸畾鐘舵�� | 閿佸畾锛岄伩鍏嶈鎷栧姩 |
 | 鎻愪氦鏂瑰紡 | Enter 鎻愪氦锛屼笉鎻愪緵鎻愪氦鎸夐挳 |
 | 鎹㈣鏂瑰紡 | Shift+Enter |
 | 杈撳嚭鍖哄煙 | 杈撳叆妗嗗簳閮ㄥ睍寮�锛屾渶澶ч珮搴︾害涓哄睆骞曢珮搴� `50%` |
+
+## 閫夋嫨杩愯妯″紡
+
+LLM 鎻掍欢鏀寔涓ょ妯″紡锛�
+
+| 妯″紡 | 閰嶇疆鍊� | 琛屼负 |
+| --- | --- | --- |
+| 渚涘簲鍟嗙洿杩炴ā寮� | `provider-direct` | 浣跨敤 Moli.Desktop 瀹夸富 LLM 浠g悊璋冪敤渚涘簲鍟嗘ā鍨嬶紱鍙鐢� AiChat 璁板繂鎺ュ彛 |
+| 鑷湁 API 妯″紡 | `aichat-api` | 浣跨敤 AiChat 椤圭洰銆佹ā鍨嬪拰鑱婂ぉ SSE锛涙彃浠朵笉鍗曠嫭澶勭悊璁板繂 |
+
+鎻掍欢閰嶇疆绀轰緥锛�
+
+```json
+{
+  "mode": "provider-direct",
+  "aichat": {
+    "baseUrl": "http://192.168.1.111:13000",
+    "account": {
+      "email": "user@example.com",
+      "password": null,
+      "passwordEnv": "MOLI_AICHAT_PASSWORD"
+    },
+    "defaultProjectId": "",
+    "memory": {
+      "enabledInProviderDirect": true,
+      "defaultScope": "PROJECT",
+      "recallLimit": 8
+    }
+  }
+}
+```
+
+缂哄皯 `mode` 鏃讹紝鎻掍欢鎸� `provider-direct` 澶勭悊锛屼互鍏煎鏃ч厤缃��
+
+## 閰嶇疆 AiChat 璐﹀彿
+
+AiChat 璐﹀彿淇℃伅鍙敤浜庢彃浠朵笌 AiChat 鏈嶅姟浜や簰銆�
+
+璐﹀彿鍏佽鐩存帴鍐欏湪閰嶇疆涓細
+
+```json
+{
+  "email": "user@example.com"
+}
+```
+
+瀵嗙爜寤鸿浣跨敤鐜鍙橀噺銆傞厤缃腑鐨� `passwordEnv` 浼樺厛浜庢槑鏂� `password`锛�
+
+```powershell
+[Environment]::SetEnvironmentVariable(
+  "MOLI_AICHAT_PASSWORD",
+  "浣犵殑 AiChat 瀵嗙爜",
+  "User"
+)
+```
+
+璁剧疆鍚庤閲嶅惎 Moli.Desktop锛岃鏂扮幆澧冨彉閲忓妗岄潰杩涚▼鐢熸晥銆傜櫥褰曟垚鍔熷悗鐨� Session Token 鍙繚瀛樺湪瀹夸富杩愯鎬侊紝涓嶅啓鍏ユ彃浠堕厤缃��
 
 ## 閰嶇疆妯″瀷
 
@@ -90,6 +160,14 @@
 
 褰撳墠 `deepseek`銆乣ollama` 鍜� `local-openai-compatible` 浼氬鐢� OpenAI-compatible 閫傞厤鍣ㄣ�傚鏋滄煇涓緵搴斿晢鎺ュ彛涓嶅吋瀹� OpenAI-compatible 娴佸紡鏍煎紡锛岄渶瑕佸悗缁柊澧炵嫭绔嬮�傞厤鍣ㄣ��
 
+鑷湁 API 妯″紡涓嬶紝妯″瀷鍒楄〃鏉ヨ嚜 AiChat锛�
+
+```text
+GET /api/chat/models
+```
+
+鎻掍欢鍙睍绀� AiChat 杩斿洖鐨勫彲鐢ㄦā鍨嬶紝骞跺湪鎻愪氦鏃舵妸鎵�閫夋ā鍨嬩綔涓� `modelName` 浼犵粰 AiChat銆�
+
 ## 閰嶇疆瀵嗛挜
 
 褰撳墠鐗堟湰浣跨敤鐜鍙橀噺浣滀负瀵嗛挜 fallback銆俙authRef` 浼氭寜浠ヤ笅鏂瑰紡瑙f瀽锛�
@@ -122,10 +200,42 @@
 1. 鍚姩 Moli.Desktop銆�
 2. 纭 `sample.llm-command-palette` 宸插湪鈥滄彃浠垛�濋〉闈腑鍚敤銆�
 3. 鍦ㄦ闈㈤《閮ㄦ壘鍒板崐閫忔槑杈撳叆鏉°��
-4. 鍦ㄥ彸渚фā鍨嬩笅鎷変腑閫夋嫨妯″瀷銆�
-5. 杈撳叆闂銆�
-6. 鎸� Enter 鎻愪氦銆�
-7. 鍦ㄨ緭鍏ユ涓嬫柟鏌ョ湅娴佸紡杈撳嚭銆�
+4. 鍦ㄥ乏渚ч」鐩笅鎷変腑閫夋嫨 AiChat 椤圭洰銆�
+5. 鍦ㄥ彸渚фā鍨嬩笅鎷変腑閫夋嫨妯″瀷銆�
+6. 杈撳叆闂銆�
+7. 鎸� Enter 鎻愪氦銆�
+8. 鍦ㄨ緭鍏ユ涓嬫柟鏌ョ湅娴佸紡杈撳嚭銆�
+
+椤圭洰涓嬫媺璇存槑锛�
+
+| 鐘舵�� | 鍚箟 |
+| --- | --- |
+| 鏄剧ず椤圭洰鍚嶇О | 宸叉垚鍔熻皟鐢� AiChat `GET /api/projects` |
+| `No project` | 鏈厤缃� AiChat銆佺櫥褰曞け璐ユ垨椤圭洰鍒楄〃涓虹┖ |
+| 鐧诲綍/鏉冮檺閿欒 | 妫�鏌ヨ处鍙峰鎵圭姸鎬併�佸瘑鐮佺幆澧冨彉閲忓拰 AiChat 鏈嶅姟鍦板潃 |
+
+鍦ㄨ嚜鏈� API 妯″紡涓嬶紝鎻愪氦浼氭惡甯﹀綋鍓嶉」鐩� ID銆傛湭閫夋嫨椤圭洰鏃讹紝AiChat 浼氭寜鑷韩鎺ュ彛瑙勫垯浣跨敤鎴栧垱寤洪粯璁ら」鐩紝浣嗗缓璁槑纭�夋嫨椤圭洰銆�
+
+椤圭洰鍜屾ā鍨嬩笅鎷変娇鐢ㄦ彃浠惰嚜缁樼殑鍦嗚鎵佸钩鎺т欢銆傚睍寮�涓嬫媺鏃讹紝杈撳叆鏉′細涓存椂璇锋眰瀹夸富澧為珮缁勪欢绐楀彛锛岄伩鍏嶉�夐」鍒楄〃琚師濮嬬粍浠堕珮搴﹁鍓紱閫夋嫨瀹屾垚鎴栫偣鍑诲閮ㄥ悗浼氭仮澶嶅埌榛樿楂樺害銆�
+
+## 璁板繂绠$悊
+
+渚涘簲鍟嗙洿杩炴ā寮忎笅锛屾彃浠跺彲浠ヤ娇鐢� AiChat 璁板繂鎺ュ彛锛�
+
+| 鎿嶄綔 | AiChat 鎺ュ彛 |
+| --- | --- |
+| 鏌ヨ璁板繂 | `GET /api/memories?scope={scope}&projectId={projectId}` |
+| 鍒涘缓璁板繂 | `POST /api/memories` |
+| 鍒犻櫎璁板繂 | `DELETE /api/memories/{memoryId}` |
+| 鍙洖璁板繂 | `POST /api/memories/recall` |
+
+鏉冮檺鏉ヨ嚜 AiChat 褰撳墠鐢ㄦ埛锛�
+
+- `canViewMemory` 鎺у埗鏄惁鑳芥煡鐪嬭蹇嗐��
+- `canManageMemory` 鎺у埗鏄惁鑳藉垱寤烘垨鍒犻櫎璁板繂銆�
+- `canUseMemory` 鎺у埗鏄惁鑳藉彫鍥炶蹇嗗苟鐢ㄤ簬鐩磋繛妯″瀷涓婁笅鏂囥��
+
+鑷湁 API 妯″紡涓嬶紝鎻掍欢涓嶅崟鐙睍绀烘垨鎵ц璁板繂绠$悊銆傝亰澶╀腑鐨勮蹇嗕娇鐢ㄧ敱 AiChat 鏈嶅姟鍜岄」鐩缃鐞嗐��
 
 蹇嵎鎿嶄綔锛�
 
@@ -168,7 +278,23 @@
 - 妫�鏌� `%AppData%\DesktopEnhancer\config\llm-models.json` 鏄惁瀛樺湪銆�
 - 纭鑷冲皯鏈変竴涓ā鍨嬬殑 `enabled` 涓� `true`銆�
 - 纭妯″瀷鐨� `endpoint` 鏄� `http` 鎴� `https` 缁濆 URL銆�
+- 濡傛灉褰撳墠鏄嚜鏈� API 妯″紡锛屾鏌� AiChat `GET /api/chat/models` 鏄惁鍙敤銆�
 - 淇閰嶇疆鍚庨噸鍚簲鐢紝鎴栧湪绠$悊绐楀彛涓噸杞芥彃浠躲��
+
+### 椤圭洰涓嬫媺涓虹┖
+
+- 妫�鏌� AiChat 鏈嶅姟鍦板潃鏄惁涓� `http://192.168.1.111:13000` 鎴栦綘鐨勫疄闄呴厤缃��
+- 妫�鏌ヨ处鍙峰拰瀵嗙爜鐜鍙橀噺鏄惁姝g‘銆�
+- 璋冪敤 AiChat `GET /api/auth/me` 纭璐﹀彿宸插鎵广��
+- 璋冪敤 AiChat `GET /api/projects` 纭璐﹀彿鏈夐」鐩��
+
+### 鑷湁 API 妯″紡鏃犳硶杈撳嚭
+
+- 妫�鏌� AiChat 鐧诲綍鏄惁鎴愬姛銆�
+- 妫�鏌ユ墍閫夋ā鍨嬫槸鍚﹀湪 AiChat `GET /api/chat/models` 杩斿洖鍒楄〃涓��
+- 濡傛灉杩斿洖 `TOKEN_TOTAL_LIMIT_REACHED`锛岄渶瑕佸湪 AiChat 涓敵璇锋垨璋冩暣 Token 閰嶉銆�
+- 濡傛灉杩斿洖 `INVALID_MODEL`锛岄渶瑕佸湪 AiChat 鏈嶅姟绔惎鐢ㄥ搴旀ā鍨嬨��
+- 濡傛灉 SSE 涓柇锛屼繚鐣欏凡杈撳嚭鍐呭鍚庨噸璇曘��
 
 ### 璇锋眰鎻愮ず瀵嗛挜缂哄け
 
@@ -184,6 +310,12 @@
 - 濡傛灉鏄繙绋嬩緵搴斿晢锛岀‘璁ゅ綋鍓嶇綉缁滃彲璁块棶璇ヤ緵搴斿晢 API銆�
 - 妫�鏌ユ棩蹇楃洰褰� `%LocalAppData%\DesktopEnhancer\logs`锛屾棩蹇楀彧浼氳褰� endpoint host锛屼笉浼氳褰曞畬鏁� API key銆�
 
+### 璁板繂鍔熻兘涓嶅彲鐢�
+
+- 璁板繂绠$悊鍙湪渚涘簲鍟嗙洿杩炴ā寮忎笅鐢辨彃浠跺鐞嗐��
+- 妫�鏌� AiChat 褰撳墠鐢ㄦ埛鏄惁鏈� `canUseMemory`銆乣canViewMemory` 鎴� `canManageMemory` 鏉冮檺銆�
+- 椤圭洰璁板繂蹇呴』閫夋嫨椤圭洰鍚庝娇鐢ㄣ��
+
 ### 娌℃湁娴佸紡杈撳嚭
 
 - 纭涓婃父鎺ュ彛鏀寔 OpenAI-compatible SSE 娴佸紡杈撳嚭銆�
@@ -195,4 +327,5 @@
 - 妯″瀷閰嶇疆褰撳墠涓昏閫氳繃鎵嬪伐缂栬緫 `llm-models.json` 瀹屾垚銆�
 - 瀵嗛挜褰撳墠浣跨敤鐜鍙橀噺 fallback锛學indows Credential Manager 绠$悊鐣岄潰灏氭湭瀹炵幇銆�
 - 褰撳墠宸插疄鐜� OpenAI-compatible 娴佸紡鍗忚锛涢潪鍏煎渚涘簲鍟嗛渶瑕佸悗缁柊澧為�傞厤鍣ㄣ��
-
+- 鑷湁 API 妯″紡鏆備笉鍦ㄦ彃浠朵腑鎻愪緵浼氳瘽涓嬫媺锛屾彁浜ゆ椂浣跨敤鎵�閫夐」鐩殑榛樿浼氳瘽瑙勫垯銆�
+- 鑷湁 API 妯″紡涓嶅湪鎻掍欢涓鐞嗚蹇嗐��
diff --git a/docs/product/desktop-enhancement-prd.md b/docs/product/desktop-enhancement-prd.md
index 305207e..c13443c 100644
--- a/docs/product/desktop-enhancement-prd.md
+++ b/docs/product/desktop-enhancement-prd.md
@@ -114,7 +114,7 @@
   - `global-top`锛氬叏灞�缃《锛屽厑璁歌鐩栧叾浠栧簲鐢ㄧ獥鍙c��
 - 澹佺焊绫诲唴瀹归粯璁や娇鐢� `desktop`锛涙櫘閫氫俊鎭被灏忕粍浠堕粯璁や娇鐢� `desktop` 鎴� `normal`锛涢渶瑕佽法搴旂敤鎻愰啋銆佹偓娴帶鍒舵垨婕旂ず鍦烘櫙鐨勭粍浠舵墠搴斾娇鐢� `app-top` 鎴� `global-top`銆�
 - 鐢ㄦ埛蹇呴』鑳藉鎸夌粍浠跺疄渚嬪垏鎹㈡樉绀哄眰绾э紝涓斿垏鎹㈢粨鏋滃繀椤绘寔涔呭寲銆�
-- `desktop` 灞傜粍浠跺繀椤诲湪鐢ㄦ埛瑙﹀彂 Win+D 鏄剧ず妗岄潰鍚庝粛淇濇寔鍙锛涚郴缁熶笉鏀寔 WorkerW 鎸傝浇鏃跺厑璁搁檷绾э紝浣嗗繀椤昏褰曡瘖鏂苟鍦� QA 璁板綍涓爣娉ㄨ鐜闄愬埗銆�
+- `desktop` 灞傜粍浠跺繀椤诲湪鐢ㄦ埛瑙﹀彂 Win+D 鏄剧ず妗岄潰鍚庝粛淇濇寔鍙锛涚郴缁熶笉鏀寔 WorkerW/Progman 妗岄潰瀹夸富鎸傝浇鏃跺厑璁搁檷绾э紝浣嗗繀椤昏褰曡瘖鏂苟鍦� QA 璁板綍涓爣娉ㄨ鐜闄愬埗銆�
 - 缁勪欢蹇呴』鏀寔鍦ㄧ紪杈戞ā寮忎笅鎷栨嫿鍜岀缉鏀俱��
 - 宸查攣瀹氱粍浠跺繀椤绘嫆缁濇嫋鎷藉拰缂╂斁鎿嶄綔銆�
 - 搴旂敤蹇呴』鏀寔鎸夌粍浠剁淮搴︾殑閰嶇疆銆�
diff --git a/docs/product/llm-command-palette-plugin-prd.md b/docs/product/llm-command-palette-plugin-prd.md
index 5f12e56..1475a83 100644
--- a/docs/product/llm-command-palette-plugin-prd.md
+++ b/docs/product/llm-command-palette-plugin-prd.md
@@ -24,9 +24,15 @@
 
 - 鎻愪緵涓�涓《閮ㄥ眳涓殑 LLM 杈撳叆鎻掍欢锛岄粯璁ゅ湪灞忓箷椤堕儴淇濈暀鍛煎惛绌洪殭銆�
 - 鏀寔鐢ㄦ埛杈撳叆鏂囨湰鍚庢寜鍥炶溅鎻愪氦锛屼笉鎻愪緵鐙珛鎻愪氦鎸夐挳銆�
-- 鏀寔鍦ㄨ緭鍏ユ鍙充晶宓屽叆妯″瀷涓嬫媺閫夋嫨銆�
+- 鏀寔涓ょ杩愯妯″紡锛屽苟鍙�氳繃鎻掍欢閰嶇疆閫夋嫨锛�
+  - 渚涘簲鍟嗙洿杩炴ā寮忥細缁х画浣跨敤褰撳墠瀹夸富 LLM 浠g悊锛屾寜 `modelId` 鐩磋繛 OpenAI-compatible銆丏eepSeek銆佹湰鍦版ā鍨嬬瓑渚涘簲鍟嗐��
+  - 鑷湁 API 妯″紡锛氭帴鍏ヨ嚜鏈� `AiChat` 鏈嶅姟锛岀粺涓� Host 榛樿涓� `http://192.168.1.111:13000`銆�
+- 鏀寔鍦ㄨ緭鍏ユ宸︿晶宓屽叆 AiChat 椤圭洰涓嬫媺锛涘彸渚т繚鐣欐ā鍨嬩笅鎷夈��
 - 鏀寔澶氫釜 LLM 妯″瀷锛屾ā鍨嬫竻鍗曟潵鑷彃浠堕厤缃垨瀹夸富閰嶇疆銆�
 - 鏀寔璋冪敤 LLM 鎺ュ彛骞跺皢缁撴灉娴佸紡灞曠ず鍦ㄨ緭鍏ユ涓嬫柟銆�
+- 鏀寔鍦ㄤ緵搴斿晢鐩磋繛妯″紡涓嬮�氳繃 AiChat API 杩涜璁板繂鏌ヨ銆佸垱寤恒�佸垹闄ゅ拰鍙洖绠$悊銆�
+- 鏀寔鍦ㄨ嚜鏈� API 妯″紡涓嬩娇鐢� AiChat 椤圭洰涓婁笅鏂囧彂璧疯亰澶╋紱璇ユā寮忎笅涓嶅鐞嗘彃浠朵晶璁板繂绠$悊銆�
+- 鏀寔鍦ㄦ彃浠堕厤缃腑缁存姢 AiChat 鏈嶅姟浜や簰鎵�闇�鐨勭敤鎴蜂俊鎭紝璐﹀彿鍏佽鏄庢枃閰嶇疆锛屽瘑鐮佸厑璁稿紩鐢ㄧ幆澧冨彉閲忋��
 - 杈撳嚭鍖哄煙涓庤緭鍏ユ淇濇寔鍚屽銆佸悓瑙嗚椋庢牸锛屾渶澶ч珮搴︿笉瓒呰繃灞忓箷楂樺害鐨� `50%`銆�
 - 淇濇寔妗岄潰娴眰杞婚噺銆侀�忔槑銆佸彲璇汇�佸彲鎭㈠鎺у埗銆�
 
@@ -34,6 +40,8 @@
 
 - 涓嶅仛瀹屾暣澶氫細璇濊亰澶╁簲鐢ㄣ��
 - 涓嶅湪鎻掍欢鍐呭疄鐜拌处鍙蜂綋绯汇�佽璐圭鐞嗘垨澶嶆潅鐭ヨ瘑搴撱��
+- 涓嶅湪 Moli.Desktop 鍐呴噸鏂板疄鐜� AiChat 鐨勯」鐩�佷細璇濄�佸鎵广�佹潈闄愬拰閰嶉绯荤粺銆�
+- 涓嶅湪鑷湁 API 妯″紡涓嬮噸澶嶅疄鐜拌蹇嗙鐞嗭紱璁板繂鐢� AiChat 鑷韩鑱婂ぉ閾捐矾鍜岄」鐩缃鐞嗐��
 - 涓嶅湪 MVP 涓敮鎸佹枃浠朵笂浼犮�佸浘鐗囩悊瑙c�佽闊宠緭鍏ユ垨澶氭ā鎬佽緭鍑恒��
 - 涓嶈姹傛浛浠g鐞嗙獥鍙f垨绯荤粺鎵樼洏鍏ュ彛銆�
 - 涓嶆妸 LLM API key 鏄庢枃鍐欏叆鎻掍欢鍓嶇婧愮爜銆�
@@ -49,10 +57,14 @@
 ## 鐢ㄦ埛鏁呬簨
 
 - 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄦ闈㈤《閮ㄧ洿鎺ヨ緭鍏ラ棶棰樺苟鎸夊洖杞︽彁浜わ紝杩欐牱鎴戣兘蹇�熷緱鍒� LLM 鍥炲銆�
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄦ彃浠堕厤缃腑閫夋嫨渚涘簲鍟嗙洿杩炴垨 AiChat 鑷湁 API锛岃繖鏍峰悓涓�涓闈㈣緭鍏ユ潯鏃㈣兘璋冪敤澶栭儴妯″瀷锛屼篃鑳借繘鍏ヨ嚜鏈夋湇鍔$殑椤圭洰涓婁笅鏂囥��
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄨ緭鍏ユ宸︿晶閫夋嫨 AiChat 椤圭洰锛岃繖鏍锋瘡娆℃彁闂兘鑳借繘鍏ュ搴旈」鐩拰榛樿浼氳瘽銆�
 - 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄨ緭鍏ユ鍙充晶鍒囨崲妯″瀷锛岃繖鏍锋垜鑳芥寜浠诲姟閫夋嫨鏇村揩鎴栨洿寮虹殑妯″瀷銆�
 - 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄥ洖澶嶇敓鎴愭椂鐪嬪埌閫愭娴佸紡杈撳嚭锛岃繖鏍锋垜鐭ラ亾璇锋眰姝e湪杩涜銆�
 - 浣滀负鐢ㄦ埛锛屾垜鍙互缁х画缂栬緫杈撳叆鍐呭銆佸鍒惰緭鍑哄唴瀹规垨鎸� Escape 鏀惰捣缁撴灉锛岃繖鏍锋闈笉浼氳闀挎枃鏈暱鏈熷崰鎹��
 - 浣滀负鐢ㄦ埛锛屾垜鍙互閫氳繃绠$悊绐楀彛鎴栭厤缃淮鎶や笉鍚屼緵搴斿晢鐨勬ā鍨嬨�乪ndpoint 鍜岄粯璁ゆā鍨嬶紝杩欐牱鎻掍欢鑳藉悓鏃舵帴鍏� OpenAI-compatible銆丏eepSeek銆佹湰鍦版ā鍨嬫垨鍚庣画鏂板渚涘簲鍟嗐��
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄤ緵搴斿晢鐩磋繛妯″紡涓嬫煡鐪嬨�佹墜鍔ㄦ坊鍔犮�佸垹闄ゅ拰鍙洖 AiChat 璁板繂锛岃繖鏍风洿杩炰緵搴斿晢鏃朵篃鑳藉鐢ㄦ垜鍦� AiChat 涓淮鎶ょ殑闀挎湡璁板繂銆�
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鎶� AiChat 瀵嗙爜鏀惧湪鐜鍙橀噺閲岋紝杩欐牱閰嶇疆鏂囦欢涓嶉渶瑕佷繚瀛樺瘑鐮佹槑鏂囥��
 
 ## 鎻掍欢绫诲瀷
 
@@ -100,7 +112,11 @@
 
 - 杈撳叆鏉′负鍗曡浼樺厛锛岄暱鏂囨湰鍙湪杈惧埌瀹藉害鍚庤交寰楂樺埌鏈�澶� 3 琛屻��
 - 鍗犱綅鏂囨锛歚What can I help you with today?` 鎴栧悗缁湰鍦板寲涓轰腑鏂囥��
-- 宸︿晶灞曠ず鐘舵�佸浘鏍囷細
+- 杈撳叆妗嗗乏渚у睍绀洪」鐩笅鎷夛細
+  - 鑷湁 API 妯″紡涓嬪繀椤讳粠 AiChat `GET /api/projects` 鑾峰彇椤圭洰鍒楄〃銆�
+  - 渚涘簲鍟嗙洿杩炴ā寮忎笅濡傛灉宸查厤缃� AiChat 璐﹀彿锛屼篃搴旀樉绀洪」鐩笅鎷夛紝鐢ㄤ簬璁板繂鏌ヨ銆佸垱寤恒�佸垹闄ゅ拰鍙洖鐨勯」鐩笂涓嬫枃銆�
+  - 鏈櫥褰曘�佹湭閰嶇疆鎴栨帴鍙d笉鍙敤鏃舵樉绀烘槑纭檷绾х姸鎬侊紝渚嬪 `No project`锛屼笉闃诲鏃犻」鐩洿杩炴彁闂��
+- 椤圭洰涓嬫媺宸︿晶鎴栬緭鍏ユ潯鍓嶇紑浣嶇疆灞曠ず鐘舵�佸浘鏍囷細
   - 绌洪棽锛氬搧鐗屾垨鏄熻姃鍥炬爣銆�
   - 璇锋眰涓細缁嗗皬鏃嬭浆鐘舵�併��
   - 閿欒锛氫綆楗卞拰璀︾ず鐘舵�併��
@@ -172,7 +188,67 @@
 
 ## 妯″瀷閰嶇疆
 
-鎻掍欢鍓嶇鍙渶瑕佺煡閬撳彲灞曠ず鐨勬ā鍨嬫竻鍗曞拰榛樿妯″瀷銆傚叿浣撲緵搴斿晢銆乪ndpoint銆侀壌鏉冩柟寮忓拰璇锋眰閫傞厤搴斾紭鍏堢敱瀹夸富渚� LLM 浠g悊绠$悊锛屾彃浠舵彁浜ゆ椂鍙紶 `modelId`銆�
+鎻掍欢閰嶇疆蹇呴』鏄惧紡鍖哄垎杩愯妯″紡銆傛彃浠跺墠绔彧闇�瑕佺煡閬撳彲灞曠ず鐨勯」鐩�佹ā鍨嬫竻鍗曞拰榛樿妯″瀷銆傚叿浣撲緵搴斿晢銆乪ndpoint銆侀壌鏉冩柟寮忋�丄iChat 鐧诲綍鎬佸拰璇锋眰閫傞厤搴斾紭鍏堢敱瀹夸富渚� LLM 浠g悊绠$悊锛屾彃浠舵彁浜ゆ椂鍙紶 `mode`銆乣projectId`銆乣modelId` 鍜屾秷鎭唴瀹广��
+
+### 杩愯妯″紡
+
+| 妯″紡 | 閰嶇疆鍊� | 鑱婂ぉ鍏ュ彛 | 妯″瀷鏉ユ簮 | 璁板繂绠$悊 |
+| --- | --- | --- | --- | --- |
+| 渚涘簲鍟嗙洿杩炴ā寮� | `provider-direct` | `window.moliDesktop.llm.streamChat` -> 渚涘簲鍟嗛�傞厤鍣� | `llm-models.json` 鎴栧涓绘ā鍨嬫敞鍐岃〃 | 閫氳繃 AiChat 璁板繂鎺ュ彛绠$悊鍜屽彫鍥� |
+| 鑷湁 API 妯″紡 | `aichat-api` | AiChat `POST /api/chat/send` + SSE | AiChat `GET /api/chat/models` | 鎻掍欢鏃犻渶澶勭悊锛屼氦鐢� AiChat 鑱婂ぉ閾捐矾 |
+
+妯″紡鍒囨崲瑙勫垯锛�
+
+- 榛樿淇濇寔 `provider-direct`锛屼繚璇佺幇鏈夎涓轰笉琚牬鍧忋��
+- 鍒囨崲鍒� `aichat-api` 鍚庯紝鎻掍欢蹇呴』鍏堢櫥褰� AiChat 骞惰幏鍙栭」鐩垪琛ㄣ��
+- `aichat-api` 妯″紡涓嬫彁浜ゆ秷鎭椂搴斾紶鍏ュ綋鍓� `projectId`锛涘鏈�夐」鐩紝鍙敱 AiChat 鎸夋帴鍙h鍒欎娇鐢ㄦ垨鍒涘缓榛樿椤圭洰锛屼絾 UI 搴斿敖閲忛�夋嫨鏄庣‘椤圭洰銆�
+- 涓ょ妯″紡閮戒笉寰楁妸瀵嗙爜銆丼ession Token銆佷緵搴斿晢 API key 鏆撮湶缁欐彃浠堕〉闈㈡棩蹇楁垨鍙鍒堕敊璇俊鎭��
+
+### AiChat 鐢ㄦ埛閰嶇疆
+
+AiChat 鏈嶅姟閰嶇疆灞炰簬鎻掍欢杩愯閰嶇疆锛屼絾鍑嵁瑙f瀽鐢卞涓绘墽琛屻�傜粺涓� Host 涓嶅弬鑰� AiChat 鎺ュ彛鏂囨。锛屼互鐢ㄦ埛缁欏畾鍊间负鍑嗭細
+
+```json
+{
+  "mode": "provider-direct",
+  "aichat": {
+    "baseUrl": "http://192.168.1.111:13000",
+    "account": {
+      "email": "user@example.com",
+      "password": null,
+      "passwordEnv": "MOLI_AICHAT_PASSWORD"
+    },
+    "defaultProjectId": "",
+    "memory": {
+      "enabledInProviderDirect": true,
+      "defaultScope": "PROJECT",
+      "recallLimit": 8
+    }
+  }
+}
+```
+
+瀛楁璇存槑锛�
+
+| 瀛楁 | 璇存槑 |
+| --- | --- |
+| `mode` | `provider-direct` 鎴� `aichat-api`锛岄粯璁� `provider-direct`銆� |
+| `aichat.baseUrl` | AiChat 鏈嶅姟 Host锛岄粯璁� `http://192.168.1.111:13000`銆� |
+| `aichat.account.email` | AiChat 鐧诲綍璐﹀彿锛屽厑璁告槑鏂囬厤缃�� |
+| `aichat.account.password` | AiChat 鐧诲綍瀵嗙爜鏄庢枃锛屼粎鍏佽涓汉鏈湴娴嬭瘯锛屼笉鎺ㄨ崘銆� |
+| `aichat.account.passwordEnv` | 瀵嗙爜鐜鍙橀噺鍚嶏紝浼樺厛绾ч珮浜� `password`銆� |
+| `aichat.defaultProjectId` | 榛樿閫変腑鐨� AiChat 椤圭洰 ID锛屽彲涓虹┖銆� |
+| `aichat.memory.enabledInProviderDirect` | 渚涘簲鍟嗙洿杩炴ā寮忎笅鏄惁鍚敤 AiChat 璁板繂绠$悊銆� |
+| `aichat.memory.defaultScope` | `GLOBAL`銆乣PROJECT` 鎴� `ALL`锛岀敤浜庡彫鍥炲拰璁板繂绠$悊榛樿鑼冨洿銆� |
+| `aichat.memory.recallLimit` | 鍙洖鏁伴噺锛屽缓璁� `1..20`銆� |
+
+AiChat 閴存潈娴佺▼锛�
+
+1. `POST /api/auth/login`锛岃姹備綋鍖呭惈 `email` 鍜岃В鏋愬悗鐨勫瘑鐮併��
+2. 淇濆瓨鍝嶅簲 `data.sessionToken` 鍒板涓诲唴瀛樻�併��
+3. 鍚庣画璇锋眰鎼哄甫 `x-session-token: <sessionToken>`銆�
+4. 鍙�夎皟鐢� `GET /api/auth/me` 鏍¢獙瀹℃壒鐘舵�併�佽蹇嗘潈闄愬拰椤圭洰鏉冮檺銆�
+5. Session 杩囨湡鎴栬繑鍥� `401` 鏃堕噸鏂扮櫥褰曚竴娆★紱浠嶅け璐ュ垯鍦ㄦ彃浠惰緭鍑哄尯灞曠ず鍙搷浣滈敊璇��
 
 鎺ㄨ崘閲囩敤鈥滄寜妯″瀷璺敱鈥濈殑閰嶇疆缁撴瀯锛氭瘡涓ā鍨嬮兘鍙互缁戝畾鐙珛 provider銆乁RL銆侀壌鏉冨紩鐢ㄥ拰璇锋眰閫傞厤鍙傛暟銆傝繖鏍峰悓涓�涓彃浠跺彲浠ュ悓鏃舵帴鍏ヤ笉鍚屼緵搴斿晢锛屼篃鍙互鎺ュ叆鍚屼竴渚涘簲鍟嗙殑涓嶅悓 base URL銆�
 
@@ -253,6 +329,8 @@
 
 ```javascript
 window.moliDesktop.llm.streamChat({
+  mode: "provider-direct",
+  projectId: "aichat_project_id",
   modelId: "gpt-5.4",
   messages: [
     { role: "user", content: "..." }
@@ -265,6 +343,34 @@
 ```
 
 鎻掍欢涓嶅簲鐩存帴浼� provider銆乪ndpoint 鎴栧瘑閽ャ�傚涓诲搷搴斾腑鍙繑鍥炴湰娆¤姹傚疄闄呭懡涓殑渚涘簲鍟嗗拰妯″瀷锛岀敤浜庤瘖鏂拰 UI tooltip锛屼絾涓嶈繑鍥炲瘑閽ャ��
+
+鏂板 AiChat 鐩稿叧妗ユ帴鑳藉姏寤鸿锛�
+
+```typescript
+window.moliDesktop.llm = {
+  getConnectionMode(): Promise<"provider-direct" | "aichat-api">;
+  setConnectionMode(mode: "provider-direct" | "aichat-api"): Promise<void>;
+  getProjects(): Promise<Array<{ id: string; name: string; projectType: "CHAT" | "REMOTE"; memoryMode: string }>>;
+  getMemories(options: { scope?: "GLOBAL" | "PROJECT"; projectId?: string }): Promise<object>;
+  createMemory(input: { scope: "GLOBAL" | "PROJECT"; projectId?: string; content: string }): Promise<object>;
+  deleteMemory(memoryId: string): Promise<void>;
+  recallMemories(input: { query: string; scope?: "GLOBAL" | "PROJECT" | "ALL"; projectId?: string; limit?: number }): Promise<object>;
+};
+```
+
+椤圭洰涓嬫媺鏁版嵁鏉ヨ嚜 AiChat `GET /api/projects`銆傝蹇嗙鐞嗘帴鍙f潵鑷� AiChat锛�
+
+- `GET /api/memories?scope={scope}&projectId={projectId}`
+- `POST /api/memories`
+- `DELETE /api/memories/{memoryId}`
+- `POST /api/memories/recall`
+
+鑷湁 API 妯″紡鑱婂ぉ璋冪敤锛�
+
+- `POST /api/chat/send`
+- `GET /api/chat/generations/{generationId}/stream?token={streamToken}`
+
+鑷湁 API 妯″紡鍙娇鐢� AiChat 椤圭洰鍜屼細璇濊鍒欙紱鎻掍欢 MVP 涓嶅繀鎻愪緵浼氳瘽涓嬫媺锛屽彧闇�浠ユ墍閫� `projectId` 鎻愪氦锛岃 AiChat 浣跨敤鎴栧垱寤鸿椤圭洰榛樿浼氳瘽銆�
 
 娴佸紡浜嬩欢寤鸿锛�
 
@@ -359,9 +465,71 @@
 ### FR-LLM-02 妯″瀷閫夋嫨
 
 - 鎻掍欢蹇呴』鍦ㄨ緭鍏ユ鍙充晶鎻愪緵妯″瀷涓嬫媺銆�
-- 妯″瀷涓嬫媺蹇呴』浠庨厤缃鍙栨ā鍨嬫竻鍗曘��
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅锛屾ā鍨嬩笅鎷夊繀椤讳粠瀹夸富 LLM 妯″瀷娉ㄥ唽琛ㄨ鍙栨ā鍨嬫竻鍗曘��
+- 鑷湁 API 妯″紡涓嬶紝妯″瀷涓嬫媺蹇呴』浼樺厛浠� AiChat `GET /api/chat/models` 璇诲彇妯″瀷娓呭崟銆�
 - 妯″瀷鍒囨崲蹇呴』褰卞搷涓嬩竴娆℃彁浜ゃ��
 - 褰撳墠璇锋眰杩涜涓椂锛屾ā鍨嬪垏鎹笉寰楀奖鍝嶅凡鍙戝嚭鐨勮姹傘��
+
+浼樺厛绾э細P1
+
+### FR-LLM-07 杩愯妯″紡閫夋嫨
+
+- 鎻掍欢蹇呴』鏀寔 `provider-direct` 鍜� `aichat-api` 涓ょ杩愯妯″紡銆�
+- 妯″紡蹇呴』鍙�氳繃鎻掍欢閰嶇疆閫夋嫨锛屽苟鑳藉湪鍚庣画绠$悊 UI 涓睍绀恒��
+- 榛樿妯″紡蹇呴』涓� `provider-direct`锛屼繚璇佺幇鏈変緵搴斿晢鐩磋繛琛屼负鍏煎銆�
+- 妯″紡鍒囨崲鍚庯紝椤圭洰涓嬫媺銆佹ā鍨嬩笅鎷夈�佽亰澶╂彁浜よ矾寰勫拰璁板繂鍏ュ彛蹇呴』鎸夋ā寮忓埛鏂般��
+
+浼樺厛绾э細P1
+
+### FR-LLM-08 AiChat 椤圭洰涓嬫媺
+
+- 杈撳叆妗嗗乏渚у繀椤绘彁渚� AiChat 椤圭洰涓嬫媺鍒楄〃銆�
+- 椤圭洰鍒楄〃蹇呴』璋冪敤 AiChat `GET /api/projects` 鑾峰彇銆�
+- 鐧诲綍澶辫触銆佽处鍙锋湭瀹℃壒銆佹棤鏉冮檺鎴栨帴鍙d笉鍙揪鏃讹紝椤圭洰涓嬫媺蹇呴』灞曠ず鍙悊瑙i檷绾х姸鎬併��
+- 鑷湁 API 妯″紡涓嬫彁浜よ亰澶╂椂蹇呴』浣跨敤褰撳墠閫変腑椤圭洰锛涙湭閫夐」鐩椂鍏佽鎸� AiChat 榛樿椤圭洰瑙勫垯闄嶇骇銆�
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅锛岄」鐩�夋嫨鐢ㄤ簬璁板繂绠$悊鍜屽彫鍥炰笂涓嬫枃锛屼笉寰楀己鍒堕樆濉炵洿杩炶亰澶┿��
+
+浼樺厛绾э細P1
+
+### FR-LLM-09 AiChat 鐢ㄦ埛閰嶇疆
+
+- 鎻掍欢閰嶇疆蹇呴』鍖呭惈 AiChat `baseUrl`銆佽处鍙峰拰瀵嗙爜寮曠敤銆�
+- `baseUrl` 榛樿鍊间负 `http://192.168.1.111:13000`銆�
+- 璐﹀彿鍏佽鏄庢枃閰嶇疆銆�
+- 瀵嗙爜蹇呴』鏀寔鐜鍙橀噺寮曠敤锛屼笖鐜鍙橀噺鍊间紭鍏堜簬鏄庢枃瀛楁銆�
+- 鐧诲綍鎴愬姛鍚庣殑 `sessionToken` 蹇呴』鍙繚瀛樺湪瀹夸富杩愯鎬侊紝涓嶅啓鍏ユ彃浠跺墠绔垨鏅�氶厤缃枃浠躲��
+- 鏃ュ織涓嶅緱杈撳嚭瀵嗙爜銆丼ession Token 鎴栧畬鏁磋姹傚ご銆�
+
+浼樺厛绾э細P1
+
+### FR-LLM-10 鑷湁 API 妯″紡鑱婂ぉ
+
+- 鑷湁 API 妯″紡涓嬶紝鎻掍欢蹇呴』閫氳繃 AiChat `POST /api/chat/send` 鍙戣捣鑱婂ぉ銆�
+- 鎻掍欢蹇呴』浣跨敤 AiChat 杩斿洖鐨� `generationId` 鍜� `streamToken` 璁㈤槄 SSE銆�
+- 鎻掍欢蹇呴』澶勭悊 `snapshot`銆乣chunk`銆乣processing`銆乣done`銆乣failed` 鍜� `aborted` 浜嬩欢銆�
+- 鎻掍欢蹇呴』鎶� AiChat 閿欒鐮佹槧灏勪负鍙悊瑙i敊璇紝渚嬪鏈櫥褰曘�佸緟瀹℃壒銆佹ā鍨嬩笉鍙敤銆侀厤棰濊�楀敖鍜屾秷鎭暟瓒呴檺銆�
+- 鑷湁 API 妯″紡涓嬫棤闇�鎻掍欢渚ц蹇嗙鐞嗭紱涓嶅緱閲嶅璋冪敤璁板繂鍙洖鎺ュ彛鎷艰 Prompt銆�
+
+浼樺厛绾э細P1
+
+### FR-LLM-11 渚涘簲鍟嗙洿杩炴ā寮忚蹇嗙鐞�
+
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅锛屽鏋滈厤缃簡 AiChat 璐﹀彿涓旂敤鎴峰叿澶囨潈闄愶紝鎻掍欢蹇呴』鏀寔 AiChat 璁板繂绠$悊銆�
+- 鎻掍欢蹇呴』鏀寔鏌ヨ鍏ㄥ眬璁板繂鍜岄」鐩蹇嗐��
+- 鎻掍欢蹇呴』鏀寔鎵嬪姩鍒涘缓鍏ㄥ眬璁板繂鍜岄」鐩蹇嗐��
+- 鎻掍欢蹇呴』鏀寔鍒犻櫎璁板繂銆�
+- 鎻掍欢蹇呴』鏀寔鎸夊綋鍓嶈緭鍏ュ拰閫変腑椤圭洰璋冪敤 `POST /api/memories/recall` 鍙洖璁板繂銆�
+- 鍙洖缁撴灉鍙綔涓轰緵搴斿晢鐩磋繛璇锋眰鐨勪笂涓嬫枃娉ㄥ叆锛屼絾蹇呴』閬靛畧椤圭洰闅旂鍜岀敤鎴锋潈闄愩��
+- 濡傛灉 AiChat 杩斿洖 `canUseMemory=false`銆乣canViewMemory=false` 鎴� `canManageMemory=false`锛屾彃浠跺繀椤绘寜鏉冮檺闅愯棌鎴栫鐢ㄥ搴旀搷浣溿��
+
+浼樺厛绾э細P1
+
+### FR-LLM-12 閰嶇疆鍏煎涓庤縼绉�
+
+- 鐜版湁浠呭寘鍚� `defaultModel` 鍜� `models` 鐨勬彃浠堕厤缃繀椤荤户缁彲鐢ㄣ��
+- 缂哄け `mode` 鏃舵寜 `provider-direct` 澶勭悊銆�
+- 缂哄け `aichat` 閰嶇疆鏃讹紝椤圭洰涓嬫媺鍜岃蹇嗗姛鑳介檷绾т负涓嶅彲鐢紝浣嗕緵搴斿晢鐩磋繛鑱婂ぉ浠嶅彲鐢ㄣ��
+- 閰嶇疆鏂囦欢蹇呴』浠� UTF-8 璇诲啓銆�
 
 浼樺厛绾э細P1
 
@@ -429,20 +597,41 @@
 - 棣栫増鎻掍欢鏃犳矙绠遍殧绂伙紝浣� LLM 璇锋眰鑳藉姏蹇呴』閫氳繃鏄庣‘鏉冮檺澹版槑銆�
 - 瀹夸富浠g悊 LLM 璇锋眰鏃讹紝搴旈檺鍒舵彃浠跺彧鑳戒娇鐢ㄥ凡鍚敤鐨勬ā鍨� id锛屽苟鐢卞涓昏В鏋愬搴� endpoint銆�
 - 鏃ュ織涓嶅緱璁板綍瀹屾暣 API key銆�
+- 鏃ュ織涓嶅緱璁板綍 AiChat 瀵嗙爜銆丼ession Token 鎴栧畬鏁� `x-session-token` 璇锋眰澶淬��
 - 榛樿涓嶆妸鐢ㄦ埛杈撳叆鍐呭鍐欏叆鎸佷箙鍖栭厤缃��
+- 渚涘簲鍟嗙洿杩炴ā寮忎娇鐢ㄨ蹇嗗彫鍥炴椂锛屽簲鍙妸鐢ㄦ埛纭鍚敤鐨勫彫鍥炲唴瀹瑰姞鍏ヤ笂涓嬫枃锛屽苟閬垮厤鍦ㄨ瘖鏂棩蹇椾腑璁板綍瀹屾暣璁板繂鍐呭銆�
 
 ## 楠屾敹鏍囧噯
 
 - 褰撴彃浠堕娆″畨瑁呭苟鍚敤鏃讹紝杈撳叆鏉″嚭鐜板湪涓诲睆椤堕儴灞呬腑锛岄《閮ㄧ暀鏈夌害 `32px` 绌洪殭銆�
+- 褰撴彃浠堕厤缃� `mode=provider-direct` 鏃讹紝鍘熸湁渚涘簲鍟嗙洿杩炴祦寮忚緭鍑洪摼璺粛鍙娇鐢ㄣ��
+- 褰撴彃浠堕厤缃� `mode=aichat-api` 鏃讹紝鎻掍欢閫氳繃 `http://192.168.1.111:13000` 鐧诲綍 AiChat锛屽苟浣跨敤 AiChat 鑱婂ぉ鎺ュ彛瀹屾垚涓�娆℃祦寮忓洖澶嶃��
+- 褰� AiChat 瀵嗙爜閰嶇疆涓虹幆澧冨彉閲忔椂锛屾彃浠惰兘璇诲彇鐜鍙橀噺瀹屾垚鐧诲綍锛岄厤缃枃浠朵腑涓嶉渶瑕佷繚瀛樺瘑鐮佹槑鏂囥��
+- 褰撶櫥褰曟垚鍔熷悗锛岃緭鍏ユ宸︿晶椤圭洰涓嬫媺鏄剧ず AiChat `GET /api/projects` 杩斿洖鐨勯」鐩��
+- 褰撶敤鎴烽�夋嫨涓嶅悓椤圭洰鍚庢彁浜ゆ椂锛岃嚜鏈� API 妯″紡璇锋眰鎼哄甫瀵瑰簲 `projectId`銆�
 - 褰撶敤鎴疯緭鍏ユ枃鏈苟鎸� Enter 鏃讹紝鎻掍欢鍙戣捣涓�娆� LLM 璇锋眰锛屼笖娌℃湁鎻愪氦鎸夐挳銆�
 - 褰撶敤鎴烽�夋嫨涓嶅悓妯″瀷鍚庡啀鎻愪氦鏃讹紝璇锋眰浣跨敤鏂版ā鍨嬨��
 - 褰撲笉鍚屾ā鍨嬮厤缃簡涓嶅悓渚涘簲鍟嗗拰 endpoint 鏃讹紝瀹夸富搴旀寜鎵�閫� `modelId` 璺敱鍒板搴� API銆�
+- 褰撲緵搴斿晢鐩磋繛妯″紡鍚敤 AiChat 璁板繂绠$悊鏃讹紝鐢ㄦ埛鍙互鏌ヨ銆佸垱寤恒�佸垹闄ゅ拰鍙洖褰撳墠椤圭洰璁板繂銆�
+- 褰撹嚜鏈� API 妯″紡鍚敤鏃讹紝鎻掍欢涓嶅睍绀烘垨涓嶆墽琛屾彃浠朵晶璁板繂绠$悊鍔ㄤ綔锛岃亰澶╄蹇嗙敱 AiChat 鏈嶅姟澶勭悊銆�
 - 褰� LLM 杩斿洖鍐呭鏃讹紝杈撳嚭鍖哄煙鍦ㄨ緭鍏ユ搴曢儴灞曞紑锛屽苟閫愭鏄剧ず娴佸紡鏂囨湰銆�
 - 褰撹緭鍑哄唴瀹硅秴杩囧睆骞曢珮搴� `50%` 鏃讹紝杈撳嚭鍖哄煙鍐呴儴婊氬姩锛屾彃浠朵笉浼氱户缁悜涓嬫棤闄愭墿寮犮��
 - 褰撶敤鎴锋寜 Escape 鏃讹紝宸插睍寮�杈撳嚭鍖哄煙鍙互鏀惰捣銆�
 - 褰� endpoint 涓嶅彲鐢ㄦ垨閴存潈澶辫触鏃讹紝杈撳嚭鍖哄煙灞曠ず鍙悊瑙i敊璇紝涓嶅鑷村涓诲穿婧冦��
 - 褰撳簲鐢ㄩ噸鍚悗锛屾彃浠朵綅缃�佸昂瀵搞�侀粯璁ゆā鍨嬪拰鏄剧ず灞傜骇浠庨厤缃仮澶嶃��
 - 褰撴彃浠跺浜庨粯璁� `desktop` 灞傛椂锛屽畠涓嶅簲瑕嗙洊鏅�氬簲鐢ㄧ獥鍙o紱鍒囨崲鍒� `global-top` 鏃跺繀椤诲彲閫氳繃鎵樼洏鎴栫鐞嗙獥鍙f仮澶嶃��
+- 褰� AiChat 杩斿洖 `USER_PENDING_APPROVAL`銆乣PERMISSION_DENIED`銆乣TOKEN_TOTAL_LIMIT_REACHED` 鎴� `INVALID_MODEL` 鏃讹紝鎻掍欢蹇呴』鏄剧ず鐭敊璇苟鍏佽鐢ㄦ埛淇敼閰嶇疆鎴栭噸璇曘��
+
+## 鐢ㄦ埛鎿嶄綔鎵嬪唽褰卞搷鑼冨洿
+
+鏈渶姹備細鏀瑰彉鐢ㄦ埛鍙閰嶇疆鍜屾彃浠舵搷浣滐紝鍚庣画寮�鍙戝畬鎴愬悗蹇呴』鍚屾鏇存柊鎿嶄綔鎵嬪唽锛岃嚦灏戝寘鎷細
+
+- LLM 鎻掍欢鐨勪袱绉嶈繍琛屾ā寮忚鏄庛��
+- AiChat Host銆佽处鍙枫�佸瘑鐮佺幆澧冨彉閲忛厤缃柟寮忋��
+- 椤圭洰涓嬫媺鐨勬潵婧愩�佸埛鏂般�佸け璐ョ姸鎬佸拰榛樿椤圭洰琛屼负銆�
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅鐨勮蹇嗘煡璇€�佸垱寤恒�佸垹闄ゅ拰鍙洖鎿嶄綔銆�
+- 鑷湁 API 妯″紡涓嬧�滀笉鍦ㄦ彃浠朵腑绠$悊璁板繂鈥濈殑闄愬埗璇存槑銆�
+- 甯歌鏁呴殰鎺掓煡锛氱櫥褰曞け璐ャ�佽处鍙锋湭瀹℃壒銆侀」鐩垪琛ㄤ负绌恒�佹ā鍨嬪垪琛ㄤ负绌恒�侀厤棰濊�楀敖銆佽蹇嗘潈闄愪笉瓒炽�丼SE 涓柇銆�
 
 ## 寰呮緞娓呴棶棰�
 
@@ -454,3 +643,6 @@
 | 鏄惁淇濈暀鍘嗗彶璁板綍 | MVP 涓嶄繚鐣欙紝浠呬繚鐣欏綋鍓嶇粨鏋� |
 | 鏄惁鏀寔鍋滄鐢熸垚 | MVP 鍙殏涓嶆敮鎸侊紝鍚庣画鏂板鍋滄鎸夐挳鎴� Escape 浜屾琛屼负 |
 | 鏄惁鍏ㄥ眬蹇嵎閿敜璧� | 鍚庣画鐗堟湰鑰冭檻锛屼緥濡� `Alt+Space` 鎴栫敤鎴疯嚜瀹氫箟蹇嵎閿� |
+| AiChat Host | 鍥哄畾榛樿 `http://192.168.1.111:13000`锛屼笉浠庢帴鍙f枃妗g幆澧冭〃鎺ㄥ |
+| AiChat 瀵嗙爜閰嶇疆 | 浼樺厛浣跨敤鐜鍙橀噺锛屽厑璁告湰鍦颁釜浜烘祴璇曟槑鏂囧瘑鐮� |
+| 鑷湁 API 妯″紡璁板繂 | 鎻掍欢涓嶅鐞嗚蹇嗙鐞嗭紝鐢� AiChat 鏈嶅姟鑱婂ぉ閾捐矾澶勭悊 |
diff --git a/docs/qa/display-layer-acceptance-2026-05-03.md b/docs/qa/display-layer-acceptance-2026-05-03.md
index 2356513..8a6f78c 100644
--- a/docs/qa/display-layer-acceptance-2026-05-03.md
+++ b/docs/qa/display-layer-acceptance-2026-05-03.md
@@ -32,6 +32,6 @@
 
 - 鍦ㄧ湡瀹� Windows 11 妗岄潰鐜鍒嗗埆鍒囨崲 `desktop`銆乣normal`銆乣app-top`銆乣global-top`锛岃瀵熺獥鍙i伄鎸¤涓恒��
 - 楠岃瘉 `desktop` 涓嶈鐩栨櫘閫氬簲鐢ㄧ獥鍙c��
-- 楠岃瘉 `desktop` 缁勪欢鍦ㄦ寜涓� Win+D 鍚庝粛鏄剧ず鍦ㄦ闈笂锛涜嫢 WorkerW 鎸傝浇澶辫触锛屽簲鍦ㄨ瘖鏂棩蹇椾腑鐪嬪埌闄嶇骇鍘熷洜銆�
+- 楠岃瘉 `desktop` 缁勪欢鍦ㄦ寜涓� Win+D 鍚庝粛鏄剧ず鍦ㄦ闈笂锛涜瘖鏂棩蹇楀簲鏄剧ず `WorkerW` 绛栫暐閫変腑锛屽苟璁板綍瀹為檯瀹夸富 `WorkerW` 鎴� `Progman`銆傝嫢妗岄潰瀹夸富鎸傝浇澶辫触锛屽簲鍦ㄨ瘖鏂棩蹇椾腑鐪嬪埌闄嶇骇鍘熷洜銆�
 - 楠岃瘉 `global-top` 鍙鐩栧叾浠栧簲鐢ㄧ獥鍙o紝骞跺彲閫氳繃绠$悊绐楀彛鎴栨墭鐩樻仮澶嶄负瀹夊叏灞傜骇銆�
 - 楠岃瘉澶氭樉绀哄櫒鍜� DPI 缂╂斁涓嬪眰绾ц涔変繚鎸佷竴鑷淬��
diff --git a/docs/qa/llm-command-palette-aichat-mode-acceptance-2026-05-04.md b/docs/qa/llm-command-palette-aichat-mode-acceptance-2026-05-04.md
new file mode 100644
index 0000000..72fd5c0
--- /dev/null
+++ b/docs/qa/llm-command-palette-aichat-mode-acceptance-2026-05-04.md
@@ -0,0 +1,57 @@
+# LLM 妗岄潰杈撳叆鎻掍欢 AiChat 妯″紡楠屾敹璁板綍
+
+鏃ユ湡锛�2026-05-04
+
+## 鑼冨洿
+
+鏈楠屾敹瑕嗙洊 `sample.llm-command-palette` 鐨勪袱绉嶆ā寮忓寮猴細
+
+- 渚涘簲鍟嗙洿杩炴ā寮忕户缁蛋瀹夸富 LLM 妯″瀷娉ㄥ唽琛ㄥ拰 provider adapter銆�
+- 鑷湁 API 妯″紡璧� AiChat 鐧诲綍銆侀」鐩�佹ā鍨嬨�佽亰澶╁彂閫佸拰 SSE銆�
+- 渚涘簲鍟嗙洿杩炴ā寮忎笅閫氳繃 AiChat 杩涜璁板繂鏌ヨ銆佸垱寤恒�佸垹闄ゅ拰鍙洖銆�
+- 鎻掍欢 UI 宸︿晶椤圭洰涓嬫媺銆佸彸渚фā鍨嬩笅鎷夊拰璁板繂鍏ュ彛銆�
+- 鐢ㄦ埛鎿嶄綔鎵嬪唽鍚屾銆�
+
+## 楠屾敹缁撹
+
+閫氳繃銆�
+
+褰撳墠瀹炵幇宸叉弧瓒虫湰杞紑鍙戦獙鏀舵潯浠躲�傜湡瀹� AiChat 璐﹀彿銆佸鎵圭姸鎬併�佹ā鍨嬮厤棰濆拰鍐呯綉鏈嶅姟鍙敤鎬т粛闇�瑕佸湪鐩爣鐜鍋氫竴娆′汉宸ョ鍒扮鑱旇皟銆�
+
+## 鎵ц缁撴灉
+
+| 椤圭洰 | 鍛戒护鎴栨柟娉� | 缁撴灉 |
+| --- | --- | --- |
+| 鏋勫缓 | `dotnet build .\Moli.Desktop.slnx` | 閫氳繃锛�0 warning锛�0 error |
+| 鑷姩鍖栨祴璇� | `dotnet test .\Moli.Desktop.slnx` | 閫氳繃锛�43/43 |
+| 鏍蜂緥鎻掍欢娓叉煋 | Edge headless 鎵撳紑 `samples/plugins/sample.llm-command-palette/index.html` | 閫氳繃锛岀敓鎴愭埅鍥� |
+| 鍍忕礌妫�鏌� | 閲囨牱鎴浘鍍忕礌 | 閫氳繃锛宍Sampled=2340 NonWhite=2340 NonTransparent=2340` |
+
+娓叉煋鎴浘锛�
+
+- `artifacts/llm-command-palette-aichat-mode-render-check.png`
+
+## 鍔熻兘楠屾敹
+
+| 楠屾敹鐐� | 缁撴灉 | 璇存槑 |
+| --- | --- | --- |
+| 榛樿淇濇寔渚涘簲鍟嗙洿杩炴ā寮� | 閫氳繃 | `plugin.json` 榛樿 `mode=provider-direct` |
+| AiChat Host 榛樿鍊� | 閫氳繃 | 閰嶇疆榛樿 `http://192.168.1.111:13000` |
+| 瀵嗙爜鐜鍙橀噺 | 閫氳繃 | `AiChatClientTests` 楠岃瘉 `passwordEnv` 浼樺厛浜庢槑鏂囧瘑鐮� |
+| Session Token 杈圭晫 | 閫氳繃 | token 浠呯敱瀹夸富 `AiChatClient` 娉ㄥ叆璇锋眰澶达紝妗ユ帴涓嶈繑鍥� token |
+| 椤圭洰涓嬫媺鏁版嵁 | 閫氳繃 | 妗ユ帴鏂板 `llm.getProjects`锛屾祴璇曡鐩栭」鐩繑鍥� |
+| AiChat 妯″瀷鍒楄〃 | 閫氳繃 | `mode=aichat-api` 鏃跺彲浠� `GET /api/chat/models` 鐢熸垚瀹夊叏妯″瀷鎽樿 |
+| 鑷湁 API 鑱婂ぉ | 閫氳繃 | 娴嬭瘯瑕嗙洊 `POST /api/chat/send` 涓庣敓鎴� SSE 瑙f瀽 |
+| SSE 浜嬩欢鏄犲皠 | 閫氳繃 | `chunk` -> `llm.delta`锛宍done` -> `llm.completed` |
+| 鐩磋繛妯″紡璁板繂鍙洖 | 閫氳繃 | 妗ユ帴鍜屽鎴风娴嬭瘯瑕嗙洊 `POST /api/memories/recall` |
+| 璁板繂绠$悊鎺ュ彛 | 閫氳繃 | 妗ユ帴鏀寔鏌ヨ銆佸垱寤恒�佸垹闄ゅ拰鍙洖 |
+| UI 娓叉煋 | 閫氳繃 | 鎴浘鏄剧ず宸︿晶 `No project`銆佽緭鍏ユ銆佽蹇嗘寜閽拰鍙充晶妯″瀷涓嬫媺 |
+| 鎿嶄綔鎵嬪唽鍚屾 | 閫氳繃 | 宸叉洿鏂� `docs/ops/user-manual/plugins/sample.llm-command-palette.md` |
+
+## 椋庨櫓涓庡悗缁�
+
+- 鏈浣跨敤 fake HTTP 瑕嗙洊 AiChat API 鍚堝悓锛屾湭浣跨敤鐪熷疄璐﹀彿璁块棶 `http://192.168.1.111:13000`銆�
+- 鎻掍欢 UI 鐩墠鎻愪緵杞婚噺璁板繂闈㈡澘锛涘悗缁闇�瑕佹洿瀹屾暣鐨勮蹇嗙紪杈戜綋楠岋紝搴旇繘鍏ョ鐞嗙獥鍙e疄鐜般��
+- 鑷湁 API 妯″紡鏆傛湭鎻愪緵浼氳瘽涓嬫媺锛屾寜 AiChat 椤圭洰榛樿浼氳瘽瑙勫垯鎻愪氦銆�
+- Windows Credential Manager 浠嶆湭瀹炵幇锛屽瘑鐮佺敓浜ц矾寰勫綋鍓嶄负鐜鍙橀噺銆�
+
diff --git a/samples/plugins/sample.llm-command-palette/demo.html b/samples/plugins/sample.llm-command-palette/demo.html
new file mode 100644
index 0000000..f86d004
--- /dev/null
+++ b/samples/plugins/sample.llm-command-palette/demo.html
@@ -0,0 +1,491 @@
+<!doctype html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <title>LLM Command Palette Demo</title>
+  <style>
+    :root {
+      color-scheme: dark;
+      font-family: "Segoe UI", system-ui, sans-serif;
+      background: #11100f;
+    }
+
+    * {
+      box-sizing: border-box;
+    }
+
+    html,
+    body {
+      width: 100%;
+      min-height: 100%;
+      margin: 0;
+      background:
+        radial-gradient(circle at 18% 18%, rgba(255, 130, 88, 0.16), transparent 28%),
+        linear-gradient(135deg, #151312 0%, #23201f 52%, #11100f 100%);
+      overflow: hidden;
+    }
+
+    body {
+      padding: 8px;
+    }
+
+    .shell {
+      width: 100%;
+      color: rgba(255, 255, 255, 0.92);
+    }
+
+    .bar,
+    .output,
+    .memory {
+      width: 100%;
+      border: 1px solid rgba(255, 255, 255, 0.14);
+      background: rgba(28, 26, 25, 0.72);
+      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
+      backdrop-filter: blur(18px);
+    }
+
+    .bar {
+      display: grid;
+      grid-template-columns: minmax(90px, 112px) 22px minmax(0, 1fr) 30px minmax(112px, 128px);
+      align-items: center;
+      gap: 14px;
+      min-height: 56px;
+      padding: 0 20px;
+      border-radius: 20px;
+    }
+
+    .mark {
+      width: 18px;
+      height: 18px;
+      color: #ff8258;
+      display: grid;
+      place-items: center;
+      font-size: 20px;
+      line-height: 1;
+      transform-origin: center;
+    }
+
+    .mark.busy {
+      animation: spin 1.1s linear infinite;
+    }
+
+    @keyframes spin {
+      to { transform: rotate(360deg); }
+    }
+
+    textarea {
+      width: 100%;
+      min-height: 24px;
+      max-height: 78px;
+      resize: none;
+      border: 0;
+      outline: none;
+      color: rgba(255, 255, 255, 0.94);
+      background: transparent;
+      font: 600 16px/1.35 "Segoe UI", system-ui, sans-serif;
+      letter-spacing: 0;
+      overflow-y: auto;
+    }
+
+    textarea::placeholder {
+      color: rgba(255, 255, 255, 0.46);
+    }
+
+    input {
+      width: 100%;
+      height: 34px;
+      border: 1px solid rgba(255, 255, 255, 0.13);
+      outline: none;
+      color: rgba(255, 255, 255, 0.88);
+      background: rgba(255, 255, 255, 0.07);
+      border-radius: 8px;
+      padding: 0 30px 0 10px;
+      font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+      letter-spacing: 0;
+      transition: background 120ms ease;
+    }
+
+    .combo {
+      position: relative;
+      width: 100%;
+      min-width: 0;
+    }
+
+    .combo-input {
+      display: none;
+    }
+
+    .combo-trigger {
+      width: 100%;
+      height: 34px;
+      border: 0;
+      border-radius: 8px;
+      color: rgba(255, 255, 255, 0.82);
+      background: transparent;
+      padding: 0 28px 0 10px;
+      text-align: left;
+      font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+      letter-spacing: 0;
+      cursor: pointer;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+      position: relative;
+      transition: background 120ms ease;
+    }
+
+    .combo-trigger::after {
+      content: "";
+      position: absolute;
+      right: 11px;
+      top: 13px;
+      width: 7px;
+      height: 7px;
+      border-right: 2px solid rgba(255, 255, 255, 0.72);
+      border-bottom: 2px solid rgba(255, 255, 255, 0.72);
+      transform: rotate(45deg);
+    }
+
+    input:hover,
+    input:focus,
+    .combo.open .combo-trigger,
+    .combo-trigger:hover,
+    .combo-trigger:focus {
+      background-color: rgba(255, 255, 255, 0.08);
+      box-shadow: none;
+    }
+
+    .combo-menu {
+      position: absolute;
+      left: 0;
+      right: 0;
+      top: calc(100% + 6px);
+      z-index: 10;
+      display: none;
+      max-height: 184px;
+      overflow-y: auto;
+      padding: 6px;
+      border: 1px solid rgba(255, 255, 255, 0.13);
+      border-radius: 10px;
+      background: rgba(28, 26, 25, 0.92);
+      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
+      backdrop-filter: blur(16px);
+    }
+
+    .combo.open .combo-menu {
+      display: block;
+    }
+
+    .combo-option {
+      min-height: 36px;
+      display: flex;
+      align-items: center;
+      border-radius: 7px;
+      padding: 0 10px;
+      color: rgba(255, 255, 255, 0.86);
+      font: 600 13px/1.2 "Segoe UI", system-ui, sans-serif;
+      cursor: pointer;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+    }
+
+    .combo-option:hover,
+    .combo-option.selected {
+      background: rgba(255, 130, 88, 0.16);
+      color: rgba(255, 255, 255, 0.96);
+    }
+
+    .output,
+    .memory {
+      display: none;
+      margin-top: 8px;
+      max-height: 50vh;
+      overflow: auto;
+      border-radius: 16px;
+      padding: 16px 18px 14px;
+      font-size: 14px;
+      line-height: 1.55;
+      white-space: pre-wrap;
+    }
+
+    .output.open,
+    .memory.open {
+      display: block;
+      animation: panelIn 160ms ease-out;
+    }
+
+    @keyframes panelIn {
+      from { opacity: 0; transform: translateY(-3px); }
+      to { opacity: 1; transform: translateY(0); }
+    }
+
+    .actions,
+    .memory-actions {
+      display: flex;
+      justify-content: flex-end;
+      gap: 8px;
+      margin-top: 12px;
+    }
+
+    .memory-row {
+      display: grid;
+      grid-template-columns: minmax(0, 1fr) 32px;
+      gap: 8px;
+      align-items: start;
+      padding: 8px 0;
+      border-top: 1px solid rgba(255, 255, 255, 0.08);
+      white-space: normal;
+    }
+
+    .memory-row:first-child {
+      border-top: 0;
+    }
+
+    .memory-content {
+      color: rgba(255, 255, 255, 0.86);
+      overflow-wrap: anywhere;
+    }
+
+    button {
+      width: 30px;
+      height: 30px;
+      border: 0;
+      border-radius: 8px;
+      color: rgba(255, 255, 255, 0.84);
+      background: rgba(255, 255, 255, 0.08);
+      cursor: pointer;
+      font: 700 13px/1 "Segoe UI", system-ui, sans-serif;
+    }
+
+    button:disabled,
+    input:disabled {
+      cursor: not-allowed;
+      opacity: 0.52;
+    }
+
+    .error {
+      color: #ffad9b;
+    }
+  </style>
+</head>
+<body>
+  <main class="shell">
+    <section class="bar">
+      <div class="combo" id="projectCombo">
+        <input id="project" class="combo-input" aria-hidden="true">
+        <button id="projectButton" class="combo-trigger" type="button" title="AiChat project">Project</button>
+        <div id="projectMenu" class="combo-menu" role="listbox"></div>
+      </div>
+      <div id="mark" class="mark" aria-hidden="true">*</div>
+      <textarea id="prompt" rows="1" placeholder="What can I help you with today?">Summarize today's desktop notes</textarea>
+      <button id="memoryToggle" title="Memory">M</button>
+      <div class="combo" id="modelCombo">
+        <input id="model" class="combo-input" aria-hidden="true">
+        <button id="modelButton" class="combo-trigger" type="button" title="Model">Model</button>
+        <div id="modelMenu" class="combo-menu" role="listbox"></div>
+      </div>
+    </section>
+    <section id="output" class="output open" aria-live="polite">
+      <div id="text">Static preview response. This demo.html has no host bridge, no network calls, and no LLM dependency. Press Enter in the prompt to preview the loading and response states.</div>
+      <div class="actions">
+        <button id="copy" title="Copy">C</button>
+        <button id="collapse" title="Collapse">-</button>
+      </div>
+    </section>
+    <section id="memory" class="memory" aria-live="polite">
+      <div id="memoryList"></div>
+      <div class="memory-actions">
+        <input id="memoryInput" placeholder="Save memory">
+        <button id="saveMemory" title="Save memory">+</button>
+        <button id="refreshMemory" title="Refresh memory">R</button>
+      </div>
+    </section>
+  </main>
+
+  <script>
+    const demoProjects = [
+      { value: "desktop", label: "Desktop", title: "CHAT / PROJECT" },
+      { value: "design", label: "Design pass", title: "CHAT / PROJECT" },
+      { value: "ops", label: "Ops notes", title: "CHAT / PROJECT" }
+    ];
+    const demoModels = [
+      { value: "deepseek-v4-flash", label: "deepseek-v4-flash", title: "deepseek / deepseek-v4-flash" },
+      { value: "kimi-k2.6", label: "kimi-k2.6", title: "kimi / kimi-k2.6" },
+      { value: "glm-4.7-flash", label: "glm-4.7-flash", title: "bigmodel / glm-4.7-flash" },
+      { value: "qwen3.6-plus", label: "qwen3.6-plus", title: "qwen / qwen3.6-plus" }
+    ];
+    let demoMemories = [
+      { id: "m1", content: "Keep the command palette compact enough for a desktop widget." },
+      { id: "m2", content: "Prefer plain static demo files for visual iteration." }
+    ];
+
+    const promptInput = document.getElementById("prompt");
+    const projectSelect = document.getElementById("project");
+    const projectCombo = document.getElementById("projectCombo");
+    const projectButton = document.getElementById("projectButton");
+    const projectMenu = document.getElementById("projectMenu");
+    const modelSelect = document.getElementById("model");
+    const modelCombo = document.getElementById("modelCombo");
+    const modelButton = document.getElementById("modelButton");
+    const modelMenu = document.getElementById("modelMenu");
+    const output = document.getElementById("output");
+    const text = document.getElementById("text");
+    const mark = document.getElementById("mark");
+    const copy = document.getElementById("copy");
+    const collapse = document.getElementById("collapse");
+    const memoryToggle = document.getElementById("memoryToggle");
+    const memoryPanel = document.getElementById("memory");
+    const memoryList = document.getElementById("memoryList");
+    const memoryInput = document.getElementById("memoryInput");
+    const saveMemory = document.getElementById("saveMemory");
+    const refreshMemory = document.getElementById("refreshMemory");
+
+    let currentText = text.textContent;
+    const projectDropdown = { input: projectSelect, root: projectCombo, button: projectButton, menu: projectMenu };
+    const modelDropdown = { input: modelSelect, root: modelCombo, button: modelButton, menu: modelMenu };
+
+    function setupDropdown(dropdown) {
+      dropdown.button.addEventListener("click", () => {
+        const willOpen = !dropdown.root.classList.contains("open");
+        closeDropdowns();
+        dropdown.root.classList.toggle("open", willOpen);
+      });
+    }
+
+    function closeDropdowns() {
+      projectCombo.classList.remove("open");
+      modelCombo.classList.remove("open");
+    }
+
+    function setDropdownOptions(dropdown, items, preferredValue) {
+      dropdown.menu.innerHTML = "";
+      const selected = items.find((item) => item.value === preferredValue) || items[0];
+      for (const item of items) {
+        const option = document.createElement("div");
+        option.className = `combo-option${item.value === selected.value ? " selected" : ""}`;
+        option.textContent = item.label;
+        option.title = item.title || item.label;
+        option.dataset.value = item.value;
+        option.addEventListener("click", () => {
+          setDropdownValue(dropdown, item);
+          closeDropdowns();
+        });
+        dropdown.menu.appendChild(option);
+      }
+      setDropdownValue(dropdown, selected, false);
+    }
+
+    function setDropdownValue(dropdown, item, notify = true) {
+      dropdown.input.value = item.value;
+      dropdown.button.textContent = item.label;
+      dropdown.button.title = item.title || item.label;
+      for (const option of dropdown.menu.children) {
+        option.classList.toggle("selected", option.dataset.value === item.value);
+      }
+      if (notify) {
+        dropdown.input.dispatchEvent(new Event("change"));
+      }
+    }
+
+    function setBusy(busy) {
+      mark.classList.toggle("busy", busy);
+    }
+
+    function openOutput() {
+      output.classList.add("open");
+    }
+
+    function submitPrompt() {
+      const content = promptInput.value.trim();
+      if (!content) return;
+
+      currentText = "";
+      text.className = "";
+      text.textContent = "";
+      openOutput();
+      setBusy(true);
+
+      setTimeout(() => {
+        currentText = `Preview only\n\nProject: ${projectButton.textContent}\nModel: ${modelButton.textContent}\nPrompt: ${content}\n\nThis static demo mimics the result panel so the visual style can be edited without running Moli.Desktop.`;
+        text.textContent = currentText;
+        setBusy(false);
+      }, 380);
+    }
+
+    function renderMemories() {
+      memoryList.innerHTML = "";
+      if (!demoMemories.length) {
+        memoryList.textContent = "No memory";
+        return;
+      }
+
+      for (const item of demoMemories) {
+        const row = document.createElement("div");
+        row.className = "memory-row";
+        const content = document.createElement("div");
+        content.className = "memory-content";
+        content.textContent = item.content;
+        row.appendChild(content);
+        const remove = document.createElement("button");
+        remove.textContent = "x";
+        remove.title = "Delete memory";
+        remove.addEventListener("click", () => {
+          demoMemories = demoMemories.filter((memory) => memory.id !== item.id);
+          renderMemories();
+        });
+        row.appendChild(remove);
+        memoryList.appendChild(row);
+      }
+    }
+
+    promptInput.addEventListener("keydown", (event) => {
+      if (event.key === "Enter" && !event.shiftKey) {
+        event.preventDefault();
+        submitPrompt();
+      }
+
+      if (event.key === "Escape") {
+        output.classList.remove("open");
+        memoryPanel.classList.remove("open");
+      }
+    });
+
+    promptInput.addEventListener("input", () => {
+      promptInput.style.height = "0";
+      promptInput.style.height = `${Math.min(promptInput.scrollHeight, 78)}px`;
+    });
+
+    memoryToggle.addEventListener("click", () => {
+      memoryPanel.classList.toggle("open");
+      if (memoryPanel.classList.contains("open")) {
+        renderMemories();
+      }
+    });
+
+    refreshMemory.addEventListener("click", renderMemories);
+    saveMemory.addEventListener("click", () => {
+      const content = memoryInput.value.trim();
+      if (!content) return;
+      demoMemories.unshift({ id: `m${Date.now()}`, content });
+      memoryInput.value = "";
+      renderMemories();
+    });
+
+    collapse.addEventListener("click", () => output.classList.remove("open"));
+    copy.addEventListener("click", () => navigator.clipboard?.writeText(currentText).catch(() => {}));
+    document.addEventListener("click", (event) => {
+      if (!projectCombo.contains(event.target) && !modelCombo.contains(event.target)) {
+        closeDropdowns();
+      }
+    });
+
+    setupDropdown(projectDropdown);
+    setupDropdown(modelDropdown);
+    setDropdownOptions(projectDropdown, demoProjects, "desktop");
+    setDropdownOptions(modelDropdown, demoModels, "deepseek-v4-flash");
+    renderMemories();
+  </script>
+</body>
+</html>
diff --git a/samples/plugins/sample.llm-command-palette/index.html b/samples/plugins/sample.llm-command-palette/index.html
index 9617dd9..0fe981e 100644
--- a/samples/plugins/sample.llm-command-palette/index.html
+++ b/samples/plugins/sample.llm-command-palette/index.html
@@ -34,21 +34,22 @@
     }
 
     .bar,
-    .output {
+    .output,
+    .memory {
       width: 100%;
-      border: 1px solid rgba(255, 255, 255, 0.16);
-      background: rgba(30, 28, 27, 0.74);
-      box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
+      border: 1px solid rgba(255, 255, 255, 0.14);
+      background: rgba(28, 26, 25, 0.72);
+      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
       backdrop-filter: blur(18px);
     }
 
     .bar {
       display: grid;
-      grid-template-columns: 24px minmax(0, 1fr) 128px;
+      grid-template-columns: minmax(90px, 112px) 22px minmax(0, 1fr) 30px minmax(112px, 128px);
       align-items: center;
       gap: 14px;
       min-height: 56px;
-      padding: 0 18px;
+      padding: 0 20px;
       border-radius: 20px;
     }
 
@@ -89,19 +90,113 @@
       color: rgba(255, 255, 255, 0.46);
     }
 
-    select {
+    input {
+      width: 100%;
+      height: 34px;
+      border: 1px solid rgba(255, 255, 255, 0.13);
+      outline: none;
+      color: rgba(255, 255, 255, 0.88);
+      background: rgba(255, 255, 255, 0.07);
+      border-radius: 8px;
+      padding: 0 30px 0 10px;
+      font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+      letter-spacing: 0;
+      transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
+    }
+
+    .combo {
+      position: relative;
+      width: 100%;
+      min-width: 0;
+    }
+
+    .combo-input {
+      display: none;
+    }
+
+    .combo-trigger {
       width: 100%;
       height: 34px;
       border: 0;
-      outline: none;
-      color: rgba(255, 255, 255, 0.82);
-      background: rgba(255, 255, 255, 0.08);
       border-radius: 8px;
-      padding: 0 8px;
+      color: rgba(255, 255, 255, 0.82);
+      background: transparent;
+      padding: 0 28px 0 10px;
+      text-align: left;
       font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+      letter-spacing: 0;
+      cursor: pointer;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+      position: relative;
+      transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
     }
 
-    .output {
+    .combo-trigger::after {
+      content: "";
+      position: absolute;
+      right: 11px;
+      top: 13px;
+      width: 7px;
+      height: 7px;
+      border-right: 2px solid rgba(255, 255, 255, 0.72);
+      border-bottom: 2px solid rgba(255, 255, 255, 0.72);
+      transform: rotate(45deg);
+    }
+
+    input:hover,
+    input:focus,
+    .combo.open .combo-trigger,
+    .combo-trigger:hover,
+    .combo-trigger:focus {
+      background-color: rgba(255, 255, 255, 0.08);
+      box-shadow: none;
+    }
+
+    .combo-menu {
+      position: absolute;
+      left: 0;
+      right: 0;
+      top: calc(100% + 6px);
+      z-index: 10;
+      display: none;
+      max-height: 184px;
+      overflow-y: auto;
+      padding: 6px;
+      border: 1px solid rgba(255, 255, 255, 0.13);
+      border-radius: 10px;
+      background: rgba(28, 26, 25, 0.92);
+      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
+      backdrop-filter: blur(16px);
+    }
+
+    .combo.open .combo-menu {
+      display: block;
+    }
+
+    .combo-option {
+      min-height: 36px;
+      display: flex;
+      align-items: center;
+      border-radius: 7px;
+      padding: 0 10px;
+      color: rgba(255, 255, 255, 0.86);
+      font: 600 13px/1.2 "Segoe UI", system-ui, sans-serif;
+      cursor: pointer;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+    }
+
+    .combo-option:hover,
+    .combo-option.selected {
+      background: rgba(255, 130, 88, 0.16);
+      color: rgba(255, 255, 255, 0.96);
+    }
+
+    .output,
+    .memory {
       display: none;
       margin-top: 8px;
       max-height: 50vh;
@@ -113,15 +208,42 @@
       white-space: pre-wrap;
     }
 
-    .output.open {
+    .output.open,
+    .memory.open {
       display: block;
+      animation: panelIn 160ms ease-out;
     }
 
-    .actions {
+    @keyframes panelIn {
+      from { opacity: 0; transform: translateY(-3px); }
+      to { opacity: 1; transform: translateY(0); }
+    }
+
+    .actions,
+    .memory-actions {
       display: flex;
       justify-content: flex-end;
       gap: 8px;
       margin-top: 12px;
+    }
+
+    .memory-row {
+      display: grid;
+      grid-template-columns: minmax(0, 1fr) 32px;
+      gap: 8px;
+      align-items: start;
+      padding: 8px 0;
+      border-top: 1px solid rgba(255, 255, 255, 0.08);
+      white-space: normal;
+    }
+
+    .memory-row:first-child {
+      border-top: 0;
+    }
+
+    .memory-content {
+      color: rgba(255, 255, 255, 0.86);
+      overflow-wrap: anywhere;
     }
 
     button {
@@ -132,6 +254,13 @@
       color: rgba(255, 255, 255, 0.84);
       background: rgba(255, 255, 255, 0.08);
       cursor: pointer;
+      font: 700 13px/1 "Segoe UI", system-ui, sans-serif;
+    }
+
+    button:disabled,
+    input:disabled {
+      cursor: not-allowed;
+      opacity: 0.52;
     }
 
     .error {
@@ -142,9 +271,19 @@
 <body>
   <main class="shell">
     <section class="bar">
+      <div class="combo" id="projectCombo">
+        <input id="project" class="combo-input" aria-hidden="true">
+        <button id="projectButton" class="combo-trigger" type="button" title="AiChat project">Project</button>
+        <div id="projectMenu" class="combo-menu" role="listbox"></div>
+      </div>
       <div id="mark" class="mark" aria-hidden="true">*</div>
       <textarea id="prompt" rows="1" placeholder="What can I help you with today?"></textarea>
-      <select id="model" title="Model"></select>
+      <button id="memoryToggle" title="Memory">M</button>
+      <div class="combo" id="modelCombo">
+        <input id="model" class="combo-input" aria-hidden="true">
+        <button id="modelButton" class="combo-trigger" type="button" title="Model">Model</button>
+        <div id="modelMenu" class="combo-menu" role="listbox"></div>
+      </div>
     </section>
     <section id="output" class="output" aria-live="polite">
       <div id="text"></div>
@@ -153,18 +292,73 @@
         <button id="collapse" title="Collapse">-</button>
       </div>
     </section>
+    <section id="memory" class="memory" aria-live="polite">
+      <div id="memoryList"></div>
+      <div class="memory-actions">
+        <input id="memoryInput" placeholder="Save memory">
+        <button id="saveMemory" title="Save memory">+</button>
+        <button id="refreshMemory" title="Refresh memory">R</button>
+      </div>
+    </section>
   </main>
 
   <script>
     const promptInput = document.getElementById("prompt");
+    const projectSelect = document.getElementById("project");
+    const projectCombo = document.getElementById("projectCombo");
+    const projectButton = document.getElementById("projectButton");
+    const projectMenu = document.getElementById("projectMenu");
     const modelSelect = document.getElementById("model");
+    const modelCombo = document.getElementById("modelCombo");
+    const modelButton = document.getElementById("modelButton");
+    const modelMenu = document.getElementById("modelMenu");
     const output = document.getElementById("output");
     const text = document.getElementById("text");
     const mark = document.getElementById("mark");
     const copy = document.getElementById("copy");
     const collapse = document.getElementById("collapse");
+    const memoryToggle = document.getElementById("memoryToggle");
+    const memoryPanel = document.getElementById("memory");
+    const memoryList = document.getElementById("memoryList");
+    const memoryInput = document.getElementById("memoryInput");
+    const saveMemory = document.getElementById("saveMemory");
+    const refreshMemory = document.getElementById("refreshMemory");
+
+    if (!window.moliDesktop) {
+      window.moliDesktop = {
+        getConfig: async () => ({
+          mode: "provider-direct",
+          aichat: { memory: { enabledInProviderDirect: false, defaultScope: "PROJECT", recallLimit: 8 } }
+        }),
+        requestResize: async () => {},
+        llm: {
+          getProjects: async () => [],
+          getModels: async () => [],
+          getMemoryCapabilities: async () => ({ canUseMemory: false, canViewMemory: false, canManageMemory: false }),
+          getMemories: async () => ({ items: [] }),
+          createMemory: async () => ({}),
+          deleteMemory: async () => {},
+          recallMemories: async () => ({ items: [] }),
+          streamChat: async () => ({ requestId: "preview" }),
+          onDelta: () => () => {},
+          onCompleted: () => () => {},
+          onError: () => () => {}
+        }
+      };
+    }
+
     let activeRequestId = null;
     let currentText = "";
+    let config = { mode: "provider-direct", aichat: { memory: { enabledInProviderDirect: true, defaultScope: "PROJECT", recallLimit: 8 } } };
+    let memoryCapabilities = { canUseMemory: false, canViewMemory: false, canManageMemory: false };
+
+    function mode() {
+      return config.mode || "provider-direct";
+    }
+
+    function selectedProjectId() {
+      return projectSelect.value || config.aichat?.defaultProjectId || "";
+    }
 
     function setBusy(busy) {
       mark.classList.toggle("busy", busy);
@@ -173,7 +367,18 @@
 
     function openOutput() {
       output.classList.add("open");
-      window.moliDesktop?.requestResize?.({ width: document.body.scrollWidth, height: Math.min(window.innerHeight, document.body.scrollHeight) }).catch(() => {});
+      requestResize();
+    }
+
+    function requestResize() {
+      const openMenu = projectCombo.classList.contains("open")
+        ? projectMenu
+        : modelCombo.classList.contains("open") ? modelMenu : null;
+      const menuBottom = openMenu ? openMenu.getBoundingClientRect().bottom + 8 : 72;
+      window.moliDesktop?.requestResize?.({
+        width: document.body.scrollWidth,
+        height: Math.max(72, Math.ceil(menuBottom))
+      }).catch(() => {});
     }
 
     function setError(message) {
@@ -183,26 +388,138 @@
       openOutput();
     }
 
+    const projectDropdown = { input: projectSelect, root: projectCombo, button: projectButton, menu: projectMenu };
+    const modelDropdown = { input: modelSelect, root: modelCombo, button: modelButton, menu: modelMenu };
+
+    function setupDropdown(dropdown) {
+      dropdown.button.addEventListener("click", () => {
+        const willOpen = !dropdown.root.classList.contains("open");
+        closeDropdowns();
+        dropdown.root.classList.toggle("open", willOpen);
+        requestResize();
+      });
+    }
+
+    function closeDropdowns() {
+      projectCombo.classList.remove("open");
+      modelCombo.classList.remove("open");
+      requestResize();
+    }
+
+    function setDropdownFallback(dropdown, label, title) {
+      dropdown.input.value = "";
+      dropdown.button.textContent = label;
+      dropdown.button.title = title || label;
+      dropdown.menu.innerHTML = "";
+      const option = document.createElement("div");
+      option.className = "combo-option";
+      option.textContent = label;
+      option.title = title || label;
+      dropdown.menu.appendChild(option);
+    }
+
+    function setDropdownOptions(dropdown, items, preferredValue, fallbackLabel) {
+      dropdown.menu.innerHTML = "";
+      if (!items.length) {
+        setDropdownFallback(dropdown, fallbackLabel);
+        return;
+      }
+
+      let selected = items.find((item) => item.value === preferredValue) || items[0];
+      for (const item of items) {
+        const option = document.createElement("div");
+        option.className = `combo-option${item.value === selected.value ? " selected" : ""}`;
+        option.textContent = item.label;
+        option.title = item.title || item.label;
+        option.dataset.value = item.value;
+        option.addEventListener("click", () => {
+          selected = item;
+          setDropdownValue(dropdown, item);
+          closeDropdowns();
+        });
+        dropdown.menu.appendChild(option);
+      }
+
+      setDropdownValue(dropdown, selected, false);
+    }
+
+    function setDropdownValue(dropdown, item, notify = true) {
+      dropdown.input.value = item.value;
+      dropdown.button.textContent = item.label;
+      dropdown.button.title = item.title || item.label;
+      for (const option of dropdown.menu.children) {
+        option.classList.toggle("selected", option.dataset.value === item.value);
+      }
+      if (notify) {
+        dropdown.input.dispatchEvent(new Event("change"));
+      }
+    }
+
+    async function loadConfig() {
+      try {
+        config = { ...config, ...(await window.moliDesktop.getConfig() || {}) };
+      } catch {
+      }
+    }
+
+    async function loadProjects() {
+      try {
+        const projects = await window.moliDesktop.llm.getProjects();
+        const items = projects.map((project) => ({
+          value: project.id,
+          label: project.name || project.id,
+          title: `${project.projectType || "CHAT"} / ${project.memoryMode || "ISOLATED"}`
+        }));
+        setDropdownOptions(projectDropdown, items, config.aichat?.defaultProjectId || "", "No project");
+      } catch (error) {
+        setDropdownFallback(projectDropdown, "Project error", error?.message || "AiChat projects could not be loaded");
+      }
+    }
+
     async function loadModels() {
       try {
         const models = await window.moliDesktop.llm.getModels();
-        modelSelect.innerHTML = "";
-        for (const model of models) {
-          const option = document.createElement("option");
-          option.value = model.id;
-          option.textContent = model.label || model.id;
-          option.title = `${model.provider} / ${model.id}`;
-          modelSelect.appendChild(option);
-        }
-
-        if (models.length === 0) {
-          const option = document.createElement("option");
-          option.textContent = "No models";
-          option.value = "";
-          modelSelect.appendChild(option);
-        }
+        const items = models.map((model) => ({
+          value: model.id,
+          label: model.label || model.id,
+          title: `${model.provider} / ${model.id}`
+        }));
+        setDropdownOptions(modelDropdown, items, config.defaultModel || "", "No models");
       } catch {
-        modelSelect.innerHTML = "<option value=\"\">No models</option>";
+        setDropdownFallback(modelDropdown, "Model error");
+      }
+    }
+
+    async function loadMemoryCapabilities() {
+      try {
+        memoryCapabilities = await window.moliDesktop.llm.getMemoryCapabilities();
+      } catch {
+        memoryCapabilities = { canUseMemory: false, canViewMemory: false, canManageMemory: false };
+      }
+
+      const memoryEnabled = mode() === "provider-direct" && config.aichat?.memory?.enabledInProviderDirect;
+      memoryToggle.disabled = !memoryEnabled || !memoryCapabilities.canViewMemory;
+      memoryInput.disabled = !memoryCapabilities.canManageMemory;
+      saveMemory.disabled = !memoryCapabilities.canManageMemory;
+      refreshMemory.disabled = !memoryCapabilities.canViewMemory;
+    }
+
+    async function recallMemory(content) {
+      if (mode() !== "provider-direct" || !config.aichat?.memory?.enabledInProviderDirect || !memoryCapabilities.canUseMemory) {
+        return [];
+      }
+
+      const projectId = selectedProjectId();
+      try {
+        const result = await window.moliDesktop.llm.recallMemories({
+          query: content,
+          scope: config.aichat.memory.defaultScope || "PROJECT",
+          projectId,
+          limit: config.aichat.memory.recallLimit || 8
+        });
+        return Array.isArray(result?.items) ? result.items : [];
+      } catch {
+        return [];
       }
     }
 
@@ -218,9 +535,21 @@
       setBusy(true);
 
       try {
+        const memories = await recallMemory(content);
+        const messages = [];
+        if (memories.length > 0) {
+          const memoryText = memories.map((item) => `- ${item.content || ""}`).filter(Boolean).join("\n");
+          if (memoryText) {
+            messages.push({ role: "system", content: `Relevant memory:\n${memoryText}` });
+          }
+        }
+        messages.push({ role: "user", content });
+
         const response = await window.moliDesktop.llm.streamChat({
+          mode: mode(),
+          projectId: selectedProjectId(),
           modelId,
-          messages: [{ role: "user", content }],
+          messages,
           options: {}
         });
         activeRequestId = response.requestId;
@@ -228,6 +557,48 @@
         activeRequestId = null;
         setBusy(false);
         setError(error?.message || "LLM request could not be started.");
+      }
+    }
+
+    async function refreshMemories() {
+      if (!memoryCapabilities.canViewMemory) return;
+      const projectId = selectedProjectId();
+      memoryList.textContent = "Loading...";
+      try {
+        const scope = config.aichat?.memory?.defaultScope === "GLOBAL" ? "GLOBAL" : "PROJECT";
+        const result = await window.moliDesktop.llm.getMemories({ scope, projectId });
+        const items = Array.isArray(result) ? result : Array.isArray(result?.items) ? result.items : [];
+        renderMemories(items);
+      } catch (error) {
+        memoryList.textContent = error?.message || "Memory unavailable.";
+      }
+    }
+
+    function renderMemories(items) {
+      memoryList.innerHTML = "";
+      if (!items.length) {
+        memoryList.textContent = "No memory";
+        return;
+      }
+
+      for (const item of items) {
+        const row = document.createElement("div");
+        row.className = "memory-row";
+        const content = document.createElement("div");
+        content.className = "memory-content";
+        content.textContent = item.content || item.id || "";
+        row.appendChild(content);
+        const remove = document.createElement("button");
+        remove.textContent = "x";
+        remove.title = "Delete memory";
+        remove.disabled = !memoryCapabilities.canManageMemory;
+        remove.addEventListener("click", async () => {
+          if (!item.id) return;
+          await window.moliDesktop.llm.deleteMemory(item.id);
+          refreshMemories();
+        });
+        row.appendChild(remove);
+        memoryList.appendChild(row);
       }
     }
 
@@ -239,6 +610,8 @@
 
       if (event.key === "Escape") {
         output.classList.remove("open");
+        memoryPanel.classList.remove("open");
+        requestResize();
       }
     });
 
@@ -247,10 +620,51 @@
       promptInput.style.height = `${Math.min(promptInput.scrollHeight, 78)}px`;
     });
 
-    collapse.addEventListener("click", () => output.classList.remove("open"));
-    copy.addEventListener("click", () => navigator.clipboard?.writeText(currentText).catch(() => {}));
+    projectSelect.addEventListener("change", () => {
+      if (memoryPanel.classList.contains("open")) {
+        refreshMemories();
+      }
+    });
 
-    window.addEventListener("DOMContentLoaded", loadModels);
+    memoryToggle.addEventListener("click", () => {
+      memoryPanel.classList.toggle("open");
+      if (memoryPanel.classList.contains("open")) {
+        refreshMemories();
+      }
+      requestResize();
+    });
+
+    refreshMemory.addEventListener("click", refreshMemories);
+    saveMemory.addEventListener("click", async () => {
+      const content = memoryInput.value.trim();
+      if (!content || !memoryCapabilities.canManageMemory) return;
+      await window.moliDesktop.llm.createMemory({
+        scope: config.aichat?.memory?.defaultScope === "GLOBAL" ? "GLOBAL" : "PROJECT",
+        projectId: selectedProjectId(),
+        content
+      });
+      memoryInput.value = "";
+      refreshMemories();
+    });
+
+    collapse.addEventListener("click", () => {
+      output.classList.remove("open");
+      requestResize();
+    });
+    copy.addEventListener("click", () => navigator.clipboard?.writeText(currentText).catch(() => {}));
+    document.addEventListener("click", (event) => {
+      if (!projectCombo.contains(event.target) && !modelCombo.contains(event.target)) {
+        closeDropdowns();
+      }
+    });
+
+    window.addEventListener("DOMContentLoaded", async () => {
+      setupDropdown(projectDropdown);
+      setupDropdown(modelDropdown);
+      await loadConfig();
+      await Promise.all([loadProjects(), loadModels(), loadMemoryCapabilities()]);
+    });
+
     window.moliDesktop?.llm?.onDelta?.((event) => {
       if (event.requestId !== activeRequestId) return;
       currentText += event.delta || "";
diff --git a/samples/plugins/sample.llm-command-palette/plugin.json b/samples/plugins/sample.llm-command-palette/plugin.json
index c23e873..2751927 100644
--- a/samples/plugins/sample.llm-command-palette/plugin.json
+++ b/samples/plugins/sample.llm-command-palette/plugin.json
@@ -22,7 +22,83 @@
     "displayLayer": "desktop"
   },
   "config": {
-    "defaultModel": "",
-    "models": []
+    "mode": "provider-direct",
+    "aichat": {
+      "baseUrl": "http://192.168.1.111:13000",
+      "account": {
+        "email": "linmolilin@163.com",
+        "password": null,
+        "passwordEnv": "MOLI_AICHAT_PASSWORD"
+      },
+      "defaultProjectId": "cmnd8uzcl0002c9usch183a01",
+      "memory": {
+        "enabledInProviderDirect": true,
+        "defaultScope": "PROJECT",
+        "recallLimit": 8
+      }
+    },
+    "defaultModel": "deepseek-v4-flash",
+    "models": [
+      {
+        "id": "deepseek-v4-flash",
+        "label": "deepseek-v4-flash",
+        "provider": "deepseek",
+        "endpoint": "https://api.deepseek.com/chat/completions",
+        "authRef": "llm_deepseek_api_key",
+        "apiModel": "deepseek-v4-flash",
+        "supportsStreaming": true,
+        "enabled": true,
+        "requestDefaults": {
+          "temperature": 0.9,
+          "maxTokens": 2560000,
+          "timeoutMs": 60000
+        }
+      },
+      {
+        "id": "kimi-k2.6",
+        "label": "kimi-k2.6",
+        "provider": "kimi",
+        "endpoint": "https://api.moonshot.cn/v1/chat/completions",
+        "authRef": "llm_kimi_api_key",
+        "apiModel": "kimi-k2.6",
+        "supportsStreaming": true,
+        "enabled": true,
+        "requestDefaults": {
+          "temperature": 0.9,
+          "maxTokens": 2560000,
+          "timeoutMs": 60000
+        }
+      },
+      {
+        "id": "glm-4.7-flash",
+        "label": "glm-4.7-flash",
+        "provider": "bigmodel",
+        "endpoint": "https://open.bigmodel.cn/api/paas/v4/chat/completions",
+        "authRef": "llm_bigmodel_api_key",
+        "apiModel": "glm-4.7-flash",
+        "supportsStreaming": true,
+        "enabled": true,
+        "requestDefaults": {
+          "temperature": 0.9,
+          "maxTokens": 2000000,
+          "timeoutMs": 60000
+        }
+      },
+      {
+        "id": "qwen3.6-plus",
+        "label": "qwen3.6-plus",
+        "provider": "qwen",
+        "endpoint": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
+        "authRef": "llm_bigmodel_api_key",
+        "apiModel": "qwen3.6-plus",
+        "supportsStreaming": true,
+        "enabled": true,
+        "requestDefaults": {
+          "temperature": 0.9,
+          "maxTokens": 2560000,
+          "timeoutMs": 60000
+        }
+      }
+    ]
   }
-}
+}
\ No newline at end of file
diff --git a/scripts/publish-to-apps.ps1 b/scripts/publish-to-apps.ps1
index c40766f..09aca40 100644
--- a/scripts/publish-to-apps.ps1
+++ b/scripts/publish-to-apps.ps1
@@ -54,11 +54,84 @@
     }
 }
 
+function Get-RelativePathCompat {
+    param(
+        [Parameter(Mandatory = $true)]
+        [string]$BasePath,
+        [Parameter(Mandatory = $true)]
+        [string]$TargetPath
+    )
+
+    $baseFullPath = [System.IO.Path]::GetFullPath($BasePath).TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar)
+    $targetFullPath = [System.IO.Path]::GetFullPath($TargetPath).TrimEnd([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar)
+    $baseUri = New-Object System.Uri(($baseFullPath + [System.IO.Path]::DirectorySeparatorChar))
+    $targetUri = New-Object System.Uri($targetFullPath)
+    $relativeUri = $baseUri.MakeRelativeUri($targetUri)
+    return [System.Uri]::UnescapeDataString($relativeUri.ToString()).Replace('/', [System.IO.Path]::DirectorySeparatorChar)
+}
+
+function Backup-DeployedPluginConfigs {
+    param(
+        [Parameter(Mandatory = $true)]
+        [string]$ApplicationDirectory,
+        [Parameter(Mandatory = $true)]
+        [string]$BackupDirectory
+    )
+
+    $pluginsRoot = Join-Path $ApplicationDirectory "samples\plugins"
+    if (-not (Test-Path -LiteralPath $pluginsRoot)) {
+        return
+    }
+
+    Get-ChildItem -LiteralPath $pluginsRoot -Directory | ForEach-Object {
+        $pluginJson = Join-Path $_.FullName "plugin.json"
+        if (-not (Test-Path -LiteralPath $pluginJson)) {
+            return
+        }
+
+        $relativeDirectory = Get-RelativePathCompat -BasePath $pluginsRoot -TargetPath $_.FullName
+        $backupPluginDirectory = Join-Path $BackupDirectory $relativeDirectory
+        New-Item -ItemType Directory -Force -Path $backupPluginDirectory | Out-Null
+        Copy-Item -LiteralPath $pluginJson -Destination (Join-Path $backupPluginDirectory "plugin.json") -Force
+    }
+}
+
+function Restore-DeployedPluginConfigs {
+    param(
+        [Parameter(Mandatory = $true)]
+        [string]$ApplicationDirectory,
+        [Parameter(Mandatory = $true)]
+        [string]$BackupDirectory
+    )
+
+    if (-not (Test-Path -LiteralPath $BackupDirectory)) {
+        return
+    }
+
+    $pluginsRoot = Join-Path $ApplicationDirectory "samples\plugins"
+    Get-ChildItem -LiteralPath $BackupDirectory -Directory | ForEach-Object {
+        $relativeDirectory = Get-RelativePathCompat -BasePath $BackupDirectory -TargetPath $_.FullName
+        $targetPluginDirectory = Join-Path $pluginsRoot $relativeDirectory
+        $newPluginJson = Join-Path $targetPluginDirectory "plugin.json"
+        $templateJson = Join-Path $targetPluginDirectory "plugin.template.json"
+        $backupPluginJson = Join-Path $_.FullName "plugin.json"
+
+        if ((Test-Path -LiteralPath $newPluginJson) -and -not (Test-Path -LiteralPath $templateJson)) {
+            Copy-Item -LiteralPath $newPluginJson -Destination $templateJson -Force
+        }
+
+        if (Test-Path -LiteralPath $backupPluginJson) {
+            Copy-Item -LiteralPath $backupPluginJson -Destination $newPluginJson -Force
+        }
+    }
+}
+
 $repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
 $solutionPath = Join-Path $repoRoot "Moli.Desktop.slnx"
 $projectPath = Join-Path $repoRoot "src\Moli.Desktop\Moli.Desktop.csproj"
 $stagingRoot = Join-Path $repoRoot "artifacts\release"
 $publishDir = Join-Path $stagingRoot "publish\$AppName"
+$configBackupDir = Join-Path $stagingRoot "preserved-plugin-configs"
 $targetRootPath = Join-Path $TargetRoot ""
 $targetDir = Join-Path $targetRootPath $AppName
 $targetExePath = Join-Path $targetDir "$AppName.exe"
@@ -103,6 +176,12 @@
 
 Stop-PublishedApplication -ProcessName $AppName -ExecutablePath $targetExePath
 
+if (Test-Path -LiteralPath $configBackupDir) {
+    Remove-Item -LiteralPath $configBackupDir -Recurse -Force
+}
+New-Item -ItemType Directory -Force -Path $configBackupDir | Out-Null
+Backup-DeployedPluginConfigs -ApplicationDirectory $targetDir -BackupDirectory $configBackupDir
+
 if (Test-Path -LiteralPath $targetDir) {
     Write-Host "Removing old published files:"
     Write-Host $targetDir
@@ -111,6 +190,7 @@
 New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
 
 Invoke-CheckedRobocopy -Source $publishDir -Destination $targetDir
+Restore-DeployedPluginConfigs -ApplicationDirectory $targetDir -BackupDirectory $configBackupDir
 
 if (-not $NoZip) {
     if (Test-Path -LiteralPath $zipPath) {
diff --git a/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs b/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs
index 7df03da..50d0eb4 100644
--- a/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs
+++ b/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs
@@ -47,6 +47,19 @@
     }
 
     [Fact]
+    public async Task Update_AllowsUnlockingLockedWidget()
+    {
+        var (manager, monitor, _) = await CreateLoadedManagerAsync();
+        var plugin = CreatePlugin(locked: true);
+        var layout = manager.CreateFromPlugin(plugin, monitor.Id);
+
+        var result = manager.Update(layout.InstanceId, new WidgetLayoutPatch { IsLocked = false });
+
+        Assert.True(result.Succeeded);
+        Assert.False(result.Value?.IsLocked);
+    }
+
+    [Fact]
     public async Task ReconcileMonitors_MovesMissingSecondaryMonitorToPrimary()
     {
         var (manager, _, diagnostics) = await CreateLoadedManagerAsync();
diff --git a/src/Moli.Desktop.Tests/Llm/AiChatClientTests.cs b/src/Moli.Desktop.Tests/Llm/AiChatClientTests.cs
new file mode 100644
index 0000000..04b43a6
--- /dev/null
+++ b/src/Moli.Desktop.Tests/Llm/AiChatClientTests.cs
@@ -0,0 +1,165 @@
+using System.Net;
+using System.Net.Http;
+using System.Text;
+using Microsoft.Extensions.Logging.Abstractions;
+using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Host;
+using Moli.Desktop.Llm;
+
+namespace Moli.Desktop.Tests.Llm;
+
+public class AiChatClientTests
+{
+    [Fact]
+    public async Task GetProjectsAsync_LogsInWithPasswordEnvAndSendsSessionToken()
+    {
+        var envName = "MOLI_AICHAT_TEST_PASSWORD_" + Guid.NewGuid().ToString("N");
+        Environment.SetEnvironmentVariable(envName, "secret-from-env");
+        try
+        {
+            var handler = new QueueHttpMessageHandler(
+                Json("""{"ok":true,"data":{"sessionToken":"session-1"}}"""),
+                Json("""{"ok":true,"data":[{"id":"project-1","name":"浜у搧闂瓟","projectType":"CHAT","memoryMode":"ISOLATED"}]}"""));
+            var client = CreateClient(handler);
+
+            var projects = await client.GetProjectsAsync(CreateConfig(passwordEnv: envName));
+
+            Assert.Single(projects);
+            Assert.Equal("project-1", projects[0].Id);
+            Assert.Equal("secret-from-env", handler.RequestBodies[0].Contains("secret-from-env") ? "secret-from-env" : "");
+            Assert.True(handler.Requests[1].Headers.TryGetValues("x-session-token", out var tokens));
+            Assert.Contains("session-1", tokens);
+        }
+        finally
+        {
+            Environment.SetEnvironmentVariable(envName, null);
+        }
+    }
+
+    [Fact]
+    public async Task GetModelsAsync_ReturnsAiChatSafeModelSummaries()
+    {
+        var handler = new QueueHttpMessageHandler(
+            Json("""{"ok":true,"data":{"sessionToken":"session-1"}}"""),
+            Json("""{"ok":true,"data":{"models":["deepseek-v4-flash"],"defaultModel":"deepseek-v4-flash"}}"""));
+        var client = CreateClient(handler);
+
+        var models = await client.GetModelsAsync(CreateConfig());
+
+        var model = Assert.Single(models);
+        Assert.Equal("deepseek-v4-flash", model.Id);
+        Assert.Equal("aichat", model.Provider);
+        Assert.True(model.SupportsStreaming);
+    }
+
+    [Fact]
+    public async Task StreamChatAsync_UsesAiChatSendAndParsesSseChunks()
+    {
+        var handler = new QueueHttpMessageHandler(
+            Json("""{"ok":true,"data":{"sessionToken":"session-1"}}"""),
+            Json("""{"ok":true,"data":{"generationId":"gen-1","streamToken":"stream-1","projectId":"project-1","conversationId":"conv-1"}}"""),
+            Sse("""
+event: chunk
+data: {"type":"chunk","delta":"Hello","sequence":1}
+
+event: done
+data: {"type":"done","generationId":"gen-1"}
+
+"""));
+        var client = CreateClient(handler);
+
+        var events = await client.StreamChatAsync(
+            new LlmChatRequest
+            {
+                RequestId = "req-1",
+                PluginId = "sample.llm-command-palette",
+                InstanceId = "host-1",
+                Mode = LlmConnectionModes.AiChatApi,
+                ProjectId = "project-1",
+                ModelId = "deepseek-v4-flash",
+                Messages = [new LlmMessage { Role = "user", Content = "hello" }]
+            },
+            CreateConfig()).ToListAsync();
+
+        Assert.Contains(events, item => item is LlmDeltaEvent { Delta: "Hello" });
+        Assert.Contains(events, item => item is LlmCompletedEvent);
+        Assert.Contains("/api/chat/send", handler.Requests[1].RequestUri?.PathAndQuery);
+        Assert.Contains("/api/chat/generations/gen-1/stream?token=stream-1", handler.Requests[2].RequestUri?.PathAndQuery);
+    }
+
+    [Fact]
+    public async Task RecallMemoriesAsync_PostsToAiChatMemoryRecall()
+    {
+        var handler = new QueueHttpMessageHandler(
+            Json("""{"ok":true,"data":{"sessionToken":"session-1"}}"""),
+            Json("""{"ok":true,"data":{"items":[{"id":"mem-1","content":"Keep replies short."}]}}"""));
+        var client = CreateClient(handler);
+
+        var result = await client.RecallMemoriesAsync(
+            CreateConfig(),
+            new AiChatRecallMemoriesRequest
+            {
+                Query = "hello",
+                Scope = "PROJECT",
+                ProjectId = "project-1",
+                Limit = 8
+            });
+
+        Assert.NotNull(result.Data);
+        Assert.Equal("/api/memories/recall", handler.Requests[1].RequestUri?.PathAndQuery);
+        Assert.Contains("project-1", handler.RequestBodies[1]);
+    }
+
+    private static AiChatClient CreateClient(QueueHttpMessageHandler handler)
+    {
+        var root = Path.Combine(Path.GetTempPath(), "Moli.Desktop.Tests", Guid.NewGuid().ToString("N"));
+        var paths = new DesktopPaths(Path.Combine(root, "app"), Path.Combine(root, "local"));
+        var diagnostics = new DiagnosticsService(paths, NullLogger<DiagnosticsService>.Instance);
+        return new AiChatClient(new HttpClient(handler), diagnostics);
+    }
+
+    private static LlmPluginRuntimeConfig CreateConfig(string? passwordEnv = null) => new()
+    {
+        Mode = LlmConnectionModes.AiChatApi,
+        AiChat = new AiChatRuntimeConfig
+        {
+            BaseUrl = "http://192.168.1.111:13000",
+            Account = new AiChatAccountConfig
+            {
+                Email = "user@example.com",
+                Password = passwordEnv is null ? "plain-secret" : null,
+                PasswordEnv = passwordEnv
+            }
+        }
+    };
+
+    private static HttpResponseMessage Json(string content, HttpStatusCode statusCode = HttpStatusCode.OK) => new(statusCode)
+    {
+        Content = new StringContent(content, Encoding.UTF8, "application/json")
+    };
+
+    private static HttpResponseMessage Sse(string content) => new(HttpStatusCode.OK)
+    {
+        Content = new StringContent(content, Encoding.UTF8, "text/event-stream")
+    };
+
+    private sealed class QueueHttpMessageHandler : HttpMessageHandler
+    {
+        private readonly Queue<HttpResponseMessage> _responses;
+
+        public QueueHttpMessageHandler(params HttpResponseMessage[] responses)
+        {
+            _responses = new Queue<HttpResponseMessage>(responses);
+        }
+
+        public List<HttpRequestMessage> Requests { get; } = [];
+        public List<string> RequestBodies { get; } = [];
+
+        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
+        {
+            Requests.Add(request);
+            RequestBodies.Add(request.Content is null ? "" : await request.Content.ReadAsStringAsync(cancellationToken));
+            return _responses.Dequeue();
+        }
+    }
+}
diff --git a/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs b/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs
index 50b76ed..cfabb6e 100644
--- a/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs
+++ b/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs
@@ -88,7 +88,43 @@
         Assert.Contains(events, item => item is LlmDeltaEvent { Delta: "ok" });
     }
 
+    [Fact]
+    public async Task StreamChatAsync_UsesAiChatClientWhenModeIsAiChatApi()
+    {
+        var aiChat = new FakeAiChatClient();
+        var gateway = CreateGateway(
+            new CapturingAdapter("openai-compatible"),
+            aiChat,
+            new LlmModelConfig
+            {
+                Id = "provider-model",
+                Label = "Provider",
+                Provider = "openai-compatible",
+                Endpoint = "http://127.0.0.1:11434/v1/chat/completions",
+                ApiModel = "provider-model",
+                Enabled = true
+            });
+
+        var events = await gateway.StreamChatAsync(new LlmChatRequest
+        {
+            RequestId = "req-aichat",
+            PluginId = "sample.llm-command-palette",
+            InstanceId = "host-1",
+            Mode = LlmConnectionModes.AiChatApi,
+            ProjectId = "project-1",
+            ModelId = "deepseek-v4-flash",
+            Messages = [new LlmMessage { Role = "user", Content = "hello" }],
+            RuntimeConfig = new LlmPluginRuntimeConfig { Mode = LlmConnectionModes.AiChatApi }
+        }).ToListAsync();
+
+        Assert.Equal("project-1", aiChat.LastRequest?.ProjectId);
+        Assert.Contains(events, item => item is LlmDeltaEvent { Delta: "from-aichat" });
+    }
+
     private static LlmGatewayService CreateGateway(CapturingAdapter adapter, params LlmModelConfig[] models)
+        => CreateGateway(adapter, null, models);
+
+    private static LlmGatewayService CreateGateway(CapturingAdapter adapter, IAiChatClient? aiChatClient, params LlmModelConfig[] models)
     {
         var root = Path.Combine(Path.GetTempPath(), "Moli.Desktop.Tests", Guid.NewGuid().ToString("N"));
         var paths = new DesktopPaths(Path.Combine(root, "app"), Path.Combine(root, "local"));
@@ -97,7 +133,8 @@
             new InMemoryRegistry(models),
             new EnvironmentCredentialStore(),
             new LlmProviderAdapterFactory([adapter]),
-            diagnostics);
+            diagnostics,
+            aiChatClient);
     }
 
     private sealed class InMemoryRegistry(IEnumerable<LlmModelConfig> models) : ILlmModelRegistry
@@ -126,6 +163,43 @@
             yield return new LlmProviderChunk { IsCompleted = true };
         }
     }
+
+    private sealed class FakeAiChatClient : IAiChatClient
+    {
+        public LlmChatRequest? LastRequest { get; private set; }
+
+        public Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken = default)
+            => Task.FromResult<IReadOnlyList<LlmModelSummary>>([]);
+
+        public Task<IReadOnlyList<AiChatProjectSummary>> GetProjectsAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken = default)
+            => Task.FromResult<IReadOnlyList<AiChatProjectSummary>>([]);
+
+        public async IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+            LlmChatRequest request,
+            LlmPluginRuntimeConfig runtimeConfig,
+            [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default)
+        {
+            await Task.Yield();
+            LastRequest = request;
+            yield return new LlmDeltaEvent { RequestId = request.RequestId, Delta = "from-aichat" };
+            yield return new LlmCompletedEvent { RequestId = request.RequestId };
+        }
+
+        public Task<AiChatMemoryCapabilities> GetMemoryCapabilitiesAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatMemoryCapabilities());
+
+        public Task<AiChatJsonResult> GetMemoriesAsync(LlmPluginRuntimeConfig runtimeConfig, AiChatGetMemoriesRequest request, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatJsonResult());
+
+        public Task<AiChatJsonResult> CreateMemoryAsync(LlmPluginRuntimeConfig runtimeConfig, AiChatCreateMemoryRequest request, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatJsonResult());
+
+        public Task DeleteMemoryAsync(LlmPluginRuntimeConfig runtimeConfig, string memoryId, CancellationToken cancellationToken = default)
+            => Task.CompletedTask;
+
+        public Task<AiChatJsonResult> RecallMemoriesAsync(LlmPluginRuntimeConfig runtimeConfig, AiChatRecallMemoriesRequest request, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatJsonResult());
+    }
 }
 
 internal static class AsyncEnumerableTestExtensions
diff --git a/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs b/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs
index 5c441e8..b50c648 100644
--- a/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs
+++ b/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs
@@ -70,6 +70,61 @@
     }
 
     [Fact]
+    public async Task DispatchAsync_ReturnsLlmModelsFromPluginConfig()
+    {
+        var dispatcher = CreateDispatcher(out _, out _);
+        var context = CreateContext(configJson: """
+        {
+          "mode": "provider-direct",
+          "defaultModel": "configured-model",
+          "models": [
+            {
+              "id": "configured-model",
+              "label": "Configured Model",
+              "provider": "test",
+              "endpoint": "https://example.test/chat",
+              "apiModel": "configured-model",
+              "supportsStreaming": true,
+              "enabled": true
+            }
+          ]
+        }
+        """);
+
+        var response = await dispatcher.DispatchAsync("""{"id":"40","method":"llm.getModels"}""", context);
+
+        Assert.True(response.Success);
+        var json = JsonSerializer.Serialize(response.Result, new JsonSerializerOptions(JsonSerializerDefaults.Web));
+        Assert.Contains("configured-model", json);
+    }
+
+    [Fact]
+    public async Task DispatchAsync_ReturnsAiChatProjects()
+    {
+        var dispatcher = CreateDispatcher(out _, out _);
+
+        var response = await dispatcher.DispatchAsync("""{"id":"41","method":"llm.getProjects"}""", CreateContext());
+
+        Assert.True(response.Success);
+        var json = JsonSerializer.Serialize(response.Result, new JsonSerializerOptions(JsonSerializerDefaults.Web));
+        Assert.Contains("project-1", json);
+    }
+
+    [Fact]
+    public async Task DispatchAsync_ReturnsMemoryRecallResult()
+    {
+        var dispatcher = CreateDispatcher(out _, out _);
+
+        var response = await dispatcher.DispatchAsync(
+            """{"id":"42","method":"llm.recallMemories","params":{"query":"hello","scope":"PROJECT","projectId":"project-1","limit":8}}""",
+            CreateContext());
+
+        Assert.True(response.Success);
+        var json = JsonSerializer.Serialize(response.Result, new JsonSerializerOptions(JsonSerializerDefaults.Web));
+        Assert.Contains("remember this", json);
+    }
+
+    [Fact]
     public async Task DispatchAsync_RejectsLlmStreamWithoutPermission()
     {
         var dispatcher = CreateDispatcher(out _, out _);
@@ -116,6 +171,8 @@
         Assert.Contains("getRuntimeInfo", script);
         Assert.Contains("requestResize", script);
         Assert.Contains("llm", script);
+        Assert.Contains("getProjects", script);
+        Assert.Contains("recallMemories", script);
         Assert.Contains("streamChat", script);
         Assert.Contains("moliDesktopResponse", script);
     }
@@ -129,7 +186,7 @@
         return new PluginBridgeDispatcher(diagnostics, events, new FakeLlmGateway());
     }
 
-    private static PluginBridgeContext CreateContext(bool includeLlmPermission = true)
+    private static PluginBridgeContext CreateContext(bool includeLlmPermission = true, string configJson = """{"label":"clock"}""")
     {
         return new PluginBridgeContext
         {
@@ -149,7 +206,7 @@
                 PluginType = PluginType.Widget,
                 HostId = "host-1"
             },
-            Config = JsonDocument.Parse("""{"label":"clock"}""").RootElement.Clone()
+            Config = JsonDocument.Parse(configJson).RootElement.Clone()
         };
     }
 
@@ -170,6 +227,42 @@
                 }
             ]);
 
+        public Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken = default)
+            => runtimeConfig.Models.Count > 0
+                ? Task.FromResult<IReadOnlyList<LlmModelSummary>>(runtimeConfig.Models
+                    .Where(model => model.Enabled)
+                    .Select(model => new LlmModelSummary
+                    {
+                        Id = model.Id,
+                        Label = model.Label,
+                        Provider = model.Provider,
+                        SupportsStreaming = model.SupportsStreaming,
+                        Enabled = model.Enabled
+                    })
+                    .ToList())
+                : GetModelsAsync(cancellationToken);
+
+        public Task<IReadOnlyList<AiChatProjectSummary>> GetProjectsAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken = default)
+            => Task.FromResult<IReadOnlyList<AiChatProjectSummary>>(
+            [
+                new AiChatProjectSummary { Id = "project-1", Name = "Project 1" }
+            ]);
+
+        public Task<AiChatMemoryCapabilities> GetMemoryCapabilitiesAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatMemoryCapabilities { CanUseMemory = true, CanViewMemory = true, CanManageMemory = true });
+
+        public Task<AiChatJsonResult> GetMemoriesAsync(LlmPluginRuntimeConfig runtimeConfig, AiChatGetMemoriesRequest request, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatJsonResult { Data = new[] { new { id = "mem-1", content = "remember this" } } });
+
+        public Task<AiChatJsonResult> CreateMemoryAsync(LlmPluginRuntimeConfig runtimeConfig, AiChatCreateMemoryRequest request, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatJsonResult { Data = new { id = "mem-2", content = request.Content } });
+
+        public Task DeleteMemoryAsync(LlmPluginRuntimeConfig runtimeConfig, string memoryId, CancellationToken cancellationToken = default)
+            => Task.CompletedTask;
+
+        public Task<AiChatJsonResult> RecallMemoriesAsync(LlmPluginRuntimeConfig runtimeConfig, AiChatRecallMemoriesRequest request, CancellationToken cancellationToken = default)
+            => Task.FromResult(new AiChatJsonResult { Data = new { items = new[] { new { id = "mem-1", content = "remember this" } } } });
+
         public async IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
             LlmChatRequest request,
             [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default)
diff --git a/src/Moli.Desktop/Diagnostics/DailyFileLoggerProvider.cs b/src/Moli.Desktop/Diagnostics/DailyFileLoggerProvider.cs
new file mode 100644
index 0000000..7a0f9fd
--- /dev/null
+++ b/src/Moli.Desktop/Diagnostics/DailyFileLoggerProvider.cs
@@ -0,0 +1,79 @@
+using System.IO;
+using System.Text;
+using Microsoft.Extensions.Logging;
+
+namespace Moli.Desktop.Diagnostics;
+
+public sealed class DailyFileLoggerProvider : ILoggerProvider
+{
+    private readonly string _logDirectory;
+    private readonly object _gate = new();
+    private bool _disposed;
+
+    public DailyFileLoggerProvider(string logDirectory)
+    {
+        _logDirectory = logDirectory;
+        Directory.CreateDirectory(_logDirectory);
+    }
+
+    public ILogger CreateLogger(string categoryName)
+        => new DailyFileLogger(categoryName, _logDirectory, _gate, () => _disposed);
+
+    public void Dispose()
+    {
+        _disposed = true;
+    }
+
+    private sealed class DailyFileLogger(
+        string categoryName,
+        string logDirectory,
+        object gate,
+        Func<bool> isDisposed) : ILogger
+    {
+        public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
+
+        public bool IsEnabled(LogLevel logLevel)
+            => logLevel != LogLevel.None && !isDisposed();
+
+        public void Log<TState>(
+            LogLevel logLevel,
+            EventId eventId,
+            TState state,
+            Exception? exception,
+            Func<TState, Exception?, string> formatter)
+        {
+            if (!IsEnabled(logLevel))
+            {
+                return;
+            }
+
+            var message = formatter(state, exception);
+            if (string.IsNullOrWhiteSpace(message) && exception is null)
+            {
+                return;
+            }
+
+            var now = DateTimeOffset.Now;
+            var line = $"{now:O} [{logLevel}] {categoryName} {message}";
+            if (exception is not null)
+            {
+                line += $" {exception.GetType().Name}: {exception.Message}";
+            }
+
+            var path = Path.Combine(logDirectory, $"moli-desktop-{now:yyyyMMdd}.log");
+            try
+            {
+                lock (gate)
+                {
+                    File.AppendAllText(path, line + Environment.NewLine, Encoding.UTF8);
+                }
+            }
+            catch (IOException)
+            {
+            }
+            catch (UnauthorizedAccessException)
+            {
+            }
+        }
+    }
+}
diff --git a/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs b/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs
index 093219d..1f1ee1f 100644
--- a/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs
+++ b/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs
@@ -10,13 +10,13 @@
     private readonly object _gate = new();
     private readonly List<DiagnosticEntry> _entries = [];
     private readonly ILogger<DiagnosticsService> _logger;
-    private readonly string _logFile;
+    private readonly string _logDirectory;
 
     public DiagnosticsService(DesktopPaths paths, ILogger<DiagnosticsService> logger)
     {
         _logger = logger;
         Directory.CreateDirectory(paths.LogDirectory);
-        _logFile = Path.Combine(paths.LogDirectory, $"moli-desktop-{DateTimeOffset.Now:yyyyMMdd}.log");
+        _logDirectory = paths.LogDirectory;
     }
 
     public DiagnosticEntry Record(
@@ -61,7 +61,10 @@
 
         try
         {
-            File.AppendAllText(_logFile, line + Environment.NewLine, Encoding.UTF8);
+            File.AppendAllText(
+                Path.Combine(_logDirectory, $"moli-desktop-{DateTimeOffset.Now:yyyyMMdd}.log"),
+                line + Environment.NewLine,
+                Encoding.UTF8);
         }
         catch (IOException)
         {
diff --git a/src/Moli.Desktop/Host/DefaultContentInstaller.cs b/src/Moli.Desktop/Host/DefaultContentInstaller.cs
index 1d03f7d..b0690d1 100644
--- a/src/Moli.Desktop/Host/DefaultContentInstaller.cs
+++ b/src/Moli.Desktop/Host/DefaultContentInstaller.cs
@@ -74,7 +74,7 @@
             }
 
             var targetDirectory = Path.Combine(_paths.PluginDirectory, manifest.Id);
-            CopyDirectoryReplacingFiles(sourceDirectory, targetDirectory);
+            CopyDirectoryPreservingPluginConfig(sourceDirectory, targetDirectory);
             manifests.Add((manifest, manifest.Id));
         }
 
@@ -183,7 +183,7 @@
         }
     }
 
-    private static void CopyDirectoryReplacingFiles(string sourceDirectory, string targetDirectory)
+    private static void CopyDirectoryPreservingPluginConfig(string sourceDirectory, string targetDirectory)
     {
         Directory.CreateDirectory(targetDirectory);
 
@@ -192,6 +192,14 @@
             var relativePath = Path.GetRelativePath(sourceDirectory, sourceFile);
             var targetFile = Path.Combine(targetDirectory, relativePath);
             Directory.CreateDirectory(Path.GetDirectoryName(targetFile)!);
+
+            if (string.Equals(relativePath, "plugin.json", StringComparison.OrdinalIgnoreCase) &&
+                File.Exists(targetFile))
+            {
+                File.Copy(sourceFile, Path.Combine(targetDirectory, "plugin.template.json"), overwrite: true);
+                continue;
+            }
+
             File.Copy(sourceFile, targetFile, overwrite: true);
         }
     }
diff --git a/src/Moli.Desktop/Host/DesktopHostBuilder.cs b/src/Moli.Desktop/Host/DesktopHostBuilder.cs
index 353614a..182b8fb 100644
--- a/src/Moli.Desktop/Host/DesktopHostBuilder.cs
+++ b/src/Moli.Desktop/Host/DesktopHostBuilder.cs
@@ -25,8 +25,10 @@
         return Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
             .ConfigureLogging(logging =>
             {
+                var paths = new DesktopPaths();
                 logging.ClearProviders();
                 logging.AddDebug();
+                logging.AddProvider(new DailyFileLoggerProvider(paths.LogDirectory));
             })
             .ConfigureServices(services =>
             {
@@ -41,6 +43,8 @@
                 services.AddSingleton<ILlmModelRegistry, LlmModelRegistry>();
                 services.AddSingleton<ICredentialStore, EnvironmentCredentialStore>();
                 services.AddHttpClient<OpenAICompatibleAdapter>();
+                services.AddHttpClient<AiChatClient>();
+                services.AddSingleton<IAiChatClient>(sp => sp.GetRequiredService<AiChatClient>());
                 services.AddSingleton<ILlmProviderAdapter>(sp => sp.GetRequiredService<OpenAICompatibleAdapter>());
                 services.AddSingleton<ILlmProviderAdapterFactory, LlmProviderAdapterFactory>();
                 services.AddSingleton<ILlmGatewayService, LlmGatewayService>();
diff --git a/src/Moli.Desktop/Host/DesktopPaths.cs b/src/Moli.Desktop/Host/DesktopPaths.cs
index 03cc730..1019aa0 100644
--- a/src/Moli.Desktop/Host/DesktopPaths.cs
+++ b/src/Moli.Desktop/Host/DesktopPaths.cs
@@ -18,7 +18,7 @@
         LocalAppDataRoot = localAppDataRoot;
         ConfigDirectory = Path.Combine(AppDataRoot, "config");
         PluginDirectory = Path.Combine(AppDataRoot, "plugins");
-        LogDirectory = Path.Combine(LocalAppDataRoot, "logs");
+        LogDirectory = Path.Combine(AppContext.BaseDirectory, "logs");
         WebViewDataDirectory = Path.Combine(LocalAppDataRoot, "WebView2");
     }
 
diff --git a/src/Moli.Desktop/Interop/NativeMethods.cs b/src/Moli.Desktop/Interop/NativeMethods.cs
index 2922088..ccd5c8a 100644
--- a/src/Moli.Desktop/Interop/NativeMethods.cs
+++ b/src/Moli.Desktop/Interop/NativeMethods.cs
@@ -6,7 +6,11 @@
 
 internal static class NativeMethods
 {
+    internal const int GwlStyle = -16;
     internal const int GwlExStyle = -20;
+    internal const uint WsChild = 0x40000000;
+    internal const uint WsPopup = 0x80000000;
+    internal const uint WsVisible = 0x10000000;
     internal const int WsExTransparent = 0x00000020;
     internal const int WsExLayered = 0x00080000;
     internal const int WsExToolWindow = 0x00000080;
@@ -16,6 +20,7 @@
     internal const uint SwpNoMove = 0x0002;
     internal const uint SwpNoZOrder = 0x0004;
     internal const uint SwpNoActivate = 0x0010;
+    internal const uint SwpFrameChanged = 0x0020;
     internal const uint SwpShowWindow = 0x0040;
     internal const uint SmtoNormal = 0x0000;
     internal static readonly IntPtr HwndBottom = new(1);
diff --git a/src/Moli.Desktop/Interop/Win32InteropService.cs b/src/Moli.Desktop/Interop/Win32InteropService.cs
index bf066f9..6bed968 100644
--- a/src/Moli.Desktop/Interop/Win32InteropService.cs
+++ b/src/Moli.Desktop/Interop/Win32InteropService.cs
@@ -79,6 +79,7 @@
 
     public void RestoreTopLevelWindow(IntPtr hwnd)
     {
+        RestoreTopLevelStyle(hwnd);
         NativeMethods.SetParent(hwnd, IntPtr.Zero);
         var error = NativeMethods.GetLastError();
         if (error != 0)
@@ -88,6 +89,18 @@
                 DiagnosticCodes.Win32InteropFailed,
                 "RestoreTopLevelWindow failed.",
                 new Dictionary<string, string> { ["hwnd"] = hwnd.ToString("X"), ["error"] = error.ToString() });
+        }
+
+        if (!NativeMethods.SetWindowPos(
+            hwnd,
+            IntPtr.Zero,
+            0,
+            0,
+            0,
+            0,
+            NativeMethods.SwpNoMove | NativeMethods.SwpNoSize | NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpFrameChanged))
+        {
+            RecordWin32Failure("RestoreTopLevelWindow.SetWindowPos", hwnd);
         }
     }
 
@@ -186,4 +199,11 @@
     {
         return new RectD(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
     }
+
+    private static void RestoreTopLevelStyle(IntPtr hwnd)
+    {
+        var current = unchecked((uint)NativeMethods.GetWindowLongPtr(hwnd, NativeMethods.GwlStyle).ToInt64());
+        var updated = (current | NativeMethods.WsPopup | NativeMethods.WsVisible) & ~NativeMethods.WsChild;
+        NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlStyle, new IntPtr(unchecked((int)updated)));
+    }
 }
diff --git a/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs b/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs
index 39a33c3..bbda7f6 100644
--- a/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs
+++ b/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs
@@ -3,7 +3,7 @@
 
 namespace Moli.Desktop.Interop;
 
-/// <summary>Attempts to attach wallpaper windows behind desktop icons through Explorer's WorkerW layer.</summary>
+/// <summary>Attempts to attach desktop surfaces through Explorer's WorkerW or Progman desktop host.</summary>
 public sealed class WorkerWDesktopLayerStrategy : IDesktopLayerStrategy
 {
     private readonly IDiagnosticsService _diagnostics;
@@ -20,24 +20,27 @@
     public bool TryAttachDesktopWindow(IntPtr hwnd, RectD bounds, out string? error)
     {
         error = null;
-        var workerW = FindWorkerW();
-        if (workerW == IntPtr.Zero)
+        var desktopHost = FindDesktopHostWindow(out var hostClass);
+        if (desktopHost == IntPtr.Zero)
         {
-            error = "WorkerW window was not found.";
+            error = "Explorer desktop host window was not found.";
             _diagnostics.Record(
                 DiagnosticSeverity.Warning,
                 DiagnosticCodes.DesktopLayerAttachFailed,
-                "WorkerW desktop layer was not found.",
+                "Explorer desktop host window was not found.",
                 new Dictionary<string, string> { ["strategy"] = Name });
             return false;
         }
 
-        if (NativeMethods.SetParent(hwnd, workerW) == IntPtr.Zero)
+        SetDesktopChildStyle(hwnd);
+
+        if (NativeMethods.SetParent(hwnd, desktopHost) == IntPtr.Zero)
         {
             var lastError = NativeMethods.GetLastError();
             if (lastError != 0)
             {
                 error = $"SetParent failed with {lastError}";
+                RestoreTopLevelStyle(hwnd);
                 return false;
             }
         }
@@ -49,9 +52,11 @@
             (int)bounds.Y,
             (int)bounds.Width,
             (int)bounds.Height,
-            NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
+            NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpFrameChanged | NativeMethods.SwpShowWindow))
         {
             error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";
+            NativeMethods.SetParent(hwnd, IntPtr.Zero);
+            RestoreTopLevelStyle(hwnd);
             return false;
         }
 
@@ -59,15 +64,24 @@
             DiagnosticSeverity.Info,
             DiagnosticCodes.DesktopLayerStrategySelected,
             "Desktop layer strategy selected.",
-            new Dictionary<string, string> { ["strategy"] = Name });
+            new Dictionary<string, string> { ["strategy"] = Name, ["host"] = hostClass });
         return true;
     }
 
-    private static IntPtr FindWorkerW()
+    private static IntPtr FindDesktopHostWindow(out string hostClass)
     {
+        hostClass = "WorkerW";
         var progman = NativeMethods.FindWindow("Progman", null);
         if (progman != IntPtr.Zero)
         {
+            NativeMethods.SendMessageTimeout(
+                progman,
+                0x052C,
+                new IntPtr(0xD),
+                IntPtr.Zero,
+                NativeMethods.SmtoNormal,
+                1000,
+                out _);
             NativeMethods.SendMessageTimeout(
                 progman,
                 0x052C,
@@ -91,6 +105,26 @@
             return workerW == IntPtr.Zero;
         }, IntPtr.Zero);
 
-        return workerW;
+        if (workerW != IntPtr.Zero)
+        {
+            return workerW;
+        }
+
+        hostClass = "Progman";
+        return progman;
+    }
+
+    private static void SetDesktopChildStyle(IntPtr hwnd)
+    {
+        var current = unchecked((uint)NativeMethods.GetWindowLongPtr(hwnd, NativeMethods.GwlStyle).ToInt64());
+        var updated = (current | NativeMethods.WsChild | NativeMethods.WsVisible) & ~NativeMethods.WsPopup;
+        NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlStyle, new IntPtr(unchecked((int)updated)));
+    }
+
+    private static void RestoreTopLevelStyle(IntPtr hwnd)
+    {
+        var current = unchecked((uint)NativeMethods.GetWindowLongPtr(hwnd, NativeMethods.GwlStyle).ToInt64());
+        var updated = (current | NativeMethods.WsPopup | NativeMethods.WsVisible) & ~NativeMethods.WsChild;
+        NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlStyle, new IntPtr(unchecked((int)updated)));
     }
 }
diff --git a/src/Moli.Desktop/Layout/LayoutManager.cs b/src/Moli.Desktop/Layout/LayoutManager.cs
index a8013c3..f2215d9 100644
--- a/src/Moli.Desktop/Layout/LayoutManager.cs
+++ b/src/Moli.Desktop/Layout/LayoutManager.cs
@@ -122,7 +122,7 @@
             ClickThrough = patch.ClickThrough ?? layout.ClickThrough,
             Scale = patch.Scale ?? layout.Scale,
             DisplayLayer = patch.DisplayLayer ?? layout.DisplayLayer
-        });
+        }, allowLocked: IsUnlockPatch(patch));
     }
 
     public IReadOnlyList<WidgetLayout> ReconcileMonitors(IReadOnlyList<MonitorInfo> monitors)
@@ -168,7 +168,7 @@
         }
     }
 
-    private OperationResult<WidgetLayout> Mutate(WidgetInstanceId instanceId, Func<WidgetLayout, WidgetLayout> update)
+    private OperationResult<WidgetLayout> Mutate(WidgetInstanceId instanceId, Func<WidgetLayout, WidgetLayout> update, bool allowLocked = false)
     {
         lock (_gate)
         {
@@ -179,7 +179,7 @@
             }
 
             var current = _document.Instances[index];
-            if (current.IsLocked)
+            if (current.IsLocked && !allowLocked)
             {
                 return OperationResult<WidgetLayout>.Failure("WidgetLayoutLocked", $"Widget layout {instanceId} is locked.");
             }
@@ -256,4 +256,14 @@
 
     private static double Clamp(double value, double min, double max)
         => Math.Min(Math.Max(value, min), max);
+
+    private static bool IsUnlockPatch(WidgetLayoutPatch patch)
+        => patch.IsLocked == false &&
+           patch.Bounds is null &&
+           patch.MonitorId is null &&
+           patch.IsVisible is null &&
+           patch.Opacity is null &&
+           patch.ClickThrough is null &&
+           patch.Scale is null &&
+           patch.DisplayLayer is null;
 }
diff --git a/src/Moli.Desktop/Llm/AiChatClient.cs b/src/Moli.Desktop/Llm/AiChatClient.cs
new file mode 100644
index 0000000..5a20ec8
--- /dev/null
+++ b/src/Moli.Desktop/Llm/AiChatClient.cs
@@ -0,0 +1,621 @@
+using System.Collections.Concurrent;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Text.Json;
+using System.IO;
+using Moli.Desktop.Diagnostics;
+
+namespace Moli.Desktop.Llm;
+
+public sealed class AiChatClient : IAiChatClient
+{
+    private readonly HttpClient _httpClient;
+    private readonly IDiagnosticsService _diagnostics;
+    private readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
+    private readonly ConcurrentDictionary<string, string> _sessionTokens = new(StringComparer.OrdinalIgnoreCase);
+
+    public AiChatClient(HttpClient httpClient, IDiagnosticsService diagnostics)
+    {
+        _httpClient = httpClient;
+        _diagnostics = diagnostics;
+    }
+
+    public async Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default)
+    {
+        using var document = await SendJsonAsync(runtimeConfig, HttpMethod.Get, "/api/chat/models", null, cancellationToken).ConfigureAwait(false);
+        if (!TryGetData(document.RootElement, out var data) ||
+            !data.TryGetProperty("models", out var modelsElement) ||
+            modelsElement.ValueKind != JsonValueKind.Array)
+        {
+            return [];
+        }
+
+        var defaultModel = data.TryGetProperty("defaultModel", out var defaultModelElement)
+            ? defaultModelElement.GetString()
+            : null;
+
+        return modelsElement
+            .EnumerateArray()
+            .Where(item => item.ValueKind == JsonValueKind.String && !string.IsNullOrWhiteSpace(item.GetString()))
+            .Select(item =>
+            {
+                var id = item.GetString()!;
+                return new LlmModelSummary
+                {
+                    Id = id,
+                    Label = id == defaultModel ? $"{id} *" : id,
+                    Provider = "aichat",
+                    SupportsStreaming = true,
+                    Enabled = true
+                };
+            })
+            .ToList();
+    }
+
+    public async Task<IReadOnlyList<AiChatProjectSummary>> GetProjectsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default)
+    {
+        try
+        {
+            using var document = await SendJsonAsync(runtimeConfig, HttpMethod.Get, "/api/projects", null, cancellationToken).ConfigureAwait(false);
+            if (!TryGetProjectsData(document.RootElement, out var data))
+            {
+                _diagnostics.Record(
+                    DiagnosticSeverity.Warning,
+                    LlmErrorCodes.AiChatProjectLoadFailed,
+                    "AiChat project response did not contain a project array.",
+                    new Dictionary<string, string> { ["baseUrl"] = runtimeConfig.AiChat.BaseUrl });
+                return [];
+            }
+
+            return data.EnumerateArray()
+                .Select(ParseProject)
+                .Where(project => project is not null)
+                .Select(project => project!)
+                .ToList();
+        }
+        catch (AiChatClientException ex)
+        {
+            _diagnostics.Record(
+                DiagnosticSeverity.Warning,
+                ex.Code,
+                "AiChat projects could not be loaded.",
+                new Dictionary<string, string>
+                {
+                    ["baseUrl"] = runtimeConfig.AiChat.BaseUrl,
+                    ["exception"] = ex.GetType().Name
+                });
+            throw;
+        }
+    }
+
+    public async IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+        LlmChatRequest request,
+        LlmPluginRuntimeConfig runtimeConfig,
+        [EnumeratorCancellation] CancellationToken cancellationToken = default)
+    {
+        JsonDocument? sendDocument = null;
+        LlmErrorEvent? startError = null;
+        try
+        {
+            var message = request.Messages.LastOrDefault(message => string.Equals(message.Role, "user", StringComparison.OrdinalIgnoreCase))?.Content
+                ?? request.Messages.Last().Content;
+            var payload = new
+            {
+                projectId = request.ProjectId,
+                modelName = request.ModelId,
+                message
+            };
+            sendDocument = await SendJsonAsync(runtimeConfig, HttpMethod.Post, "/api/chat/send", payload, cancellationToken).ConfigureAwait(false);
+        }
+        catch (AiChatClientException ex)
+        {
+            startError = new LlmErrorEvent { RequestId = request.RequestId, Code = ex.Code, Message = ex.Message };
+        }
+
+        if (startError is not null)
+        {
+            yield return startError;
+            yield break;
+        }
+
+        var generationDocument = sendDocument;
+        if (generationDocument is null)
+        {
+            yield return new LlmErrorEvent
+            {
+                RequestId = request.RequestId,
+                Code = LlmErrorCodes.AiChatApiFailed,
+                Message = "AiChat did not return a valid generation stream."
+            };
+            yield break;
+        }
+
+        using (generationDocument)
+        {
+            if (!TryGetData(generationDocument.RootElement, out var data) ||
+                !data.TryGetProperty("generationId", out var generationIdElement) ||
+                !data.TryGetProperty("streamToken", out var streamTokenElement) ||
+                string.IsNullOrWhiteSpace(generationIdElement.GetString()) ||
+                string.IsNullOrWhiteSpace(streamTokenElement.GetString()))
+            {
+                yield return new LlmErrorEvent
+                {
+                    RequestId = request.RequestId,
+                    Code = LlmErrorCodes.AiChatApiFailed,
+                    Message = "AiChat did not return a valid generation stream."
+                };
+                yield break;
+            }
+
+            var path = $"/api/chat/generations/{Uri.EscapeDataString(generationIdElement.GetString()!)}/stream?token={Uri.EscapeDataString(streamTokenElement.GetString()!)}";
+            await foreach (var streamEvent in StreamAiChatEventsAsync(runtimeConfig, request.RequestId, path, cancellationToken).ConfigureAwait(false))
+            {
+                yield return streamEvent;
+            }
+        }
+    }
+
+    public async Task<AiChatMemoryCapabilities> GetMemoryCapabilitiesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default)
+    {
+        using var document = await SendJsonAsync(runtimeConfig, HttpMethod.Get, "/api/auth/me", null, cancellationToken).ConfigureAwait(false);
+        if (!TryGetData(document.RootElement, out var data))
+        {
+            return new AiChatMemoryCapabilities();
+        }
+
+        return new AiChatMemoryCapabilities
+        {
+            CanUseMemory = ReadBool(data, "canUseMemory"),
+            CanViewMemory = ReadBool(data, "canViewMemory"),
+            CanManageMemory = ReadBool(data, "canManageMemory")
+        };
+    }
+
+    public async Task<AiChatJsonResult> GetMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatGetMemoriesRequest request,
+        CancellationToken cancellationToken = default)
+    {
+        var query = new List<string>();
+        if (!string.IsNullOrWhiteSpace(request.Scope))
+        {
+            query.Add($"scope={Uri.EscapeDataString(request.Scope)}");
+        }
+
+        if (!string.IsNullOrWhiteSpace(request.ProjectId))
+        {
+            query.Add($"projectId={Uri.EscapeDataString(request.ProjectId)}");
+        }
+
+        var path = "/api/memories" + (query.Count > 0 ? "?" + string.Join("&", query) : "");
+        using var document = await SendJsonAsync(runtimeConfig, HttpMethod.Get, path, null, cancellationToken).ConfigureAwait(false);
+        return CloneData(document);
+    }
+
+    public async Task<AiChatJsonResult> CreateMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatCreateMemoryRequest request,
+        CancellationToken cancellationToken = default)
+    {
+        using var document = await SendJsonAsync(runtimeConfig, HttpMethod.Post, "/api/memories", request, cancellationToken).ConfigureAwait(false);
+        return CloneData(document);
+    }
+
+    public async Task DeleteMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        string memoryId,
+        CancellationToken cancellationToken = default)
+    {
+        if (string.IsNullOrWhiteSpace(memoryId))
+        {
+            throw new AiChatClientException(LlmErrorCodes.RequestInvalid, "memoryId is required.");
+        }
+
+        using var _ = await SendJsonAsync(runtimeConfig, HttpMethod.Delete, $"/api/memories/{Uri.EscapeDataString(memoryId)}", null, cancellationToken).ConfigureAwait(false);
+    }
+
+    public async Task<AiChatJsonResult> RecallMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatRecallMemoriesRequest request,
+        CancellationToken cancellationToken = default)
+    {
+        using var document = await SendJsonAsync(runtimeConfig, HttpMethod.Post, "/api/memories/recall", request, cancellationToken).ConfigureAwait(false);
+        return CloneData(document);
+    }
+
+    private async IAsyncEnumerable<LlmStreamEvent> StreamAiChatEventsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        string requestId,
+        string path,
+        [EnumeratorCancellation] CancellationToken cancellationToken)
+    {
+        using var request = await CreateRequestAsync(runtimeConfig, HttpMethod.Get, path, null, cancellationToken).ConfigureAwait(false);
+        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"));
+        using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+        if (!response.IsSuccessStatusCode)
+        {
+            yield return new LlmErrorEvent
+            {
+                RequestId = requestId,
+                Code = MapStatusCode(response.StatusCode),
+                Message = $"AiChat stream returned {(int)response.StatusCode}."
+            };
+            yield break;
+        }
+
+        await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
+        using var reader = new StreamReader(stream, Encoding.UTF8);
+        var eventName = "message";
+        var dataLines = new List<string>();
+
+        while (await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false) is { } line)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+            if (line.StartsWith(":", StringComparison.Ordinal))
+            {
+                continue;
+            }
+
+            if (line.Length == 0)
+            {
+                foreach (var streamEvent in ParseSseEvent(requestId, eventName, string.Join('\n', dataLines)))
+                {
+                    yield return streamEvent;
+                    if (streamEvent is LlmCompletedEvent or LlmErrorEvent)
+                    {
+                        yield break;
+                    }
+                }
+
+                eventName = "message";
+                dataLines.Clear();
+                continue;
+            }
+
+            if (line.StartsWith("event:", StringComparison.OrdinalIgnoreCase))
+            {
+                eventName = line["event:".Length..].Trim();
+                continue;
+            }
+
+            if (line.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
+            {
+                dataLines.Add(line["data:".Length..].TrimStart());
+            }
+        }
+
+        if (dataLines.Count > 0)
+        {
+            foreach (var streamEvent in ParseSseEvent(requestId, eventName, string.Join('\n', dataLines)))
+            {
+                yield return streamEvent;
+                if (streamEvent is LlmCompletedEvent or LlmErrorEvent)
+                {
+                    yield break;
+                }
+            }
+        }
+
+        yield return new LlmErrorEvent
+        {
+            RequestId = requestId,
+            Code = LlmErrorCodes.AiChatSseInterrupted,
+            Message = "AiChat stream ended before completion."
+        };
+    }
+
+    private IEnumerable<LlmStreamEvent> ParseSseEvent(string requestId, string eventName, string data)
+    {
+        if (string.IsNullOrWhiteSpace(data))
+        {
+            yield break;
+        }
+
+        JsonDocument document;
+        try
+        {
+            document = JsonDocument.Parse(data);
+        }
+        catch (JsonException ex)
+        {
+            throw new AiChatClientException(LlmErrorCodes.StreamParseFailed, "Failed to parse AiChat stream chunk.", ex);
+        }
+
+        using (document)
+        {
+            var root = document.RootElement;
+            if (eventName.Equals("chunk", StringComparison.OrdinalIgnoreCase) &&
+                root.TryGetProperty("delta", out var delta) &&
+                delta.ValueKind == JsonValueKind.String)
+            {
+                yield return new LlmDeltaEvent { RequestId = requestId, Delta = delta.GetString() ?? "" };
+                yield break;
+            }
+
+            if (eventName.Equals("snapshot", StringComparison.OrdinalIgnoreCase) &&
+                root.TryGetProperty("content", out var content) &&
+                content.ValueKind == JsonValueKind.String &&
+                !string.IsNullOrEmpty(content.GetString()))
+            {
+                yield return new LlmDeltaEvent { RequestId = requestId, Delta = content.GetString() ?? "" };
+                yield break;
+            }
+
+            if (eventName.Equals("done", StringComparison.OrdinalIgnoreCase))
+            {
+                yield return new LlmCompletedEvent { RequestId = requestId };
+                yield break;
+            }
+
+            if (eventName.Equals("failed", StringComparison.OrdinalIgnoreCase) ||
+                eventName.Equals("aborted", StringComparison.OrdinalIgnoreCase))
+            {
+                var message = root.TryGetProperty("error", out var error) && error.ValueKind == JsonValueKind.String
+                    ? error.GetString() ?? "AiChat request failed."
+                    : eventName.Equals("aborted", StringComparison.OrdinalIgnoreCase) ? "AiChat request was aborted." : "AiChat request failed.";
+                yield return new LlmErrorEvent { RequestId = requestId, Code = LlmErrorCodes.AiChatApiFailed, Message = message };
+            }
+        }
+    }
+
+    private async Task<JsonDocument> SendJsonAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        HttpMethod method,
+        string path,
+        object? payload,
+        CancellationToken cancellationToken)
+    {
+        using var request = await CreateRequestAsync(runtimeConfig, method, path, payload, cancellationToken).ConfigureAwait(false);
+        using var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+        if (response.StatusCode == HttpStatusCode.Unauthorized)
+        {
+            ClearSession(runtimeConfig);
+            using var retry = await CreateRequestAsync(runtimeConfig, method, path, payload, cancellationToken).ConfigureAwait(false);
+            using var retryResponse = await _httpClient.SendAsync(retry, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+            return await ReadJsonResponseAsync(retryResponse, cancellationToken).ConfigureAwait(false);
+        }
+
+        return await ReadJsonResponseAsync(response, cancellationToken).ConfigureAwait(false);
+    }
+
+    private async Task<HttpRequestMessage> CreateRequestAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        HttpMethod method,
+        string path,
+        object? payload,
+        CancellationToken cancellationToken)
+    {
+        var uri = BuildUri(runtimeConfig, path);
+        var request = new HttpRequestMessage(method, uri);
+        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+        if (!path.Equals("/api/auth/login", StringComparison.OrdinalIgnoreCase))
+        {
+            var sessionToken = await EnsureSessionAsync(runtimeConfig, cancellationToken).ConfigureAwait(false);
+            request.Headers.Add("x-session-token", sessionToken);
+        }
+
+        if (payload is not null)
+        {
+            request.Content = new StringContent(JsonSerializer.Serialize(payload, _jsonOptions), Encoding.UTF8, "application/json");
+        }
+
+        return request;
+    }
+
+    private async Task<string> EnsureSessionAsync(LlmPluginRuntimeConfig runtimeConfig, CancellationToken cancellationToken)
+    {
+        var key = SessionKey(runtimeConfig);
+        if (_sessionTokens.TryGetValue(key, out var existing) && !string.IsNullOrWhiteSpace(existing))
+        {
+            return existing;
+        }
+
+        var email = runtimeConfig.AiChat.Account.Email;
+        var password = ResolvePassword(runtimeConfig);
+        if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
+        {
+            throw new AiChatClientException(LlmErrorCodes.AiChatCredentialMissing, "AiChat account or password is missing.");
+        }
+
+        using var request = new HttpRequestMessage(HttpMethod.Post, BuildUri(runtimeConfig, "/api/auth/login"))
+        {
+            Content = new StringContent(
+                JsonSerializer.Serialize(new { email, password }, _jsonOptions),
+                Encoding.UTF8,
+                "application/json")
+        };
+        using var response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
+        using var document = await ReadJsonResponseAsync(response, cancellationToken).ConfigureAwait(false);
+        if (!TryGetData(document.RootElement, out var data) ||
+            !data.TryGetProperty("sessionToken", out var token) ||
+            token.ValueKind != JsonValueKind.String ||
+            string.IsNullOrWhiteSpace(token.GetString()))
+        {
+            throw new AiChatClientException(LlmErrorCodes.AiChatLoginFailed, "AiChat login did not return a session token.");
+        }
+
+        _sessionTokens[key] = token.GetString()!;
+        return token.GetString()!;
+    }
+
+    private async Task<JsonDocument> ReadJsonResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
+    {
+        await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
+        JsonDocument document;
+        try
+        {
+            document = await JsonDocument.ParseAsync(stream, cancellationToken: cancellationToken).ConfigureAwait(false);
+        }
+        catch (JsonException) when (response.Content.Headers.ContentLength == 0)
+        {
+            document = JsonDocument.Parse("""{"ok":true}""");
+        }
+
+        if (!response.IsSuccessStatusCode)
+        {
+            var (code, message) = ExtractError(document.RootElement, response.StatusCode);
+            document.Dispose();
+            throw new AiChatClientException(code, message);
+        }
+
+        if (document.RootElement.TryGetProperty("ok", out var ok) && ok.ValueKind == JsonValueKind.False)
+        {
+            var (code, message) = ExtractError(document.RootElement, response.StatusCode);
+            document.Dispose();
+            throw new AiChatClientException(code, message);
+        }
+
+        return document;
+    }
+
+    private static AiChatProjectSummary? ParseProject(JsonElement item)
+    {
+        if (!item.TryGetProperty("id", out var id) || id.ValueKind != JsonValueKind.String)
+        {
+            return null;
+        }
+
+        return new AiChatProjectSummary
+        {
+            Id = id.GetString()!,
+            Name = item.TryGetProperty("name", out var name) && name.ValueKind == JsonValueKind.String ? name.GetString() ?? id.GetString()! : id.GetString()!,
+            ProjectType = item.TryGetProperty("projectType", out var projectType) && projectType.ValueKind == JsonValueKind.String ? projectType.GetString() ?? "CHAT" : "CHAT",
+            MemoryMode = item.TryGetProperty("memoryMode", out var memoryMode) && memoryMode.ValueKind == JsonValueKind.String ? memoryMode.GetString() ?? "ISOLATED" : "ISOLATED"
+        };
+    }
+
+    private static AiChatJsonResult CloneData(JsonDocument document)
+    {
+        if (!TryGetData(document.RootElement, out var data))
+        {
+            return new AiChatJsonResult();
+        }
+
+        return new AiChatJsonResult { Data = JsonSerializer.Deserialize<object>(data.GetRawText()) };
+    }
+
+    private static bool TryGetData(JsonElement root, out JsonElement data)
+    {
+        if (root.TryGetProperty("data", out data))
+        {
+            return true;
+        }
+
+        data = default;
+        return false;
+    }
+
+    private static bool TryGetProjectsData(JsonElement root, out JsonElement projects)
+    {
+        if (TryGetData(root, out var data))
+        {
+            if (data.ValueKind == JsonValueKind.Array)
+            {
+                projects = data;
+                return true;
+            }
+
+            if (data.ValueKind == JsonValueKind.Object &&
+                data.TryGetProperty("projects", out var nestedProjects) &&
+                nestedProjects.ValueKind == JsonValueKind.Array)
+            {
+                projects = nestedProjects;
+                return true;
+            }
+        }
+
+        projects = default;
+        return false;
+    }
+
+    private static bool ReadBool(JsonElement root, string property)
+        => root.TryGetProperty(property, out var value) &&
+           (value.ValueKind == JsonValueKind.True || (value.ValueKind == JsonValueKind.String && bool.TryParse(value.GetString(), out var parsed) && parsed));
+
+    private static (string Code, string Message) ExtractError(JsonElement root, HttpStatusCode statusCode)
+    {
+        var apiCode = root.TryGetProperty("code", out var codeElement) && codeElement.ValueKind == JsonValueKind.String
+            ? codeElement.GetString()
+            : null;
+        var message = root.TryGetProperty("error", out var errorElement) && errorElement.ValueKind == JsonValueKind.String
+            ? errorElement.GetString() ?? $"AiChat returned {(int)statusCode}."
+            : $"AiChat returned {(int)statusCode}.";
+
+        return (MapApiCode(apiCode, statusCode), message);
+    }
+
+    private static string MapApiCode(string? apiCode, HttpStatusCode statusCode)
+    {
+        if (string.Equals(apiCode, "TOKEN_TOTAL_LIMIT_REACHED", StringComparison.OrdinalIgnoreCase) ||
+            string.Equals(apiCode, "TOKEN_PER_REQUEST_LIMIT_REACHED", StringComparison.OrdinalIgnoreCase))
+        {
+            return LlmErrorCodes.AiChatQuotaExceeded;
+        }
+
+        if (string.Equals(apiCode, "PERMISSION_DENIED", StringComparison.OrdinalIgnoreCase))
+        {
+            return LlmErrorCodes.AiChatMemoryPermissionDenied;
+        }
+
+        if (statusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
+        {
+            return LlmErrorCodes.AiChatLoginFailed;
+        }
+
+        return apiCode ?? LlmErrorCodes.AiChatApiFailed;
+    }
+
+    private static string MapStatusCode(HttpStatusCode statusCode)
+        => statusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden
+            ? LlmErrorCodes.AiChatLoginFailed
+            : LlmErrorCodes.AiChatApiFailed;
+
+    private static Uri BuildUri(LlmPluginRuntimeConfig runtimeConfig, string path)
+    {
+        var baseUrl = string.IsNullOrWhiteSpace(runtimeConfig.AiChat.BaseUrl)
+            ? "http://192.168.1.111:13000"
+            : runtimeConfig.AiChat.BaseUrl;
+        if (!Uri.TryCreate(baseUrl, UriKind.Absolute, out var baseUri) ||
+            baseUri.Scheme is not ("http" or "https"))
+        {
+            throw new AiChatClientException(LlmErrorCodes.RequestInvalid, "AiChat baseUrl must be an absolute HTTP or HTTPS URL.");
+        }
+
+        return new Uri(baseUri, path);
+    }
+
+    private static string? ResolvePassword(LlmPluginRuntimeConfig runtimeConfig)
+    {
+        var envName = runtimeConfig.AiChat.Account.PasswordEnv;
+        if (!string.IsNullOrWhiteSpace(envName))
+        {
+            var envValue = Environment.GetEnvironmentVariable(envName)
+                ?? Environment.GetEnvironmentVariable(envName, EnvironmentVariableTarget.User)
+                ?? Environment.GetEnvironmentVariable(envName, EnvironmentVariableTarget.Machine);
+            if (!string.IsNullOrWhiteSpace(envValue))
+            {
+                return envValue;
+            }
+        }
+
+        return runtimeConfig.AiChat.Account.Password;
+    }
+
+    private void ClearSession(LlmPluginRuntimeConfig runtimeConfig)
+    {
+        _sessionTokens.TryRemove(SessionKey(runtimeConfig), out _);
+    }
+
+    private static string SessionKey(LlmPluginRuntimeConfig runtimeConfig)
+        => $"{runtimeConfig.AiChat.BaseUrl}|{runtimeConfig.AiChat.Account.Email}";
+}
diff --git a/src/Moli.Desktop/Llm/ILlmServices.cs b/src/Moli.Desktop/Llm/ILlmServices.cs
index 777ac1e..2258be5 100644
--- a/src/Moli.Desktop/Llm/ILlmServices.cs
+++ b/src/Moli.Desktop/Llm/ILlmServices.cs
@@ -4,6 +4,38 @@
 {
     Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(CancellationToken cancellationToken = default);
 
+    Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    Task<IReadOnlyList<AiChatProjectSummary>> GetProjectsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatMemoryCapabilities> GetMemoryCapabilitiesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatJsonResult> GetMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatGetMemoriesRequest request,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatJsonResult> CreateMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatCreateMemoryRequest request,
+        CancellationToken cancellationToken = default);
+
+    Task DeleteMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        string memoryId,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatJsonResult> RecallMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatRecallMemoriesRequest request,
+        CancellationToken cancellationToken = default);
+
     IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
         LlmChatRequest request,
         CancellationToken cancellationToken = default);
@@ -35,3 +67,43 @@
 {
     Task<string?> ResolveSecretAsync(string? authRef, CancellationToken cancellationToken = default);
 }
+
+public interface IAiChatClient
+{
+    Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    Task<IReadOnlyList<AiChatProjectSummary>> GetProjectsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+        LlmChatRequest request,
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatMemoryCapabilities> GetMemoryCapabilitiesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatJsonResult> GetMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatGetMemoriesRequest request,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatJsonResult> CreateMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatCreateMemoryRequest request,
+        CancellationToken cancellationToken = default);
+
+    Task DeleteMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        string memoryId,
+        CancellationToken cancellationToken = default);
+
+    Task<AiChatJsonResult> RecallMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatRecallMemoriesRequest request,
+        CancellationToken cancellationToken = default);
+}
diff --git a/src/Moli.Desktop/Llm/LlmGatewayService.cs b/src/Moli.Desktop/Llm/LlmGatewayService.cs
index 3290988..472ecda 100644
--- a/src/Moli.Desktop/Llm/LlmGatewayService.cs
+++ b/src/Moli.Desktop/Llm/LlmGatewayService.cs
@@ -18,18 +18,21 @@
     private readonly ICredentialStore _credentialStore;
     private readonly ILlmProviderAdapterFactory _adapterFactory;
     private readonly IDiagnosticsService _diagnostics;
+    private readonly IAiChatClient? _aiChatClient;
     private readonly ConcurrentDictionary<string, CancellationTokenSource> _activeRequests = new(StringComparer.OrdinalIgnoreCase);
 
     public LlmGatewayService(
         ILlmModelRegistry registry,
         ICredentialStore credentialStore,
         ILlmProviderAdapterFactory adapterFactory,
-        IDiagnosticsService diagnostics)
+        IDiagnosticsService diagnostics,
+        IAiChatClient? aiChatClient = null)
     {
         _registry = registry;
         _credentialStore = credentialStore;
         _adapterFactory = adapterFactory;
         _diagnostics = diagnostics;
+        _aiChatClient = aiChatClient;
     }
 
     public async Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(CancellationToken cancellationToken = default)
@@ -48,6 +51,84 @@
             .ToList();
     }
 
+    public async Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default)
+    {
+        if (runtimeConfig.IsAiChatMode)
+        {
+            return _aiChatClient is null
+                ? []
+                : await _aiChatClient.GetModelsAsync(runtimeConfig, cancellationToken).ConfigureAwait(false);
+        }
+
+        var configuredModels = runtimeConfig.Models
+            .Where(IsUsableRuntimeModel)
+            .Select(model => new LlmModelSummary
+            {
+                Id = model.Id,
+                Label = string.Equals(model.Id, runtimeConfig.DefaultModel, StringComparison.OrdinalIgnoreCase)
+                    ? $"{model.Label} *"
+                    : model.Label,
+                Provider = model.Provider,
+                SupportsStreaming = model.SupportsStreaming,
+                Enabled = model.Enabled
+            })
+            .ToList();
+        if (configuredModels.Count > 0)
+        {
+            return configuredModels;
+        }
+
+        return await GetModelsAsync(cancellationToken).ConfigureAwait(false);
+    }
+
+    public Task<IReadOnlyList<AiChatProjectSummary>> GetProjectsAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default)
+        => _aiChatClient is null
+            ? Task.FromResult<IReadOnlyList<AiChatProjectSummary>>([])
+            : _aiChatClient.GetProjectsAsync(runtimeConfig, cancellationToken);
+
+    public Task<AiChatMemoryCapabilities> GetMemoryCapabilitiesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        CancellationToken cancellationToken = default)
+        => _aiChatClient is null
+            ? Task.FromResult(new AiChatMemoryCapabilities())
+            : _aiChatClient.GetMemoryCapabilitiesAsync(runtimeConfig, cancellationToken);
+
+    public Task<AiChatJsonResult> GetMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatGetMemoriesRequest request,
+        CancellationToken cancellationToken = default)
+        => _aiChatClient is null
+            ? Task.FromResult(new AiChatJsonResult())
+            : _aiChatClient.GetMemoriesAsync(runtimeConfig, request, cancellationToken);
+
+    public Task<AiChatJsonResult> CreateMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatCreateMemoryRequest request,
+        CancellationToken cancellationToken = default)
+        => _aiChatClient is null
+            ? Task.FromResult(new AiChatJsonResult())
+            : _aiChatClient.CreateMemoryAsync(runtimeConfig, request, cancellationToken);
+
+    public Task DeleteMemoryAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        string memoryId,
+        CancellationToken cancellationToken = default)
+        => _aiChatClient is null
+            ? Task.CompletedTask
+            : _aiChatClient.DeleteMemoryAsync(runtimeConfig, memoryId, cancellationToken);
+
+    public Task<AiChatJsonResult> RecallMemoriesAsync(
+        LlmPluginRuntimeConfig runtimeConfig,
+        AiChatRecallMemoriesRequest request,
+        CancellationToken cancellationToken = default)
+        => _aiChatClient is null
+            ? Task.FromResult(new AiChatJsonResult())
+            : _aiChatClient.RecallMemoriesAsync(runtimeConfig, request, cancellationToken);
+
     public async IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
         LlmChatRequest request,
         [EnumeratorCancellation] CancellationToken cancellationToken = default)
@@ -63,7 +144,31 @@
             yield break;
         }
 
-        var model = await _registry.GetEnabledModelAsync(request.ModelId, cancellationToken).ConfigureAwait(false);
+        if (string.Equals(request.Mode, LlmConnectionModes.AiChatApi, StringComparison.OrdinalIgnoreCase))
+        {
+            if (_aiChatClient is null)
+            {
+                yield return new LlmErrorEvent
+                {
+                    RequestId = request.RequestId,
+                    Code = LlmErrorCodes.AiChatApiFailed,
+                    Message = "AiChat client is not available."
+                };
+                yield break;
+            }
+
+            await foreach (var streamEvent in _aiChatClient.StreamChatAsync(request, request.RuntimeConfig, cancellationToken).ConfigureAwait(false))
+            {
+                yield return streamEvent;
+            }
+
+            yield break;
+        }
+
+        var model = request.RuntimeConfig.Models.FirstOrDefault(model =>
+            IsUsableRuntimeModel(model) &&
+            string.Equals(model.Id, request.ModelId, StringComparison.OrdinalIgnoreCase));
+        model ??= await _registry.GetEnabledModelAsync(request.ModelId, cancellationToken).ConfigureAwait(false);
         if (model is null)
         {
             yield return new LlmErrorEvent
@@ -222,6 +327,14 @@
         return true;
     }
 
+    private static bool IsUsableRuntimeModel(LlmModelConfig model)
+        => model.Enabled &&
+           !string.IsNullOrWhiteSpace(model.Id) &&
+           !string.IsNullOrWhiteSpace(model.Label) &&
+           !string.IsNullOrWhiteSpace(model.Provider) &&
+           !string.IsNullOrWhiteSpace(model.Endpoint) &&
+           !string.IsNullOrWhiteSpace(model.ApiModel);
+
     private void RecordFailure(LlmChatRequest request, LlmModelConfig model, string code, string exception)
     {
         var host = Uri.TryCreate(model.Endpoint, UriKind.Absolute, out var endpoint)
diff --git a/src/Moli.Desktop/Llm/LlmModels.cs b/src/Moli.Desktop/Llm/LlmModels.cs
index c63cbf3..aab6a29 100644
--- a/src/Moli.Desktop/Llm/LlmModels.cs
+++ b/src/Moli.Desktop/Llm/LlmModels.cs
@@ -43,9 +43,12 @@
     public required string RequestId { get; init; }
     public required string PluginId { get; init; }
     public required string InstanceId { get; init; }
+    public string Mode { get; init; } = LlmConnectionModes.ProviderDirect;
+    public string? ProjectId { get; init; }
     public required string ModelId { get; init; }
     public required IReadOnlyList<LlmMessage> Messages { get; init; }
     public LlmRequestOptions Options { get; init; } = new();
+    public LlmPluginRuntimeConfig RuntimeConfig { get; init; } = new();
 }
 
 public sealed record LlmMessage
@@ -119,4 +122,102 @@
     public const string Timeout = "LlmTimeout";
     public const string StreamParseFailed = "LlmStreamParseFailed";
     public const string RequestInvalid = "LlmRequestInvalid";
+    public const string AiChatCredentialMissing = "AiChatCredentialMissing";
+    public const string AiChatLoginFailed = "AiChatLoginFailed";
+    public const string AiChatProjectLoadFailed = "AiChatProjectLoadFailed";
+    public const string AiChatQuotaExceeded = "AiChatQuotaExceeded";
+    public const string AiChatMemoryPermissionDenied = "AiChatMemoryPermissionDenied";
+    public const string AiChatSseInterrupted = "AiChatSseInterrupted";
+    public const string AiChatApiFailed = "AiChatApiFailed";
+}
+
+public static class LlmConnectionModes
+{
+    public const string ProviderDirect = "provider-direct";
+    public const string AiChatApi = "aichat-api";
+}
+
+public sealed record LlmPluginRuntimeConfig
+{
+    public string Mode { get; init; } = LlmConnectionModes.ProviderDirect;
+    public AiChatRuntimeConfig AiChat { get; init; } = new();
+    public string? DefaultModel { get; init; }
+    public List<LlmModelConfig> Models { get; init; } = [];
+
+    public bool IsAiChatMode => string.Equals(Mode, LlmConnectionModes.AiChatApi, StringComparison.OrdinalIgnoreCase);
+}
+
+public sealed record AiChatRuntimeConfig
+{
+    public string BaseUrl { get; init; } = "http://192.168.1.111:13000";
+    public AiChatAccountConfig Account { get; init; } = new();
+    public string? DefaultProjectId { get; init; }
+    public AiChatMemoryConfig Memory { get; init; } = new();
+}
+
+public sealed record AiChatAccountConfig
+{
+    public string? Email { get; init; }
+    public string? Password { get; init; }
+    public string? PasswordEnv { get; init; } = "MOLI_AICHAT_PASSWORD";
+}
+
+public sealed record AiChatMemoryConfig
+{
+    public bool EnabledInProviderDirect { get; init; } = true;
+    public string DefaultScope { get; init; } = "PROJECT";
+    public int RecallLimit { get; init; } = 8;
+}
+
+public sealed record AiChatProjectSummary
+{
+    public required string Id { get; init; }
+    public required string Name { get; init; }
+    public string ProjectType { get; init; } = "CHAT";
+    public string MemoryMode { get; init; } = "ISOLATED";
+}
+
+public sealed record AiChatMemoryCapabilities
+{
+    public bool CanUseMemory { get; init; }
+    public bool CanViewMemory { get; init; }
+    public bool CanManageMemory { get; init; }
+}
+
+public sealed record AiChatGetMemoriesRequest
+{
+    public string? Scope { get; init; }
+    public string? ProjectId { get; init; }
+}
+
+public sealed record AiChatCreateMemoryRequest
+{
+    public required string Scope { get; init; }
+    public string? ProjectId { get; init; }
+    public required string Content { get; init; }
+}
+
+public sealed record AiChatRecallMemoriesRequest
+{
+    public required string Query { get; init; }
+    public string? Scope { get; init; }
+    public string? ProjectId { get; init; }
+    public string? ConversationId { get; init; }
+    public int? Limit { get; init; }
+}
+
+public sealed record AiChatJsonResult
+{
+    public object? Data { get; init; }
+}
+
+public sealed class AiChatClientException : Exception
+{
+    public AiChatClientException(string code, string message, Exception? innerException = null)
+        : base(message, innerException)
+    {
+        Code = code;
+    }
+
+    public string Code { get; }
 }
diff --git a/src/Moli.Desktop/Management/ManagementWindow.xaml b/src/Moli.Desktop/Management/ManagementWindow.xaml
index 8a5ef92..de834cb 100644
--- a/src/Moli.Desktop/Management/ManagementWindow.xaml
+++ b/src/Moli.Desktop/Management/ManagementWindow.xaml
@@ -92,6 +92,22 @@
                     <DataGrid x:Name="DiagnosticsGrid" AutoGenerateColumns="True" IsReadOnly="True" />
                 </DockPanel>
             </TabItem>
+            <TabItem Header="Log">
+                <DockPanel Margin="8">
+                    <WrapPanel DockPanel.Dock="Top" Margin="0,0,0,8">
+                        <TextBlock x:Name="LogPathText" VerticalAlignment="Center" Margin="0,0,12,0" />
+                        <Button Content="鎵撳紑鏃ュ織鐩綍" Width="112" Click="OpenLogDirectory_Click" />
+                    </WrapPanel>
+                    <TextBox x:Name="LogTextBox"
+                             FontFamily="Consolas"
+                             FontSize="12"
+                             IsReadOnly="True"
+                             TextWrapping="NoWrap"
+                             AcceptsReturn="True"
+                             VerticalScrollBarVisibility="Auto"
+                             HorizontalScrollBarVisibility="Auto" />
+                </DockPanel>
+            </TabItem>
         </TabControl>
     </DockPanel>
 </Window>
diff --git a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
index 1bee7d6..19185ed 100644
--- a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
+++ b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
@@ -30,6 +30,8 @@
     private readonly DesktopPaths _paths;
     private readonly DispatcherTimer _timer;
     private AppRuntimeState? _state;
+    private string? _selectedWidgetForDisplayLayer;
+    private bool _isRefreshing;
 
     public ManagementWindow(
         IDesktopRuntime runtime,
@@ -43,6 +45,7 @@
         _paths = paths;
         InitializeComponent();
         DisplayLayerSelector.ItemsSource = Enum.GetValues<DisplayLayer>();
+        WidgetSelector.SelectionChanged += WidgetSelector_SelectionChanged;
         _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
         _timer.Tick += async (_, _) => await RefreshAsync();
         Loaded += async (_, _) =>
@@ -55,33 +58,42 @@
 
     private async Task RefreshAsync()
     {
-        _state = await _runtime.GetStateAsync();
-        var api = _apiStatus.GetStatus();
-        var diagnostics = _diagnostics.Snapshot().OrderByDescending(entry => entry.Timestamp).ToArray();
-        var webViewStatus = diagnostics.FirstOrDefault(entry => entry.Code == DiagnosticCodes.WebViewHostInitialized) is null
-            ? "鏈娴嬪埌鍒濆鍖栬褰�"
-            : "宸插垵濮嬪寲";
+        _isRefreshing = true;
+        try
+        {
+            _state = await _runtime.GetStateAsync();
+            var api = _apiStatus.GetStatus();
+            var diagnostics = _diagnostics.Snapshot().OrderByDescending(entry => entry.Timestamp).ToArray();
+            var webViewStatus = diagnostics.FirstOrDefault(entry => entry.Code == DiagnosticCodes.WebViewHostInitialized) is null
+                ? "鏈娴嬪埌鍒濆鍖栬褰�"
+                : "宸插垵濮嬪寲";
 
-        StatusSummaryText.Text = $"鎻掍欢 {_state.Plugins.Count} 涓紝缁勪欢 {_state.Widgets.Count} 涓紝璇婃柇 {diagnostics.Length} 鏉�";
-        RuntimeText.Text = $"杩愯鏃讹細缂栬緫={_state.IsEditMode}锛屽畨鍏ㄨ緭鍏�={_state.IsSafeInputMode}锛屽叏灞�閿佸畾={_state.IsGlobalLocked}";
-        ApiText.Text = api.IsListening ? $"API锛�127.0.0.1:{api.Port}" : $"API锛氭湭鐩戝惉 {api.ErrorCode ?? ""}";
-        WallpaperText.Text = $"澹佺焊锛氬惎鐢�={_state.Wallpaper.IsEnabled}锛屾彃浠�={_state.Wallpaper.PluginId?.Value ?? "鏃�"}";
-        WebViewText.Text = $"WebView2锛歿webViewStatus}";
-        WallpaperDetailText.Text = $"鍚敤锛歿_state.Wallpaper.IsEnabled}\n鏆傚仠锛歿_state.Wallpaper.IsPaused}\n闈欓煶锛歿_state.Wallpaper.IsMuted}\n閫忔槑搴︼細{_state.Wallpaper.Opacity}\n鐐瑰嚮绌块�忥細{_state.Wallpaper.ClickThrough}";
-        EditModeButton.Content = _state.IsEditMode ? "閫�鍑虹紪杈�" : "杩涘叆缂栬緫";
-        SafeInputButton.Content = _state.IsSafeInputMode ? "閫�鍑哄畨鍏�" : "瀹夊叏杈撳叆";
-        GlobalLockButton.Content = _state.IsGlobalLocked ? "瑙i攣鍏ㄩ儴" : "閿佸畾鍏ㄩ儴";
+            StatusSummaryText.Text = $"鎻掍欢 {_state.Plugins.Count} 涓紝缁勪欢 {_state.Widgets.Count} 涓紝璇婃柇 {diagnostics.Length} 鏉�";
+            RuntimeText.Text = $"杩愯鏃讹細缂栬緫={_state.IsEditMode}锛屽畨鍏ㄨ緭鍏�={_state.IsSafeInputMode}锛屽叏灞�閿佸畾={_state.IsGlobalLocked}";
+            ApiText.Text = api.IsListening ? $"API锛�127.0.0.1:{api.Port}" : $"API锛氭湭鐩戝惉 {api.ErrorCode ?? ""}";
+            WallpaperText.Text = $"澹佺焊锛氬惎鐢�={_state.Wallpaper.IsEnabled}锛屾彃浠�={_state.Wallpaper.PluginId?.Value ?? "鏃�"}";
+            WebViewText.Text = $"WebView2锛歿webViewStatus}";
+            WallpaperDetailText.Text = $"鍚敤锛歿_state.Wallpaper.IsEnabled}\n鏆傚仠锛歿_state.Wallpaper.IsPaused}\n闈欓煶锛歿_state.Wallpaper.IsMuted}\n閫忔槑搴︼細{_state.Wallpaper.Opacity}\n鐐瑰嚮绌块�忥細{_state.Wallpaper.ClickThrough}";
+            EditModeButton.Content = _state.IsEditMode ? "閫�鍑虹紪杈�" : "杩涘叆缂栬緫";
+            SafeInputButton.Content = _state.IsSafeInputMode ? "閫�鍑哄畨鍏�" : "瀹夊叏杈撳叆";
+            GlobalLockButton.Content = _state.IsGlobalLocked ? "瑙i攣鍏ㄩ儴" : "閿佸畾鍏ㄩ儴";
 
-        var widgets = _state.Widgets.Select(WidgetRow.From).ToArray();
-        var selected = (WidgetSelector.SelectedItem as WidgetRow)?.InstanceId;
-        WidgetSelector.ItemsSource = widgets;
-        WidgetSelector.SelectedItem = widgets.FirstOrDefault(widget => widget.InstanceId == selected) ?? widgets.FirstOrDefault();
-        WidgetsGrid.ItemsSource = widgets;
-        DisplayLayerSelector.SelectedItem = (WidgetSelector.SelectedItem as WidgetRow)?.DisplayLayer ?? DisplayLayer.Desktop;
-        PluginsGrid.ItemsSource = _state.Plugins.Select(PluginRow.From).ToArray();
-        DiagnosticsGrid.ItemsSource = diagnostics.Select(DiagnosticRow.From).ToArray();
-        RecentDiagnosticsGrid.ItemsSource = diagnostics.Take(8).Select(DiagnosticRow.From).ToArray();
-        ManifestErrorsText.Text = BuildManifestErrorText(_state);
+            var widgets = _state.Widgets.Select(WidgetRow.From).ToArray();
+            var selected = (WidgetSelector.SelectedItem as WidgetRow)?.InstanceId;
+            WidgetSelector.ItemsSource = widgets;
+            WidgetSelector.SelectedItem = widgets.FirstOrDefault(widget => widget.InstanceId == selected) ?? widgets.FirstOrDefault();
+            WidgetsGrid.ItemsSource = widgets;
+            SyncDisplayLayerSelector(force: _selectedWidgetForDisplayLayer != (WidgetSelector.SelectedItem as WidgetRow)?.InstanceId);
+            PluginsGrid.ItemsSource = _state.Plugins.Select(PluginRow.From).ToArray();
+            DiagnosticsGrid.ItemsSource = diagnostics.Select(DiagnosticRow.From).ToArray();
+            RecentDiagnosticsGrid.ItemsSource = diagnostics.Take(8).Select(DiagnosticRow.From).ToArray();
+            ManifestErrorsText.Text = BuildManifestErrorText(_state);
+            LoadTodayLog();
+        }
+        finally
+        {
+            _isRefreshing = false;
+        }
     }
 
     private async void RefreshButton_Click(object sender, RoutedEventArgs e) => await RefreshAsync();
@@ -199,6 +211,12 @@
     private void OpenPluginsJson_Click(object sender, RoutedEventArgs e)
         => OpenJson(Path.Combine(_paths.ConfigDirectory, "plugins.json"));
 
+    private void OpenLogDirectory_Click(object sender, RoutedEventArgs e)
+    {
+        Directory.CreateDirectory(_paths.LogDirectory);
+        Process.Start(new ProcessStartInfo("explorer.exe", $"\"{_paths.LogDirectory}\"") { UseShellExecute = true });
+    }
+
     private void OpenPluginJson_Click(object sender, RoutedEventArgs e)
     {
         if ((PluginsGrid.SelectedItem as PluginRow) is not { } plugin)
@@ -228,6 +246,65 @@
 
     private WidgetRow? SelectedWidget() => WidgetSelector.SelectedItem as WidgetRow;
 
+    private void WidgetSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
+    {
+        if (!_isRefreshing)
+        {
+            SyncDisplayLayerSelector(force: true);
+        }
+    }
+
+    private void SyncDisplayLayerSelector(bool force)
+    {
+        if (SelectedWidget() is not { } widget)
+        {
+            DisplayLayerSelector.SelectedItem = DisplayLayer.Desktop;
+            _selectedWidgetForDisplayLayer = null;
+            return;
+        }
+
+        if (!force)
+        {
+            return;
+        }
+
+        DisplayLayerSelector.SelectedItem = widget.DisplayLayer;
+        _selectedWidgetForDisplayLayer = widget.InstanceId;
+    }
+
+    private void LoadTodayLog()
+    {
+        var logPath = Path.Combine(_paths.LogDirectory, $"moli-desktop-{DateTimeOffset.Now:yyyyMMdd}.log");
+        LogPathText.Text = logPath;
+        if (!File.Exists(logPath))
+        {
+            LogTextBox.Text = "褰撳ぉ鏆傛棤鏃ュ織銆�";
+            return;
+        }
+
+        try
+        {
+            var text = File.ReadAllText(logPath, Encoding.UTF8);
+            if (LogTextBox.Text == text)
+            {
+                return;
+            }
+
+            var wasNearBottom = LogTextBox.VerticalOffset >= LogTextBox.ExtentHeight - LogTextBox.ViewportHeight - 24;
+            LogTextBox.Text = text;
+            if (wasNearBottom)
+            {
+                LogTextBox.ScrollToEnd();
+            }
+        }
+        catch (IOException)
+        {
+        }
+        catch (UnauthorizedAccessException)
+        {
+        }
+    }
+
     private async Task InstallWallpaperFilePluginAsync(string fileName)
     {
         Directory.CreateDirectory(_paths.PluginDirectory);
diff --git a/src/Moli.Desktop/Runtime/RuntimeState.cs b/src/Moli.Desktop/Runtime/RuntimeState.cs
index 75401ba..d119a6f 100644
--- a/src/Moli.Desktop/Runtime/RuntimeState.cs
+++ b/src/Moli.Desktop/Runtime/RuntimeState.cs
@@ -1,6 +1,8 @@
 using Moli.Desktop.Diagnostics;
 using Moli.Desktop.Layout;
 using Moli.Desktop.Plugins;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
 
 namespace Moli.Desktop.Runtime;
 
@@ -42,6 +44,12 @@
 {
     private readonly object _gate = new();
     private readonly List<Func<RuntimeEvent, Task>> _handlers = [];
+    private readonly ILogger<RuntimeEventBus> _logger;
+
+    public RuntimeEventBus(ILogger<RuntimeEventBus>? logger = null)
+    {
+        _logger = logger ?? NullLogger<RuntimeEventBus>.Instance;
+    }
 
     public IDisposable Subscribe(Func<RuntimeEvent, Task> handler)
     {
@@ -61,6 +69,7 @@
 
     public async Task PublishAsync(RuntimeEvent runtimeEvent, CancellationToken cancellationToken = default)
     {
+        _logger.LogDebug("Runtime event published: {EventName}", runtimeEvent.Name);
         Func<RuntimeEvent, Task>[] handlers;
         lock (_gate)
         {
diff --git a/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs b/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs
index 0c8c988..e6f3e91 100644
--- a/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs
+++ b/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs
@@ -20,7 +20,14 @@
         "requestShow",
         "requestHide",
         "requestResize",
+        "llm.getConnectionMode",
         "llm.getModels",
+        "llm.getProjects",
+        "llm.getMemoryCapabilities",
+        "llm.getMemories",
+        "llm.createMemory",
+        "llm.deleteMemory",
+        "llm.recallMemories",
         "llm.streamChat",
         "llm.cancel"
     ];
@@ -78,17 +85,149 @@
             "requestShow" => await HandleEventAsync(request, context, "plugin.showRequested", cancellationToken).ConfigureAwait(false),
             "requestHide" => await HandleEventAsync(request, context, "plugin.hideRequested", cancellationToken).ConfigureAwait(false),
             "requestResize" => await HandleEventAsync(request, context, "plugin.resizeRequested", cancellationToken).ConfigureAwait(false),
-            "llm.getModels" => await HandleGetLlmModelsAsync(request, cancellationToken).ConfigureAwait(false),
+            "llm.getConnectionMode" => PluginBridgeResponse.Ok(request.Id ?? string.Empty, new { mode = ReadRuntimeConfig(context).Mode }),
+            "llm.getModels" => await HandleGetLlmModelsAsync(request, context, cancellationToken).ConfigureAwait(false),
+            "llm.getProjects" => await HandleGetAiChatProjectsAsync(request, context, cancellationToken).ConfigureAwait(false),
+            "llm.getMemoryCapabilities" => await HandleGetMemoryCapabilitiesAsync(request, context, cancellationToken).ConfigureAwait(false),
+            "llm.getMemories" => await HandleGetMemoriesAsync(request, context, cancellationToken).ConfigureAwait(false),
+            "llm.createMemory" => await HandleCreateMemoryAsync(request, context, cancellationToken).ConfigureAwait(false),
+            "llm.deleteMemory" => await HandleDeleteMemoryAsync(request, context, cancellationToken).ConfigureAwait(false),
+            "llm.recallMemories" => await HandleRecallMemoriesAsync(request, context, cancellationToken).ConfigureAwait(false),
             "llm.streamChat" => await HandleStreamLlmChatAsync(request, context, cancellationToken).ConfigureAwait(false),
             "llm.cancel" => await HandleCancelLlmChatAsync(request, cancellationToken).ConfigureAwait(false),
             _ => PluginBridgeResponse.Failure(request.Id, "BridgeMethodNotAllowed", $"Bridge method {request.Method} is not allowed.")
         };
     }
 
-    private async Task<PluginBridgeResponse> HandleGetLlmModelsAsync(BridgeRequest request, CancellationToken cancellationToken)
+    private async Task<PluginBridgeResponse> HandleGetLlmModelsAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
     {
-        var models = await _llmGateway.GetModelsAsync(cancellationToken).ConfigureAwait(false);
+        var models = await _llmGateway.GetModelsAsync(ReadRuntimeConfig(context), cancellationToken).ConfigureAwait(false);
         return PluginBridgeResponse.Ok(request.Id ?? string.Empty, models);
+    }
+
+    private async Task<PluginBridgeResponse> HandleGetAiChatProjectsAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        try
+        {
+            var projects = await _llmGateway.GetProjectsAsync(ReadRuntimeConfig(context), cancellationToken).ConfigureAwait(false);
+            return PluginBridgeResponse.Ok(request.Id ?? string.Empty, projects);
+        }
+        catch (AiChatClientException ex)
+        {
+            return PluginBridgeResponse.Failure(request.Id, ex.Code, ex.Message);
+        }
+    }
+
+    private async Task<PluginBridgeResponse> HandleGetMemoryCapabilitiesAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        try
+        {
+            var capabilities = await _llmGateway.GetMemoryCapabilitiesAsync(ReadRuntimeConfig(context), cancellationToken).ConfigureAwait(false);
+            return PluginBridgeResponse.Ok(request.Id ?? string.Empty, capabilities);
+        }
+        catch (AiChatClientException ex)
+        {
+            return PluginBridgeResponse.Failure(request.Id, ex.Code, ex.Message);
+        }
+    }
+
+    private async Task<PluginBridgeResponse> HandleGetMemoriesAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        var payload = DeserializePayload<AiChatGetMemoriesRequest>(request, out var error);
+        if (error is not null)
+        {
+            return error;
+        }
+
+        try
+        {
+            var result = await _llmGateway.GetMemoriesAsync(ReadRuntimeConfig(context), payload!, cancellationToken).ConfigureAwait(false);
+            return PluginBridgeResponse.Ok(request.Id ?? string.Empty, result.Data);
+        }
+        catch (AiChatClientException ex)
+        {
+            return PluginBridgeResponse.Failure(request.Id, ex.Code, ex.Message);
+        }
+    }
+
+    private async Task<PluginBridgeResponse> HandleCreateMemoryAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        var payload = DeserializePayload<AiChatCreateMemoryRequest>(request, out var error);
+        if (error is not null)
+        {
+            return error;
+        }
+
+        try
+        {
+            var result = await _llmGateway.CreateMemoryAsync(ReadRuntimeConfig(context), payload!, cancellationToken).ConfigureAwait(false);
+            return PluginBridgeResponse.Ok(request.Id ?? string.Empty, result.Data);
+        }
+        catch (AiChatClientException ex)
+        {
+            return PluginBridgeResponse.Failure(request.Id, ex.Code, ex.Message);
+        }
+    }
+
+    private async Task<PluginBridgeResponse> HandleDeleteMemoryAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        if (request.Params.ValueKind is not JsonValueKind.Object ||
+            !request.Params.TryGetProperty("memoryId", out var memoryIdElement) ||
+            memoryIdElement.ValueKind != JsonValueKind.String ||
+            string.IsNullOrWhiteSpace(memoryIdElement.GetString()))
+        {
+            return PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", "memoryId is required.");
+        }
+
+        try
+        {
+            await _llmGateway.DeleteMemoryAsync(ReadRuntimeConfig(context), memoryIdElement.GetString()!, cancellationToken).ConfigureAwait(false);
+            return PluginBridgeResponse.Ok(request.Id ?? string.Empty, new { accepted = true });
+        }
+        catch (AiChatClientException ex)
+        {
+            return PluginBridgeResponse.Failure(request.Id, ex.Code, ex.Message);
+        }
+    }
+
+    private async Task<PluginBridgeResponse> HandleRecallMemoriesAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        var payload = DeserializePayload<AiChatRecallMemoriesRequest>(request, out var error);
+        if (error is not null)
+        {
+            return error;
+        }
+
+        try
+        {
+            var result = await _llmGateway.RecallMemoriesAsync(ReadRuntimeConfig(context), payload!, cancellationToken).ConfigureAwait(false);
+            return PluginBridgeResponse.Ok(request.Id ?? string.Empty, result.Data);
+        }
+        catch (AiChatClientException ex)
+        {
+            return PluginBridgeResponse.Failure(request.Id, ex.Code, ex.Message);
+        }
     }
 
     private Task<PluginBridgeResponse> HandleStreamLlmChatAsync(
@@ -127,9 +266,12 @@
             RequestId = requestId,
             PluginId = context.RuntimeInfo.PluginId,
             InstanceId = context.HostId,
+            Mode = string.IsNullOrWhiteSpace(payload.Mode) ? ReadRuntimeConfig(context).Mode : payload.Mode!,
+            ProjectId = payload.ProjectId,
             ModelId = payload.ModelId,
             Messages = payload.Messages,
-            Options = payload.Options ?? new LlmRequestOptions()
+            Options = payload.Options ?? new LlmRequestOptions(),
+            RuntimeConfig = ReadRuntimeConfig(context)
         };
 
         _ = Task.Run(() => PumpLlmStreamAsync(chatRequest, context, CancellationToken.None));
@@ -212,6 +354,54 @@
     private static bool HasPermission(PluginBridgeContext context, string permission)
         => context.Manifest.Permissions.Any(item => string.Equals(item, permission, StringComparison.OrdinalIgnoreCase));
 
+    private T? DeserializePayload<T>(BridgeRequest request, out PluginBridgeResponse? error)
+    {
+        error = null;
+        if (request.Params.ValueKind is not JsonValueKind.Object)
+        {
+            error = PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", $"{request.Method} expects an object payload.");
+            return default;
+        }
+
+        try
+        {
+            return request.Params.Deserialize<T>(_jsonOptions);
+        }
+        catch (JsonException)
+        {
+            error = PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", $"{request.Method} payload could not be parsed.");
+            return default;
+        }
+    }
+
+    private LlmPluginRuntimeConfig ReadRuntimeConfig(PluginBridgeContext context)
+    {
+        if (context.Config.ValueKind is not JsonValueKind.Object)
+        {
+            return new LlmPluginRuntimeConfig();
+        }
+
+        try
+        {
+            var config = context.Config.Deserialize<LlmPluginRuntimeConfig>(_jsonOptions) ?? new LlmPluginRuntimeConfig();
+            if (string.IsNullOrWhiteSpace(config.Mode))
+            {
+                config = config with { Mode = LlmConnectionModes.ProviderDirect };
+            }
+
+            if (config.AiChat is null)
+            {
+                config = config with { AiChat = new AiChatRuntimeConfig() };
+            }
+
+            return config;
+        }
+        catch (JsonException)
+        {
+            return new LlmPluginRuntimeConfig();
+        }
+    }
+
     private sealed record BridgeRequest
     {
         public string? Id { get; init; }
@@ -222,6 +412,8 @@
     private sealed record LlmBridgeStreamRequest
     {
         public string? RequestId { get; init; }
+        public string? Mode { get; init; }
+        public string? ProjectId { get; init; }
         public required string ModelId { get; init; }
         public IReadOnlyList<LlmMessage> Messages { get; init; } = [];
         public LlmRequestOptions? Options { get; init; }
diff --git a/src/Moli.Desktop/WebView/PluginBridgeScript.cs b/src/Moli.Desktop/WebView/PluginBridgeScript.cs
index d483fdf..a6963bf 100644
--- a/src/Moli.Desktop/WebView/PluginBridgeScript.cs
+++ b/src/Moli.Desktop/WebView/PluginBridgeScript.cs
@@ -39,7 +39,14 @@
             requestHide: () => call("requestHide"),
             requestResize: (size) => call("requestResize", size),
             llm: Object.freeze({
+              getConnectionMode: () => call("llm.getConnectionMode"),
               getModels: () => call("llm.getModels"),
+              getProjects: () => call("llm.getProjects"),
+              getMemoryCapabilities: () => call("llm.getMemoryCapabilities"),
+              getMemories: (options) => call("llm.getMemories", options || {}),
+              createMemory: (input) => call("llm.createMemory", input),
+              deleteMemory: (memoryId) => call("llm.deleteMemory", { memoryId }),
+              recallMemories: (input) => call("llm.recallMemories", input),
               streamChat: (request) => call("llm.streamChat", request),
               cancel: (requestId) => call("llm.cancel", { requestId }),
               onDelta: (handler) => on("moli:llm-delta", handler),
diff --git a/src/Moli.Desktop/Windows/RuntimeSurfaceController.cs b/src/Moli.Desktop/Windows/RuntimeSurfaceController.cs
index ca24bb8..00fd78c 100644
--- a/src/Moli.Desktop/Windows/RuntimeSurfaceController.cs
+++ b/src/Moli.Desktop/Windows/RuntimeSurfaceController.cs
@@ -1,4 +1,5 @@
 using System.Windows;
+using System.Text.Json;
 using Microsoft.Extensions.DependencyInjection;
 using Moli.Desktop.Configuration;
 using Moli.Desktop.Diagnostics;
@@ -21,11 +22,13 @@
     private readonly DesktopPaths _paths;
     private readonly IDiagnosticsService _diagnostics;
     private readonly IServiceProvider _services;
+    private readonly IRuntimeEventBus _events;
     private readonly Dictionary<WidgetInstanceId, WidgetWindow> _widgets = [];
     private WallpaperWindow? _wallpaper;
     private WallpaperRuntimeState _wallpaperState = new();
     private bool _editMode;
     private bool _safeInputMode;
+    private IDisposable? _eventSubscription;
 
     public RuntimeSurfaceController(
         IPluginManager plugins,
@@ -33,7 +36,8 @@
         IWebViewHostFactory webViews,
         DesktopPaths paths,
         IDiagnosticsService diagnostics,
-        IServiceProvider services)
+        IServiceProvider services,
+        IRuntimeEventBus events)
     {
         _plugins = plugins;
         _interop = interop;
@@ -41,6 +45,8 @@
         _paths = paths;
         _diagnostics = diagnostics;
         _services = services;
+        _events = events;
+        _eventSubscription = _events.Subscribe(HandleRuntimeEventAsync);
     }
 
     public Task ApplyEditModeAsync(bool enabled, CancellationToken cancellationToken = default)
@@ -127,6 +133,7 @@
             _wallpaper.Show();
             await _wallpaper.LoadAsync(wallpaper, cancellationToken).ConfigureAwait(true);
             _wallpaper.ApplyState(wallpaper, _safeInputMode);
+            ReapplyDesktopWidgetLayers();
         });
 
     public Task DisableWallpaperAsync(CancellationToken cancellationToken = default)
@@ -149,6 +156,8 @@
             _widgets.Clear();
             _wallpaper?.Close();
             _wallpaper = null;
+            _eventSubscription?.Dispose();
+            _eventSubscription = null;
             return Task.CompletedTask;
         });
 
@@ -161,6 +170,72 @@
         await runtime.UpdateWidgetLayoutAsync(instanceId, patch, cancellationToken).ConfigureAwait(true);
     }
 
+    private void ReapplyDesktopWidgetLayers()
+    {
+        foreach (var widget in _widgets.Values.Where(widget => widget.CurrentLayout.DisplayLayer == DisplayLayer.Desktop))
+        {
+            widget.ApplyLayout(widget.CurrentLayout, _editMode, _safeInputMode);
+        }
+    }
+
+    private Task HandleRuntimeEventAsync(RuntimeEvent runtimeEvent)
+    {
+        if (!string.Equals(runtimeEvent.Name, "plugin.resizeRequested", StringComparison.OrdinalIgnoreCase) ||
+            runtimeEvent.Payload is null)
+        {
+            return Task.CompletedTask;
+        }
+
+        return OnUiThreadAsync(() =>
+        {
+            try
+            {
+                var json = JsonSerializer.Serialize(runtimeEvent.Payload, new JsonSerializerOptions(JsonSerializerDefaults.Web));
+                using var document = JsonDocument.Parse(json);
+                var root = document.RootElement;
+                if (!root.TryGetProperty("hostId", out var hostIdElement))
+                {
+                    return Task.CompletedTask;
+                }
+
+                var hostId = hostIdElement.GetString();
+                var widget = _widgets.Values.FirstOrDefault(item => string.Equals(item.HostId, hostId, StringComparison.OrdinalIgnoreCase));
+                if (widget is null ||
+                    !root.TryGetProperty("params", out var parameters) ||
+                    parameters.ValueKind != JsonValueKind.Object)
+                {
+                    return Task.CompletedTask;
+                }
+
+                var width = TryReadPositiveDouble(parameters, "width");
+                var height = TryReadPositiveDouble(parameters, "height");
+                widget.ApplyRequestedSize(width, height);
+            }
+            catch (JsonException ex)
+            {
+                _diagnostics.Record(
+                    DiagnosticSeverity.Warning,
+                    "PluginResizeRequestInvalid",
+                    "Plugin resize request payload could not be parsed.",
+                    new Dictionary<string, string> { ["exception"] = ex.GetType().Name });
+            }
+
+            return Task.CompletedTask;
+        });
+    }
+
+    private static double? TryReadPositiveDouble(JsonElement parameters, string propertyName)
+    {
+        if (!parameters.TryGetProperty(propertyName, out var value))
+        {
+            return null;
+        }
+
+        return value.ValueKind == JsonValueKind.Number && value.TryGetDouble(out var number) && number > 0
+            ? number
+            : null;
+    }
+
     private static async Task OnUiThreadAsync(Func<Task> action)
     {
         var dispatcher = Application.Current?.Dispatcher;
diff --git a/src/Moli.Desktop/Windows/WidgetWindow.cs b/src/Moli.Desktop/Windows/WidgetWindow.cs
index 18fecbc..ed232bc 100644
--- a/src/Moli.Desktop/Windows/WidgetWindow.cs
+++ b/src/Moli.Desktop/Windows/WidgetWindow.cs
@@ -33,6 +33,7 @@
     private readonly Border _editBorder;
     private readonly Border _resizeGrip;
     private WidgetLayout _layout;
+    private double? _requestedHeight;
     private bool _editMode;
     private bool _safeInputMode;
     private Point? _dragStart;
@@ -98,6 +99,10 @@
 
     public WidgetInstanceId InstanceId => _layout.InstanceId;
 
+    public WidgetLayout CurrentLayout => _layout;
+
+    public string HostId => _webView.HostId;
+
     public async Task LoadAsync(CancellationToken cancellationToken = default)
     {
         ApplyLayout(_layout, _editMode, _safeInputMode);
@@ -123,7 +128,7 @@
         Left = layout.Bounds.X;
         Top = layout.Bounds.Y;
         Width = layout.Bounds.Width;
-        Height = layout.Bounds.Height;
+        Height = Math.Max(layout.Bounds.Height, _requestedHeight ?? layout.Bounds.Height);
         Opacity = Math.Clamp(layout.Opacity, 0.1, 1.0);
         Visibility = layout.IsVisible ? Visibility.Visible : Visibility.Hidden;
         Topmost = layout.DisplayLayer == DisplayLayer.GlobalTop;
@@ -132,6 +137,20 @@
         ApplyWin32Styles();
     }
 
+    public void ApplyRequestedSize(double? width, double? height)
+    {
+        if (width is > 0)
+        {
+            Width = Math.Max(LayoutManager.MinWidth, width.Value);
+        }
+
+        _requestedHeight = height is > 0 && height.Value > _layout.Bounds.Height
+            ? height.Value
+            : null;
+        Height = Math.Max(_layout.Bounds.Height, _requestedHeight ?? _layout.Bounds.Height);
+        ApplyWin32Styles();
+    }
+
     public Task SetEditModeAsync(bool enabled, CancellationToken cancellationToken = default)
     {
         ApplyLayout(_layout, enabled, _safeInputMode);

--
Gitblit v1.9.1