openclaw-plugin-model-fetch 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README-CN.md CHANGED
@@ -1,244 +1,126 @@
1
1
  # OpenClaw Model Fetch
2
2
 
3
- > [English](./README.md) · 中文
3
+ [English](./README.md) | 中文
4
4
 
5
5
  [![CI](https://github.com/AdoShan/OpenClaw-ModelFetch/actions/workflows/ci.yml/badge.svg)](https://github.com/AdoShan/OpenClaw-ModelFetch/actions/workflows/ci.yml)
6
6
  [![npm version](https://img.shields.io/npm/v/openclaw-plugin-model-fetch.svg)](https://www.npmjs.com/package/openclaw-plugin-model-fetch)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
8
 
9
- 在 OpenClaw Control UI 中获取指定 Provider 的远端模型,按 Provider 独立配置包含正则、排除正则和手动白名单,再将确认后的模型列表写入 `models.providers.<providerId>.models`,供 WebUI 选用。
9
+ 在 OpenClaw Control UI 中获取指定 Provider 的远端模型,按 Provider 筛选,并将确认后的模型写入 OpenClaw 配置,供 WebUI 选用。
10
10
 
11
11
  ## 功能
12
12
 
13
- - 支持 OpenAI 兼容 Provider、Anthropic 兼容 Provider、Ollama 和 OpenRouter。
14
- - 支持“获取远端模型”和“应用策略到配置”两个独立步骤,获取操作不会修改配置。
15
- - 每个 Provider 独立保存筛选策略,切换 Provider 不会混用正则或白名单。
16
- - 包含正则、排除正则和手动白名单可以组合使用;手动勾选的模型不会被排除正则删除。
17
- - 正则输入框失焦或按 Enter 后更新筛选结果,非法正则会阻止保存和应用。
18
- - 应用策略前自动重新获取模型并生成删除清单;确认期间列表或配置发生变化时取消写入。
19
- - 默认使用替换模式,最终配置只保留当前策略选中的远端模型和已手动选择的模型。
20
- - 自动保护仍被非 Agent 配置引用的模型,例如 utility、决策、媒体、voice、PDF、嵌入式 Agent failover 和 hooks 模型;确认弹窗会列出保留它们的配置路径。
21
- - 已有模型 ID 会保留原有的名称、价格、模态等扩展字段,不暴露 Provider API Key。
22
- - 选择“覆盖 Agent”后,应用策略会同步该 Agent 的 allowlist 与模型映射:新增本次选中的模型,并移除该 Provider 下已取消选择的精确条目,避免 WebUI 继续显示过期模型。
13
+ - 支持 OpenAI 兼容、Anthropic 兼容、Ollama 和 OpenRouter Provider。
14
+ - 为每个 Provider 独立保存包含正则、排除正则和手动白名单策略。
15
+ - 将获取模型与应用配置分开,并在写入前显示所有待删除模型。
16
+ - 保护仍被其他 OpenClaw 配置引用的模型,并可同步 Agent 模型 allowlist。
23
17
 
24
18
  ## 环境要求
25
19
 
26
20
  - Node.js 24.16 或更新版本
27
21
  - OpenClaw `2026.10.5` 或更新版本
28
- - 已配置至少一个 `models.providers.<providerId>`,并完成该 Provider 的认证
22
+ - 已配置至少一个具有有效 `baseUrl` 及所需认证信息的 `models.providers.<providerId>`
29
23
 
30
- ## 安装
24
+ ## 快速开始
31
25
 
32
- 在仓库目录构建并检查插件:
26
+ ### 1. 安装
33
27
 
34
28
  ```bash
35
- npm install
36
- npm run plugin:build
37
- npm run plugin:validate
29
+ openclaw plugins install openclaw-plugin-model-fetch
38
30
  ```
39
31
 
40
- 从当前目录安装:
32
+ ### 2. 开启设置界面
41
33
 
42
- ```bash
43
- openclaw plugins install /absolute/path/to/OpenClaw-ModelFetch
44
- ```
34
+ 自定义插件 UI 默认关闭。打开与 Gateway 同源的 Control UI,然后开启:
45
35
 
46
- 本地开发时建议使用链接安装,修改后重新构建:
36
+ **Settings -> Labs -> Custom plugin UI**
37
+
38
+ 也可以直接使用 OpenClaw CLI 开启:
47
39
 
48
40
  ```bash
49
- openclaw plugins install /absolute/path/to/OpenClaw-ModelFetch --link
50
- npm run plugin:build
41
+ openclaw config set gateway.controlUi.experimental.customPlugins true --strict-json
51
42
  ```
52
43
 
53
- 可用以下命令检查插件状态:
44
+ 刷新浏览器页面后,Control UI 侧边栏会出现 **Model Fetch**。它同时也会出现在「页面」区的「编辑固定项」列表中,可按需固定或取消固定。
45
+
46
+ ### 3. 检查安装
54
47
 
55
48
  ```bash
56
49
  openclaw plugins list
57
50
  openclaw plugins doctor
58
51
  ```
59
52
 
60
- ## 开启设置界面
53
+ 插件应处于启用、已加载状态,并且没有配置错误。
61
54
 
62
- 自定义插件 UI 默认关闭。打开与 Gateway 同源的 Control UI 后,进入:
55
+ ## 使用
63
56
 
64
- **Settings → Labs → Custom plugin UI**
57
+ 1. 打开 **Model Fetch**,选择目标 Provider。
58
+ 2. 点击 **获取远端模型**。该操作只读取远端模型列表。
59
+ 3. 设置包含正则、排除正则,或勾选模型加入手动白名单。
60
+ 4. 选择需要同步模型 allowlist 的 Agent。
61
+ 5. 点击 **保存策略**。
62
+ 6. 点击 **应用策略到配置**。
63
+ 7. 出现删除确认弹窗时逐项检查。确认前不会写入任何模型配置。
64
+ 8. 打开 OpenClaw 的 Models 页面,选用新写入的模型。
65
65
 
66
- 开启后刷新浏览器页面,Control UI 侧边栏会出现 **Model Fetch**。如果使用已安装的本地插件但没有看到菜单,请依次确认:
66
+ 设置界面会跟随 OpenClaw WebUI 的语言显示:中文区域使用中文,其他区域默认使用英文。
67
67
 
68
- 1. `openclaw plugins list` 中插件已启用且没有配置错误。
69
- 2. Custom plugin UI 已开启。
70
- 3. 已经运行 `npm run plugin:build`,并刷新 Control UI。
71
- 4. Control UI 与 Gateway 同源,且使用 HTTPS 或浏览器可信的 loopback 地址。
68
+ ### 各操作的影响
72
69
 
73
- 等价的配置项是:
70
+ | 操作 | 修改插件策略 | 修改 Provider 模型 | 需要删除确认 |
71
+ | --- | --- | --- | --- |
72
+ | 获取远端模型 | 否 | 否 | 否 |
73
+ | 保存策略 | 是 | 否 | 否 |
74
+ | 应用策略到配置 | 否 | 是 | 仅在会删除模型时 |
74
75
 
75
- ```json5
76
- {
77
- gateway: {
78
- controlUi: {
79
- experimental: {
80
- customPlugins: true,
81
- },
82
- },
83
- },
84
- }
85
- ```
76
+ 默认使用替换模式。应用策略时,未选中的已有 Provider 模型会被删除;仍被其他 OpenClaw 配置引用的模型会受到保护。
86
77
 
87
- 插件不自行绘制 OpenClaw 的应用侧边栏;页面和导航由 Control UI 宿主管理。
88
-
89
- ### 常见问题:安装后看不到 Model Fetch 设置页
90
-
91
- 可按以下顺序排查:
92
-
93
- 1. 确认插件已安装并启用:
94
-
95
- ```bash
96
- openclaw plugins list
97
- openclaw plugins doctor
98
- ```
99
-
100
- 2. 确认已经重新构建并让 Gateway 读取到最新 `openclaw.plugin.json`:
101
-
102
- ```bash
103
- npm run plugin:build
104
- ```
105
-
106
- 3. 重启 Gateway 或刷新 Control UI 页面,再进入:
107
-
108
- - 设置页入口:`/settings/plugins/model-fetch?view=settings`
109
- - 插件页面入口:`/plugin?plugin=model-fetch&id=model-fetch`
110
-
111
- 4. 若页面可打开但无功能,请检查浏览器控制台是否有报错,并优先确认插件 session action 返回值是 JSON 兼容对象(本插件当前实现已按 JSON 兼容返回)。
112
-
113
- ## 使用流程
114
-
115
- 1. 打开 **Model Fetch**,在当前 Provider 下拉框中选择目标 Provider。
116
- 2. 点击 **获取远端模型**。这一步只读取远端模型列表,不写入配置。
117
- 3. 设置包含正则、排除正则,或勾选白名单模型。勾选只会把模型加入白名单,不会立即修改 OpenClaw 配置。
118
- 4. 在“覆盖 Agent”里勾选要同步 allowlist 的 agent(仅对已配置 modelPolicy.allow 的 agent 生效)。
119
- 5. 点击 **保存策略**,保存当前 Provider 的独立筛选配置与目标 agent。
120
- 6. 点击 **应用策略到配置**。插件会重新获取远端模型并检查配置。
121
- 7. 如果这次操作会删除已有模型,确认弹窗会逐项列出即将删除的模型。确认后才会写入。
122
- 8. 回到 OpenClaw 的 Models 页面,即可选用新写入的模型。
123
-
124
- 如果你启用了模型策略 allowlist(`agents.defaults.modelPolicy.allow` 或 `agents.entries.<agent>.modelPolicy.allow` 非空),插件在应用策略时会同步本次写入的 `provider/model`。对“覆盖 Agent”中选中的 Agent,同步会移除该 Provider 下已取消选择的精确模型条目;其他 Provider、通配规则(如 `provider/*`)和保留模型的自定义 Agent 配置不会被删除。
125
-
126
- 应用默认采用替换模式:当前 Provider 中未被策略选中的模型会被删除。如果模型仍被非 Agent 消费方引用,例如 `agents.defaults.utilityModel`、`agents.defaults.imageModel`、`agents.defaults.mediaModels.*`、`agents.defaults.voiceModel`、`agents.defaults.pdfModel`、`agents.defaults.embeddedAgent.cyberFailover.model`、`agents.entries.*.utilityModel`、`agents.entries.*.decisionModel`、`hooks.gmail.model` 或 `hooks.mappings[].model`,该模型会被保留,确认弹窗会列出这些引用。若预览后远端列表、筛选策略、引用保护集合或其他配置发生变化,本次写入会中止并要求重新预览。
127
-
128
- ## 筛选规则
129
-
130
- - `includeRegex`:仅选择模型 ID 匹配该 JavaScript 正则的模型。留空时不按正则限制。
131
- - `excludeRegex`:从正则选择结果中排除匹配的模型。
132
- - `manualIds`:精确手动白名单。存在白名单且 `includeRegex` 为空时,只选择白名单模型。
133
- - 手动白名单优先:白名单中的模型即使匹配排除正则,仍会被选择。
134
- - 手动白名单中的模型如果仍存在于配置中,会继续保留,即使远端这次没有返回它。
135
- - `replace`:插件默认使用 `true`。设置界面始终按替换模式运行;Agent 工具调用可显式传入 `false`,只增加模型而不删除旧模型。
136
- - 非法正则不会被保存或应用。
137
-
138
- Provider 策略保存在插件配置中:
139
-
140
- ```json
141
- {
142
- "plugins": {
143
- "entries": {
144
- "model-fetch": {
145
- "config": {
146
- "providers": {
147
- "openrouter": {
148
- "filter": {
149
- "includeRegex": "^(openai|anthropic)/",
150
- "excludeRegex": "(embed|rerank)",
151
- "manualIds": ["openai/gpt-4o-mini"],
152
- "replace": true
153
- }
154
- },
155
- "ollama": {
156
- "filter": {
157
- "manualIds": ["qwen3:latest", "llama3.1:8b"],
158
- "replace": true
159
- }
160
- }
161
- }
162
- }
163
- }
164
- }
165
- }
166
- }
167
- ```
78
+ 筛选规则、引用保护、Agent 同步、`model_fetch` 工具和 Provider 示例请阅读 [配置参考](https://github.com/AdoShan/OpenClaw-ModelFetch/blob/main/docs/zh-CN/configuration.md)。
168
79
 
169
- ## Agent 工具
80
+ ## 故障排查
170
81
 
171
- 工具名称为 `model_fetch`。只使用已保存策略刷新并写入配置:
82
+ ### 没有显示或启用 Model Fetch
172
83
 
173
- ```json
174
- {
175
- "provider": "openrouter"
176
- }
177
- ```
84
+ 运行 `openclaw plugins list` 和 `openclaw plugins doctor`。如果插件缺失或被判定为包损坏,请重新安装。
178
85
 
179
- 使用临时筛选做 dry run,不写配置:
86
+ ### 侧边栏没有 Model Fetch 入口
180
87
 
181
- ```json
182
- {
183
- "provider": "openrouter",
184
- "includeRegex": "anthropic/",
185
- "dryRun": true
186
- }
187
- ```
88
+ 确认已开启 **Settings -> Labs -> Custom plugin UI**,然后刷新 Control UI。设置页直达地址是 `/settings/plugins/model-fetch?view=settings`。
188
89
 
189
- 临时手动选择模型:
90
+ 升级 OpenClaw 后首次打开时,Model Fetch 会从「页面」区自动恢复为固定项;此后手动取消固定将保持生效。
190
91
 
191
- ```json
192
- {
193
- "provider": "ollama",
194
- "manualIds": ["qwen3:latest", "llama3.1:8b"]
195
- }
196
- ```
92
+ ### 手机 App 里看不到 Model Fetch
197
93
 
198
- 工具结果包含 Provider、远端模型数、最终选中的模型 ID、新增/未变/删除数量、受引用保护的模型及其配置路径、配置路径以及是否已持久化。
199
-
200
- ## Provider 示例
201
-
202
- ```json
203
- {
204
- "models": {
205
- "providers": {
206
- "openrouter": {
207
- "baseUrl": "https://openrouter.ai/api/v1",
208
- "api": "openai-responses",
209
- "models": []
210
- }
211
- }
212
- }
213
- }
214
- ```
94
+ Android 与 iOS App 通过 Gateway hello 消息中的 `controlUiTabs` 获取插件页面。请确认手机已配对并授予 `operator.read` 权限,然后重启 App 以重新获取 hello 消息。
215
95
 
216
- Ollama 或其他本地地址需要显式允许私有网络访问:
217
-
218
- ```json
219
- {
220
- "models": {
221
- "providers": {
222
- "ollama": {
223
- "baseUrl": "http://127.0.0.1:11434",
224
- "api": "ollama",
225
- "request": {
226
- "allowPrivateNetwork": true
227
- },
228
- "models": []
229
- }
230
- }
231
- }
232
- }
233
- ```
96
+ ### 获取远端模型失败
97
+
98
+ 确认 Provider 的 `baseUrl`、`api` 和认证信息在 OpenClaw 中可以正常工作。Ollama 等本机或私有网络地址需要启用 `request.allowPrivateNetwork: true`。
99
+
100
+ ### 应用后仍能看到旧模型
101
+
102
+ 确认应用操作已经完成,并检查相关 Agent 是否已选择同步。部分模型可能因引用保护而被有意保留。请检查应用结果后刷新 Models 页面或受影响的会话。
103
+
104
+ ## 文档与反馈
105
+
106
+ - [配置参考](https://github.com/AdoShan/OpenClaw-ModelFetch/blob/main/docs/zh-CN/configuration.md)
107
+ - [English configuration reference](https://github.com/AdoShan/OpenClaw-ModelFetch/blob/main/docs/en/configuration.md)
108
+ - [问题反馈](https://github.com/AdoShan/OpenClaw-ModelFetch/issues)
109
+ - [版本发布](https://github.com/AdoShan/OpenClaw-ModelFetch/releases)
110
+ - [npm 包](https://www.npmjs.com/package/openclaw-plugin-model-fetch)
234
111
 
235
112
  ## 开发
236
113
 
114
+ 在源码仓库中运行:
115
+
237
116
  ```bash
117
+ npm ci
238
118
  npm test
239
- npm run typecheck
240
- npm run plugin:build
241
119
  npm run plugin:validate
242
120
  ```
243
121
 
244
- 浏览器界面源文件是 `src/control-ui.ts` 和 `src/settings-view.ts`。`npm run plugin:build` 会生成带内容哈希的 `dist/control-ui/` 资源,并更新 `openclaw.plugin.json.controlUi`。
122
+ `plugin:validate` 会构建并校验插件。需要直接使用源码目录时,可运行 `openclaw plugins install /absolute/path/to/OpenClaw-ModelFetch --link`。源码修改后需要重新构建并重新加载插件。
123
+
124
+ ## License
125
+
126
+ MIT
package/README.md CHANGED
@@ -1,247 +1,125 @@
1
1
  # OpenClaw Model Fetch
2
2
 
3
- > English · [中文](./README-CN.md)
3
+ English | [中文](./README-CN.md)
4
4
 
5
5
  [![CI](https://github.com/AdoShan/OpenClaw-ModelFetch/actions/workflows/ci.yml/badge.svg)](https://github.com/AdoShan/OpenClaw-ModelFetch/actions/workflows/ci.yml)
6
6
  [![npm version](https://img.shields.io/npm/v/openclaw-plugin-model-fetch.svg)](https://www.npmjs.com/package/openclaw-plugin-model-fetch)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
8
 
9
- Fetch a provider's remote model list inside the OpenClaw Control UI, apply a per-provider strategy built from include regexes, exclude regexes and a manual allowlist, then write the confirmed selection into `models.providers.<providerId>.models` for the WebUI to use.
9
+ Fetch a provider's remote model list in the OpenClaw Control UI, filter it per provider, and write the confirmed models into OpenClaw configuration for the WebUI to use.
10
10
 
11
11
  ## Features
12
12
 
13
- - Supports OpenAI-compatible providers, Anthropic-compatible providers, Ollama and OpenRouter.
14
- - Separates "fetch remote models" from "apply strategy to config": fetching never mutates configuration.
15
- - Persists an independent filter strategy per provider, so switching providers never mixes regexes or allowlists.
16
- - Combines include regex, exclude regex and manual allowlist; manually selected models survive the exclude regex.
17
- - Refreshes results on blur or Enter; invalid regexes block saving and applying.
18
- - Re-fetches and re-plans before applying, and aborts the write if the remote list or config changed during confirmation.
19
- - Defaults to replace mode: the final config keeps only the models selected by the current strategy plus manually selected ones.
20
- - Protects models still referenced by non-agent settings such as utility, decision, media, voice, PDF, embedded-agent failover and hook models; the delete dialog lists the config paths that kept them.
21
- - Preserves existing per-model fields (name, cost, modalities and so on) for known IDs, and never exposes provider API keys.
22
- - When "override agent" is selected, applying also syncs that agent's allowlist and model map: newly selected models are added and deselected exact entries for the same provider are removed, so the WebUI stops offering stale models.
13
+ - Fetches models from OpenAI-compatible, Anthropic-compatible, Ollama, and OpenRouter providers.
14
+ - Saves independent include regex, exclude regex, and manual whitelist strategies for each provider.
15
+ - Separates remote fetching from configuration writes and shows every model deletion before applying.
16
+ - Preserves models referenced by other OpenClaw settings and can synchronize Agent model allowlists.
23
17
 
24
18
  ## Requirements
25
19
 
26
20
  - Node.js 24.16 or newer
27
21
  - OpenClaw `2026.10.5` or newer
28
- - At least one configured `models.providers.<providerId>` with working authentication
22
+ - At least one configured `models.providers.<providerId>` with a valid `baseUrl` and any authentication required by the provider
29
23
 
30
- ## Installation
24
+ ## Quick Start
31
25
 
32
- Build and validate the plugin from the repository root:
26
+ ### 1. Install
33
27
 
34
28
  ```bash
35
- npm install
36
- npm run plugin:build
37
- npm run plugin:validate
29
+ openclaw plugins install openclaw-plugin-model-fetch
38
30
  ```
39
31
 
40
- Install from this checkout:
32
+ ### 2. Enable the settings UI
41
33
 
42
- ```bash
43
- openclaw plugins install /absolute/path/to/OpenClaw-ModelFetch
44
- ```
34
+ Custom plugin UIs are disabled by default. Open the Control UI from the same origin as the Gateway, then enable:
45
35
 
46
- For local development, link the checkout instead of copying it, then rebuild after changes:
36
+ **Settings -> Labs -> Custom plugin UI**
37
+
38
+ Alternatively, enable it directly with the OpenClaw CLI:
47
39
 
48
40
  ```bash
49
- openclaw plugins install /absolute/path/to/OpenClaw-ModelFetch --link
50
- npm run plugin:build
41
+ openclaw config set gateway.controlUi.experimental.customPlugins true --strict-json
51
42
  ```
52
43
 
53
- Check plugin status with:
44
+ Reload the browser page. **Model Fetch** should now appear in the Control UI sidebar. It is also listed under the sidebar "Edit pinned items" menu, so you can pin or unpin it as needed.
45
+
46
+ ### 3. Verify the installation
54
47
 
55
48
  ```bash
56
49
  openclaw plugins list
57
50
  openclaw plugins doctor
58
51
  ```
59
52
 
60
- ## Enabling the settings UI
61
-
62
- Custom plugin UIs are disabled by default. Open the Control UI served from the same origin as the Gateway, then go to:
53
+ The plugin should be enabled, loaded, and free of configuration errors.
63
54
 
64
- **Settings → Labs → Custom plugin UI**
65
-
66
- Enable it and reload the browser page. **Model Fetch** then appears in the Control UI sidebar. If you installed a local plugin but the entry is missing, check in order:
67
-
68
- 1. `openclaw plugins list` shows the plugin enabled with no configuration errors.
69
- 2. Custom plugin UI is enabled.
70
- 3. `npm run plugin:build` has been run and the Control UI reloaded.
71
- 4. The Control UI shares the Gateway origin and is served over HTTPS or a browser-trusted loopback address.
72
-
73
- The equivalent config entry is:
74
-
75
- ```json5
76
- {
77
- gateway: {
78
- controlUi: {
79
- experimental: {
80
- customPlugins: true,
81
- },
82
- },
83
- },
84
- }
85
- ```
55
+ ## Usage
86
56
 
87
- The plugin does not draw OpenClaw's application sidebar itself; pages and navigation are managed by the Control UI host.
57
+ 1. Open **Model Fetch** and select the target provider.
58
+ 2. Click **Fetch remote models**. This only reads the remote model list.
59
+ 3. Set the include and exclude regexes, or tick models to add them to the manual whitelist.
60
+ 4. Select any Agents whose model allowlists should be synchronized.
61
+ 5. Click **Save strategy**.
62
+ 6. Click **Apply strategy to config**.
63
+ 7. Review the deletion dialog when shown. No model configuration is written until you confirm.
64
+ 8. Open the OpenClaw Models page and select the newly available models.
88
65
 
89
- ### Troubleshooting: the Model Fetch settings page is missing
66
+ The settings interface follows the OpenClaw WebUI language: Chinese locales use Chinese, and other locales default to English.
90
67
 
91
- Work through these in order:
68
+ ### What each action changes
92
69
 
93
- 1. Confirm the plugin is installed and enabled:
70
+ | Action | Changes plugin strategy | Changes provider models | Requires deletion confirmation |
71
+ | --- | --- | --- | --- |
72
+ | Fetch remote models | No | No | No |
73
+ | Save strategy | Yes | No | No |
74
+ | Apply strategy to config | No | Yes | Only when models will be deleted |
94
75
 
95
- ```bash
96
- openclaw plugins list
97
- openclaw plugins doctor
98
- ```
76
+ Replacement mode is the default. Applying a strategy removes existing provider models that are not selected, except models protected by other OpenClaw configuration references.
99
77
 
100
- 2. Confirm you rebuilt and the Gateway picked up the latest `openclaw.plugin.json`:
78
+ See the [configuration reference](https://github.com/AdoShan/OpenClaw-ModelFetch/blob/main/docs/en/configuration.md) for filter rules, protected references, Agent synchronization, the `model_fetch` tool, and provider examples.
101
79
 
102
- ```bash
103
- npm run plugin:build
104
- ```
80
+ ## Troubleshooting
105
81
 
106
- 3. Restart the Gateway or reload the Control UI page, then try:
82
+ ### Model Fetch is not listed or enabled
107
83
 
108
- - Settings page: `/settings/plugins/model-fetch?view=settings`
109
- - Plugin page: `/plugin?plugin=model-fetch&id=model-fetch`
84
+ Run `openclaw plugins list` and `openclaw plugins doctor`. Reinstall the package if it is missing or reported as broken.
110
85
 
111
- 4. If the page opens but does nothing, check the browser console for errors and verify the plugin session action returns a JSON-compatible object (the current implementation already does).
86
+ ### The Model Fetch navigation entry is missing
112
87
 
113
- ## Usage
88
+ Confirm that **Settings -> Labs -> Custom plugin UI** is enabled, then reload the Control UI. The direct settings route is `/settings/plugins/model-fetch?view=settings`.
114
89
 
115
- 1. Open **Model Fetch** and pick the target provider from the provider dropdown.
116
- 2. Click **Fetch remote models**. This only reads the remote model list and never writes config.
117
- 3. Set the include regex and exclude regex, or tick allowlist models. Ticking only adds to the allowlist and does not modify OpenClaw config.
118
- 4. Under **Override agent**, tick the agents whose allowlist should be synced (only affects agents that already have `modelPolicy.allow` configured).
119
- 5. Click **Save strategy** to persist the per-provider filter and target agents.
120
- 6. Click **Apply strategy to config**. The plugin re-fetches remote models and re-checks the config.
121
- 7. If the operation would delete existing models, the confirmation dialog lists each one. Nothing is written until you confirm.
122
- 8. Return to the OpenClaw Models page and the newly written models are available.
123
-
124
- If you use model policy allowlists (`agents.defaults.modelPolicy.allow` or a non-empty `agents.entries.<agent>.modelPolicy.allow`), applying the strategy also syncs the `provider/model` entries written in this run. For agents ticked under "Override agent", the sync removes deselected exact model entries for that provider; other providers, wildcard rules such as `provider/*`, and custom agent configs for retained models are left alone.
125
-
126
- Applying uses replace mode by default: models for the current provider that the strategy did not select are removed. A model is kept when it is still referenced by a non-agent consumer such as `agents.defaults.utilityModel`, `agents.defaults.imageModel`, `agents.defaults.mediaModels.*`, `agents.defaults.voiceModel`, `agents.defaults.pdfModel`, `agents.defaults.embeddedAgent.cyberFailover.model`, `agents.entries.*.utilityModel`, `agents.entries.*.decisionModel`, `hooks.gmail.model` or `hooks.mappings[].model`. The confirmation dialog lists those references. If the remote list, filter strategy, protected references or other config changes after the preview, the write is aborted and a fresh preview is required.
127
-
128
- ## Filter rules
129
-
130
- - `includeRegex`: select only model IDs matching this JavaScript regex. Empty means no regex restriction.
131
- - `excludeRegex`: remove matching models from the regex-selected set.
132
- - `manualIds`: exact manual allowlist. With an allowlist and no `includeRegex`, only allowlisted models are selected.
133
- - Manual allowlist wins: allowlisted models are selected even if they match the exclude regex.
134
- - Allowlisted models already present in config are retained even if the remote list no longer returns them.
135
- - `replace`: the plugin defaults to `true`. The settings UI always runs in replace mode; agent tool calls may pass `false` to add models without removing old ones.
136
- - Invalid regexes are neither saved nor applied.
137
-
138
- Provider strategies are stored in the plugin config:
139
-
140
- ```json
141
- {
142
- "plugins": {
143
- "entries": {
144
- "model-fetch": {
145
- "config": {
146
- "providers": {
147
- "openrouter": {
148
- "filter": {
149
- "includeRegex": "^(openai|anthropic)/",
150
- "excludeRegex": "(embed|rerank)",
151
- "manualIds": ["openai/gpt-4o-mini"],
152
- "replace": true
153
- }
154
- },
155
- "ollama": {
156
- "filter": {
157
- "manualIds": ["qwen3:latest", "llama3.1:8b"],
158
- "replace": true
159
- }
160
- }
161
- }
162
- }
163
- }
164
- }
165
- }
166
- }
167
- ```
90
+ After an OpenClaw upgrade, the first activation restores Model Fetch as a pinned item in the "Pages" section. Later manual removals are kept.
168
91
 
169
- ## Agent tool
92
+ ### Model Fetch does not show up in the mobile apps
170
93
 
171
- The tool is named `model_fetch`. Refresh and write using the persisted strategy only:
172
-
173
- ```json
174
- {
175
- "provider": "openrouter"
176
- }
177
- ```
94
+ The Android and iOS apps learn about plugin pages from the `controlUiTabs` payload in the Gateway hello message. Make sure the phone is paired with the `operator.read` scope, then restart the app so it fetches a fresh hello message.
178
95
 
179
- Dry run with a temporary filter, without writing config:
96
+ ### Fetching remote models fails
180
97
 
181
- ```json
182
- {
183
- "provider": "openrouter",
184
- "includeRegex": "anthropic/",
185
- "dryRun": true
186
- }
187
- ```
98
+ Confirm that the provider's `baseUrl`, `api`, and authentication work in OpenClaw. Local or private-network endpoints such as Ollama require `request.allowPrivateNetwork: true`.
188
99
 
189
- Temporary manual selection:
100
+ ### Old models are still visible after applying
190
101
 
191
- ```json
192
- {
193
- "provider": "ollama",
194
- "manualIds": ["qwen3:latest", "llama3.1:8b"]
195
- }
196
- ```
102
+ Confirm that the apply operation completed and that the relevant Agents were selected for synchronization. Some models can remain intentionally because of reference protection. Reload the Models page or the affected session after checking the apply result.
197
103
 
198
- The result reports the provider, remote model count, the final selected model IDs, added/unchanged/removed counts, protected models with their reference paths, the config path and whether the config was persisted.
199
-
200
- ## Provider examples
201
-
202
- ```json
203
- {
204
- "models": {
205
- "providers": {
206
- "openrouter": {
207
- "baseUrl": "https://openrouter.ai/api/v1",
208
- "api": "openai-responses",
209
- "models": []
210
- }
211
- }
212
- }
213
- }
214
- ```
104
+ ## Documentation and Support
215
105
 
216
- Ollama or another local address needs explicit private-network access:
217
-
218
- ```json
219
- {
220
- "models": {
221
- "providers": {
222
- "ollama": {
223
- "baseUrl": "http://127.0.0.1:11434",
224
- "api": "ollama",
225
- "request": {
226
- "allowPrivateNetwork": true
227
- },
228
- "models": []
229
- }
230
- }
231
- }
232
- }
233
- ```
106
+ - [Configuration reference](https://github.com/AdoShan/OpenClaw-ModelFetch/blob/main/docs/en/configuration.md)
107
+ - [中文配置参考](https://github.com/AdoShan/OpenClaw-ModelFetch/blob/main/docs/zh-CN/configuration.md)
108
+ - [Report an issue](https://github.com/AdoShan/OpenClaw-ModelFetch/issues)
109
+ - [Releases](https://github.com/AdoShan/OpenClaw-ModelFetch/releases)
110
+ - [npm package](https://www.npmjs.com/package/openclaw-plugin-model-fetch)
234
111
 
235
112
  ## Development
236
113
 
114
+ For a source checkout, run:
115
+
237
116
  ```bash
117
+ npm ci
238
118
  npm test
239
- npm run typecheck
240
- npm run plugin:build
241
119
  npm run plugin:validate
242
120
  ```
243
121
 
244
- The browser UI sources are `src/control-ui.ts` and `src/settings-view.ts`. `npm run plugin:build` generates content-hashed assets under `dist/control-ui/` and updates `openclaw.plugin.json.controlUi`.
122
+ `plugin:validate` builds and validates the plugin. To use the checkout directly, install it with `openclaw plugins install /absolute/path/to/OpenClaw-ModelFetch --link`. Rebuild and reload the plugin after source changes.
245
123
 
246
124
  ## License
247
125