From b3bde921167ee0a7dc21cf7e3d642840a0fcc11e Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期一, 04 五月 2026 18:55:57 +0800
Subject: [PATCH] 增加LLM对话插件

---
 src/Moli.Desktop/Llm/LlmModels.cs                             |  122 ++
 .ai/workflows/dev-workflow.md                                 |   40 
 docs/product/llm-command-palette-plugin-prd.md                |   94 +
 src/Moli.Desktop/Llm/LlmGatewayService.cs                     |  243 ++++
 src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs |   89 +
 docs/ops/user-manual.md                                       |   26 
 src/Moli.Desktop/WebView/PluginBridgeScript.cs                |   15 
 src/Moli.Desktop/Host/DefaultContentInstaller.cs              |   27 
 docs/README.md                                                |    4 
 docs/ops/user-manual/plugins/sample.clock.md                  |   58 +
 src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs           |   87 +
 src/Moli.Desktop/Llm/OpenAICompatibleAdapter.cs               |  139 ++
 .ai/agents/qa-agent.md                                        |    4 
 .ai/agents/dev-agent.md                                       |    3 
 samples/plugins/sample.llm-command-palette/index.html         |  273 +++++
 docs/ops/user-manual/plugins/sample.llm-command-palette.md    |  198 +++
 .ai/agents/product-agent.md                                   |    3 
 src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs            |  114 ++
 src/Moli.Desktop/WebView/WebViewHost.cs                       |   40 
 samples/plugins/sample.llm-command-palette/plugin.json        |   28 
 src/Moli.Desktop/Llm/LlmProviderAdapterFactory.cs             |   31 
 src/Moli.Desktop/Llm/LlmModelRegistry.cs                      |  205 ++++
 src/Moli.Desktop/Host/DesktopHostBuilder.cs                   |    7 
 docs/ops/user-manual/plugins/sample.system-info.md            |   58 +
 docs/ops/user-manual/plugins/sample.audio-visualizer.md       |   77 +
 docs/ops/user-manual/plugins/sample.webview-test.md           |   47 
 docs/qa/llm-command-palette-acceptance-2026-05-04.md          |   65 +
 docs/architecture/llm-command-palette-architecture.md         |  613 ++++++++++++
 src/Moli.Desktop/Llm/ILlmServices.cs                          |   37 
 docs/ops/user-manual/moli-desktop.md                          |   41 
 docs/ops/user-manual/plugins/sample.wallpaper.md              |   59 +
 src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs          |  143 ++
 src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs            |   25 
 33 files changed, 2,958 insertions(+), 57 deletions(-)

diff --git a/.ai/agents/dev-agent.md b/.ai/agents/dev-agent.md
index b2f8dbb..f64e0e5 100644
--- a/.ai/agents/dev-agent.md
+++ b/.ai/agents/dev-agent.md
@@ -17,6 +17,7 @@
 - 妯″潡鎴栨彃浠跺疄鐜�
 - 閰嶇疆鏂囦欢銆佹帴鍙e畾涔夊拰蹇呰鑴氭湰
 - 鏈湴杩愯璇存槑
+- 鍔熻兘鎴栨彃浠跺紑鍙�/璋冩暣鍚庣殑鐢ㄦ埛鎿嶄綔鎵嬪唽鏇存柊锛屼紭鍏堢淮鎶� `docs/product/user-manual.md` 涓� `docs/product/user-manual/`
 - 鍙樻洿璇存槑
 - 宸叉墽琛岀殑楠岃瘉鍛戒护鍜岀粨鏋�
 
@@ -26,7 +27,7 @@
 - 褰撳彂鐜扮幇鏈夋灦鏋勬棤娉曟敮鎾戦渶姹傛垨闇�瑕佽皟鏁存ā鍧楄竟鐣屾椂锛岃皟鐢� `architect-agent`銆�
 - 褰撴秹鍙婃寔涔呭寲缁撴瀯銆侀厤缃� schema 鎴栨暟鎹縼绉绘椂锛岃皟鐢� `dba-agent`銆�
 - 褰撻渶瑕佹祴璇曠敤渚嬨�侀獙鏀堕獙璇佹垨缂洪櫡澶嶇幇鏃讹紝璋冪敤 `qa-agent`銆�
+- 褰撳姛鑳芥垨鎻掍欢鍙樻洿褰卞搷瀹夎銆佸惎鍔ㄣ�侀厤缃�佷氦浜掋�佹晠闅滄帓鏌ユ垨鐢ㄦ埛鍙闄愬埗鏃讹紝鍦ㄦ彁浜ょ粰 QA 鍓嶈ˉ鍏呮垨鏇存柊鎿嶄綔鎵嬪唽锛涘鏃犵敤鎴峰彲瑙佸彉鍖栵紝鍦ㄥ疄鐜拌鏄庝腑娉ㄦ槑鏃犻渶鏇存柊鎵嬪唽鐨勫師鍥犮��
 - 褰撻渶瑕佺敓鎴愭垨淇敼浠g爜鏃讹紝浣跨敤 `codegen-skill`銆�
 - 褰撳紑鍙戞彃浠躲�佹彃浠跺崗璁垨鎻掍欢閰嶇疆鑳藉姏鏃讹紝浣跨敤 `plugin-skill`銆�
 - 褰撳畾浣嶈繍琛岄敊璇�佹瀯寤哄け璐ャ�乄ebView2 寮傚父鎴栫獥鍙h涓洪棶棰樻椂锛屼娇鐢� `debug-skill`銆�
-
diff --git a/.ai/agents/product-agent.md b/.ai/agents/product-agent.md
index e578c0d..c06a73e 100644
--- a/.ai/agents/product-agent.md
+++ b/.ai/agents/product-agent.md
@@ -19,6 +19,7 @@
 - 鍔熻兘浼樺厛绾�
 - 闈炲姛鑳介渶姹�
 - 楠屾敹鏍囧噯
+- 鐢ㄦ埛鎿嶄綔鎵嬪唽褰卞搷鑼冨洿锛岃鏄庢柊澧炴垨璋冩暣鐨勭敤鎴锋祦绋嬨�侀厤缃」銆侀檺鍒跺拰鏁呴殰鎺掓煡淇℃伅
 - 寰呮緞娓呴棶棰樻竻鍗�
 
 ## decision
@@ -27,6 +28,6 @@
 - 褰撻渶姹傞渶瑕佹媶瑙d负寮�鍙戜换鍔°�佷唬鐮佺敓鎴愭垨鎺ュ彛瀹氫箟鏃讹紝璋冪敤 `dev-agent`銆�
 - 褰撻渶姹傛秹鍙婇厤缃寔涔呭寲銆佹彃浠舵暟鎹粨鏋勩�佽縼绉绘垨瀛樺偍绛栫暐鏃讹紝璋冪敤 `dba-agent`銆�
 - 褰撻渶姹傞渶瑕侀獙鏀舵爣鍑嗐�佹祴璇曠煩闃垫垨鍥炲綊绛栫暐鏃讹紝璋冪敤 `qa-agent`銆�
+- 褰撻渶姹備細鏀瑰彉鐢ㄦ埛鍙鐨勫姛鑳姐�佹彃浠舵搷浣溿�侀厤缃垨闄愬埗鏃讹紝瑕佹眰鍚庣画寮�鍙戝畬鎴愬悗鍚屾鏇存柊鎿嶄綔鎵嬪唽銆�
 - 褰撻渶瑕佹暣鐞� PRD 鏃讹紝浣跨敤 `prd-skill`銆�
 - 褰撻渶姹備笌鎻掍欢鑳藉姏銆佹彃浠惰鑼冩垨妗岄潰鎸備欢浣撻獙鐩稿叧鏃讹紝浣跨敤 `plugin-skill`銆�
-
diff --git a/.ai/agents/qa-agent.md b/.ai/agents/qa-agent.md
index 7bf770e..cb7bf2f 100644
--- a/.ai/agents/qa-agent.md
+++ b/.ai/agents/qa-agent.md
@@ -9,6 +9,7 @@
 - Product Agent 杈撳嚭鐨勯獙鏀舵爣鍑�
 - Architect Agent 杈撳嚭鐨勬灦鏋勫拰椋庨櫓鐐�
 - Dev Agent 杈撳嚭鐨勫疄鐜拌鏄庛�佽繍琛屾柟寮忓拰鍙樻洿娓呭崟
+- 鍔熻兘鎴栨彃浠跺彉鏇村搴旂殑鐢ㄦ埛鎿嶄綔鎵嬪唽鏇存柊锛屾垨鏃犻渶鏇存柊鎵嬪唽鐨勮鏄�
 - 缂洪櫡鎶ュ憡銆佹棩蹇椼�佹埅鍥俱�佸綍灞忔垨鐢ㄦ埛鍙嶉
 
 ## output
@@ -18,6 +19,7 @@
 - 楠屾敹缁撴灉
 - 缂洪櫡鎶ュ憡
 - 鍥炲綊娴嬭瘯娓呭崟
+- 鐢ㄦ埛鎿嶄綔鎵嬪唽涓�鑷存�ф鏌ョ粨鏋�
 - 鍙戝竷椋庨櫓璇勪及
 
 ## decision
@@ -25,7 +27,7 @@
 - 褰撻獙鏀舵爣鍑嗕笉鏄庣‘鎴栨祴璇曟湡鏈涗笌闇�姹傚啿绐佹椂锛岃皟鐢� `product-agent`銆�
 - 褰撻棶棰樺彲鑳芥簮浜庢灦鏋勮璁°�佹ā鍧楄竟鐣屾垨鎶�鏈柟妗堟椂锛岃皟鐢� `architect-agent`銆�
 - 褰撻渶瑕佷慨澶嶇己闄枫�佽ˉ鍏呮棩蹇楁垨澧炲姞鍙祴璇曟�т唬鐮佹椂锛岃皟鐢� `dev-agent`銆�
+- 褰撳姛鑳芥垨鎻掍欢宸插彉鏇翠絾鎿嶄綔鎵嬪唽缂哄け銆佽繃鏈熸垨涓庡疄闄呰涓轰笉涓�鑷存椂锛岄��鍥� `dev-agent` 鎴� `product-agent` 琛ュ厖鎵嬪唽銆�
 - 褰撻棶棰樻秹鍙婇厤缃鍐欍�佽縼绉汇�佸巻鍙叉暟鎹吋瀹规垨榛樿鍊兼椂锛岃皟鐢� `dba-agent`銆�
 - 褰撹璁℃祴璇曠煩闃点�佹祴璇曡剼鏈垨楠屾敹鍛戒护鏃讹紝浣跨敤 `test-skill`銆�
 - 褰撳鐜板拰瀹氫綅缂洪櫡鏃讹紝浣跨敤 `debug-skill`銆�
-
diff --git a/.ai/workflows/dev-workflow.md b/.ai/workflows/dev-workflow.md
index be4f7f3..1196650 100644
--- a/.ai/workflows/dev-workflow.md
+++ b/.ai/workflows/dev-workflow.md
@@ -15,16 +15,19 @@
   Product["Product\nproduct-agent + prd-skill"]
   Architect["Architect\narchitect-agent + arch-skill + plugin-skill"]
   Dev["Dev\ndev-agent + codegen-skill + plugin-skill + debug-skill"]
+  Docs["Manual Update\ndev-agent + product-agent"]
   QA["QA\nqa-agent + test-skill + debug-skill"]
   Review["Review\nall agents"]
 
   Product --> Architect
   Architect --> Dev
-  Dev --> QA
+  Dev --> Docs
+  Docs --> QA
   QA --> Review
   Review --> Product
   Review --> Architect
   Review --> Dev
+  Review --> Docs
 ```
 
 ## steps
@@ -44,6 +47,7 @@
   - PRD
   - user stories
   - acceptance criteria
+  - user manual impact scope when the change affects user-visible flows
   - open questions
 - next:
   - send PRD to `architect-agent`
@@ -84,9 +88,28 @@
   - local verification results
   - implementation notes
 - next:
-  - send completed implementation and verification notes to `qa-agent`
+  - send completed implementation and verification notes to Manual Update
 
-### 4. QA
+### 4. Manual Update
+
+- agent:
+  - `dev-agent` for implementation-aligned operation steps
+  - `product-agent` when the wording, user scenario, or product boundary needs clarification
+- skills:
+  - `plugin-skill` when updating plugin operation docs
+  - `prd-skill` when user-facing behavior or positioning needs product confirmation
+- input:
+  - completed code, configuration, script, or plugin changes from `dev-agent`
+  - PRD acceptance criteria and user scenarios from `product-agent`
+  - existing user manual files under `docs/product/user-manual.md` and `docs/product/user-manual/`
+- output:
+  - updated user operation manual for new or changed functionality
+  - updated plugin operation manual when plugin behavior, configuration, startup, interaction, or troubleshooting changes
+  - documentation notes covering unchanged-manual decisions when no user-facing behavior changed
+- next:
+  - send implementation notes, verification notes, and manual changes to `qa-agent`
+
+### 5. QA
 
 - agent: `qa-agent`
 - skills:
@@ -96,18 +119,21 @@
   - PRD acceptance criteria
   - architecture risk points
   - Dev Agent implementation notes
+  - user operation manual changes or unchanged-manual rationale
   - changed files and build output
 - output:
   - test plan
   - test cases
   - defect report
   - regression result
+  - manual consistency result
   - release recommendation
 - next:
   - send pass or fail result to Review
   - route defects back to `dev-agent`
+  - route missing or inaccurate operation manual content back to Manual Update
 
-### 5. Review
+### 6. Review
 
 - agent:
   - `product-agent`
@@ -126,6 +152,7 @@
   - PRD
   - architecture design
   - implementation summary
+  - user operation manual changes
   - test results
   - known risks
 - output:
@@ -139,6 +166,8 @@
 - If the requirement is unclear, return to `product-agent`.
 - If module boundaries, runtime model, or technical risks change, return to `architect-agent`.
 - If implementation fails or defects are confirmed, return to `dev-agent`.
+- If a completed feature or plugin change affects user-visible operation, configuration, startup, interaction, troubleshooting, or known limitations, update the operation manual before QA.
+- If manual content is missing, outdated, or inconsistent with actual behavior, return to Manual Update.
 - If persistence schema, migration, default values, or compatibility is involved, call `dba-agent`.
 - If release confidence is low, return to `qa-agent` for expanded verification.
 
@@ -153,10 +182,11 @@
 
 ## Development Output
 
+## Manual Update Output
+
 ## QA Output
 
 ## Review Decision
 
 ## Follow Up Tasks
 ```
-
diff --git a/docs/README.md b/docs/README.md
index 392374c..8d5b594 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -15,13 +15,14 @@
 ## 褰撳墠浜у搧鏂囨。
 
 - [Windows 11 妗岄潰澧炲己搴旂敤 PRD](product/desktop-enhancement-prd.md)
-- [Moli.Desktop 鐢ㄦ埛鎿嶄綔鎵嬪唽](product/user-manual.md)
+- [Moli.Desktop 鐢ㄦ埛鎵嬪唽绱㈠紩](product/user-manual.md)
 - [LLM 妗岄潰杈撳叆鎻掍欢 PRD](product/llm-command-palette-plugin-prd.md)
 
 ## 褰撳墠鏋舵瀯鏂囨。
 
 - [Moli.Desktop Runtime 鏋舵瀯璁捐](architecture/runtime-architecture.md)
 - [Moli.Desktop MVP 璇︾粏璁捐](architecture/detailed-design.md)
+- [LLM 妗岄潰杈撳叆鎻掍欢鏋舵瀯璁捐](architecture/llm-command-palette-architecture.md)
 
 ## 褰撳墠寮�鍙戞枃妗�
 
@@ -39,6 +40,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)
 
 ## 褰撳墠杩愮淮鏂囨。
 
