@lakphy/local-router 0.3.1 → 0.4.0-beta.1

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.md CHANGED
@@ -99,6 +99,7 @@ local-router version
99
99
  - `--host <host>`:指定监听地址
100
100
  - `--port <port>`:指定监听端口
101
101
  - `--daemon`:后台运行
102
+ - `--idle-timeout <sec>`:设置 Bun 连接空闲超时(默认 600 秒,设为 `0` 可关闭)
102
103
 
103
104
  ## 请求入口(给你的应用调用)
104
105
 
@@ -195,6 +196,25 @@ curl -X POST "http://127.0.0.1:4099/openai-completions/v1/chat/completions" \
195
196
  - `routes` 引用的 provider 是否存在
196
197
  - 配置文件是否是合法 JSON5
197
198
 
199
+
200
+ ### 运行较久请求出现 `[Bun.serve]: request timed out after 10 seconds` 怎么办?
201
+
202
+ 这是 Bun 服务端连接空闲超时触发导致的(常见于长流式响应或慢速上游)。
203
+
204
+ 可在启动时放宽超时:
205
+
206
+ ```sh
207
+ local-router start --idle-timeout 600
208
+ # 或彻底关闭空闲超时
209
+ local-router start --idle-timeout 0
210
+ ```
211
+
212
+ 也支持环境变量:
213
+
214
+ ```sh
215
+ LOCAL_ROUTER_IDLE_TIMEOUT=600 local-router start
216
+ ```
217
+
198
218
  ### 如何升级?
199
219
 
200
220
  ```sh
@@ -167,6 +167,13 @@
167
167
  "additionalProperties": {
168
168
  "$ref": "#/$defs/modelCapabilities"
169
169
  }
170
+ },
171
+ "plugins": {
172
+ "type": "array",
173
+ "description": "插件列表。数组顺序决定洋葱模型的外→内层级:请求阶段正序执行,响应阶段逆序执行。",
174
+ "items": {
175
+ "$ref": "#/$defs/pluginConfig"
176
+ }
170
177
  }
171
178
  }
172
179
  },
@@ -218,8 +225,8 @@
218
225
  "type": "string",
219
226
  "enum": ["off", "masked", "full"],
220
227
  "default": "off",
221
- "description": "请求体与响应体的记录策略。off:不记录 body 内容(推荐日常使用);masked:脱敏后记录(当前版本行为同 full,后续将完善字段级脱敏);full:完整记录所有内容(仅建议调试时临时开启,注意隐私风险)。",
222
- "markdownDescription": "请求体与响应体的记录策略:\n- `off`:不记录 body 内容(推荐日常使用)\n- `masked`:脱敏后记录(当前版本行为同 `full`,后续完善)\n- `full`:完整记录所有内容(仅调试时使用)"
228
+ "description": "请求体与响应体的记录策略。off:不记录 body 内容(推荐日常使用);full:完整记录所有内容(仅建议调试时临时开启,注意隐私风险)。为兼容旧配置,masked 仍被接受,但当前行为等同于 full",
229
+ "markdownDescription": "请求体与响应体的记录策略:\n- `off`:不记录 body 内容(推荐日常使用)\n- `full`:完整记录所有内容(仅调试时使用)\n- `masked`:兼容旧配置,当前行为等同于 `full`"
223
230
  }
224
231
  }
225
232
  },
@@ -259,6 +266,25 @@
259
266
  "description": "单个流式请求最大记录字节数(默认约 10MB = 10485760 字节)。超出部分将被截断并在文件末尾追加 [TRUNCATED] 标记。设置合理上限可防止异常长响应撑爆磁盘。"
260
267
  }
261
268
  }
269
+ },
270
+ "pluginConfig": {
271
+ "type": "object",
272
+ "description": "单个插件的配置。package 指定 npm 包名或本地路径,params 为传递给 create() 的参数对象。",
273
+ "additionalProperties": false,
274
+ "required": ["package"],
275
+ "properties": {
276
+ "package": {
277
+ "type": "string",
278
+ "minLength": 1,
279
+ "description": "插件包名或本地路径。以 ./ 或 ../ 或 / 开头视为本地文件(相对于配置文件目录解析),否则作为 npm 包名通过 import() 加载。",
280
+ "examples": ["local-router-plugin-audit", "./plugins/content-filter.ts"]
281
+ },
282
+ "params": {
283
+ "type": "object",
284
+ "description": "传递给插件 create() 方法的参数对象。",
285
+ "additionalProperties": true
286
+ }
287
+ }
262
288
  }
263
289
  }
264
290
  }