diff --git a/docs/architecture/llm-command-palette-architecture.md b/docs/architecture/llm-command-palette-architecture.md
new file mode 100644
index 0000000..d4b445b
--- /dev/null
+++ b/docs/architecture/llm-command-palette-architecture.md
@@ -0,0 +1,613 @@
+# Architecture: LLM Command Palette Plugin
+
+## Context
+
+鏈枃妗e熀浜� `docs/product/llm-command-palette-plugin-prd.md`锛屼负 LLM 妗岄潰杈撳叆鎻掍欢璁捐杩愯鏃舵灦鏋勩�佹ā鍧楄竟鐣屻�侀厤缃ā鍨嬨�佹祦寮忚皟鐢ㄩ摼璺拰瀹炵幇鎷嗗垎銆�
+
+Moli.Desktop 宸插叿澶� WebView2 灏忕粍浠剁獥鍙c�佹彃浠� manifest銆佸竷灞�鎸佷箙鍖栥�佹湰鍦� HTTP API銆乄ebSocket 浜嬩欢鍜� `window.moliDesktop` 妗ユ帴鑳藉姏銆侺LM 鎻掍欢搴斿鐢ㄨ繖浜涘熀纭�璁炬柦锛屽苟鏂板涓�灞傚涓讳晶 LLM 浠g悊鑳藉姏锛岀敤浜庢寜 `modelId` 璺敱鍒颁笉鍚屼緵搴斿晢鍜屼笉鍚� endpoint銆�
+
+鏍稿績鏋舵瀯鍐崇瓥锛�
+
+- 鎻掍欢鍓嶇鍙礋璐h緭鍏ャ�佹ā鍨嬮�夋嫨鍜屾祦寮忔覆鏌撱��
+- 鎻掍欢鍓嶇鍙紶 `modelId`銆乣messages` 鍜岃姹傚弬鏁帮紝涓嶇洿鎺ヤ紶 provider銆乪ndpoint 鎴� API key銆�
+- 瀹夸富缁存姢 LLM 妯″瀷娉ㄥ唽琛紝姣忎釜妯″瀷鍙嫭绔嬮厤缃� `provider`銆乣endpoint`銆乣authRef` 鍜� `apiModel`銆�
+- 瀹夸富鎸� `modelId` 閫夋嫨 provider adapter锛屽苟鎶婁笉鍚屼緵搴斿晢鐨勬祦寮忓搷搴旂粺涓�杞崲鎴愭彃浠跺彲娑堣垂鐨勪簨浠躲��
+- API key 涓嶈繘鍏ユ彃浠跺墠绔祫婧愩�乵anifest 绀轰緥鎴栨櫘閫氭棩蹇椼��
+
+## Goals
+
+- 鏀寔涓�涓《閮ㄥ眳涓殑 LLM 杈撳叆灏忕粍浠讹紝榛樿浣滀负 `widget` 鎻掍欢杩愯銆�
+- 鏀寔澶氫緵搴斿晢銆佸 endpoint銆佸妯″瀷鍏卞瓨銆�
+- 鏀寔 OpenAI-compatible銆丏eepSeek銆佹湰鍦� OpenAI-compatible 鏈嶅姟锛屽悗缁彲鎵╁睍 Anthropic銆丱llama 绛夐�傞厤鍣ㄣ��
+- 鏀寔娴佸紡杈撳嚭锛屽苟灏嗕緵搴斿晢宸紓灞忚斀鍦ㄥ涓讳晶銆�
+- 淇濇寔鎻掍欢绯荤粺杈圭晫锛歐ebView 椤甸潰鍙闂櫧鍚嶅崟妗ユ帴 API銆�
+- 閰嶇疆鍜屽瘑閽ヨ竟鐣屾竻鏅帮紝渚夸簬鍚庣画绠$悊绐楀彛鍜屾暟鎹縼绉荤户缁墿灞曘��
+
+## Non Goals
+
+- 涓嶅疄鐜板畬鏁磋亰澶╀細璇濈郴缁熴��
+- 涓嶅疄鐜颁簯绔悓姝ャ�佸洟闃熷叡浜ā鍨嬮厤缃垨璁¤垂绯荤粺銆�
+- 涓嶅湪鎻掍欢鍓嶇鐩存帴淇濆瓨鎴栫鐞� API key銆�
+- 涓嶅湪 MVP 涓疄鐜版枃浠朵笂浼犮�佸妯℃�佽緭鍏ユ垨闀挎湡鍘嗗彶璁板綍銆�
+- 涓嶈姹傛妸 LLM 浠g悊鏆撮湶鎴愬叕缃� API銆�
+
+## Module Design
+
+### Module Overview
+
+```mermaid
+flowchart TB
+  Plugin["sample.llm-command-palette WebView"]
+  Bridge["PluginBridgeScript / WebViewHost"]
+  Runtime["DesktopRuntimeCoordinator"]
+  LlmService["LlmGatewayService"]
+  Registry["LlmModelRegistry"]
+  SecretStore["CredentialStore"]
+  AdapterFactory["LlmProviderAdapterFactory"]
+  OpenAI["OpenAICompatibleAdapter"]
+  DeepSeek["DeepSeekAdapter"]
+  Local["LocalOpenAICompatibleAdapter"]
+  Config["ConfigurationService"]
+  Events["RuntimeEventBus"]
+  Diagnostics["DiagnosticsService"]
+
+  Plugin --> Bridge
+  Bridge --> Runtime
+  Runtime --> LlmService
+  LlmService --> Registry
+  Registry --> Config
+  LlmService --> SecretStore
+  LlmService --> AdapterFactory
+  AdapterFactory --> OpenAI
+  AdapterFactory --> DeepSeek
+  AdapterFactory --> Local
+  LlmService --> Events
+  LlmService --> Diagnostics
+  Bridge --> Plugin
+```
+
+### Responsibilities
+
+| 妯″潡 | 鑱岃矗 | 涓嶈礋璐� |
+| --- | --- | --- |
+| `sample.llm-command-palette` | 杈撳叆銆佹ā鍨嬩笅鎷夈�丒nter 鎻愪氦銆佹祦寮忔枃鏈覆鏌撱�侀敊璇睍绀� | 渚涘簲鍟� API 閫傞厤銆佸瘑閽ヨ鍙� |
+| `PluginBridgeScript` | 鍚� WebView 娉ㄥ叆 `window.moliDesktop.llm` API锛屽鐞� Promise 涓庝簨浠舵淳鍙� | 鐩存帴鍙戣捣澶栭儴 HTTP 璇锋眰 |
+| `DesktopRuntimeCoordinator` | 缁熶竴鎺ユ敹鎻掍欢妗ユ帴鍛戒护锛屾牎楠屾彃浠跺疄渚嬪拰鏉冮檺锛岃皟鐢� LLM 鏈嶅姟 | 瑙f瀽渚涘簲鍟嗘祦寮忓崗璁� |
+| `LlmGatewayService` | LLM 璇锋眰鍏ュ彛銆佹ā鍨嬭矾鐢便�佸彇娑堛�佽秴鏃躲�佷簨浠跺綊涓�鍖� | 鎸佷箙鍖栧竷灞�鎴栫獥鍙g姸鎬� |
+| `LlmModelRegistry` | 鍔犺浇鍜屾牎楠屾ā鍨嬮厤缃紝鎸� `modelId` 鏌ユ壘妯″瀷 | 淇濆瓨 API key 鏄庢枃 |
+| `CredentialStore` | 鎸� `authRef` 鎻愪緵瀵嗛挜锛岄殣钘忕湡瀹� key | 淇濆瓨鏅�氭彃浠堕厤缃� |
+| `LlmProviderAdapter` | 鎸� provider 閫傞厤璇锋眰鍜屾祦寮忓搷搴� | 鍐冲畾鎻掍欢 UI 琛屼负 |
+| `RuntimeEventBus` | 骞挎挱 `llm.delta`銆乣llm.completed`銆乣llm.error` 绛変簨浠� | 瀛樺偍鍘嗗彶瀵硅瘽 |
+| `DiagnosticsService` | 璁板綍閴存潈澶辫触銆乪ndpoint 涓嶅彲杈俱�佹祦瑙f瀽澶辫触銆佽秴鏃� | 璁板綍瀹屾暣 prompt 鎴� key |
+
+### Dependency Direction
+
+- 鎻掍欢 UI 鍙兘渚濊禆 `window.moliDesktop.llm`銆�
+- 妗ユ帴灞傚彧渚濊禆杩愯鏃舵帴鍙o紝涓嶇洿鎺ヤ緷璧栧叿浣� provider adapter銆�
+- Provider adapter 鍙敱 `LlmGatewayService` 閫氳繃宸ュ巶鍒涘缓鎴栧彇寰椼��
+- 閰嶇疆璇诲啓浠嶇粡 `ConfigurationService`锛屼笉鍏佽鎻掍欢鎴� adapter 鐩存帴鍐� JSON銆�
+
+## Runtime Flow
+
+### Model List Load
+
+```mermaid
+sequenceDiagram
+  participant Plugin
+  participant Bridge
+  participant Runtime
+  participant Llm as LlmGatewayService
+  participant Registry as LlmModelRegistry
+
+  Plugin->>Bridge: window.moliDesktop.llm.getModels()
+  Bridge->>Runtime: GetLlmModels(pluginId, instanceId)
+  Runtime->>Llm: GetAvailableModels(pluginId)
+  Llm->>Registry: Load enabled model summaries
+  Registry-->>Llm: model id, label, provider, supportsStreaming
+  Llm-->>Runtime: safe model summaries
+  Runtime-->>Bridge: summaries without endpoint/authRef
+  Bridge-->>Plugin: Promise resolve
+```
+
+鎻掍欢妯″瀷涓嬫媺鍙兘鎷垮埌瀹夊叏鎽樿锛�
+
+```json
+[
+  {
+    "id": "gpt-5.4",
+    "label": "GPT-5.4",
+    "provider": "openai-compatible",
+    "supportsStreaming": true,
+    "enabled": true
+  }
+]
+```
+
+榛樿涓嶈繑鍥� `endpoint`銆乣authRef`銆丄PI key 鎴栧叾浠栨晱鎰熼厤缃�傜鐞嗙獥鍙e彲浠ュ湪鍙楁帶 UI 涓睍绀哄拰缂栬緫 endpoint锛屼絾鎻掍欢鍓嶇涓嶉渶瑕佺煡閬撱��
+
+### Stream Chat
+
+```mermaid
+sequenceDiagram
+  participant Plugin
+  participant Bridge
+  participant Runtime
+  participant Llm as LlmGatewayService
+  participant Registry as LlmModelRegistry
+  participant Secret as CredentialStore
+  participant Adapter as ProviderAdapter
+  participant Upstream as LLM Provider
+
+  Plugin->>Bridge: streamChat(modelId, messages, options)
+  Bridge->>Runtime: StreamLlmChat(request)
+  Runtime->>Runtime: Validate plugin permission llm.stream
+  Runtime->>Llm: StreamChatAsync(request)
+  Llm->>Registry: Get model by modelId
+  Registry-->>Llm: provider, endpoint, authRef, apiModel
+  Llm->>Secret: Resolve authRef
+  Secret-->>Llm: credential or null
+  Llm->>Adapter: StreamAsync(normalized request)
+  Adapter->>Upstream: HTTP streaming request
+  Upstream-->>Adapter: provider stream chunks
+  Adapter-->>Llm: normalized deltas
+  Llm-->>Runtime: LlmStreamEvent
+  Runtime-->>Bridge: llm.delta / completed / error
+  Bridge-->>Plugin: DOM event or callback
+```
+
+### Cancellation
+
+MVP 鍙厛瀹炵幇鈥滆姹備腑蹇界暐閲嶅 Enter鈥濄�傛灦鏋勪笂棰勭暀鍙栨秷鑳藉姏锛�
+
+- 姣忔 `streamChat` 鐢熸垚 `requestId`銆�
+- `LlmGatewayService` 淇濆瓨 `requestId -> CancellationTokenSource`銆�
+- 鎻掍欢鍚庣画鍙皟鐢� `window.moliDesktop.llm.cancel(requestId)`銆�
+- Escape 鍙湪 UI 灞傚厛鏀惰捣杈撳嚭锛涜嫢鍚庣画鍚敤鍙栨秷璇箟锛屽垯 Escape 浜屾瑙﹀彂 cancel銆�
+
+## Data Model
+
+### LLM Settings Document
+
+寤鸿鏂板鐙珛閰嶇疆鏂囦欢锛�
+
+```text
+%AppData%\DesktopEnhancer\config\llm-models.json
+```
+
+鐙珛鏂囦欢鐨勫ソ澶勶細
+
+- 閬垮厤鎶婁緵搴斿晢 endpoint 鍜屾ā鍨嬮厤缃鍏� `layout.json` 鎴栨櫘閫氭彃浠� manifest銆�
+- 渚夸簬绠$悊绐楀彛鍗曠嫭鍋氣�滄ā鍨嬮厤缃�濋〉銆�
+- 鍚庣画杩佺Щ鍒板姞瀵嗗瓨鍌ㄦ垨鏈嶅姟绔厤缃椂杈圭晫鏇存竻鏅般��
+
+绀轰緥锛�
+
+```json
+{
+  "schemaVersion": 1,
+  "defaultModel": "gpt-5.4",
+  "models": [
+    {
+      "id": "gpt-5.4",
+      "label": "GPT-5.4",
+      "provider": "openai-compatible",
+      "endpoint": "https://api.openai.example/v1/chat/completions",
+      "authRef": "llm.openai.primary",
+      "apiModel": "gpt-5.4",
+      "supportsStreaming": true,
+      "enabled": true,
+      "requestDefaults": {
+        "temperature": 0.7,
+        "maxTokens": 2048,
+        "timeoutMs": 60000
+      }
+    },
+    {
+      "id": "deepseek-chat",
+      "label": "DeepSeek",
+      "provider": "deepseek",
+      "endpoint": "https://api.deepseek.com/chat/completions",
+      "authRef": "llm.deepseek.primary",
+      "apiModel": "deepseek-chat",
+      "supportsStreaming": true,
+      "enabled": true,
+      "requestDefaults": {
+        "temperature": 0.7,
+        "maxTokens": 2048,
+        "timeoutMs": 60000
+      }
+    },
+    {
+      "id": "local-qwen",
+      "label": "Local Qwen",
+      "provider": "openai-compatible",
+      "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+      "authRef": null,
+      "apiModel": "qwen2.5:14b",
+      "supportsStreaming": true,
+      "enabled": false,
+      "requestDefaults": {
+        "temperature": 0.6,
+        "maxTokens": 2048,
+        "timeoutMs": 120000
+      }
+    }
+  ]
+}
+```
+
+### Model Validation Rules
+
+| 瀛楁 | 瑙勫垯 |
+| --- | --- |
+| `schemaVersion` | 蹇呭~锛屽綋鍓嶄负 `1` |
+| `defaultModel` | 蹇呴』涓虹┖鎴栨寚鍚戜竴涓� enabled 妯″瀷 |
+| `models[].id` | 鍏ㄥ眬鍞竴锛屾帹鑽� `provider-name` 鎴栫敤鎴峰彲璇� id |
+| `models[].label` | 1 鍒� 40 瀛楃锛屼緵涓嬫媺灞曠ず |
+| `models[].provider` | 蹇呴』瀛樺湪瀵瑰簲 adapter |
+| `models[].endpoint` | 蹇呴』鏄� `http` 鎴� `https` 缁濆 URL |
+| `models[].authRef` | 鍙负绌猴紱涓嶄负绌烘椂涓嶅緱鍖呭惈鏄庢枃 key |
+| `models[].apiModel` | 蹇呭~锛屽彂閫佺粰涓婃父渚涘簲鍟嗙殑鐪熷疄妯″瀷鍚� |
+| `models[].timeoutMs` | 寤鸿 `5000..300000` |
+
+### Credential Storage
+
+MVP 寤鸿浼樺厛椤哄簭锛�
+
+1. Windows Credential Manager锛氱敓浜ц矾寰勶紝鎸� `authRef` 瀛樺彇瀵嗛挜銆�
+2. 鐢ㄦ埛鐜鍙橀噺锛氬紑鍙�/璋冭瘯璺緞锛屼緥濡� `MOLI_LLM_OPENAI_PRIMARY_KEY`銆�
+3. 鏄庢枃 JSON锛氫笉鎺ㄨ崘锛涘涓存椂鏀寔锛屽繀椤讳粎鐢ㄤ簬鏈湴娴嬭瘯骞跺湪绠$悊绐楀彛鏄庣‘鏍囨敞椋庨櫓銆�
+
+`authRef` 涓嶇洿鎺ョ瓑浜庣幆澧冨彉閲忓悕锛屽彲浠ラ�氳繃瀹夸富鏄犲皠锛�
+
+```json
+{
+  "authRef": "llm.openai.primary"
+}
+```
+
+瀹夸富瑙f瀽椤哄簭绀轰緥锛�
+
+```text
+Windows Credential Manager: Moli.Desktop/llm.openai.primary
+Environment variable: MOLI_LLM_OPENAI_PRIMARY
+```
+
+## Interfaces
+
+### C# Service Contracts
+
+```csharp
+public interface ILlmGatewayService
+{
+    Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(CancellationToken cancellationToken);
+    IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+        LlmChatRequest request,
+        CancellationToken cancellationToken);
+    Task CancelAsync(string requestId, CancellationToken cancellationToken);
+}
+
+public interface ILlmModelRegistry
+{
+    Task<LlmSettingsDocument> LoadAsync(CancellationToken cancellationToken);
+    Task<LlmModelConfig?> GetEnabledModelAsync(string modelId, CancellationToken cancellationToken);
+}
+
+public interface ILlmProviderAdapter
+{
+    string Provider { get; }
+    IAsyncEnumerable<LlmProviderChunk> StreamAsync(
+        LlmProviderRequest request,
+        CancellationToken cancellationToken);
+}
+
+public interface ICredentialStore
+{
+    Task<string?> ResolveSecretAsync(string authRef, CancellationToken cancellationToken);
+}
+```
+
+### Request DTOs
+
+```csharp
+public sealed record LlmChatRequest
+{
+    public required string RequestId { get; init; }
+    public required string PluginId { get; init; }
+    public required string InstanceId { get; init; }
+    public required string ModelId { get; init; }
+    public required IReadOnlyList<LlmMessage> Messages { get; init; }
+    public LlmRequestOptions Options { get; init; } = new();
+}
+
+public sealed record LlmMessage
+{
+    public required string Role { get; init; }
+    public required string Content { get; init; }
+}
+
+public sealed record LlmRequestOptions
+{
+    public double? Temperature { get; init; }
+    public int? MaxTokens { get; init; }
+    public int? TimeoutMs { get; init; }
+}
+```
+
+### Stream Events
+
+```csharp
+public abstract record LlmStreamEvent
+{
+    public required string RequestId { get; init; }
+}
+
+public sealed record LlmDeltaEvent : LlmStreamEvent
+{
+    public required string Delta { get; init; }
+}
+
+public sealed record LlmCompletedEvent : LlmStreamEvent
+{
+    public LlmUsage? Usage { get; init; }
+}
+
+public sealed record LlmErrorEvent : LlmStreamEvent
+{
+    public required string Code { get; init; }
+    public required string Message { get; init; }
+}
+```
+
+### Plugin Bridge API
+
+```typescript
+type LlmModelSummary = {
+  id: string;
+  label: string;
+  provider: string;
+  supportsStreaming: boolean;
+  enabled: boolean;
+};
+
+type LlmStreamRequest = {
+  modelId: string;
+  messages: Array<{ role: "system" | "user" | "assistant"; content: string }>;
+  options?: {
+    temperature?: number;
+    maxTokens?: number;
+    timeoutMs?: number;
+  };
+};
+
+window.moliDesktop.llm = {
+  getModels(): Promise<LlmModelSummary[]>;
+  streamChat(request: LlmStreamRequest): Promise<{ requestId: string }>;
+  cancel(requestId: string): Promise<void>;
+  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;
+};
+```
+
+### Provider Adapter Contract
+
+涓嶅悓渚涘簲鍟嗙殑閫傞厤鍣ㄥ繀椤荤粺涓�杈撳嚭锛�
+
+- `delta`: 澧為噺鏂囨湰銆�
+- `completed`: 姝e父缁撴潫鍜屽彲閫� usage銆�
+- `error`: 渚涘簲鍟嗛敊璇綊涓�鍖栥��
+
+OpenAI-compatible adapter 鍙綔涓虹涓�浼樺厛绾э紝瀹冭兘瑕嗙洊 OpenAI銆丏eepSeek 鐨勫吋瀹规ā寮忋�佹湰鍦� Ollama/LM Studio 绛夊鏁� MVP 鍦烘櫙銆侱eepSeek 濡備娇鐢ㄩ潪鍏煎瀛楁锛屽啀鍗曠嫭娲剧敓 adapter銆�
+
+## Plugin Layout and Window Behavior
+
+LLM 鎻掍欢浠嶆槸鏅�� widget 瀹炰緥锛屽竷灞�鐢� `LayoutManager` 鍜� `WidgetWindow` 鎺у埗銆�
+
+榛樿瀹夎瑙勫垯寤鸿鐢� `DefaultContentInstaller` 鐗瑰垽 `sample.llm-command-palette`锛�
+
+- `width = min(760, primaryWorkArea.Width * 0.72)`
+- `height = 72`
+- `x = primaryWorkArea.X + (primaryWorkArea.Width - width) / 2`
+- `y = primaryWorkArea.Y + 32`
+- `locked = true`
+- `clickThrough = false`
+- `displayLayer = desktop`
+- `opacity = 0.96`
+
+杈撳嚭灞曞紑楂樺害瀛樺湪涓ゅ眰绾︽潫锛�
+
+1. 鎻掍欢鍓嶇 CSS 闄愬埗杈撳嚭鍖哄煙 `max-height: 50vh`銆�
+2. 濡傛彃浠惰姹� `requestResize`锛屽涓诲竷灞�灞傞檺鍒剁粍浠舵�婚珮搴︿笉瓒呰繃褰撳墠鏄剧ず鍣ㄩ珮搴� `50% + inputBarHeight + margin`锛岄伩鍏嶇獥鍙f棤闄愭墿寮犮��
+
+## Error Handling
+
+| 閿欒鐮� | 鍦烘櫙 | UI 琛屼负 | 璇婃柇 |
+| --- | --- | --- | --- |
+| `LlmModelNotFound` | `modelId` 涓嶅瓨鍦ㄦ垨 disabled | 杈撳嚭鍖烘樉绀烘ā鍨嬩笉鍙敤 | Warning |
+| `LlmProviderUnsupported` | provider 鏃� adapter | 杈撳嚭鍖烘樉绀轰緵搴斿晢涓嶆敮鎸� | Error |
+| `LlmCredentialMissing` | `authRef` 鏃犳硶瑙f瀽 | 杈撳嚭鍖烘彁绀烘鏌ュ瘑閽� | Error锛屼笉璁板綍 key |
+| `LlmEndpointUnavailable` | 缃戠粶澶辫触銆丏NS銆佽繛鎺ユ嫆缁� | 杈撳嚭鍖烘彁绀� endpoint 涓嶅彲杈� | Error锛岃褰� endpoint host |
+| `LlmUnauthorized` | 401/403 | 杈撳嚭鍖烘彁绀洪壌鏉冨け璐� | Error锛屼笉璁板綍 key |
+| `LlmRateLimited` | 429 | 杈撳嚭鍖烘彁绀虹◢鍚庨噸璇� | Warning |
+| `LlmTimeout` | 瓒呮椂 | 杈撳嚭鍖烘彁绀鸿姹傝秴鏃� | Warning |
+| `LlmStreamParseFailed` | 渚涘簲鍟嗘祦鏍煎紡寮傚父 | 淇濈暀宸茶緭鍑哄唴瀹瑰苟鎻愮ず瑙f瀽澶辫触 | Error |
+
+鏃ュ織瑙勫垯锛�
+
+- 鍙互璁板綍 `requestId`銆乣modelId`銆乣provider`銆乪ndpoint host銆丠TTP status銆�
+- 涓嶈褰曞畬鏁� API key銆�
+- 榛樿涓嶈褰曞畬鏁� prompt锛涘鍚庣画闇�瑕佽皟璇曞紑鍏筹紝蹇呴』鐢辩敤鎴锋樉寮忓惎鐢ㄣ��
+
+## Security Boundaries
+
+- `llm.stream` 蹇呴』浣滀负鎻掍欢鏉冮檺澹版槑锛屾湭澹版槑鏃舵ˉ鎺ュ眰鎷掔粷璋冪敤銆�
+- 鎻掍欢鍙兘鐪嬪埌 enabled 妯″瀷鎽樿銆�
+- 鎻掍欢涓嶈兘瑕嗙洊 endpoint銆乸rovider銆乤uthRef 鎴� apiModel銆�
+- `setConfig` 涓嶅厑璁稿啓鍏ュ涓荤骇 LLM 妯″瀷娉ㄥ唽琛ㄣ��
+- 鏈湴 HTTP API 濡傚悗缁毚闇� LLM 璋冪敤锛屼篃蹇呴』榛樿缁戝畾 `127.0.0.1`锛屽苟澶嶇敤鍚屼竴 `ILlmGatewayService`銆�
+- 杩滅▼ endpoint 蹇呴』缁忚繃 URL 鏍¢獙锛岀姝� `file://`銆佺浉瀵硅矾寰勫拰闈� HTTP 鍗忚銆�
+
+## Alternatives
+
+| 鏂规 | 缁撹 | 鍘熷洜 |
+| --- | --- | --- |
+| 鎻掍欢鍓嶇鐩存帴璋冪敤鍚勪緵搴斿晢 API | 涓嶉噰鐢� | 瀵嗛挜鏆撮湶銆佽法渚涘簲鍟嗗樊寮傛墿鏁e埌鎻掍欢 UI銆佹棩蹇楀拰閿欒杈圭晫闅炬帶 |
+| 鍏ㄥ眬鍗� provider + 鍗� endpoint | 涓嶉噰鐢� | 鏃犳硶鑷劧鏀寔涓嶅悓渚涘簲鍟嗗拰姣忔ā鍨嬬嫭绔� URL |
+| 瀹夸富缁熶竴浠g悊锛屾寜 `modelId` 璺敱 | 閲囩敤 | 婊¤冻澶氫緵搴斿晢锛屽瘑閽ョ暀鍦ㄥ涓伙紝鎻掍欢 UI 绠�娲� |
+| 鍙疄鐜� OpenAI-compatible adapter | MVP 鍙綔涓虹涓�闃舵 | 蹇�熻鐩栧鏁颁緵搴斿晢锛屼絾淇濈暀 provider adapter 鎵╁睍鐐� |
+| 鎶婃ā鍨嬮厤缃斁杩涙彃浠� manifest | 浠呬綔涓� fallback | manifest 灞炰簬鎻掍欢鍖咃紝涓嶉�傚悎淇濆瓨鐢ㄦ埛鐪熷疄 endpoint 鍜屽瘑閽ュ紩鐢� |
+| 鎶婃ā鍨嬮厤缃斁杩� `appsettings.json` | 鍙浣嗕笉鎺ㄨ崘 | LLM 閰嶇疆浼氬闀匡紝鐙珛鏂囦欢鏇村埄浜庣鐞嗗拰杩佺Щ |
+
+## Implementation Tasks
+
+### A01 LLM Configuration Model
+
+杈撳嚭锛�
+
+- `LlmSettingsDocument`
+- `LlmModelConfig`
+- `LlmRequestDefaults`
+- `llm-models.json` 榛樿鐢熸垚鍜屾牎楠�
+
+楠屾敹锛�
+
+- 缂哄け閰嶇疆鏃剁敓鎴愮┖妯″瀷鍒楄〃鎴栨牱渚� disabled 妯″瀷銆�
+- 闈炴硶 provider銆侀噸澶� id銆侀潪娉� endpoint 浼氫骇鐢熻瘖鏂��
+- `defaultModel` 鎸囧悜 disabled 鎴栦笉瀛樺湪妯″瀷鏃堕檷绾т负绌恒��
+
+### A02 Credential Store
+
+杈撳嚭锛�
+
+- `ICredentialStore`
+- Windows Credential Manager 瀹炵幇鎴栫幆澧冨彉閲� fallback
+- 瀵嗛挜鑴辨晱鏃ュ織宸ュ叿
+
+楠屾敹锛�
+
+- `authRef = null` 鏀寔鏈湴鏃犻壌鏉冩ā鍨嬨��
+- 缂哄け瀵嗛挜杩斿洖鏄庣‘ `LlmCredentialMissing`銆�
+- 鏃ュ織鍜屽紓甯镐腑涓嶅嚭鐜板畬鏁� key銆�
+
+### A03 Provider Adapter Layer
+
+杈撳嚭锛�
+
+- `ILlmProviderAdapter`
+- `OpenAICompatibleAdapter`
+- adapter factory
+- 娴佸紡 SSE 瑙f瀽鍣�
+
+楠屾敹锛�
+
+- 鑳借В鏋� `data: ...` 澧為噺鏂囨湰銆�
+- 鑳借瘑鍒� `[DONE]`銆�
+- 涓婃父 401銆�429銆�5xx 鑳芥槧灏勪负缁熶竴閿欒銆�
+
+### A04 LLM Gateway Service
+
+杈撳嚭锛�
+
+- `ILlmGatewayService`
+- 妯″瀷璺敱銆佽秴鏃躲�佸彇娑堛�佷簨浠跺綊涓�鍖�
+- 璇锋眰澶у皬鍜屾秷鎭鑹叉牎楠�
+
+楠屾敹锛�
+
+- 涓嶅悓 `modelId` 璺敱鍒颁笉鍚� endpoint銆�
+- 璇锋眰瓒呮椂杩斿洖 `LlmTimeout`銆�
+- provider 涓嶅瓨鍦ㄨ繑鍥� `LlmProviderUnsupported`銆�
+
+### A05 WebView Bridge Extension
+
+杈撳嚭锛�
+
+- `window.moliDesktop.llm.getModels`
+- `streamChat`
+- `cancel`
+- `onDelta` / `onCompleted` / `onError`
+- 鏉冮檺鏍¢獙 `llm.stream`
+
+楠屾敹锛�
+
+- 鏈0鏄庢潈闄愮殑鎻掍欢璋冪敤 LLM API 琚嫆缁濄��
+- 鎻掍欢鍙敹鍒板畨鍏ㄦā鍨嬫憳瑕併��
+- 娴佸紡 delta 鍙互鍒拌揪褰撳墠鎻掍欢瀹炰緥銆�
+
+### A06 Sample Plugin
+
+杈撳嚭锛�
+
+- `samples/plugins/sample.llm-command-palette/plugin.json`
+- `index.html`
+- 鍗婇�忔槑椤堕儴杈撳叆鏉°�佹ā鍨嬩笅鎷夈�佽緭鍑哄睍寮�鍖哄煙
+
+楠屾敹锛�
+
+- 榛樿椤堕儴灞呬腑銆�
+- Enter 鎻愪氦锛孲hift+Enter 鎹㈣銆�
+- 杈撳嚭鍖烘渶澶ч珮搴︿笉瓒呰繃灞忓箷 `50%`銆�
+- 閿欒灞曠ず鍦ㄨ緭鍑哄尯锛屼笉寮圭郴缁熸ā鎬佹銆�
+
+### A07 Management Window Extension
+
+杈撳嚭锛�
+
+- 妯″瀷閰嶇疆椤垫垨鎻掍欢閰嶇疆鍏ュ彛銆�
+- 澧炲垹鏀规ā鍨嬶細id銆乴abel銆乸rovider銆乪ndpoint銆乤piModel銆乤uthRef銆乪nabled銆�
+- 瀵嗛挜閰嶇疆鍏ュ彛锛屾樉绀� `authRef` 鐘舵�佷絾涓嶆樉绀烘槑鏂� key銆�
+
+楠屾敹锛�
+
+- 淇濆瓨妯″瀷閰嶇疆鍚庢彃浠朵笅鎷夊埛鏂般��
+- 鏃犳晥 endpoint 鎴� provider 鏄剧ず鍙閿欒銆�
+- 绠$悊绐楀彛涓嶆硠闇插畬鏁� key銆�
+
+### A08 Verification and QA Handoff
+
+杈撳嚭锛�
+
+- LLM 鏋舵瀯楠岃瘉璁板綍銆�
+- mock adapter 娴嬭瘯銆�
+- 鏈湴 OpenAI-compatible endpoint 鎵嬪伐楠岃瘉璇存槑銆�
+
+楠屾敹锛�
+
+- `dotnet build` 閫氳繃銆�
+- LLM 閰嶇疆鍜� adapter 鍗曞厓娴嬭瘯閫氳繃銆�
+- 浣跨敤涓や釜涓嶅悓 endpoint 鐨勬ā鍨嬪彲鍒嗗埆璺敱銆�
+
+## Verification Plan
+
+### Unit Tests
+
+- `LlmModelRegistry`锛氶噸澶� id銆乨isabled model銆侀潪娉� endpoint銆侀粯璁ゆā鍨嬮檷绾с��
+- `CredentialStore`锛氱┖ `authRef`銆佺己澶卞瘑閽ャ�佺幆澧冨彉閲� fallback銆�
+- `OpenAICompatibleAdapter`锛歋SE delta銆乣[DONE]`銆侀敊璇搷搴斻�佸紓甯告祦銆�
+- `LlmGatewayService`锛氭ā鍨嬭矾鐢便�佽秴鏃躲�佸彇娑堛�侀敊璇槧灏勩��
+
+### Integration Tests
+
+- 浣跨敤 fake provider adapter 楠岃瘉 `modelId -> endpoint` 璺敱銆�
+- 浣跨敤 fake WebView bridge 楠岃瘉 `llm.delta` 鍙淳鍙戠粰璇锋眰鏉ユ簮鎻掍欢瀹炰緥銆�
+- 浣跨敤鎹熷潖 `llm-models.json` 楠岃瘉澶囦唤鎭㈠鍜岃瘖鏂��
+
+### Manual QA
+
+- 閰嶇疆涓や釜妯″瀷锛屽垎鍒寚鍚戜笉鍚� endpoint锛岄�夋嫨涓嶅悓妯″瀷鎻愪氦鍚庢鏌ヨ矾鐢辨棩蹇椼��
+- 閰嶇疆缂哄け `authRef`锛岀‘璁よ緭鍑哄尯鏄剧ず閴存潈閰嶇疆閿欒銆�
+- 閰嶇疆鏈湴 OpenAI-compatible 鏈嶅姟锛岀‘璁ゆ棤 key 妯″瀷鍙祦寮忚緭鍑恒��
+- 鏂綉鎴栧叧闂湰鍦� endpoint锛岀‘璁ゆ彃浠惰緭鍑哄尯鏄剧ず endpoint 涓嶅彲杈俱��
+- 杈撳嚭闀挎枃鏈紝纭鎻掍欢绐楀彛鍜岃緭鍑哄尯涓嶈秴杩囧睆骞曢珮搴︾害鏉熴��
+
+## Open Decisions
+
+| 闂 | 寤鸿榛樿鍊� | 鍚庣画瑙﹀彂鏉′欢 |
+| --- | --- | --- |
+| 瀵嗛挜鐢熶骇瀛樺偍 | Windows Credential Manager | 绠$悊绐楀彛瀹炵幇瀵嗛挜缂栬緫鏃惰惤鍦� |
+| 榛樿 adapter | OpenAI-compatible | 鍏堣鐩� OpenAI銆丏eepSeek 鍏煎鎺ュ彛鍜屾湰鍦版湇鍔� |
+| DeepSeek 鏄惁鐙珛 adapter | 鏆備笉寮哄埗 | 濡傛灉瀹為檯鎺ュ彛涓� OpenAI-compatible 宸紓鏄庢樉鍐嶆媶 |
+| 鏄惁鏆撮湶鏈湴 HTTP LLM API | 鏆備笉鏆撮湶 | 鎻掍欢妗ユ帴鍏堟弧瓒抽渶姹傦紱澶栭儴鑷姩鍖栭渶瑕佹椂鍐嶈璁� |
+| 鏄惁淇濆瓨 prompt 鍘嗗彶 | 榛樿涓嶄繚瀛� | 鐢ㄦ埛鏄庣‘闇�瑕佸巻鍙叉垨璋冭瘯瀹¤鏃跺啀璇勪及 |
+
diff --git a/docs/ops/user-manual.md b/docs/ops/user-manual.md
new file mode 100644
index 0000000..fec2686
--- /dev/null
+++ b/docs/ops/user-manual.md
@@ -0,0 +1,26 @@
+# Moli.Desktop 鐢ㄦ埛鎵嬪唽绱㈠紩
+
+鏃ユ湡锛�2026-05-04
+
+鏈枃妗f槸鐢ㄦ埛鎵嬪唽鍏ュ彛銆備富绋嬪簭鍜屾瘡涓彃浠剁殑鎿嶄綔璇存槑宸叉媶鍒嗕负鐙珛鏂囦欢锛屼究浜庡悗缁寜妯″潡缁存姢銆�
+
+## 涓荤▼搴�
+
+- [Moli.Desktop 涓荤▼搴忔搷浣滄墜鍐宂(user-manual/moli-desktop.md)
+
+## 鎻掍欢
+
+- [sample.wallpaper 鍔ㄦ�佸绾告彃浠禲(user-manual/plugins/sample.wallpaper.md)
+- [sample.clock 鏃堕挓鎻掍欢](user-manual/plugins/sample.clock.md)
+- [sample.system-info 绯荤粺淇℃伅鎻掍欢](user-manual/plugins/sample.system-info.md)
+- [sample.audio-visualizer 闊充箰寰嬪姩鎻掍欢](user-manual/plugins/sample.audio-visualizer.md)
+- [sample.llm-command-palette LLM 妗岄潰杈撳叆鎻掍欢](user-manual/plugins/sample.llm-command-palette.md)
+- [sample.webview-test WebView 娴嬭瘯鎻掍欢](user-manual/plugins/sample.webview-test.md)
+
+## 閫氱敤鍙傝��
+
+- 閰嶇疆鏂囦欢鐩綍锛歚%AppData%\DesktopEnhancer\config`
+- 鎻掍欢鐩綍锛歚%AppData%\DesktopEnhancer\plugins`
+- 鏃ュ織鐩綍锛歚%LocalAppData%\DesktopEnhancer\logs`
+- WebView2 鏁版嵁鐩綍锛歚%LocalAppData%\DesktopEnhancer\WebView2`
+
diff --git a/docs/product/user-manual.md b/docs/ops/user-manual/moli-desktop.md
similarity index 89%
rename from docs/product/user-manual.md
rename to docs/ops/user-manual/moli-desktop.md
index 2290ccf..e3a3d29 100644
--- a/docs/product/user-manual.md
+++ b/docs/ops/user-manual/moli-desktop.md
@@ -1,12 +1,21 @@
-# Moli.Desktop 鐢ㄦ埛鎿嶄綔鎵嬪唽
+# Moli.Desktop 涓荤▼搴忔搷浣滄墜鍐�
 
-鏃ユ湡锛�2026-05-02
+鏃ユ湡锛�2026-05-04
 
 ## 閫傜敤鑼冨洿
 
-鏈枃妗i潰鍚� Moli.Desktop 鐨勬渶缁堢敤鎴枫�佽瘯鐢ㄧ敤鎴峰拰鐜板満楠岃瘉浜哄憳锛岃鏄庡浣曞畨瑁呫�佸惎鍔ㄣ�佺鐞嗗姩鎬佸绾搞�佺鐞嗘闈㈠皬缁勪欢銆佹煡鐪嬭瘖鏂俊鎭互鍙婂鐞嗗父瑙侀棶棰樸��
+鏈枃妗i潰鍚� Moli.Desktop 鐨勬渶缁堢敤鎴枫�佽瘯鐢ㄧ敤鎴峰拰鐜板満楠岃瘉浜哄憳锛岃鏄庡浣曞畨瑁呫�佸惎鍔ㄣ�佷娇鐢ㄦ墭鐩樿彍鍗曘�佺鐞嗙獥鍙c�佹彃浠堕�氱敤鑳藉姏銆佹湰鍦� API銆佸浠芥仮澶嶄互鍙婂鐞嗕富绋嬪簭甯歌闂銆�
 
 Moli.Desktop 鏄竴娆� Windows 11 妗岄潰澧炲己搴旂敤銆傚畠涓嶄細鏇夸唬 Windows 妗岄潰銆丒xplorer銆佷换鍔℃爮鎴栧紑濮嬭彍鍗曪紝鑰屾槸鍦ㄥ師鐢熸闈箣涓婂鍔� WebView2 椹卞姩鐨� H5 鍔ㄦ�佸绾稿拰 HTML 灏忕粍浠惰兘鍔涖��
+
+鍚勬彃浠剁殑涓撻棬鎿嶄綔璇锋煡鐪嬶細
+
+- [sample.wallpaper 鍔ㄦ�佸绾告彃浠禲(plugins/sample.wallpaper.md)
+- [sample.clock 鏃堕挓鎻掍欢](plugins/sample.clock.md)
+- [sample.system-info 绯荤粺淇℃伅鎻掍欢](plugins/sample.system-info.md)
+- [sample.audio-visualizer 闊充箰寰嬪姩鎻掍欢](plugins/sample.audio-visualizer.md)
+- [sample.llm-command-palette LLM 妗岄潰杈撳叆鎻掍欢](plugins/sample.llm-command-palette.md)
+- [sample.webview-test WebView 娴嬭瘯鎻掍欢](plugins/sample.webview-test.md)
 
 ## 浣跨敤鍓嶅噯澶�
 
@@ -54,6 +63,10 @@
 - `sample.wallpaper`锛氭湰鍦� H5 鍔ㄦ�佸绾搞��
 - `sample.clock`锛氭闈㈡椂閽熷皬缁勪欢銆�
 - `sample.system-info`锛氱郴缁熶俊鎭崰浣嶅皬缁勪欢銆�
+- `sample.audio-visualizer`锛氶煶涔愬緥鍔ㄥ皬缁勪欢銆�
+- `sample.llm-command-palette`锛氶《閮� LLM 杈撳叆鎻掍欢銆�
+
+`sample.webview-test` 涓昏鐢ㄤ簬寮�鍙戦獙璇侊紝閫氬父涓嶄細榛樿鍚敤銆�
 
 ## 鎵樼洏鑿滃崟
 
@@ -102,27 +115,9 @@
 | 鎻掍欢 | 宸叉壂鎻忔彃浠剁殑鍚嶇О銆佺被鍨嬨�佺姸鎬併�佸叆鍙e拰閿欒鐮� |
 | 璇婃柇 | 璇婃柇璁板綍鍜屾彃浠� manifest 閿欒鎽樿 |
 
-## 鍔ㄦ�佸绾�
+## 閫氱敤缁勪欢鎿嶄綔
 
-Moli.Desktop 浣跨敤 WebView2 鍔犺浇 H5 澹佺焊銆傞粯璁ゆ牱渚嬩负 `sample.wallpaper`銆�
-
-甯哥敤鎿嶄綔锛�
-
-1. 鎵撳紑鎵樼洏鑿滃崟鎴栫鐞嗙獥鍙c��
-2. 鐐瑰嚮鈥滃惎鐢ㄥ绾糕�濇樉绀哄绾搞��
-3. 鐐瑰嚮鈥滅鐢ㄥ绾糕�濆叧闂绾搞��
-4. 濡傛灉妗岄潰榧犳爣鎿嶄綔鍙楀奖鍝嶏紝鎵撳紑鈥滃畨鍏ㄨ緭鍏ユā寮忊�濇仮澶嶅彲鎿嶄綔鐘舵�併��
-
-澹佺焊灞傝璁$洰鏍囨槸浣嶄簬妗岄潰鍥炬爣涔嬪悗锛屼笌鍘熺敓妗岄潰铻嶅悎銆備笉鍚� Windows 妗岄潰鐘舵�併�佹樉鍗¢┍鍔ㄥ拰 WebView2 Runtime 鐘舵�佸彲鑳藉奖鍝嶅疄闄呰〃鐜帮紱濡傛樉绀哄紓甯革紝璇峰厛鏌ョ湅璇婃柇椤靛拰鏃ュ織鐩綍銆�
-
-## 妗岄潰灏忕粍浠�
-
-灏忕粍浠舵潵鑷湰鍦� HTML 鎻掍欢銆傞粯璁ゆ牱渚嬪寘鍚細
-
-| 鎻掍欢 | 鐢ㄩ�� |
-| --- | --- |
-| `sample.clock` | 鏃堕挓灏忕粍浠� |
-| `sample.system-info` | 绯荤粺淇℃伅鍗犱綅灏忕粍浠� |
+灏忕粍浠舵潵鑷湰鍦� HTML 鎻掍欢銆傛瘡涓皬缁勪欢閮藉彲浠ラ�氳繃绠$悊绐楀彛杩涜鏄剧ず銆侀殣钘忋�侀攣瀹氬拰瑙i攣銆�
 
 ### 鏄剧ず鎴栭殣钘忕粍浠�
 
diff --git a/docs/ops/user-manual/plugins/sample.audio-visualizer.md b/docs/ops/user-manual/plugins/sample.audio-visualizer.md
new file mode 100644
index 0000000..a197f59
--- /dev/null
+++ b/docs/ops/user-manual/plugins/sample.audio-visualizer.md
@@ -0,0 +1,77 @@
+# sample.audio-visualizer 闊充箰寰嬪姩鎻掍欢鎵嬪唽
+
+鏃ユ湡锛�2026-05-04
+
+## 鎻掍欢鐢ㄩ��
+
+`sample.audio-visualizer` 鏄唴缃煶涔愬緥鍔ㄥ皬缁勪欢銆傚畠浠ラ�忔槑鑳屾櫙鏄剧ず涓�缁勬í鍚戦摵寮�鐨勭珫绾匡紝鏍规嵁闊抽棰戣氨鎴栧崰浣嶅姩鏁堣繘琛屽緥鍔紝鐢ㄤ簬楠岃瘉妗岄潰闊抽鍙鍖栥�侀�忔槑娓叉煋鍜屾ˉ鎺ヤ簨浠惰兘鍔涖��
+
+## 榛樿甯冨眬
+
+榛樿瀹夎鏃讹紝瀹夸富浼氭寜涓诲睆灏哄鐢熸垚甯冨眬锛�
+
+| 瀛楁 | 榛樿琛屼负 |
+| --- | --- |
+| `x` | `0` |
+| `width` | 涓诲睆瀹藉害 |
+| `y` | 绾︿负涓诲睆楂樺害鐨� `2/3` |
+| `height` | 涓嶈秴杩囦富灞忛珮搴︾殑 `25%` |
+| `displayLayer` | `desktop` |
+| `clickThrough` | 閫氬父寮�鍚紝閬垮厤褰卞搷妗岄潰鎿嶄綔 |
+
+## 浣跨敤鏂瑰紡
+
+1. 鍚姩 Moli.Desktop銆�
+2. 纭 `sample.audio-visualizer` 宸插湪鈥滄彃浠垛�濋〉闈㈠惎鐢ㄣ��
+3. 鎾斁绯荤粺闊抽銆�
+4. 鍦ㄦ闈笂鏌ョ湅寰嬪姩鏁堟灉銆�
+
+濡傛灉绯荤粺涓嶅厑璁搁煶棰戦噰闆嗭紝鎻掍欢浠嶅簲鏄剧ず浣庡己搴﹀崰浣嶅姩鏁堬紝閬垮厤妗岄潰鍖哄煙涓虹┖鐧姐��
+
+## 绉诲姩涓庨攣瀹�
+
+濡傛灉闇�瑕佽皟鏁翠綅缃細
+
+1. 鎵撳紑绠$悊绐楀彛銆�
+2. 杩涘叆鈥滅粍浠垛�濋〉闈€��
+3. 閫夋嫨 `sample.audio-visualizer.default`銆�
+4. 瑙i攣缁勪欢銆�
+5. 杩涘叆缂栬緫妯″紡璋冩暣浣嶇疆鎴栧昂瀵搞��
+6. 閫�鍑虹紪杈戞ā寮忎繚瀛樺竷灞�銆�
+
+## 鎻掍欢鏂囦欢
+
+榛樿鎻掍欢鐩綍锛�
+
+```text
+%AppData%\DesktopEnhancer\plugins\sample.audio-visualizer
+```
+
+婧愮爜鏍蜂緥鐩綍锛�
+
+```text
+samples\plugins\sample.audio-visualizer
+```
+
+鍏抽敭鏂囦欢锛�
+
+| 鏂囦欢 | 璇存槑 |
+| --- | --- |
+| `plugin.json` | 鎻掍欢 manifest |
+| `index.html` | 褰撳墠鎻掍欢鍏ュ彛 |
+| `demo.html` | 瑙嗚鍙傝�冩垨婕旂ず椤甸潰 |
+
+## 甯歌闂
+
+### 娌℃湁闅忛煶涔愬彉鍖�
+
+- 纭绯荤粺姝e湪鎾斁闊抽銆�
+- 妫�鏌ユ彃浠舵槸鍚︽湁 `audio-capture` 鏉冮檺銆�
+- 濡傛灉闊抽閲囬泦涓嶅彲鐢紝鎻掍欢鍙兘鏄剧ず鍗犱綅鍔ㄦ晥銆�
+- 鏌ョ湅鏃ュ織鐩綍鍜岃瘖鏂〉闈㈡槸鍚﹀瓨鍦ㄩ煶棰戦噰闆嗛敊璇��
+
+### 寰嬪姩鏉℃尅浣忔闈㈢偣鍑�
+
+- 鍦ㄧ鐞嗙獥鍙f鏌ヨ缁勪欢鐐瑰嚮绌块�忕姸鎬併��
+- 浠庢墭鐩樿彍鍗曞紑鍚�滃畨鍏ㄨ緭鍏ユā寮忊�濇仮澶嶆帶鍒躲��
+
diff --git a/docs/ops/user-manual/plugins/sample.clock.md b/docs/ops/user-manual/plugins/sample.clock.md
new file mode 100644
index 0000000..b42a5f0
--- /dev/null
+++ b/docs/ops/user-manual/plugins/sample.clock.md
@@ -0,0 +1,58 @@
+# sample.clock 鏃堕挓鎻掍欢鎵嬪唽
+
+鏃ユ湡锛�2026-05-04
+
+## 鎻掍欢鐢ㄩ��
+
+`sample.clock` 鏄唴缃闈㈡椂閽熷皬缁勪欢锛岀敤浜庢樉绀哄綋鍓嶆椂闂达紝骞堕獙璇佹櫘閫� widget 鐨勫姞杞姐�佸竷灞�銆侀攣瀹氬拰鏄剧ず闅愯棌鑳藉姏銆�
+
+## 鏄剧ず涓庨殣钘�
+
+1. 鎵撳紑绠$悊绐楀彛銆�
+2. 杩涘叆鈥滅粍浠垛�濋〉闈€��
+3. 閫夋嫨 `sample.clock.default`銆�
+4. 鐐瑰嚮鈥滄樉绀�/闅愯棌鈥濄��
+
+## 绉诲姩涓庨攣瀹�
+
+1. 鍦ㄧ鐞嗙獥鍙i�夋嫨 `sample.clock.default`銆�
+2. 鐐瑰嚮鈥滈攣瀹�/瑙i攣鈥濊В闄ら攣瀹氥��
+3. 杩涘叆缂栬緫妯″紡銆�
+4. 鍦ㄦ闈笂鎷栧姩鏃堕挓鍒扮洰鏍囦綅缃��
+5. 閫�鍑虹紪杈戞ā寮忥紝甯冨眬浼氫繚瀛樺埌 `layout.json`銆�
+
+## 鎻掍欢鏂囦欢
+
+榛樿鎻掍欢鐩綍锛�
+
+```text
+%AppData%\DesktopEnhancer\plugins\sample.clock
+```
+
+婧愮爜鏍蜂緥鐩綍锛�
+
+```text
+samples\plugins\sample.clock
+```
+
+鍏抽敭鏂囦欢锛�
+
+| 鏂囦欢 | 璇存槑 |
+| --- | --- |
+| `plugin.json` | 鎻掍欢 manifest |
+| `index.html` | 鏃堕挓椤甸潰鍏ュ彛 |
+
+## 甯歌闂
+
+### 鏃堕挓涓嶆樉绀�
+
+- 纭缁勪欢娌℃湁琚殣钘忋��
+- 纭 `sample.clock` 鎻掍欢鐘舵�佷负 enabled銆�
+- 鐐瑰嚮鈥滈噸杞芥彃浠垛�濄��
+- 鏌ョ湅璇婃柇椤垫槸鍚﹀瓨鍦� manifest 鎴� entry 閿欒銆�
+
+### 鏃堕挓浣嶇疆涓嶅悎閫�
+
+- 瑙i攣缁勪欢鍚庤繘鍏ョ紪杈戞ā寮忚皟鏁翠綅缃��
+- 濡傛灉缁勪欢璺戝埌灞忓箷澶栵紝鍙娇鐢ㄧ鐞嗙獥鍙b�滈噸缃竷灞�鈥濄��
+
diff --git a/docs/ops/user-manual/plugins/sample.llm-command-palette.md b/docs/ops/user-manual/plugins/sample.llm-command-palette.md
new file mode 100644
index 0000000..ace5c2b
--- /dev/null
+++ b/docs/ops/user-manual/plugins/sample.llm-command-palette.md
@@ -0,0 +1,198 @@
+# sample.llm-command-palette LLM 妗岄潰杈撳叆鎻掍欢鎵嬪唽
+
+鏃ユ湡锛�2026-05-04
+
+## 鎻掍欢鐢ㄩ��
+
+`sample.llm-command-palette` 鏄竴涓《閮ㄥ眳涓殑妗岄潰杈撳叆鏉°�傚畠鏀寔鍦ㄨ緭鍏ユ涓洿鎺ヨ緭鍏ラ棶棰橈紝鎸� Enter 鎻愪氦锛屽彸渚т笅鎷夐�夋嫨妯″瀷锛屽苟鍦ㄨ緭鍏ユ涓嬫柟灞曞紑娴佸紡杈撳嚭銆�
+
+## 浣跨敤鍓嶅噯澶�
+
+浣跨敤璇ユ彃浠跺墠锛岄渶瑕佸噯澶囪嚦灏戜竴涓彲璁块棶鐨� LLM 鎺ュ彛銆傚綋鍓嶇増鏈紭鍏堟敮鎸� OpenAI-compatible 娴佸紡鎺ュ彛锛屼篃鍙互閰嶇疆 DeepSeek銆佹湰鍦� Ollama/LM Studio 绛夊吋瀹规帴鍙c��
+
+## 榛樿琛屼负
+
+| 椤圭洰 | 榛樿琛屼负 |
+| --- | --- |
+| 浣嶇疆 | 涓诲睆椤堕儴灞呬腑锛岄《閮ㄤ繚鐣欑害 `32px` 绌洪殭 |
+| 鏄剧ず灞傜骇 | `desktop` |
+| 鐐瑰嚮绌块�� | 鍏抽棴锛屼究浜庢帴鏀堕敭鐩樺拰榧犳爣杈撳叆 |
+| 閿佸畾鐘舵�� | 閿佸畾锛岄伩鍏嶈鎷栧姩 |
+| 鎻愪氦鏂瑰紡 | Enter 鎻愪氦锛屼笉鎻愪緵鎻愪氦鎸夐挳 |
+| 鎹㈣鏂瑰紡 | Shift+Enter |
+| 杈撳嚭鍖哄煙 | 杈撳叆妗嗗簳閮ㄥ睍寮�锛屾渶澶ч珮搴︾害涓哄睆骞曢珮搴� `50%` |
+
+## 閰嶇疆妯″瀷
+
+LLM 鎻掍欢涓嶄細鐩存帴淇濆瓨渚涘簲鍟嗗瘑閽ワ紝涔熶笉浼氭妸 endpoint 鏆撮湶缁欐彃浠跺墠绔�傚涓讳細璇诲彇妯″瀷娉ㄥ唽琛紝鏍规嵁鐢ㄦ埛閫夋嫨鐨� `modelId` 璺敱鍒板搴斾緵搴斿晢鍜� endpoint銆�
+
+妯″瀷閰嶇疆鏂囦欢浣嶄簬锛�
+
+```text
+%AppData%\DesktopEnhancer\config\llm-models.json
+```
+
+棣栨鍚姩鍚庯紝濡傛灉鏂囦欢涓嶅瓨鍦紝搴旂敤浼氱敓鎴愰粯璁ゆ枃浠躲�傚綋鍓嶇鐞嗙獥鍙e皻鏈彁渚涙ā鍨嬬紪杈戦〉闈紝鐭湡鍙墜宸ョ紪杈戣鏂囦欢銆�
+
+绀轰緥閰嶇疆锛�
+
+```json
+{
+  "schemaVersion": 1,
+  "defaultModel": "deepseek-chat",
+  "models": [
+    {
+      "id": "deepseek-chat",
+      "label": "DeepSeek",
+      "provider": "deepseek",
+      "endpoint": "https://api.deepseek.com/chat/completions",
+      "authRef": "llm.deepseek.primary",
+      "apiModel": "deepseek-chat",
+      "supportsStreaming": true,
+      "enabled": true,
+      "requestDefaults": {
+        "temperature": 0.7,
+        "maxTokens": 2048,
+        "timeoutMs": 60000
+      }
+    },
+    {
+      "id": "local-qwen",
+      "label": "Local Qwen",
+      "provider": "openai-compatible",
+      "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+      "authRef": null,
+      "apiModel": "qwen2.5:14b",
+      "supportsStreaming": true,
+      "enabled": true,
+      "requestDefaults": {
+        "temperature": 0.6,
+        "maxTokens": 2048,
+        "timeoutMs": 120000
+      }
+    }
+  ]
+}
+```
+
+瀛楁璇存槑锛�
+
+| 瀛楁 | 璇存槑 |
+| --- | --- |
+| `id` | 鎻掍欢涓嬫媺鍜岃姹備娇鐢ㄧ殑妯″瀷 ID锛屽繀椤诲敮涓� |
+| `label` | 涓嬫媺涓樉绀虹殑鍚嶇О锛屽缓璁煭涓�鐐� |
+| `provider` | 渚涘簲鍟嗘垨鍗忚閫傞厤鍣紝渚嬪 `openai-compatible`銆乣deepseek`銆乣ollama` |
+| `endpoint` | 褰撳墠妯″瀷鑷繁鐨勮姹� URL锛屽彲姣忎釜妯″瀷涓嶅悓 |
+| `authRef` | 瀵嗛挜寮曠敤锛屼笉鏄槑鏂囧瘑閽ワ紱鏈湴鏃犻壌鏉冩ā鍨嬪彲濉� `null` |
+| `apiModel` | 鍙戦�佺粰涓婃父鎺ュ彛鐨勭湡瀹炴ā鍨嬪悕 |
+| `supportsStreaming` | 鏄惁鏀寔娴佸紡杈撳嚭 |
+| `enabled` | 鏄惁鏄剧ず鍦ㄦ彃浠舵ā鍨嬩笅鎷変腑 |
+
+褰撳墠 `deepseek`銆乣ollama` 鍜� `local-openai-compatible` 浼氬鐢� OpenAI-compatible 閫傞厤鍣ㄣ�傚鏋滄煇涓緵搴斿晢鎺ュ彛涓嶅吋瀹� OpenAI-compatible 娴佸紡鏍煎紡锛岄渶瑕佸悗缁柊澧炵嫭绔嬮�傞厤鍣ㄣ��
+
+## 閰嶇疆瀵嗛挜
+
+褰撳墠鐗堟湰浣跨敤鐜鍙橀噺浣滀负瀵嗛挜 fallback銆俙authRef` 浼氭寜浠ヤ笅鏂瑰紡瑙f瀽锛�
+
+1. 鐩存帴璇诲彇鍚屽悕鐜鍙橀噺銆�
+2. 濡傛灉涓嶅瓨鍦紝鎶� `authRef` 杞垚 `MOLI_` 鍓嶇紑鐨勫ぇ鍐欑幆澧冨彉閲忓悕銆�
+
+渚嬪锛�
+
+```text
+authRef = llm.deepseek.primary
+```
+
+鍙缃幆澧冨彉閲忥細
+
+```powershell
+[Environment]::SetEnvironmentVariable(
+  "MOLI_LLM_DEEPSEEK_PRIMARY",
+  "浣犵殑 API Key",
+  "User"
+)
+```
+
+璁剧疆鍚庤閲嶅惎 Moli.Desktop锛岃鏂扮幆澧冨彉閲忓妗岄潰杩涚▼鐢熸晥銆�
+
+濡傛灉浣跨敤鏈湴鏃犻壌鏉冩湇鍔★紝渚嬪鏈満 Ollama 鎴� LM Studio 鐨� OpenAI-compatible endpoint锛屽彲浠ュ皢 `authRef` 璁剧疆涓� `null`銆�
+
+## 浣跨敤杈撳叆鏉�
+
+1. 鍚姩 Moli.Desktop銆�
+2. 纭 `sample.llm-command-palette` 宸插湪鈥滄彃浠垛�濋〉闈腑鍚敤銆�
+3. 鍦ㄦ闈㈤《閮ㄦ壘鍒板崐閫忔槑杈撳叆鏉°��
+4. 鍦ㄥ彸渚фā鍨嬩笅鎷変腑閫夋嫨妯″瀷銆�
+5. 杈撳叆闂銆�
+6. 鎸� Enter 鎻愪氦銆�
+7. 鍦ㄨ緭鍏ユ涓嬫柟鏌ョ湅娴佸紡杈撳嚭銆�
+
+蹇嵎鎿嶄綔锛�
+
+| 鎿嶄綔 | 鏁堟灉 |
+| --- | --- |
+| Enter | 鎻愪氦褰撳墠杈撳叆 |
+| Shift+Enter | 鍦ㄨ緭鍏ユ鍐呮崲琛� |
+| Escape | 鏀惰捣宸插睍寮�鐨勮緭鍑哄尯鍩� |
+| Copy 鎸夐挳 | 澶嶅埗褰撳墠杈撳嚭鏂囨湰 |
+| Collapse 鎸夐挳 | 鏀惰捣杈撳嚭鍖哄煙 |
+
+濡傛灉璇锋眰姝e湪杩涜锛岄噸澶嶆寜 Enter 榛樿涓嶄細鍙戣捣鏂扮殑璇锋眰銆傝绛夊緟褰撳墠璇锋眰瀹屾垚锛屾垨鍚庣画鐗堟湰浣跨敤鍙栨秷鍔熻兘銆�
+
+## 璋冩暣浣嶇疆鍜屽眰绾�
+
+LLM 鎻掍欢榛樿閿佸畾骞朵綅浜� `desktop` 灞傘�傚鏋滈渶瑕佺Щ鍔細
+
+1. 鎵撳紑绠$悊绐楀彛銆�
+2. 杩涘叆鈥滅粍浠垛�濋〉闈€��
+3. 閫夋嫨 `sample.llm-command-palette.default`銆�
+4. 瑙i攣缁勪欢銆�
+5. 杩涘叆缂栬緫妯″紡骞惰皟鏁翠綅缃��
+6. 璋冩暣瀹屾垚鍚庨��鍑虹紪杈戞ā寮忥紝骞舵寜闇�閲嶆柊閿佸畾銆�
+
+濡傛灉甯屾湜杈撳叆鏉¤鐩栨櫘閫氬簲鐢ㄧ獥鍙o紝鍙湪甯冨眬閰嶇疆鎴栧悗缁鐞� UI 涓皢鏄剧ず灞傜骇鏀逛负 `app-top` 鎴� `global-top`銆備娇鐢� `global-top` 鏃惰纭繚鎵樼洏浠嶅彲璁块棶锛屼究浜庢仮澶嶆帶鍒躲��
+
+## 澶囦唤
+
+寤鸿澶囦唤锛�
+
+```text
+%AppData%\DesktopEnhancer\config\llm-models.json
+%AppData%\DesktopEnhancer\plugins\sample.llm-command-palette
+```
+
+## 甯歌闂
+
+### 涓嬫媺涓病鏈夋ā鍨�
+
+- 妫�鏌� `%AppData%\DesktopEnhancer\config\llm-models.json` 鏄惁瀛樺湪銆�
+- 纭鑷冲皯鏈変竴涓ā鍨嬬殑 `enabled` 涓� `true`銆�
+- 纭妯″瀷鐨� `endpoint` 鏄� `http` 鎴� `https` 缁濆 URL銆�
+- 淇閰嶇疆鍚庨噸鍚簲鐢紝鎴栧湪绠$悊绐楀彛涓噸杞芥彃浠躲��
+
+### 璇锋眰鎻愮ず瀵嗛挜缂哄け
+
+- 妫�鏌ユā鍨嬮厤缃腑鐨� `authRef`銆�
+- 纭宸茶缃搴旂幆澧冨彉閲忋��
+- 濡傛灉鍒氳缃幆澧冨彉閲忥紝璇烽噸鍚� Moli.Desktop銆�
+- 鏈湴鏃犻壌鏉冩ā鍨嬪彲灏� `authRef` 璁剧疆涓� `null`銆�
+
+### 璇锋眰鎻愮ず endpoint 涓嶅彲杈�
+
+- 纭 `endpoint` 鍦板潃姝g‘銆�
+- 濡傛灉鏄湰鍦版ā鍨嬫湇鍔★紝纭鏈嶅姟宸插惎鍔ㄥ苟鐩戝惉瀵瑰簲绔彛銆�
+- 濡傛灉鏄繙绋嬩緵搴斿晢锛岀‘璁ゅ綋鍓嶇綉缁滃彲璁块棶璇ヤ緵搴斿晢 API銆�
+- 妫�鏌ユ棩蹇楃洰褰� `%LocalAppData%\DesktopEnhancer\logs`锛屾棩蹇楀彧浼氳褰� endpoint host锛屼笉浼氳褰曞畬鏁� API key銆�
+
+### 娌℃湁娴佸紡杈撳嚭
+
+- 纭涓婃父鎺ュ彛鏀寔 OpenAI-compatible SSE 娴佸紡杈撳嚭銆�
+- 纭妯″瀷閰嶇疆 `supportsStreaming` 涓� `true`銆�
+- 濡傛灉渚涘簲鍟嗕笉鏄� OpenAI-compatible锛屽綋鍓嶇増鏈彲鑳介渶瑕佹柊澧炲搴� provider adapter銆�
+
+## 褰撳墠闄愬埗
+
+- 妯″瀷閰嶇疆褰撳墠涓昏閫氳繃鎵嬪伐缂栬緫 `llm-models.json` 瀹屾垚銆�
+- 瀵嗛挜褰撳墠浣跨敤鐜鍙橀噺 fallback锛學indows Credential Manager 绠$悊鐣岄潰灏氭湭瀹炵幇銆�
+- 褰撳墠宸插疄鐜� OpenAI-compatible 娴佸紡鍗忚锛涢潪鍏煎渚涘簲鍟嗛渶瑕佸悗缁柊澧為�傞厤鍣ㄣ��
+
diff --git a/docs/ops/user-manual/plugins/sample.system-info.md b/docs/ops/user-manual/plugins/sample.system-info.md
new file mode 100644
index 0000000..4d50185
--- /dev/null
+++ b/docs/ops/user-manual/plugins/sample.system-info.md
@@ -0,0 +1,58 @@
+# sample.system-info 绯荤粺淇℃伅鎻掍欢鎵嬪唽
+
+鏃ユ湡锛�2026-05-04
+
+## 鎻掍欢鐢ㄩ��
+
+`sample.system-info` 鏄郴缁熶俊鎭崰浣嶅皬缁勪欢锛岀敤浜庨獙璇佹櫘閫氫俊鎭被 widget 鐨勫姞杞姐�侀�忔槑鑳屾櫙銆佸竷灞�鍜屾樉绀洪殣钘忚兘鍔涖��
+
+褰撳墠鏍蜂緥浠ュ睍绀哄熀鏈郴缁熶俊鎭垨鍗犱綅鍐呭涓轰富锛屼笉浠h〃瀹屾暣鎬ц兘鐩戞帶鑳藉姏銆�
+
+## 鏄剧ず涓庨殣钘�
+
+1. 鎵撳紑绠$悊绐楀彛銆�
+2. 杩涘叆鈥滅粍浠垛�濋〉闈€��
+3. 閫夋嫨 `sample.system-info.default`銆�
+4. 鐐瑰嚮鈥滄樉绀�/闅愯棌鈥濄��
+
+## 绉诲姩涓庨攣瀹�
+
+1. 鍦ㄧ鐞嗙獥鍙i�夋嫨 `sample.system-info.default`銆�
+2. 鐐瑰嚮鈥滈攣瀹�/瑙i攣鈥濄��
+3. 杩涘叆缂栬緫妯″紡銆�
+4. 鍦ㄦ闈笂璋冩暣浣嶇疆鍜屽昂瀵搞��
+5. 閫�鍑虹紪杈戞ā寮忎繚瀛樺竷灞�銆�
+
+## 鎻掍欢鏂囦欢
+
+榛樿鎻掍欢鐩綍锛�
+
+```text
+%AppData%\DesktopEnhancer\plugins\sample.system-info
+```
+
+婧愮爜鏍蜂緥鐩綍锛�
+
+```text
+samples\plugins\sample.system-info
+```
+
+鍏抽敭鏂囦欢锛�
+
+| 鏂囦欢 | 璇存槑 |
+| --- | --- |
+| `plugin.json` | 鎻掍欢 manifest |
+| `index.html` | 绯荤粺淇℃伅椤甸潰鍏ュ彛 |
+
+## 甯歌闂
+
+### 淇℃伅娌℃湁鍒锋柊
+
+- 褰撳墠鏍蜂緥涓昏鐢ㄤ簬灞曠ず鍜岄獙璇佸涓绘彃浠惰兘鍔涳紝瀹炴椂绯荤粺閲囬泦鑳藉姏鏈夐檺銆�
+- 鐐瑰嚮鈥滈噸杞芥彃浠垛�濆彲閲嶆柊鍔犺浇椤甸潰銆�
+
+### 鎻掍欢鏄剧ず閿欒
+
+- 妫�鏌� `plugin.json` 鏄惁瀛樺湪銆�
+- 妫�鏌ョ鐞嗙獥鍙b�滄彃浠垛�濆拰鈥滆瘖鏂�濋〉闈€��
+
diff --git a/docs/ops/user-manual/plugins/sample.wallpaper.md b/docs/ops/user-manual/plugins/sample.wallpaper.md
new file mode 100644
index 0000000..857ad52
--- /dev/null
+++ b/docs/ops/user-manual/plugins/sample.wallpaper.md
@@ -0,0 +1,59 @@
+# sample.wallpaper 鍔ㄦ�佸绾告彃浠舵墜鍐�
+
+鏃ユ湡锛�2026-05-04
+
+## 鎻掍欢鐢ㄩ��
+
+`sample.wallpaper` 鏄唴缃� H5 鍔ㄦ�佸绾告牱渚嬶紝鐢ㄤ簬楠岃瘉 WebView2 澹佺焊鍔犺浇銆侀�忔槑鑳屾櫙銆佺偣鍑荤┛閫忓拰妗岄潰灞傜骇鑳藉姏銆�
+
+## 鍚敤涓庣鐢�
+
+1. 鍚姩 Moli.Desktop銆�
+2. 鍙抽敭鎵樼洏鍥炬爣锛屾垨鎵撳紑绠$悊绐楀彛銆�
+3. 鐐瑰嚮鈥滃惎鐢ㄥ绾糕�濇樉绀哄绾搞��
+4. 鐐瑰嚮鈥滅鐢ㄥ绾糕�濆叧闂绾搞��
+
+濡傛灉澹佺焊褰卞搷榧犳爣鎿嶄綔锛岃浠庢墭鐩樿彍鍗曞紑鍚�滃畨鍏ㄨ緭鍏ユā寮忊�濄��
+
+## 鎻掍欢鏂囦欢
+
+榛樿鎻掍欢鐩綍锛�
+
+```text
+%AppData%\DesktopEnhancer\plugins\sample.wallpaper
+```
+
+婧愮爜鏍蜂緥鐩綍锛�
+
+```text
+samples\plugins\sample.wallpaper
+```
+
+鍏抽敭鏂囦欢锛�
+
+| 鏂囦欢 | 璇存槑 |
+| --- | --- |
+| `plugin.json` | 鎻掍欢 manifest |
+| `index.html` | H5 澹佺焊鍏ュ彛 |
+
+## 甯冨眬涓庢樉绀�
+
+澹佺焊鎻掍欢閫氬父浣滀负 `wallpaper` 绫诲瀷杩愯锛岀敱瀹夸富鍒涘缓澹佺焊绐楀彛骞惰鐩栫洰鏍囨樉绀哄櫒銆傚绾稿眰鐩爣鏄綅浜庢闈㈠浘鏍囦箣鍚庯紝涓庡師鐢熸闈㈣瀺鍚堛��
+
+涓嶅悓 Windows 妗岄潰鐘舵�併�佹樉鍗¢┍鍔ㄥ拰 WebView2 Runtime 鐘舵�佸彲鑳藉奖鍝嶅疄闄呰〃鐜帮紱濡傛樉绀哄紓甯革紝璇峰厛鏌ョ湅绠$悊绐楀彛鈥滆瘖鏂�濋〉鍜屾棩蹇楃洰褰曘��
+
+## 甯歌闂
+
+### 澹佺焊娌℃湁鏄剧ず
+
+- 纭鎻掍欢鐩綍涓瓨鍦� `plugin.json` 鍜� `index.html`銆�
+- 鍦ㄧ鐞嗙獥鍙b�滄彃浠垛�濋〉闈㈡煡鐪� `sample.wallpaper` 鐘舵�併��
+- 鐐瑰嚮鈥滈噸杞芥彃浠垛�濄��
+- 纭 WebView2 Runtime 宸插畨瑁呫��
+
+### 澹佺焊鎸′綇妗岄潰鐐瑰嚮
+
+- 浠庢墭鐩樿彍鍗曞紑鍚�滃畨鍏ㄨ緭鍏ユā寮忊�濄��
+- 鍦ㄧ鐞嗙獥鍙f鏌ュ绾哥偣鍑荤┛閫忕姸鎬併��
+- 蹇呰鏃剁鐢ㄥ绾稿悗閲嶆柊鍚敤銆�
+
diff --git a/docs/ops/user-manual/plugins/sample.webview-test.md b/docs/ops/user-manual/plugins/sample.webview-test.md
new file mode 100644
index 0000000..3827184
--- /dev/null
+++ b/docs/ops/user-manual/plugins/sample.webview-test.md
@@ -0,0 +1,47 @@
+# sample.webview-test WebView 娴嬭瘯鎻掍欢鎵嬪唽
+
+鏃ユ湡锛�2026-05-04
+
+## 鎻掍欢鐢ㄩ��
+
+`sample.webview-test` 鏄紑鍙戝拰鎵嬪伐楠岃瘉鐢ㄦ彃浠讹紝鐢ㄤ簬妫�鏌� WebView2 鍔犺浇銆佸涓绘ˉ鎺ャ�佹彃浠� manifest銆侀�忔槑鑳屾櫙鍜屽熀纭�杩愯鏃剁姸鎬併��
+
+璇ユ彃浠朵笉鏄潰鍚戞櫘閫氱敤鎴风殑榛樿鍔熻兘鎻掍欢锛岄�氬父鐢ㄤ簬寮�鍙戙�丵A 鎴栫幇鍦烘帓闅溿��
+
+## 浣跨敤鏂瑰紡
+
+1. 灏嗘彃浠剁洰褰曞鍒跺埌 `%AppData%\DesktopEnhancer\plugins\sample.webview-test`銆�
+2. 鎵撳紑绠$悊绐楀彛銆�
+3. 鐐瑰嚮鈥滈噸杞芥彃浠垛�濄��
+4. 鍦ㄢ�滄彃浠垛�濋〉闈㈢‘璁� `sample.webview-test` 鐘舵�併��
+5. 濡傞渶鏄剧ず涓虹粍浠讹紝纭 `plugins.json` 鍜� `layout.json` 涓湁瀵瑰簲鍚敤鐘舵�佸拰甯冨眬瀹炰緥銆�
+
+## 鎻掍欢鏂囦欢
+
+婧愮爜鏍蜂緥鐩綍锛�
+
+```text
+samples\plugins\sample.webview-test
+```
+
+鍏抽敭鏂囦欢锛�
+
+| 鏂囦欢 | 璇存槑 |
+| --- | --- |
+| `plugin.json` | 鎻掍欢 manifest |
+| `index.html` | WebView 娴嬭瘯鍏ュ彛 |
+
+## 甯歌闂
+
+### 鎻掍欢娌℃湁鍑虹幇鍦ㄥ垪琛ㄤ腑
+
+- 纭鎻掍欢鐩綍鍚嶅拰 `plugin.json` 瀛樺湪銆�
+- 鐐瑰嚮鈥滈噸杞芥彃浠垛�濄��
+- 鏌ョ湅绠$悊绐楀彛鈥滆瘖鏂�濋〉闈€��
+
+### 椤甸潰鍔犺浇澶辫触
+
+- 妫�鏌� `plugin.json` 涓殑 `entry` 鏄惁鎸囧悜瀛樺湪鐨勫叆鍙f枃浠躲��
+- 纭 WebView2 Runtime 宸插畨瑁呫��
+- 鏌ョ湅鏃ュ織鐩綍 `%LocalAppData%\DesktopEnhancer\logs`銆�
+
diff --git a/docs/product/llm-command-palette-plugin-prd.md b/docs/product/llm-command-palette-plugin-prd.md
index f33af38..5f12e56 100644
--- a/docs/product/llm-command-palette-plugin-prd.md
+++ b/docs/product/llm-command-palette-plugin-prd.md
@@ -52,7 +52,7 @@
 - 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄨ緭鍏ユ鍙充晶鍒囨崲妯″瀷锛岃繖鏍锋垜鑳芥寜浠诲姟閫夋嫨鏇村揩鎴栨洿寮虹殑妯″瀷銆�
 - 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄥ洖澶嶇敓鎴愭椂鐪嬪埌閫愭娴佸紡杈撳嚭锛岃繖鏍锋垜鐭ラ亾璇锋眰姝e湪杩涜銆�
 - 浣滀负鐢ㄦ埛锛屾垜鍙互缁х画缂栬緫杈撳叆鍐呭銆佸鍒惰緭鍑哄唴瀹规垨鎸� Escape 鏀惰捣缁撴灉锛岃繖鏍锋闈笉浼氳闀挎枃鏈暱鏈熷崰鎹��
-- 浣滀负鐢ㄦ埛锛屾垜鍙互閫氳繃绠$悊绐楀彛鎴栭厤缃垏鎹� API endpoint銆佹ā鍨嬪垪琛ㄥ拰榛樿妯″瀷锛岃繖鏍锋彃浠惰兘閫傞厤涓嶅悓 LLM 鏈嶅姟銆�
+- 浣滀负鐢ㄦ埛锛屾垜鍙互閫氳繃绠$悊绐楀彛鎴栭厤缃淮鎶や笉鍚屼緵搴斿晢鐨勬ā鍨嬨�乪ndpoint 鍜岄粯璁ゆā鍨嬶紝杩欐牱鎻掍欢鑳藉悓鏃舵帴鍏� OpenAI-compatible銆丏eepSeek銆佹湰鍦版ā鍨嬫垨鍚庣画鏂板渚涘簲鍟嗐��
 
 ## 鎻掍欢绫诲瀷
 
@@ -139,9 +139,9 @@
 
 ### 閿欒鐘舵��
 
-- API key 缂哄け銆乪ndpoint 涓嶅彲杈俱�佹ā鍨嬩笉鍙敤銆佽姹傝秴鏃跺拰娴佸紡瑙f瀽澶辫触蹇呴』灞曠ず鐭敊璇��
+- API key 缂哄け銆佹ā鍨� endpoint 涓嶅彲杈俱�佹ā鍨嬩笉鍙敤銆佽姹傝秴鏃跺拰娴佸紡瑙f瀽澶辫触蹇呴』灞曠ず鐭敊璇��
 - 閿欒淇℃伅鏄剧ず鍦ㄨ緭鍑哄尯鍩熷唴锛屼笉寮瑰嚭绯荤粺妯℃�佹銆�
-- 閿欒鏂囨湰搴斿寘鍚彲鎿嶄綔鏂瑰悜锛屼緥濡傗�滆鍦ㄦ彃浠堕厤缃腑妫�鏌� endpoint 鍜屽瘑閽モ�濄��
+- 閿欒鏂囨湰搴斿寘鍚彲鎿嶄綔鏂瑰悜锛屼緥濡傗�滆鍦ㄦā鍨嬮厤缃腑妫�鏌ヨ妯″瀷鐨� endpoint 鍜屽瘑閽モ�濄��
 
 ## 瑙嗚璁捐
 
@@ -172,23 +172,43 @@
 
 ## 妯″瀷閰嶇疆
 
-鎻掍欢閰嶇疆搴旀敮鎸侊細
+鎻掍欢鍓嶇鍙渶瑕佺煡閬撳彲灞曠ず鐨勬ā鍨嬫竻鍗曞拰榛樿妯″瀷銆傚叿浣撲緵搴斿晢銆乪ndpoint銆侀壌鏉冩柟寮忓拰璇锋眰閫傞厤搴斾紭鍏堢敱瀹夸富渚� LLM 浠g悊绠$悊锛屾彃浠舵彁浜ゆ椂鍙紶 `modelId`銆�
+
+鎺ㄨ崘閲囩敤鈥滄寜妯″瀷璺敱鈥濈殑閰嶇疆缁撴瀯锛氭瘡涓ā鍨嬮兘鍙互缁戝畾鐙珛 provider銆乁RL銆侀壌鏉冨紩鐢ㄥ拰璇锋眰閫傞厤鍙傛暟銆傝繖鏍峰悓涓�涓彃浠跺彲浠ュ悓鏃舵帴鍏ヤ笉鍚屼緵搴斿晢锛屼篃鍙互鎺ュ叆鍚屼竴渚涘簲鍟嗙殑涓嶅悓 base URL銆�
 
 ```json
 {
-  "provider": "openai-compatible",
-  "endpoint": "https://api.example.com/v1/chat/completions",
   "defaultModel": "gpt-5.4",
   "models": [
     {
       "id": "gpt-5.4",
       "label": "GPT-5.4",
-      "supportsStreaming": true
+      "provider": "openai-compatible",
+      "endpoint": "https://api.openai.example/v1/chat/completions",
+      "authRef": "llm.openai.primary",
+      "apiModel": "gpt-5.4",
+      "supportsStreaming": true,
+      "enabled": true
     },
     {
       "id": "deepseek-chat",
       "label": "DeepSeek",
-      "supportsStreaming": true
+      "provider": "deepseek",
+      "endpoint": "https://api.deepseek.com/chat/completions",
+      "authRef": "llm.deepseek.primary",
+      "apiModel": "deepseek-chat",
+      "supportsStreaming": true,
+      "enabled": true
+    },
+    {
+      "id": "local-qwen",
+      "label": "Local Qwen",
+      "provider": "openai-compatible",
+      "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+      "authRef": null,
+      "apiModel": "qwen2.5:14b",
+      "supportsStreaming": true,
+      "enabled": false
     }
   ],
   "request": {
@@ -199,7 +219,33 @@
 }
 ```
 
-API key 涓嶅簲瀛樻斁鍦ㄥ墠绔� `index.html` 鎴栧叕寮�閰嶇疆涓�侻VP 寤鸿鐢卞涓绘彁渚涙湰鍦� LLM 浠g悊鑳藉姏锛屾彃浠跺彧鍚戝涓昏姹傛祦寮忕敓鎴愶紱濡傛灉鐭湡鐩存帴浠庢彃浠惰皟鐢ㄨ繙绋� OpenAI-compatible endpoint锛屽垯蹇呴』鍦ㄦ枃妗e拰绠$悊鐣岄潰涓槑纭彁绀哄瘑閽ユ毚闇查闄╋紝骞朵粎鐢ㄤ簬鏈湴涓汉娴嬭瘯銆�
+瀛楁璇存槑锛�
+
+| 瀛楁 | 璇存槑 |
+| --- | --- |
+| `id` | 鎻掍欢 UI 鍜岃姹備腑浣跨敤鐨勭ǔ瀹氭ā鍨� id銆� |
+| `label` | 涓嬫媺涓睍绀虹殑鐭悕绉般�� |
+| `provider` | 渚涘簲鍟嗘垨鍗忚閫傞厤鍣紝渚嬪 `openai-compatible`銆乣deepseek`銆乣anthropic`銆乣ollama`銆� |
+| `endpoint` | 褰撳墠妯″瀷浣跨敤鐨勫畬鏁磋姹� URL锛屽厑璁告瘡涓ā鍨嬩笉鍚屻�� |
+| `authRef` | 瀹夸富渚у瘑閽ュ紩鐢紝涓嶆槸鏄庢枃瀵嗛挜锛涙湰鍦版棤閴存潈妯″瀷鍙负 `null`銆� |
+| `apiModel` | 鍙戦�佺粰涓婃父 API 鐨勭湡瀹炴ā鍨嬪悕銆� |
+| `supportsStreaming` | 鏄惁鍏佽娴佸紡杈撳嚭锛涗笉鏀寔鏃跺涓诲彲闄嶇骇涓轰竴娆℃�ц繑鍥炪�� |
+| `enabled` | 鏄惁鍦ㄦ彃浠舵ā鍨嬩笅鎷変腑鏄剧ず銆� |
+
+API key 涓嶅簲瀛樻斁鍦ㄥ墠绔� `index.html` 鎴栧叕寮�閰嶇疆涓�侻VP 寤鸿鐢卞涓绘彁渚涙湰鍦� LLM 浠g悊鑳藉姏锛屾彃浠跺彧鍚戝涓昏姹傛祦寮忕敓鎴愶紱瀹夸富鍐嶆牴鎹� `modelId` 鎵惧埌 provider銆乪ndpoint銆乤uthRef 鍜� apiModel 骞惰皟鐢ㄥ搴斾緵搴斿晢銆傚鏋滅煭鏈熺洿鎺ヤ粠鎻掍欢璋冪敤杩滅▼ endpoint锛屽垯蹇呴』鍦ㄦ枃妗e拰绠$悊鐣岄潰涓槑纭彁绀哄瘑閽ユ毚闇查闄╋紝骞朵粎鐢ㄤ簬鏈湴涓汉娴嬭瘯銆�
+
+### 璺敱绛栫暐
+
+鎺ㄨ崘璺嚎锛�
+
+1. 鎻掍欢璋冪敤瀹夸富锛歚modelId + messages + options`銆�
+2. 瀹夸富璇诲彇 LLM 妯″瀷娉ㄥ唽琛ㄣ��
+3. 瀹夸富鎸� `modelId` 鎵惧埌瀵瑰簲妯″瀷閰嶇疆銆�
+4. 瀹夸富鎸� `provider` 閫夋嫨閫傞厤鍣ㄣ��
+5. 閫傞厤鍣ㄦ寜璇ユā鍨嬬殑 `endpoint`銆乣authRef`銆乣apiModel` 鍙戣捣璇锋眰銆�
+6. 瀹夸富鎶婁緵搴斿晢娴佸紡鍝嶅簲缁熶竴杞崲涓� `llm.delta`銆乣llm.completed`銆乣llm.error` 浜嬩欢銆�
+
+杩欑璁捐姣旀彃浠剁鐩存帴鎸変緵搴斿晢鍐欏濂楄姹傛洿绋筹細妯″瀷鍙嫭绔嬮厤缃� URL锛屽瘑閽ョ暀鍦ㄥ涓讳晶锛屾彃浠� UI 鍙叧蹇冣�滅敤鎴烽�変簡鍝釜妯″瀷鈥濄��
 
 ## 瀹夸富涓庢彃浠堕�氫俊
 
@@ -207,7 +253,7 @@
 
 ```javascript
 window.moliDesktop.llm.streamChat({
-  model: "gpt-5.4",
+  modelId: "gpt-5.4",
   messages: [
     { role: "user", content: "..." }
   ],
@@ -217,6 +263,8 @@
   }
 });
 ```
+
+鎻掍欢涓嶅簲鐩存帴浼� provider銆乪ndpoint 鎴栧瘑閽ャ�傚涓诲搷搴斾腑鍙繑鍥炴湰娆¤姹傚疄闄呭懡涓殑渚涘簲鍟嗗拰妯″瀷锛岀敤浜庤瘖鏂拰 UI tooltip锛屼絾涓嶈繑鍥炲瘑閽ャ��
 
 娴佸紡浜嬩欢寤鸿锛�
 
@@ -278,9 +326,19 @@
     "displayLayer": "desktop"
   },
   "config": {
-    "provider": "openai-compatible",
     "defaultModel": "gpt-5.4",
-    "models": []
+    "models": [
+      {
+        "id": "gpt-5.4",
+        "label": "GPT-5.4",
+        "provider": "openai-compatible",
+        "endpoint": "",
+        "authRef": "",
+        "apiModel": "gpt-5.4",
+        "supportsStreaming": true,
+        "enabled": false
+      }
+    ]
   }
 }
 ```
@@ -328,8 +386,11 @@
 
 ### FR-LLM-05 閰嶇疆涓庡瘑閽�
 
-- 鎻掍欢蹇呴』鏀寔閰嶇疆 endpoint銆佹ā鍨嬪垪琛ㄣ�侀粯璁ゆā鍨嬪拰璇锋眰鍙傛暟銆�
+- 鎻掍欢蹇呴』鏀寔閰嶇疆妯″瀷鍒楄〃銆侀粯璁ゆā鍨嬪拰璇锋眰鍙傛暟銆�
+- 姣忎釜妯″瀷蹇呴』鑳藉閰嶇疆鐙珛鐨� provider銆乪ndpoint銆佺湡瀹炰笂娓告ā鍨嬪悕鍜屽惎鐢ㄧ姸鎬併��
+- 瀹夸富搴旀牴鎹� `modelId` 璺敱鍒板搴� provider 閫傞厤鍣紝骞惰皟鐢ㄨ妯″瀷鑷繁鐨� endpoint銆�
 - API key 涓嶅緱鍐欐鍦ㄦ彃浠跺墠绔祫婧愪腑銆�
+- API key 搴斾互 `authRef` 褰㈠紡寮曠敤瀹夸富渚у瘑閽ュ瓨鍌ㄦ垨鐢ㄦ埛鐜閰嶇疆銆�
 - 濡傛灉瀹夸富鏆傛湭鎻愪緵瀵嗛挜瀹夊叏瀛樺偍锛孧VP 蹇呴』灏嗚鑳藉姏鏍囪涓哄彈闄愶紝骞舵彁渚涙竻鏅伴闄╂彁绀恒��
 
 浼樺厛绾э細P1
@@ -366,7 +427,7 @@
 ### 瀹夊叏
 
 - 棣栫増鎻掍欢鏃犳矙绠遍殧绂伙紝浣� LLM 璇锋眰鑳藉姏蹇呴』閫氳繃鏄庣‘鏉冮檺澹版槑銆�
-- 瀹夸富浠g悊 LLM 璇锋眰鏃讹紝搴旈檺鍒舵彃浠跺彧鑳戒娇鐢ㄨ鍏佽鐨� endpoint 鍜屾ā鍨嬨��
+- 瀹夸富浠g悊 LLM 璇锋眰鏃讹紝搴旈檺鍒舵彃浠跺彧鑳戒娇鐢ㄥ凡鍚敤鐨勬ā鍨� id锛屽苟鐢卞涓昏В鏋愬搴� endpoint銆�
 - 鏃ュ織涓嶅緱璁板綍瀹屾暣 API key銆�
 - 榛樿涓嶆妸鐢ㄦ埛杈撳叆鍐呭鍐欏叆鎸佷箙鍖栭厤缃��
 
@@ -375,6 +436,7 @@
 - 褰撴彃浠堕娆″畨瑁呭苟鍚敤鏃讹紝杈撳叆鏉″嚭鐜板湪涓诲睆椤堕儴灞呬腑锛岄《閮ㄧ暀鏈夌害 `32px` 绌洪殭銆�
 - 褰撶敤鎴疯緭鍏ユ枃鏈苟鎸� Enter 鏃讹紝鎻掍欢鍙戣捣涓�娆� LLM 璇锋眰锛屼笖娌℃湁鎻愪氦鎸夐挳銆�
 - 褰撶敤鎴烽�夋嫨涓嶅悓妯″瀷鍚庡啀鎻愪氦鏃讹紝璇锋眰浣跨敤鏂版ā鍨嬨��
+- 褰撲笉鍚屾ā鍨嬮厤缃簡涓嶅悓渚涘簲鍟嗗拰 endpoint 鏃讹紝瀹夸富搴旀寜鎵�閫� `modelId` 璺敱鍒板搴� API銆�
 - 褰� LLM 杩斿洖鍐呭鏃讹紝杈撳嚭鍖哄煙鍦ㄨ緭鍏ユ搴曢儴灞曞紑锛屽苟閫愭鏄剧ず娴佸紡鏂囨湰銆�
 - 褰撹緭鍑哄唴瀹硅秴杩囧睆骞曢珮搴� `50%` 鏃讹紝杈撳嚭鍖哄煙鍐呴儴婊氬姩锛屾彃浠朵笉浼氱户缁悜涓嬫棤闄愭墿寮犮��
 - 褰撶敤鎴锋寜 Escape 鏃讹紝宸插睍寮�杈撳嚭鍖哄煙鍙互鏀惰捣銆�
@@ -387,8 +449,8 @@
 | 闂 | 寤鸿榛樿鍊� |
 | --- | --- |
 | MVP 鏄惁鐢卞涓讳唬鐞� LLM 璇锋眰 | 鏄紝閬垮厤 API key 鏆撮湶缁欐彃浠跺墠绔� |
-| 榛樿妯″瀷鍒楄〃鏉ユ簮 | 鎻掍欢閰嶇疆锛屽悗缁彲鐢辩鐞嗙獥鍙g紪杈� |
+| 榛樿妯″瀷鍒楄〃鏉ユ簮 | 瀹夸富渚� LLM 妯″瀷娉ㄥ唽琛紝鎻掍欢 manifest 鍙彁渚� fallback |
+| 妯″瀷鏄惁鍏辩敤 endpoint | 涓嶅己鍒跺叡鐢紱姣忎釜妯″瀷鍙厤缃嫭绔� endpoint锛屽涓荤粺涓�鎸� `modelId` 璺敱 |
 | 鏄惁淇濈暀鍘嗗彶璁板綍 | MVP 涓嶄繚鐣欙紝浠呬繚鐣欏綋鍓嶇粨鏋� |
 | 鏄惁鏀寔鍋滄鐢熸垚 | MVP 鍙殏涓嶆敮鎸侊紝鍚庣画鏂板鍋滄鎸夐挳鎴� Escape 浜屾琛屼负 |
 | 鏄惁鍏ㄥ眬蹇嵎閿敜璧� | 鍚庣画鐗堟湰鑰冭檻锛屼緥濡� `Alt+Space` 鎴栫敤鎴疯嚜瀹氫箟蹇嵎閿� |
-
diff --git a/docs/qa/llm-command-palette-acceptance-2026-05-04.md b/docs/qa/llm-command-palette-acceptance-2026-05-04.md
new file mode 100644
index 0000000..1bf91a6
--- /dev/null
+++ b/docs/qa/llm-command-palette-acceptance-2026-05-04.md
@@ -0,0 +1,65 @@
+# LLM 妗岄潰杈撳叆鎻掍欢楠屾敹璁板綍
+
+鏃ユ湡锛�2026-05-04
+
+## 鑼冨洿
+
+鏈楠屾敹瑕嗙洊 `sample.llm-command-palette` 鎻掍欢鍜屽涓讳晶 LLM 浠g悊鏈�灏忛棴鐜細
+
+- LLM 妯″瀷閰嶇疆鏂囦欢 `llm-models.json`銆�
+- 姣忔ā鍨嬬嫭绔� `provider`銆乣endpoint`銆乣authRef`銆乣apiModel` 鐨勮矾鐢辩粨鏋勩��
+- `ILlmGatewayService`銆乣ILlmModelRegistry`銆乣ICredentialStore`銆乣ILlmProviderAdapter`銆�
+- WebView bridge 鐨� `window.moliDesktop.llm` API銆�
+- OpenAI-compatible 娴佸紡鍝嶅簲瑙f瀽銆�
+- 椤堕儴鍗婇�忔槑杈撳叆鎻掍欢闈欐�佹覆鏌撱��
+
+## 楠屾敹缁撹
+
+褰撳墠瀹炵幇婊¤冻鏈疆闇�姹傜殑寮�鍙戦獙鏀舵潯浠讹紝鍙繘鍏ュ悗缁湡瀹炰緵搴斿晢鑱旇皟銆�
+
+宸查�氳繃锛�
+
+- 鑷姩鍖栨瀯寤恒��
+- 鑷姩鍖栧崟鍏冩祴璇曘��
+- 鏍蜂緥鎻掍欢闈欐�佹覆鏌撻潪绌烘鏌ャ��
+
+鏈鐩栵細
+
+- 鐪熷疄 OpenAI / DeepSeek / 鏈湴妯″瀷鏈嶅姟鐨勮仈缃戣姹傘��
+- Windows Credential Manager 鐢熶骇瀵嗛挜瀛樺偍銆�
+- 绠$悊绐楀彛閲岀殑妯″瀷閰嶇疆缂栬緫 UI銆�
+
+## 鎵ц缁撴灉
+
+| 椤圭洰 | 鍛戒护鎴栨柟娉� | 缁撴灉 |
+| --- | --- | --- |
+| 鏋勫缓 | `dotnet build .\Moli.Desktop.slnx` | 閫氳繃锛�0 warning锛�0 error |
+| 鑷姩鍖栨祴璇� | `dotnet test .\Moli.Desktop.slnx` | 閫氳繃锛�36/36 |
+| 鏍蜂緥鎻掍欢娓叉煋 | Edge headless 鎵撳紑 `samples/plugins/sample.llm-command-palette/index.html` | 閫氳繃锛岀敓鎴愭埅鍥� |
+| 鍍忕礌妫�鏌� | 閲囨牱鎴浘鍍忕礌 | 閫氳繃锛宍Sampled=1620 NonWhite=1620 NonTransparent=1620` |
+
+娓叉煋鎴浘锛�
+
+- `artifacts/llm-command-palette-edge-render-check.png`
+
+## 鍔熻兘楠屾敹
+
+| 楠屾敹鐐� | 缁撴灉 | 璇存槑 |
+| --- | --- | --- |
+| 鎻掍欢榛樿 manifest 鍚堟硶 | 閫氳繃 | 鏂板 `sample.llm-command-palette/plugin.json`锛屽0鏄� `llm.stream` 鏉冮檺 |
+| 鎻掍欢鏍峰紡涓洪《閮ㄥ崐閫忔槑杈撳叆鏉� | 閫氳繃 | HTML/CSS 瀹炵幇娣辫壊鍗婇�忔槑杈撳叆鏉°�佹ā鍨嬩笅鎷夊拰杈撳嚭鍖哄煙 |
+| Enter 鎻愪氦銆丼hift+Enter 鎹㈣ | 閫氳繃 | 鍓嶇浜嬩欢宸插疄鐜� |
+| 妯″瀷閫夋嫨浠庡涓昏鍙� | 閫氳繃 | `window.moliDesktop.llm.getModels()` 杩斿洖瀹夊叏妯″瀷鎽樿 |
+| 鎻掍欢涓嶆帴瑙� endpoint/key | 閫氳繃 | bridge 鍙繑鍥� id銆乴abel銆乸rovider銆乻upportsStreaming銆乪nabled |
+| 姣忔ā鍨嬬嫭绔嬭矾鐢� | 閫氳繃 | `LlmGatewayServiceTests` 楠岃瘉鎵�閫� `modelId` 璺敱鍒板搴� endpoint |
+| 鏈0鏄庢潈闄愭嫆缁濇祦寮忚皟鐢� | 閫氳繃 | bridge 娴嬭瘯瑕嗙洊 `BridgePermissionDenied` |
+| 娴佸紡浜嬩欢娲惧彂鍒版彃浠� | 閫氳繃 | bridge 娴嬭瘯瑕嗙洊 `llm.delta` 浜嬩欢鍙戝竷 |
+| 閰嶇疆鎹熷潖鎭㈠ | 閫氳繃 | `llm-models.json` 鎹熷潖鍚庡浠藉苟鎭㈠榛樿鍊� |
+| 闈炴硶妯″瀷杩囨护 | 閫氳繃 | 閲嶅 id 鍜岄潪娉� endpoint 浼氳杩囨护骞惰褰曡瘖鏂� |
+
+## 椋庨櫓涓庡悗缁�
+
+- 褰撳墠瀵嗛挜瀛樺偍瀹炵幇涓虹幆澧冨彉閲� fallback锛宍authRef` 鐨� Windows Credential Manager 瀹炵幇浠嶉渶琛ラ綈銆�
+- 褰撳墠 provider adapter 浼樺厛瑕嗙洊 OpenAI-compatible SSE 鍗忚锛涘鏋� DeepSeek 瀹為檯鎺ュ彛瀛樺湪宸紓锛屽簲鏂板鐙珛 `DeepSeekAdapter`銆�
+- 绠$悊绐楀彛灏氭湭鎻愪緵妯″瀷閰嶇疆 UI锛涚煭鏈熷彲鎵嬪伐缂栬緫 `%AppData%\DesktopEnhancer\config\llm-models.json`銆�
+- 鐪熷疄渚涘簲鍟嗛獙鏀堕渶瑕佸噯澶囧彲鐢� endpoint 鍜� key锛屽啀鎵ц绔埌绔祦寮忚緭鍑烘祴璇曘��
diff --git a/samples/plugins/sample.llm-command-palette/index.html b/samples/plugins/sample.llm-command-palette/index.html
new file mode 100644
index 0000000..9617dd9
--- /dev/null
+++ b/samples/plugins/sample.llm-command-palette/index.html
@@ -0,0 +1,273 @@
+<!doctype html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <title>LLM Command Palette</title>
+  <style>
+    :root {
+      color-scheme: dark;
+      font-family: "Segoe UI", system-ui, sans-serif;
+      background: transparent;
+    }
+
+    * {
+      box-sizing: border-box;
+    }
+
+    html,
+    body {
+      width: 100%;
+      min-height: 100%;
+      margin: 0;
+      background: transparent;
+      overflow: hidden;
+    }
+
+    body {
+      padding: 8px;
+    }
+
+    .shell {
+      width: 100%;
+      color: rgba(255, 255, 255, 0.92);
+    }
+
+    .bar,
+    .output {
+      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);
+      backdrop-filter: blur(18px);
+    }
+
+    .bar {
+      display: grid;
+      grid-template-columns: 24px minmax(0, 1fr) 128px;
+      align-items: center;
+      gap: 14px;
+      min-height: 56px;
+      padding: 0 18px;
+      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);
+    }
+
+    select {
+      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;
+      font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+    }
+
+    .output {
+      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 {
+      display: block;
+    }
+
+    .actions {
+      display: flex;
+      justify-content: flex-end;
+      gap: 8px;
+      margin-top: 12px;
+    }
+
+    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;
+    }
+
+    .error {
+      color: #ffad9b;
+    }
+  </style>
+</head>
+<body>
+  <main class="shell">
+    <section class="bar">
+      <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>
+    </section>
+    <section id="output" class="output" aria-live="polite">
+      <div id="text"></div>
+      <div class="actions">
+        <button id="copy" title="Copy">C</button>
+        <button id="collapse" title="Collapse">-</button>
+      </div>
+    </section>
+  </main>
+
+  <script>
+    const promptInput = document.getElementById("prompt");
+    const modelSelect = document.getElementById("model");
+    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");
+    let activeRequestId = null;
+    let currentText = "";
+
+    function setBusy(busy) {
+      mark.classList.toggle("busy", busy);
+      mark.textContent = busy ? "*" : "*";
+    }
+
+    function openOutput() {
+      output.classList.add("open");
+      window.moliDesktop?.requestResize?.({ width: document.body.scrollWidth, height: Math.min(window.innerHeight, document.body.scrollHeight) }).catch(() => {});
+    }
+
+    function setError(message) {
+      currentText = message;
+      text.className = "error";
+      text.textContent = message;
+      openOutput();
+    }
+
+    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);
+        }
+      } catch {
+        modelSelect.innerHTML = "<option value=\"\">No models</option>";
+      }
+    }
+
+    async function submitPrompt() {
+      const content = promptInput.value.trim();
+      const modelId = modelSelect.value;
+      if (!content || !modelId || activeRequestId) return;
+
+      currentText = "";
+      text.className = "";
+      text.textContent = "";
+      openOutput();
+      setBusy(true);
+
+      try {
+        const response = await window.moliDesktop.llm.streamChat({
+          modelId,
+          messages: [{ role: "user", content }],
+          options: {}
+        });
+        activeRequestId = response.requestId;
+      } catch (error) {
+        activeRequestId = null;
+        setBusy(false);
+        setError(error?.message || "LLM request could not be started.");
+      }
+    }
+
+    promptInput.addEventListener("keydown", (event) => {
+      if (event.key === "Enter" && !event.shiftKey) {
+        event.preventDefault();
+        submitPrompt();
+      }
+
+      if (event.key === "Escape") {
+        output.classList.remove("open");
+      }
+    });
+
+    promptInput.addEventListener("input", () => {
+      promptInput.style.height = "0";
+      promptInput.style.height = `${Math.min(promptInput.scrollHeight, 78)}px`;
+    });
+
+    collapse.addEventListener("click", () => output.classList.remove("open"));
+    copy.addEventListener("click", () => navigator.clipboard?.writeText(currentText).catch(() => {}));
+
+    window.addEventListener("DOMContentLoaded", loadModels);
+    window.moliDesktop?.llm?.onDelta?.((event) => {
+      if (event.requestId !== activeRequestId) return;
+      currentText += event.delta || "";
+      text.textContent = currentText;
+      output.scrollTop = output.scrollHeight;
+    });
+    window.moliDesktop?.llm?.onCompleted?.((event) => {
+      if (event.requestId !== activeRequestId) return;
+      activeRequestId = null;
+      setBusy(false);
+    });
+    window.moliDesktop?.llm?.onError?.((event) => {
+      if (event.requestId !== activeRequestId) return;
+      activeRequestId = null;
+      setBusy(false);
+      setError(event.message || "LLM request failed.");
+    });
+  </script>
+</body>
+</html>
diff --git a/samples/plugins/sample.llm-command-palette/plugin.json b/samples/plugins/sample.llm-command-palette/plugin.json
new file mode 100644
index 0000000..c23e873
--- /dev/null
+++ b/samples/plugins/sample.llm-command-palette/plugin.json
@@ -0,0 +1,28 @@
+{
+  "id": "sample.llm-command-palette",
+  "name": "LLM Command Palette",
+  "version": "1.0.0",
+  "type": "widget",
+  "entry": "index.html",
+  "description": "A translucent desktop prompt bar for streaming LLM responses.",
+  "author": "Moli.Desktop",
+  "permissions": [
+    "llm.stream",
+    "config.read"
+  ],
+  "defaultLayout": {
+    "x": 580,
+    "y": 32,
+    "width": 760,
+    "height": 72,
+    "locked": true,
+    "clickThrough": false,
+    "opacity": 0.96,
+    "scale": 1,
+    "displayLayer": "desktop"
+  },
+  "config": {
+    "defaultModel": "",
+    "models": []
+  }
+}
diff --git a/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs b/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs
new file mode 100644
index 0000000..50b76ed
--- /dev/null
+++ b/src/Moli.Desktop.Tests/Llm/LlmGatewayServiceTests.cs
@@ -0,0 +1,143 @@
+using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Host;
+using Moli.Desktop.Llm;
+using Microsoft.Extensions.Logging.Abstractions;
+
+namespace Moli.Desktop.Tests.Llm;
+
+public class LlmGatewayServiceTests
+{
+    [Fact]
+    public async Task StreamChatAsync_RoutesSelectedModelToMatchingAdapter()
+    {
+        var adapter = new CapturingAdapter("openai-compatible");
+        var gateway = CreateGateway(adapter, new LlmModelConfig
+        {
+            Id = "model-a",
+            Label = "Model A",
+            Provider = "openai-compatible",
+            Endpoint = "http://127.0.0.1:11434/v1/chat/completions",
+            ApiModel = "actual-model",
+            Enabled = true
+        });
+
+        var events = await gateway.StreamChatAsync(new LlmChatRequest
+        {
+            RequestId = "req-1",
+            PluginId = "sample.llm-command-palette",
+            InstanceId = "host-1",
+            ModelId = "model-a",
+            Messages = [new LlmMessage { Role = "user", Content = "hello" }]
+        }).ToListAsync();
+
+        Assert.Equal("http://127.0.0.1:11434/v1/chat/completions", adapter.LastRequest?.Model.Endpoint);
+        Assert.Contains(events, item => item is LlmDeltaEvent { Delta: "ok" });
+        Assert.Contains(events, item => item is LlmCompletedEvent);
+    }
+
+    [Fact]
+    public async Task StreamChatAsync_ReturnsModelNotFoundForDisabledModel()
+    {
+        var gateway = CreateGateway(new CapturingAdapter("openai-compatible"), new LlmModelConfig
+        {
+            Id = "model-a",
+            Label = "Model A",
+            Provider = "openai-compatible",
+            Endpoint = "http://127.0.0.1:11434/v1/chat/completions",
+            ApiModel = "actual-model",
+            Enabled = false
+        });
+
+        var events = await gateway.StreamChatAsync(new LlmChatRequest
+        {
+            RequestId = "req-2",
+            PluginId = "sample.llm-command-palette",
+            InstanceId = "host-1",
+            ModelId = "model-a",
+            Messages = [new LlmMessage { Role = "user", Content = "hello" }]
+        }).ToListAsync();
+
+        var error = Assert.IsType<LlmErrorEvent>(Assert.Single(events));
+        Assert.Equal(LlmErrorCodes.ModelNotFound, error.Code);
+    }
+
+    [Fact]
+    public async Task StreamChatAsync_UsesOpenAICompatibleAdapterForDeepSeekAlias()
+    {
+        var adapter = new CapturingAdapter("openai-compatible");
+        var gateway = CreateGateway(adapter, new LlmModelConfig
+        {
+            Id = "deepseek-chat",
+            Label = "DeepSeek",
+            Provider = "deepseek",
+            Endpoint = "https://api.deepseek.com/chat/completions",
+            ApiModel = "deepseek-chat",
+            Enabled = true
+        });
+
+        var events = await gateway.StreamChatAsync(new LlmChatRequest
+        {
+            RequestId = "req-3",
+            PluginId = "sample.llm-command-palette",
+            InstanceId = "host-1",
+            ModelId = "deepseek-chat",
+            Messages = [new LlmMessage { Role = "user", Content = "hello" }]
+        }).ToListAsync();
+
+        Assert.Equal("deepseek", adapter.LastRequest?.Model.Provider);
+        Assert.Contains(events, item => item is LlmDeltaEvent { Delta: "ok" });
+    }
+
+    private static LlmGatewayService CreateGateway(CapturingAdapter adapter, 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"));
+        var diagnostics = new DiagnosticsService(paths, NullLogger<DiagnosticsService>.Instance);
+        return new LlmGatewayService(
+            new InMemoryRegistry(models),
+            new EnvironmentCredentialStore(),
+            new LlmProviderAdapterFactory([adapter]),
+            diagnostics);
+    }
+
+    private sealed class InMemoryRegistry(IEnumerable<LlmModelConfig> models) : ILlmModelRegistry
+    {
+        private readonly List<LlmModelConfig> _models = [.. models];
+
+        public Task<LlmSettingsDocument> LoadAsync(CancellationToken cancellationToken = default)
+            => Task.FromResult(new LlmSettingsDocument { Models = _models });
+
+        public Task<LlmModelConfig?> GetEnabledModelAsync(string modelId, CancellationToken cancellationToken = default)
+            => Task.FromResult(_models.FirstOrDefault(model => model.Enabled && model.Id == modelId));
+    }
+
+    private sealed class CapturingAdapter(string provider) : ILlmProviderAdapter
+    {
+        public string Provider { get; } = provider;
+        public LlmProviderRequest? LastRequest { get; private set; }
+
+        public async IAsyncEnumerable<LlmProviderChunk> StreamAsync(
+            LlmProviderRequest request,
+            [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default)
+        {
+            await Task.Yield();
+            LastRequest = request;
+            yield return new LlmProviderChunk { Delta = "ok" };
+            yield return new LlmProviderChunk { IsCompleted = true };
+        }
+    }
+}
+
+internal static class AsyncEnumerableTestExtensions
+{
+    public static async Task<List<T>> ToListAsync<T>(this IAsyncEnumerable<T> source)
+    {
+        var results = new List<T>();
+        await foreach (var item in source)
+        {
+            results.Add(item);
+        }
+
+        return results;
+    }
+}
diff --git a/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs b/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs
new file mode 100644
index 0000000..03c53b1
--- /dev/null
+++ b/src/Moli.Desktop.Tests/Llm/LlmModelRegistryTests.cs
@@ -0,0 +1,87 @@
+using Microsoft.Extensions.Logging.Abstractions;
+using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Host;
+using Moli.Desktop.Llm;
+
+namespace Moli.Desktop.Tests.Llm;
+
+public class LlmModelRegistryTests
+{
+    [Fact]
+    public async Task LoadAsync_CreatesDefaultLlmModelDocument()
+    {
+        var (registry, paths, _) = CreateRegistry();
+
+        var document = await registry.LoadAsync();
+
+        Assert.Equal(1, document.SchemaVersion);
+        Assert.True(File.Exists(Path.Combine(paths.ConfigDirectory, LlmModelRegistry.FileName)));
+    }
+
+    [Fact]
+    public async Task LoadAsync_FiltersInvalidAndDuplicateModels()
+    {
+        var (registry, paths, diagnostics) = CreateRegistry();
+        Directory.CreateDirectory(paths.ConfigDirectory);
+        await File.WriteAllTextAsync(Path.Combine(paths.ConfigDirectory, LlmModelRegistry.FileName), """
+        {
+          "schemaVersion": 1,
+          "defaultModel": "valid",
+          "models": [
+            {
+              "id": "valid",
+              "label": "Valid",
+              "provider": "openai-compatible",
+              "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+              "apiModel": "qwen",
+              "enabled": true
+            },
+            {
+              "id": "valid",
+              "label": "Duplicate",
+              "provider": "openai-compatible",
+              "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
+              "apiModel": "qwen",
+              "enabled": true
+            },
+            {
+              "id": "bad-url",
+              "label": "Bad",
+              "provider": "openai-compatible",
+              "endpoint": "file:///tmp/model",
+              "apiModel": "qwen",
+              "enabled": true
+            }
+          ]
+        }
+        """);
+
+        var document = await registry.LoadAsync();
+
+        Assert.Single(document.Models);
+        Assert.Equal("valid", document.DefaultModel);
+        Assert.Contains(diagnostics.Snapshot(), entry => entry.Code == "LlmModelInvalid");
+    }
+
+    [Fact]
+    public async Task LoadAsync_BacksUpInvalidJsonAndRecovers()
+    {
+        var (registry, paths, diagnostics) = CreateRegistry();
+        Directory.CreateDirectory(paths.ConfigDirectory);
+        await File.WriteAllTextAsync(Path.Combine(paths.ConfigDirectory, LlmModelRegistry.FileName), "{ broken");
+
+        var document = await registry.LoadAsync();
+
+        Assert.Equal(1, document.SchemaVersion);
+        Assert.NotEmpty(Directory.GetFiles(paths.ConfigDirectory, "llm-models.invalid.*.json"));
+        Assert.Contains(diagnostics.Snapshot(), entry => entry.Code == DiagnosticCodes.ConfigurationRecovered);
+    }
+
+    private static (LlmModelRegistry Registry, DesktopPaths Paths, DiagnosticsService Diagnostics) CreateRegistry()
+    {
+        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 LlmModelRegistry(paths, diagnostics), paths, diagnostics);
+    }
+}
diff --git a/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs b/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs
index cc879a3..5c441e8 100644
--- a/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs
+++ b/src/Moli.Desktop.Tests/WebView/PluginBridgeDispatcherTests.cs
@@ -2,6 +2,7 @@
 using Microsoft.Extensions.Logging.Abstractions;
 using Moli.Desktop.Diagnostics;
 using Moli.Desktop.Host;
+using Moli.Desktop.Llm;
 using Moli.Desktop.Plugins;
 using Moli.Desktop.Runtime;
 using Moli.Desktop.WebView;
@@ -56,12 +57,66 @@
     }
 
     [Fact]
+    public async Task DispatchAsync_ReturnsSafeLlmModelSummaries()
+    {
+        var dispatcher = CreateDispatcher(out _, out _);
+
+        var response = await dispatcher.DispatchAsync("""{"id":"4","method":"llm.getModels"}""", CreateContext());
+
+        Assert.True(response.Success);
+        var json = JsonSerializer.Serialize(response.Result, new JsonSerializerOptions(JsonSerializerDefaults.Web));
+        Assert.Contains("gpt-test", json);
+        Assert.DoesNotContain("endpoint", json, StringComparison.OrdinalIgnoreCase);
+    }
+
+    [Fact]
+    public async Task DispatchAsync_RejectsLlmStreamWithoutPermission()
+    {
+        var dispatcher = CreateDispatcher(out _, out _);
+        var context = CreateContext(includeLlmPermission: false);
+
+        var response = await dispatcher.DispatchAsync(
+            """{"id":"5","method":"llm.streamChat","params":{"modelId":"gpt-test","messages":[{"role":"user","content":"hello"}]}}""",
+            context);
+
+        Assert.False(response.Success);
+        Assert.Equal("BridgePermissionDenied", response.Error?.Code);
+    }
+
+    [Fact]
+    public async Task DispatchAsync_StartsLlmStreamForPermittedPlugin()
+    {
+        var dispatcher = CreateDispatcher(out _, out var events);
+        var seenDelta = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
+        using var subscription = events.Subscribe(runtimeEvent =>
+        {
+            if (runtimeEvent.Name == "llm.delta")
+            {
+                seenDelta.TrySetResult(JsonSerializer.Serialize(runtimeEvent.Payload));
+            }
+
+            return Task.CompletedTask;
+        });
+
+        var response = await dispatcher.DispatchAsync(
+            """{"id":"6","method":"llm.streamChat","params":{"modelId":"gpt-test","messages":[{"role":"user","content":"hello"}]}}""",
+            CreateContext());
+
+        Assert.True(response.Success);
+        var completed = await Task.WhenAny(seenDelta.Task, Task.Delay(TimeSpan.FromSeconds(3)));
+        Assert.Same(seenDelta.Task, completed);
+        Assert.Contains("Hello", await seenDelta.Task);
+    }
+
+    [Fact]
     public void BridgeScript_ExposesExpectedPluginMethods()
     {
         var script = PluginBridgeScript.Build();
 
         Assert.Contains("getRuntimeInfo", script);
         Assert.Contains("requestResize", script);
+        Assert.Contains("llm", script);
+        Assert.Contains("streamChat", script);
         Assert.Contains("moliDesktopResponse", script);
     }
 
@@ -71,10 +126,10 @@
         var paths = new DesktopPaths(Path.Combine(root, "app"), Path.Combine(root, "local"));
         diagnostics = new DiagnosticsService(paths, NullLogger<DiagnosticsService>.Instance);
         events = new RuntimeEventBus();
-        return new PluginBridgeDispatcher(diagnostics, events);
+        return new PluginBridgeDispatcher(diagnostics, events, new FakeLlmGateway());
     }
 
-    private static PluginBridgeContext CreateContext()
+    private static PluginBridgeContext CreateContext(bool includeLlmPermission = true)
     {
         return new PluginBridgeContext
         {
@@ -85,7 +140,8 @@
                 Name = "Clock",
                 Version = "1.0.0",
                 Type = PluginType.Widget,
-                Entry = "index.html"
+                Entry = "index.html",
+                Permissions = includeLlmPermission ? ["llm.stream"] : []
             },
             RuntimeInfo = new PluginRuntimeBridgeInfo
             {
@@ -96,4 +152,31 @@
             Config = JsonDocument.Parse("""{"label":"clock"}""").RootElement.Clone()
         };
     }
+
+    private sealed class FakeLlmGateway : ILlmGatewayService
+    {
+        public Task CancelAsync(string requestId, CancellationToken cancellationToken = default) => Task.CompletedTask;
+
+        public Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(CancellationToken cancellationToken = default)
+            => Task.FromResult<IReadOnlyList<LlmModelSummary>>(
+            [
+                new LlmModelSummary
+                {
+                    Id = "gpt-test",
+                    Label = "GPT Test",
+                    Provider = "openai-compatible",
+                    SupportsStreaming = true,
+                    Enabled = true
+                }
+            ]);
+
+        public async IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+            LlmChatRequest request,
+            [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default)
+        {
+            await Task.Yield();
+            yield return new LlmDeltaEvent { RequestId = request.RequestId, Delta = "Hello" };
+            yield return new LlmCompletedEvent { RequestId = request.RequestId };
+        }
+    }
 }
diff --git a/src/Moli.Desktop/Host/DefaultContentInstaller.cs b/src/Moli.Desktop/Host/DefaultContentInstaller.cs
index b41fdad..1d03f7d 100644
--- a/src/Moli.Desktop/Host/DefaultContentInstaller.cs
+++ b/src/Moli.Desktop/Host/DefaultContentInstaller.cs
@@ -17,7 +17,8 @@
         "sample.wallpaper",
         "sample.clock",
         "sample.system-info",
-        "sample.audio-visualizer"
+        "sample.audio-visualizer",
+        "sample.llm-command-palette"
     };
 
     private readonly DesktopPaths _paths;
@@ -219,14 +220,34 @@
     private static bool IsAudioVisualizer(PluginManifest manifest)
         => string.Equals(manifest.Id, "sample.audio-visualizer", StringComparison.OrdinalIgnoreCase);
 
+    private static bool IsLlmCommandPalette(PluginManifest manifest)
+        => string.Equals(manifest.Id, "sample.llm-command-palette", StringComparison.OrdinalIgnoreCase);
+
     private static double ResolveDefaultX(PluginManifest manifest)
-        => IsAudioVisualizer(manifest) ? 0 : manifest.DefaultLayout.X;
+    {
+        if (IsAudioVisualizer(manifest))
+        {
+            return 0;
+        }
+
+        if (IsLlmCommandPalette(manifest))
+        {
+            var width = ResolveDefaultWidth(manifest);
+            return Math.Max(0, (SystemParameters.PrimaryScreenWidth - width) / 2);
+        }
+
+        return manifest.DefaultLayout.X;
+    }
 
     private static double ResolveDefaultY(PluginManifest manifest)
         => IsAudioVisualizer(manifest) ? SystemParameters.PrimaryScreenHeight * 2 / 3 : manifest.DefaultLayout.Y;
 
     private static double ResolveDefaultWidth(PluginManifest manifest)
-        => IsAudioVisualizer(manifest) ? SystemParameters.PrimaryScreenWidth : manifest.DefaultLayout.Width;
+        => IsAudioVisualizer(manifest)
+            ? SystemParameters.PrimaryScreenWidth
+            : IsLlmCommandPalette(manifest)
+                ? Math.Min(manifest.DefaultLayout.Width, SystemParameters.PrimaryScreenWidth * 0.72)
+                : manifest.DefaultLayout.Width;
 
     private static double ResolveDefaultHeight(PluginManifest manifest)
         => IsAudioVisualizer(manifest)
diff --git a/src/Moli.Desktop/Host/DesktopHostBuilder.cs b/src/Moli.Desktop/Host/DesktopHostBuilder.cs
index 070bf69..353614a 100644
--- a/src/Moli.Desktop/Host/DesktopHostBuilder.cs
+++ b/src/Moli.Desktop/Host/DesktopHostBuilder.cs
@@ -7,6 +7,7 @@
 using Moli.Desktop.Interop;
 using Moli.Desktop.Layout;
 using Moli.Desktop.Api;
+using Moli.Desktop.Llm;
 using Moli.Desktop.Management;
 using Moli.Desktop.Plugins;
 using Moli.Desktop.Runtime;
@@ -37,6 +38,12 @@
                 services.AddSingleton<IRuntimeSurfaceController, RuntimeSurfaceController>();
                 services.AddSingleton<IDesktopRuntime, DesktopRuntimeCoordinator>();
                 services.AddSingleton<IConfigurationService, JsonConfigurationService>();
+                services.AddSingleton<ILlmModelRegistry, LlmModelRegistry>();
+                services.AddSingleton<ICredentialStore, EnvironmentCredentialStore>();
+                services.AddHttpClient<OpenAICompatibleAdapter>();
+                services.AddSingleton<ILlmProviderAdapter>(sp => sp.GetRequiredService<OpenAICompatibleAdapter>());
+                services.AddSingleton<ILlmProviderAdapterFactory, LlmProviderAdapterFactory>();
+                services.AddSingleton<ILlmGatewayService, LlmGatewayService>();
                 services.AddSingleton<IPluginManifestValidator, PluginManifestValidator>();
                 services.AddSingleton<PluginStateMachine>();
                 services.AddSingleton<IPluginManager, PluginManager>();
diff --git a/src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs b/src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs
new file mode 100644
index 0000000..81d040c
--- /dev/null
+++ b/src/Moli.Desktop/Llm/EnvironmentCredentialStore.cs
@@ -0,0 +1,25 @@
+namespace Moli.Desktop.Llm;
+
+public sealed class EnvironmentCredentialStore : ICredentialStore
+{
+    public Task<string?> ResolveSecretAsync(string? authRef, CancellationToken cancellationToken = default)
+    {
+        cancellationToken.ThrowIfCancellationRequested();
+        if (string.IsNullOrWhiteSpace(authRef))
+        {
+            return Task.FromResult<string?>(null);
+        }
+
+        var direct = Environment.GetEnvironmentVariable(authRef);
+        if (!string.IsNullOrWhiteSpace(direct))
+        {
+            return Task.FromResult<string?>(direct);
+        }
+
+        var normalized = "MOLI_" + new string(authRef
+            .Select(ch => char.IsLetterOrDigit(ch) ? char.ToUpperInvariant(ch) : '_')
+            .ToArray());
+
+        return Task.FromResult(Environment.GetEnvironmentVariable(normalized));
+    }
+}
diff --git a/src/Moli.Desktop/Llm/ILlmServices.cs b/src/Moli.Desktop/Llm/ILlmServices.cs
new file mode 100644
index 0000000..777ac1e
--- /dev/null
+++ b/src/Moli.Desktop/Llm/ILlmServices.cs
@@ -0,0 +1,37 @@
+namespace Moli.Desktop.Llm;
+
+public interface ILlmGatewayService
+{
+    Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(CancellationToken cancellationToken = default);
+
+    IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+        LlmChatRequest request,
+        CancellationToken cancellationToken = default);
+
+    Task CancelAsync(string requestId, CancellationToken cancellationToken = default);
+}
+
+public interface ILlmModelRegistry
+{
+    Task<LlmSettingsDocument> LoadAsync(CancellationToken cancellationToken = default);
+    Task<LlmModelConfig?> GetEnabledModelAsync(string modelId, CancellationToken cancellationToken = default);
+}
+
+public interface ILlmProviderAdapter
+{
+    string Provider { get; }
+
+    IAsyncEnumerable<LlmProviderChunk> StreamAsync(
+        LlmProviderRequest request,
+        CancellationToken cancellationToken = default);
+}
+
+public interface ILlmProviderAdapterFactory
+{
+    ILlmProviderAdapter? Get(string provider);
+}
+
+public interface ICredentialStore
+{
+    Task<string?> ResolveSecretAsync(string? authRef, CancellationToken cancellationToken = default);
+}
diff --git a/src/Moli.Desktop/Llm/LlmGatewayService.cs b/src/Moli.Desktop/Llm/LlmGatewayService.cs
new file mode 100644
index 0000000..3290988
--- /dev/null
+++ b/src/Moli.Desktop/Llm/LlmGatewayService.cs
@@ -0,0 +1,243 @@
+using System.Collections.Concurrent;
+using System.Net.Http;
+using System.Runtime.CompilerServices;
+using Moli.Desktop.Diagnostics;
+
+namespace Moli.Desktop.Llm;
+
+public sealed class LlmGatewayService : ILlmGatewayService
+{
+    private static readonly HashSet<string> AllowedRoles = new(StringComparer.OrdinalIgnoreCase)
+    {
+        "system",
+        "user",
+        "assistant"
+    };
+
+    private readonly ILlmModelRegistry _registry;
+    private readonly ICredentialStore _credentialStore;
+    private readonly ILlmProviderAdapterFactory _adapterFactory;
+    private readonly IDiagnosticsService _diagnostics;
+    private readonly ConcurrentDictionary<string, CancellationTokenSource> _activeRequests = new(StringComparer.OrdinalIgnoreCase);
+
+    public LlmGatewayService(
+        ILlmModelRegistry registry,
+        ICredentialStore credentialStore,
+        ILlmProviderAdapterFactory adapterFactory,
+        IDiagnosticsService diagnostics)
+    {
+        _registry = registry;
+        _credentialStore = credentialStore;
+        _adapterFactory = adapterFactory;
+        _diagnostics = diagnostics;
+    }
+
+    public async Task<IReadOnlyList<LlmModelSummary>> GetModelsAsync(CancellationToken cancellationToken = default)
+    {
+        var document = await _registry.LoadAsync(cancellationToken).ConfigureAwait(false);
+        return document.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();
+    }
+
+    public async IAsyncEnumerable<LlmStreamEvent> StreamChatAsync(
+        LlmChatRequest request,
+        [EnumeratorCancellation] CancellationToken cancellationToken = default)
+    {
+        if (!IsValidRequest(request, out var validationError))
+        {
+            yield return new LlmErrorEvent
+            {
+                RequestId = request.RequestId,
+                Code = LlmErrorCodes.RequestInvalid,
+                Message = validationError
+            };
+            yield break;
+        }
+
+        var model = await _registry.GetEnabledModelAsync(request.ModelId, cancellationToken).ConfigureAwait(false);
+        if (model is null)
+        {
+            yield return new LlmErrorEvent
+            {
+                RequestId = request.RequestId,
+                Code = LlmErrorCodes.ModelNotFound,
+                Message = "Selected LLM model is unavailable."
+            };
+            yield break;
+        }
+
+        var adapter = _adapterFactory.Get(model.Provider);
+        if (adapter is null)
+        {
+            yield return new LlmErrorEvent
+            {
+                RequestId = request.RequestId,
+                Code = LlmErrorCodes.ProviderUnsupported,
+                Message = "Selected LLM provider is unsupported."
+            };
+            yield break;
+        }
+
+        var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
+        var timeoutMs = request.Options.TimeoutMs ?? model.RequestDefaults.TimeoutMs;
+        linkedCts.CancelAfter(TimeSpan.FromMilliseconds(timeoutMs));
+        _activeRequests[request.RequestId] = linkedCts;
+
+        var secret = await _credentialStore.ResolveSecretAsync(model.AuthRef, linkedCts.Token).ConfigureAwait(false);
+        if (!string.IsNullOrWhiteSpace(model.AuthRef) && string.IsNullOrWhiteSpace(secret))
+        {
+            yield return new LlmErrorEvent
+            {
+                RequestId = request.RequestId,
+                Code = LlmErrorCodes.CredentialMissing,
+                Message = "LLM credential is missing. Check the model authRef configuration."
+            };
+            yield break;
+        }
+
+        var providerRequest = new LlmProviderRequest
+        {
+            RequestId = request.RequestId,
+            Model = model,
+            Messages = request.Messages,
+            Options = request.Options,
+            ApiKey = secret
+        };
+
+        await using var enumerator = adapter.StreamAsync(providerRequest, linkedCts.Token).GetAsyncEnumerator(linkedCts.Token);
+        while (true)
+        {
+            LlmStreamEvent? nextEvent = null;
+            try
+            {
+                if (!await enumerator.MoveNextAsync().ConfigureAwait(false))
+                {
+                    _activeRequests.TryRemove(request.RequestId, out _);
+                    linkedCts.Dispose();
+                    yield break;
+                }
+
+                var chunk = enumerator.Current;
+                if (!string.IsNullOrEmpty(chunk.Delta))
+                {
+                    nextEvent = new LlmDeltaEvent { RequestId = request.RequestId, Delta = chunk.Delta };
+                }
+                if (chunk.IsCompleted)
+                {
+                    nextEvent = new LlmCompletedEvent { RequestId = request.RequestId, Usage = chunk.Usage };
+                }
+            }
+            catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
+            {
+                nextEvent = new LlmErrorEvent
+                {
+                    RequestId = request.RequestId,
+                    Code = LlmErrorCodes.Timeout,
+                    Message = "LLM request timed out."
+                };
+            }
+            catch (HttpRequestException ex)
+            {
+                RecordFailure(request, model, LlmErrorCodes.EndpointUnavailable, ex.GetType().Name);
+                nextEvent = new LlmErrorEvent
+                {
+                    RequestId = request.RequestId,
+                    Code = LlmErrorCodes.EndpointUnavailable,
+                    Message = "LLM endpoint is unavailable."
+                };
+            }
+            catch (LlmProviderException ex)
+            {
+                RecordFailure(request, model, ex.Code, ex.GetType().Name);
+                nextEvent = new LlmErrorEvent
+                {
+                    RequestId = request.RequestId,
+                    Code = ex.Code,
+                    Message = ex.Message
+                };
+            }
+            finally
+            {
+                if (nextEvent is LlmCompletedEvent or LlmErrorEvent)
+                {
+                    _activeRequests.TryRemove(request.RequestId, out _);
+                    linkedCts.Dispose();
+                }
+            }
+
+            if (nextEvent is null)
+            {
+                continue;
+            }
+
+            yield return nextEvent;
+            if (nextEvent is LlmCompletedEvent or LlmErrorEvent)
+            {
+                yield break;
+            }
+        }
+    }
+
+    public Task CancelAsync(string requestId, CancellationToken cancellationToken = default)
+    {
+        cancellationToken.ThrowIfCancellationRequested();
+        if (_activeRequests.TryRemove(requestId, out var cts))
+        {
+            cts.Cancel();
+            cts.Dispose();
+        }
+
+        return Task.CompletedTask;
+    }
+
+    private static bool IsValidRequest(LlmChatRequest request, out string error)
+    {
+        if (string.IsNullOrWhiteSpace(request.RequestId) ||
+            string.IsNullOrWhiteSpace(request.PluginId) ||
+            string.IsNullOrWhiteSpace(request.InstanceId) ||
+            string.IsNullOrWhiteSpace(request.ModelId))
+        {
+            error = "requestId, pluginId, instanceId and modelId are required.";
+            return false;
+        }
+
+        if (request.Messages.Count == 0 || request.Messages.Any(message =>
+                string.IsNullOrWhiteSpace(message.Content) ||
+                !AllowedRoles.Contains(message.Role)))
+        {
+            error = "At least one valid message is required.";
+            return false;
+        }
+
+        error = "";
+        return true;
+    }
+
+    private void RecordFailure(LlmChatRequest request, LlmModelConfig model, string code, string exception)
+    {
+        var host = Uri.TryCreate(model.Endpoint, UriKind.Absolute, out var endpoint)
+            ? endpoint.Host
+            : "";
+        _diagnostics.Record(
+            DiagnosticSeverity.Warning,
+            code,
+            "LLM request failed.",
+            new Dictionary<string, string>
+            {
+                ["requestId"] = request.RequestId,
+                ["modelId"] = request.ModelId,
+                ["provider"] = model.Provider,
+                ["endpointHost"] = host,
+                ["exception"] = exception
+            });
+    }
+}
diff --git a/src/Moli.Desktop/Llm/LlmModelRegistry.cs b/src/Moli.Desktop/Llm/LlmModelRegistry.cs
new file mode 100644
index 0000000..ca8ee57
--- /dev/null
+++ b/src/Moli.Desktop/Llm/LlmModelRegistry.cs
@@ -0,0 +1,205 @@
+using System.IO;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Host;
+
+namespace Moli.Desktop.Llm;
+
+public sealed class LlmModelRegistry : ILlmModelRegistry
+{
+    public const string FileName = "llm-models.json";
+
+    private readonly DesktopPaths _paths;
+    private readonly IDiagnosticsService _diagnostics;
+    private readonly JsonSerializerOptions _jsonOptions = new()
+    {
+        PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+        PropertyNameCaseInsensitive = true,
+        WriteIndented = true,
+        Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
+    };
+
+    public LlmModelRegistry(DesktopPaths paths, IDiagnosticsService diagnostics)
+    {
+        _paths = paths;
+        _diagnostics = diagnostics;
+    }
+
+    public async Task<LlmSettingsDocument> LoadAsync(CancellationToken cancellationToken = default)
+    {
+        Directory.CreateDirectory(_paths.ConfigDirectory);
+        var path = Path.Combine(_paths.ConfigDirectory, FileName);
+
+        if (!File.Exists(path))
+        {
+            var created = CreateDefault();
+            await SaveAsync(created, cancellationToken).ConfigureAwait(false);
+            return created;
+        }
+
+        try
+        {
+            await using var stream = File.OpenRead(path);
+            var document = await JsonSerializer.DeserializeAsync<LlmSettingsDocument>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
+            if (document is null || document.SchemaVersion <= 0)
+            {
+                throw new JsonException("LLM settings document is empty or missing schemaVersion.");
+            }
+
+            return Normalize(document);
+        }
+        catch (Exception ex) when (ex is JsonException or IOException or UnauthorizedAccessException)
+        {
+            BackupInvalidFile(path);
+            var recovered = CreateDefault();
+            await SaveAsync(recovered, cancellationToken).ConfigureAwait(false);
+            _diagnostics.Record(
+                DiagnosticSeverity.Warning,
+                DiagnosticCodes.ConfigurationRecovered,
+                "Recovered llm-models.json from invalid configuration.",
+                new Dictionary<string, string> { ["exception"] = ex.GetType().Name });
+            return recovered;
+        }
+    }
+
+    public async Task<LlmModelConfig?> GetEnabledModelAsync(string modelId, CancellationToken cancellationToken = default)
+    {
+        if (string.IsNullOrWhiteSpace(modelId))
+        {
+            return null;
+        }
+
+        var document = await LoadAsync(cancellationToken).ConfigureAwait(false);
+        return document.Models.FirstOrDefault(model =>
+            model.Enabled &&
+            string.Equals(model.Id, modelId, StringComparison.OrdinalIgnoreCase));
+    }
+
+    private async Task SaveAsync(LlmSettingsDocument document, CancellationToken cancellationToken)
+    {
+        Directory.CreateDirectory(_paths.ConfigDirectory);
+        var path = Path.Combine(_paths.ConfigDirectory, FileName);
+        var tempPath = path + ".tmp";
+        var backupPath = path + ".bak";
+
+        await using (var stream = File.Create(tempPath))
+        {
+            await JsonSerializer.SerializeAsync(stream, document, _jsonOptions, cancellationToken).ConfigureAwait(false);
+        }
+
+        if (File.Exists(path))
+        {
+            File.Copy(path, backupPath, overwrite: true);
+        }
+
+        File.Move(tempPath, path, overwrite: true);
+    }
+
+    private LlmSettingsDocument Normalize(LlmSettingsDocument document)
+    {
+        var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
+        var normalized = new List<LlmModelConfig>();
+
+        foreach (var model in document.Models)
+        {
+            if (!IsValidModel(model, seen))
+            {
+                continue;
+            }
+
+            seen.Add(model.Id);
+            normalized.Add(model);
+        }
+
+        var defaultModel = normalized.Any(model =>
+            model.Enabled &&
+            string.Equals(model.Id, document.DefaultModel, StringComparison.OrdinalIgnoreCase))
+                ? document.DefaultModel
+                : normalized.FirstOrDefault(model => model.Enabled)?.Id;
+
+        return document with
+        {
+            DefaultModel = defaultModel,
+            Models = normalized
+        };
+    }
+
+    private bool IsValidModel(LlmModelConfig model, HashSet<string> seen)
+    {
+        if (string.IsNullOrWhiteSpace(model.Id) || seen.Contains(model.Id))
+        {
+            RecordInvalid(model.Id, "Model id is empty or duplicated.");
+            return false;
+        }
+
+        if (string.IsNullOrWhiteSpace(model.Label) || model.Label.Length > 40)
+        {
+            RecordInvalid(model.Id, "Model label is empty or too long.");
+            return false;
+        }
+
+        if (string.IsNullOrWhiteSpace(model.Provider))
+        {
+            RecordInvalid(model.Id, "Model provider is required.");
+            return false;
+        }
+
+        if (!Uri.TryCreate(model.Endpoint, UriKind.Absolute, out var endpoint) ||
+            endpoint.Scheme is not ("http" or "https"))
+        {
+            RecordInvalid(model.Id, "Model endpoint must be an absolute HTTP or HTTPS URL.");
+            return false;
+        }
+
+        if (string.IsNullOrWhiteSpace(model.ApiModel))
+        {
+            RecordInvalid(model.Id, "apiModel is required.");
+            return false;
+        }
+
+        return true;
+    }
+
+    private void RecordInvalid(string? modelId, string message)
+    {
+        _diagnostics.Record(
+            DiagnosticSeverity.Warning,
+            "LlmModelInvalid",
+            message,
+            new Dictionary<string, string> { ["modelId"] = modelId ?? "" });
+    }
+
+    private static LlmSettingsDocument CreateDefault() => new()
+    {
+        DefaultModel = null,
+        Models =
+        [
+            new LlmModelConfig
+            {
+                Id = "local-openai-compatible",
+                Label = "Local",
+                Provider = "openai-compatible",
+                Endpoint = "http://127.0.0.1:11434/v1/chat/completions",
+                AuthRef = null,
+                ApiModel = "qwen2.5:14b",
+                SupportsStreaming = true,
+                Enabled = false
+            }
+        ]
+    };
+
+    private static void BackupInvalidFile(string path)
+    {
+        if (!File.Exists(path))
+        {
+            return;
+        }
+
+        var timestamp = DateTimeOffset.Now.ToString("yyyyMMddHHmmss");
+        var invalidPath = Path.Combine(
+            Path.GetDirectoryName(path)!,
+            $"{Path.GetFileNameWithoutExtension(path)}.invalid.{timestamp}{Path.GetExtension(path)}");
+        File.Move(path, invalidPath, overwrite: true);
+    }
+}
diff --git a/src/Moli.Desktop/Llm/LlmModels.cs b/src/Moli.Desktop/Llm/LlmModels.cs
new file mode 100644
index 0000000..c63cbf3
--- /dev/null
+++ b/src/Moli.Desktop/Llm/LlmModels.cs
@@ -0,0 +1,122 @@
+using System.Text.Json.Serialization;
+
+namespace Moli.Desktop.Llm;
+
+public sealed record LlmSettingsDocument
+{
+    public int SchemaVersion { get; init; } = 1;
+    public string? DefaultModel { get; init; }
+    public List<LlmModelConfig> Models { get; init; } = [];
+}
+
+public sealed record LlmModelConfig
+{
+    public required string Id { get; init; }
+    public required string Label { get; init; }
+    public required string Provider { get; init; }
+    public required string Endpoint { get; init; }
+    public string? AuthRef { get; init; }
+    public required string ApiModel { get; init; }
+    public bool SupportsStreaming { get; init; } = true;
+    public bool Enabled { get; init; }
+    public LlmRequestDefaults RequestDefaults { get; init; } = new();
+}
+
+public sealed record LlmRequestDefaults
+{
+    public double Temperature { get; init; } = 0.7;
+    public int MaxTokens { get; init; } = 2048;
+    public int TimeoutMs { get; init; } = 60000;
+}
+
+public sealed record LlmModelSummary
+{
+    public required string Id { get; init; }
+    public required string Label { get; init; }
+    public required string Provider { get; init; }
+    public bool SupportsStreaming { get; init; }
+    public bool Enabled { get; init; }
+}
+
+public sealed record LlmChatRequest
+{
+    public required string RequestId { get; init; }
+    public required string PluginId { get; init; }
+    public required string InstanceId { get; init; }
+    public required string ModelId { get; init; }
+    public required IReadOnlyList<LlmMessage> Messages { get; init; }
+    public LlmRequestOptions Options { get; init; } = new();
+}
+
+public sealed record LlmMessage
+{
+    public required string Role { get; init; }
+    public required string Content { get; init; }
+}
+
+public sealed record LlmRequestOptions
+{
+    public double? Temperature { get; init; }
+    public int? MaxTokens { get; init; }
+    public int? TimeoutMs { get; init; }
+}
+
+public sealed record LlmProviderRequest
+{
+    public required string RequestId { get; init; }
+    public required LlmModelConfig Model { get; init; }
+    public required IReadOnlyList<LlmMessage> Messages { get; init; }
+    public required LlmRequestOptions Options { get; init; }
+    public string? ApiKey { get; init; }
+}
+
+[JsonPolymorphic(TypeDiscriminatorPropertyName = "kind")]
+[JsonDerivedType(typeof(LlmDeltaEvent), "delta")]
+[JsonDerivedType(typeof(LlmCompletedEvent), "completed")]
+[JsonDerivedType(typeof(LlmErrorEvent), "error")]
+public abstract record LlmStreamEvent
+{
+    public required string RequestId { get; init; }
+}
+
+public sealed record LlmDeltaEvent : LlmStreamEvent
+{
+    public required string Delta { get; init; }
+}
+
+public sealed record LlmCompletedEvent : LlmStreamEvent
+{
+    public LlmUsage? Usage { get; init; }
+}
+
+public sealed record LlmErrorEvent : LlmStreamEvent
+{
+    public required string Code { get; init; }
+    public required string Message { get; init; }
+}
+
+public sealed record LlmUsage
+{
+    public int? InputTokens { get; init; }
+    public int? OutputTokens { get; init; }
+}
+
+public sealed record LlmProviderChunk
+{
+    public string? Delta { get; init; }
+    public bool IsCompleted { get; init; }
+    public LlmUsage? Usage { get; init; }
+}
+
+public static class LlmErrorCodes
+{
+    public const string ModelNotFound = "LlmModelNotFound";
+    public const string ProviderUnsupported = "LlmProviderUnsupported";
+    public const string CredentialMissing = "LlmCredentialMissing";
+    public const string EndpointUnavailable = "LlmEndpointUnavailable";
+    public const string Unauthorized = "LlmUnauthorized";
+    public const string RateLimited = "LlmRateLimited";
+    public const string Timeout = "LlmTimeout";
+    public const string StreamParseFailed = "LlmStreamParseFailed";
+    public const string RequestInvalid = "LlmRequestInvalid";
+}
diff --git a/src/Moli.Desktop/Llm/LlmProviderAdapterFactory.cs b/src/Moli.Desktop/Llm/LlmProviderAdapterFactory.cs
new file mode 100644
index 0000000..4699934
--- /dev/null
+++ b/src/Moli.Desktop/Llm/LlmProviderAdapterFactory.cs
@@ -0,0 +1,31 @@
+namespace Moli.Desktop.Llm;
+
+public sealed class LlmProviderAdapterFactory : ILlmProviderAdapterFactory
+{
+    private static readonly IReadOnlyDictionary<string, string> ProviderAliases = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
+    {
+        ["deepseek"] = "openai-compatible",
+        ["ollama"] = "openai-compatible",
+        ["local-openai-compatible"] = "openai-compatible"
+    };
+
+    private readonly IReadOnlyDictionary<string, ILlmProviderAdapter> _adapters;
+
+    public LlmProviderAdapterFactory(IEnumerable<ILlmProviderAdapter> adapters)
+    {
+        _adapters = adapters.ToDictionary(adapter => adapter.Provider, StringComparer.OrdinalIgnoreCase);
+    }
+
+    public ILlmProviderAdapter? Get(string provider)
+    {
+        if (_adapters.TryGetValue(provider, out var adapter))
+        {
+            return adapter;
+        }
+
+        return ProviderAliases.TryGetValue(provider, out var targetProvider) &&
+            _adapters.TryGetValue(targetProvider, out adapter)
+                ? adapter
+                : null;
+    }
+}
diff --git a/src/Moli.Desktop/Llm/OpenAICompatibleAdapter.cs b/src/Moli.Desktop/Llm/OpenAICompatibleAdapter.cs
new file mode 100644
index 0000000..9517eda
--- /dev/null
+++ b/src/Moli.Desktop/Llm/OpenAICompatibleAdapter.cs
@@ -0,0 +1,139 @@
+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;
+
+namespace Moli.Desktop.Llm;
+
+public sealed class OpenAICompatibleAdapter : ILlmProviderAdapter
+{
+    private readonly HttpClient _httpClient;
+    private readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
+
+    public OpenAICompatibleAdapter(HttpClient httpClient)
+    {
+        _httpClient = httpClient;
+    }
+
+    public string Provider => "openai-compatible";
+
+    public async IAsyncEnumerable<LlmProviderChunk> StreamAsync(
+        LlmProviderRequest request,
+        [EnumeratorCancellation] CancellationToken cancellationToken = default)
+    {
+        using var httpRequest = new HttpRequestMessage(HttpMethod.Post, request.Model.Endpoint);
+        if (!string.IsNullOrWhiteSpace(request.ApiKey))
+        {
+            httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", request.ApiKey);
+        }
+
+        var payload = new
+        {
+            model = request.Model.ApiModel,
+            messages = request.Messages.Select(message => new { role = message.Role, content = message.Content }).ToArray(),
+            temperature = request.Options.Temperature ?? request.Model.RequestDefaults.Temperature,
+            max_tokens = request.Options.MaxTokens ?? request.Model.RequestDefaults.MaxTokens,
+            stream = request.Model.SupportsStreaming
+        };
+
+        httpRequest.Content = new StringContent(JsonSerializer.Serialize(payload, _jsonOptions), Encoding.UTF8, "application/json");
+
+        using var response = await _httpClient.SendAsync(
+            httpRequest,
+            HttpCompletionOption.ResponseHeadersRead,
+            cancellationToken).ConfigureAwait(false);
+
+        if (!response.IsSuccessStatusCode)
+        {
+            throw new LlmProviderException(MapStatusCode(response.StatusCode), $"LLM provider returned {(int)response.StatusCode}.");
+        }
+
+        await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
+        using var reader = new StreamReader(stream, Encoding.UTF8);
+        while (await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false) is { } line)
+        {
+            cancellationToken.ThrowIfCancellationRequested();
+            if (string.IsNullOrWhiteSpace(line) || !line.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
+            {
+                continue;
+            }
+
+            var data = line["data:".Length..].Trim();
+            if (data == "[DONE]")
+            {
+                yield return new LlmProviderChunk { IsCompleted = true };
+                yield break;
+            }
+
+            LlmProviderChunk? chunk;
+            try
+            {
+                chunk = ParseChunk(data);
+            }
+            catch (JsonException ex)
+            {
+                throw new LlmProviderException(LlmErrorCodes.StreamParseFailed, "Failed to parse LLM stream chunk.", ex);
+            }
+
+            if (chunk is not null)
+            {
+                yield return chunk;
+            }
+        }
+
+        yield return new LlmProviderChunk { IsCompleted = true };
+    }
+
+    private LlmProviderChunk? ParseChunk(string data)
+    {
+        using var document = JsonDocument.Parse(data);
+        var root = document.RootElement;
+        if (!root.TryGetProperty("choices", out var choices) || choices.ValueKind != JsonValueKind.Array || choices.GetArrayLength() == 0)
+        {
+            return null;
+        }
+
+        var first = choices[0];
+        if (first.TryGetProperty("delta", out var delta) &&
+            delta.TryGetProperty("content", out var content) &&
+            content.ValueKind == JsonValueKind.String)
+        {
+            return new LlmProviderChunk { Delta = content.GetString() ?? string.Empty };
+        }
+
+        if (first.TryGetProperty("message", out var message) &&
+            message.TryGetProperty("content", out content) &&
+            content.ValueKind == JsonValueKind.String)
+        {
+            return new LlmProviderChunk { Delta = content.GetString() ?? string.Empty, IsCompleted = true };
+        }
+
+        if (first.TryGetProperty("finish_reason", out var finishReason) && finishReason.ValueKind != JsonValueKind.Null)
+        {
+            return new LlmProviderChunk { IsCompleted = true };
+        }
+
+        return null;
+    }
+
+    private static string MapStatusCode(HttpStatusCode statusCode) => statusCode switch
+    {
+        HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden => LlmErrorCodes.Unauthorized,
+        (HttpStatusCode)429 => LlmErrorCodes.RateLimited,
+        _ => LlmErrorCodes.EndpointUnavailable
+    };
+}
+
+public sealed class LlmProviderException : Exception
+{
+    public LlmProviderException(string code, string message, Exception? innerException = null)
+        : base(message, innerException)
+    {
+        Code = code;
+    }
+
+    public string Code { get; }
+}
diff --git a/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs b/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs
index f1aa9bc..0c8c988 100644
--- a/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs
+++ b/src/Moli.Desktop/WebView/PluginBridgeDispatcher.cs
@@ -1,5 +1,6 @@
 using System.Text.Json;
 using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Llm;
 using Moli.Desktop.Runtime;
 
 namespace Moli.Desktop.WebView;
@@ -18,17 +19,22 @@
         "requestReload",
         "requestShow",
         "requestHide",
-        "requestResize"
+        "requestResize",
+        "llm.getModels",
+        "llm.streamChat",
+        "llm.cancel"
     ];
 
     private readonly IDiagnosticsService _diagnostics;
     private readonly IRuntimeEventBus _events;
+    private readonly ILlmGatewayService _llmGateway;
     private readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
 
-    public PluginBridgeDispatcher(IDiagnosticsService diagnostics, IRuntimeEventBus events)
+    public PluginBridgeDispatcher(IDiagnosticsService diagnostics, IRuntimeEventBus events, ILlmGatewayService llmGateway)
     {
         _diagnostics = diagnostics;
         _events = events;
+        _llmGateway = llmGateway;
     }
 
     public async Task<PluginBridgeResponse> DispatchAsync(
@@ -72,8 +78,101 @@
             "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.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)
+    {
+        var models = await _llmGateway.GetModelsAsync(cancellationToken).ConfigureAwait(false);
+        return PluginBridgeResponse.Ok(request.Id ?? string.Empty, models);
+    }
+
+    private Task<PluginBridgeResponse> HandleStreamLlmChatAsync(
+        BridgeRequest request,
+        PluginBridgeContext context,
+        CancellationToken cancellationToken)
+    {
+        if (!HasPermission(context, "llm.stream"))
+        {
+            return Task.FromResult(PluginBridgeResponse.Failure(request.Id, "BridgePermissionDenied", "Plugin does not declare llm.stream permission."));
+        }
+
+        if (request.Params.ValueKind is not JsonValueKind.Object)
+        {
+            return Task.FromResult(PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", "llm.streamChat expects an object payload."));
+        }
+
+        LlmBridgeStreamRequest? payload;
+        try
+        {
+            payload = request.Params.Deserialize<LlmBridgeStreamRequest>(_jsonOptions);
+        }
+        catch (JsonException)
+        {
+            return Task.FromResult(PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", "llm.streamChat payload could not be parsed."));
+        }
+
+        if (payload is null || string.IsNullOrWhiteSpace(payload.ModelId))
+        {
+            return Task.FromResult(PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", "modelId is required."));
+        }
+
+        var requestId = string.IsNullOrWhiteSpace(payload.RequestId) ? $"llm-{Guid.NewGuid():N}" : payload.RequestId!;
+        var chatRequest = new LlmChatRequest
+        {
+            RequestId = requestId,
+            PluginId = context.RuntimeInfo.PluginId,
+            InstanceId = context.HostId,
+            ModelId = payload.ModelId,
+            Messages = payload.Messages,
+            Options = payload.Options ?? new LlmRequestOptions()
+        };
+
+        _ = Task.Run(() => PumpLlmStreamAsync(chatRequest, context, CancellationToken.None));
+        return Task.FromResult(PluginBridgeResponse.Ok(request.Id ?? string.Empty, new { requestId }));
+    }
+
+    private async Task<PluginBridgeResponse> HandleCancelLlmChatAsync(BridgeRequest request, CancellationToken cancellationToken)
+    {
+        if (request.Params.ValueKind is not JsonValueKind.Object ||
+            !request.Params.TryGetProperty("requestId", out var requestIdElement) ||
+            requestIdElement.ValueKind != JsonValueKind.String ||
+            string.IsNullOrWhiteSpace(requestIdElement.GetString()))
+        {
+            return PluginBridgeResponse.Failure(request.Id, "BridgePayloadInvalid", "requestId is required.");
+        }
+
+        await _llmGateway.CancelAsync(requestIdElement.GetString()!, cancellationToken).ConfigureAwait(false);
+        return PluginBridgeResponse.Ok(request.Id ?? string.Empty, new { accepted = true });
+    }
+
+    private async Task PumpLlmStreamAsync(LlmChatRequest chatRequest, PluginBridgeContext context, CancellationToken cancellationToken)
+    {
+        await foreach (var streamEvent in _llmGateway.StreamChatAsync(chatRequest, cancellationToken).ConfigureAwait(false))
+        {
+            var eventName = streamEvent switch
+            {
+                LlmDeltaEvent => "llm.delta",
+                LlmCompletedEvent => "llm.completed",
+                LlmErrorEvent => "llm.error",
+                _ => "llm.event"
+            };
+
+            await _events.PublishAsync(new RuntimeEvent
+            {
+                Name = eventName,
+                Payload = new
+                {
+                    context.HostId,
+                    context.RuntimeInfo.PluginId,
+                    Event = streamEvent
+                }
+            }, cancellationToken).ConfigureAwait(false);
+        }
     }
 
     private async Task<PluginBridgeResponse> HandleEventAsync(
@@ -110,12 +209,23 @@
         return PluginBridgeResponse.Ok(request.Id ?? string.Empty, new { accepted = true });
     }
 
+    private static bool HasPermission(PluginBridgeContext context, string permission)
+        => context.Manifest.Permissions.Any(item => string.Equals(item, permission, StringComparison.OrdinalIgnoreCase));
+
     private sealed record BridgeRequest
     {
         public string? Id { get; init; }
         public string? Method { get; init; }
         public JsonElement Params { get; init; }
     }
+
+    private sealed record LlmBridgeStreamRequest
+    {
+        public string? RequestId { get; init; }
+        public required string ModelId { get; init; }
+        public IReadOnlyList<LlmMessage> Messages { get; init; } = [];
+        public LlmRequestOptions? Options { get; init; }
+    }
 }
 
 public sealed record PluginBridgeResponse
diff --git a/src/Moli.Desktop/WebView/PluginBridgeScript.cs b/src/Moli.Desktop/WebView/PluginBridgeScript.cs
index ab12d06..d483fdf 100644
--- a/src/Moli.Desktop/WebView/PluginBridgeScript.cs
+++ b/src/Moli.Desktop/WebView/PluginBridgeScript.cs
@@ -23,6 +23,11 @@
             pending.set(id, { resolve, reject });
             chrome.webview.postMessage({ id, method, params });
           });
+          const on = (name, handler) => {
+            const wrapped = (event) => handler(event.detail || {});
+            window.addEventListener(name, wrapped);
+            return () => window.removeEventListener(name, wrapped);
+          };
           window.moliDesktop = Object.freeze({
             getManifest: () => call("getManifest"),
             getRuntimeInfo: () => call("getRuntimeInfo"),
@@ -32,7 +37,15 @@
             requestReload: () => call("requestReload"),
             requestShow: () => call("requestShow"),
             requestHide: () => call("requestHide"),
-            requestResize: (size) => call("requestResize", size)
+            requestResize: (size) => call("requestResize", size),
+            llm: Object.freeze({
+              getModels: () => call("llm.getModels"),
+              streamChat: (request) => call("llm.streamChat", request),
+              cancel: (requestId) => call("llm.cancel", { requestId }),
+              onDelta: (handler) => on("moli:llm-delta", handler),
+              onCompleted: (handler) => on("moli:llm-completed", handler),
+              onError: (handler) => on("moli:llm-error", handler)
+            })
           });
         })();
         """;
diff --git a/src/Moli.Desktop/WebView/WebViewHost.cs b/src/Moli.Desktop/WebView/WebViewHost.cs
index 59b2a10..dd39b80 100644
--- a/src/Moli.Desktop/WebView/WebViewHost.cs
+++ b/src/Moli.Desktop/WebView/WebViewHost.cs
@@ -25,6 +25,7 @@
     private PluginBridgeContext? _bridgeContext;
     private WebViewHostOptions? _options;
     private IDisposable? _audioSubscription;
+    private IDisposable? _llmSubscription;
     private bool _initialized;
 
     public WebViewHost(
@@ -67,6 +68,8 @@
         {
             _audioSubscription = _events.Subscribe(DispatchAudioSpectrumAsync);
         }
+
+        _llmSubscription = _events.Subscribe(DispatchLlmEventAsync);
 
         if (!string.IsNullOrWhiteSpace(options.InitialScript))
         {
@@ -127,6 +130,8 @@
     {
         _audioSubscription?.Dispose();
         _audioSubscription = null;
+        _llmSubscription?.Dispose();
+        _llmSubscription = null;
 
         if (Control.CoreWebView2 is not null)
         {
@@ -157,6 +162,41 @@
         return dispatcher.InvokeAsync(() => ExecuteScriptSafelyAsync(script)).Task.Unwrap();
     }
 
+    private Task DispatchLlmEventAsync(RuntimeEvent runtimeEvent)
+    {
+        if (_bridgeContext is null || runtimeEvent.Payload is null || !runtimeEvent.Name.StartsWith("llm.", StringComparison.OrdinalIgnoreCase))
+        {
+            return Task.CompletedTask;
+        }
+
+        var payloadJson = JsonSerializer.Serialize(runtimeEvent.Payload, _jsonOptions);
+        using var document = JsonDocument.Parse(payloadJson);
+        var root = document.RootElement;
+        if (!root.TryGetProperty("hostId", out var hostId) ||
+            !string.Equals(hostId.GetString(), HostId, StringComparison.OrdinalIgnoreCase) ||
+            !root.TryGetProperty("event", out var llmEvent))
+        {
+            return Task.CompletedTask;
+        }
+
+        var domEventName = runtimeEvent.Name switch
+        {
+            "llm.delta" => "moli:llm-delta",
+            "llm.completed" => "moli:llm-completed",
+            "llm.error" => "moli:llm-error",
+            _ => "moli:llm-event"
+        };
+        var detail = llmEvent.GetRawText();
+        var script = $"window.dispatchEvent(new CustomEvent(\"{domEventName}\", {{ detail: {detail} }}));";
+        var dispatcher = Control.Dispatcher;
+        if (dispatcher.CheckAccess())
+        {
+            return ExecuteScriptSafelyAsync(script);
+        }
+
+        return dispatcher.InvokeAsync(() => ExecuteScriptSafelyAsync(script)).Task.Unwrap();
+    }
+
     private async void OnWebMessageReceived(object? sender, CoreWebView2WebMessageReceivedEventArgs e)
     {
         if (_bridgeContext is null)

--
Gitblit v1.9.1