feat: 所有超时收成一份、全部可调(设置 → 超时,18 项)
用户要求"全部超时做成可调"。改造前 15 个超时散在 10 个文件里当模块级常量, 说不清一共有几个,也答不了"哪些能调"。 内核 - 新增 android/kernel/timeouts.py:**超时的唯一一份定义**(DEFAULT + SPECS), 带每项的 名字/分组/说明/默认值/上下界;get() 一律夹取,用户填什么都不炸 - 新增 GET/POST /api/timeouts(清单 + 当前值 + 保存 + 恢复默认) - 各处改现读:tools_runtime(tool)、builtin_tools(shell/pythonRun)、 doubao_entry(termux)、providers(model)、speech(tts/stt)、 mcp_client(请求/连接/调用)、meeting(meetingNode)、custom_nodes(customNode)、 app.py 的 SSE 心跳 - ask_user / show_ui 用 TIMEOUT_KEYS 声明"哪个参数该用设置里的值", 内核调用前注入(工具的默认值退化成单独跑时的兜底) - store.py:timeouts 走**整体替换**而不是深合并 —— 深合并会让"改回默认"删不掉 安卓 - data/AppTimeouts.kt:客户端缓存(OkHttp 的 readTimeout、文件选择没法现问内核) - KernelClient:readTimeout 跟着 sseRead 走,改完重建连接池;新增 timeouts 接口 - ui/TimeoutsScreen.kt:全屏界面,按分组列出、-/+ 与输入框、恢复默认 - 设置页加「超时」卡片入口;NativeBridge 的本地接口请求 / 选文件等待接上 - Settings 模型加 TimeoutItem / TimeoutsState(字段全部来自内核) Node 端(Web/exe) - 新增 server/src/timeouts.mjs(和 Python 那份逐字对应) - config.mjs 加 timeouts(同样整体替换);speech / python-tools / mcp / providers 各处改读;index.mjs 加 /api/timeouts 验证 - 新增 scripts/verify-timeouts.py:清单完整性、边界容错(文字/空串/负数/超大值/ 带单位/None)、**扫内核有没有漏网的硬编码超时**(带白名单)、 工具侧声明、以及和 Node 端逐项对拍 - 实测真机:界面显示 18 项来自内核 → 点 + 保存 → 内核 heartbeat 15→25 → 恢复默认 → 回 15;askUser 显示"不限时" 文档:README §3.13;docs/AI界面能力.md 的"不限时要三处一起改"补上可调入口。 版本 2.0.46。
This commit is contained in:
@@ -18,6 +18,10 @@ import shutil
|
||||
import sys
|
||||
import threading
|
||||
|
||||
# 超时全部收在 timeouts.py 里(用户可在「设置 → 超时」调)。
|
||||
# 它读不到设置时会回落默认值,所以在启动早期 import 也是安全的。
|
||||
import timeouts
|
||||
|
||||
# 内置工具(构建时由 scripts/build-apk.mjs 拷进 Python 源集根目录)
|
||||
BUNDLED_TOOL_FILES = [
|
||||
'_protocol.py',
|
||||
@@ -148,7 +152,10 @@ SHELL_TOOL_SPEC = {
|
||||
'properties': {
|
||||
'command': {'type': 'string', 'description': '要执行的命令'},
|
||||
'cwd': {'type': 'string', 'description': '工作目录,可留空'},
|
||||
'timeout': {'type': 'number', 'description': '超时秒数,默认 30,最大 300'},
|
||||
'timeout': {
|
||||
'type': 'number',
|
||||
'description': '超时秒数。不传就用设置里「超时 → Termux 命令」那个值',
|
||||
},
|
||||
},
|
||||
'required': ['command'],
|
||||
},
|
||||
@@ -223,7 +230,7 @@ def shell_run(args: dict) -> dict:
|
||||
if not command or _android is None:
|
||||
return fallback_shell(args)
|
||||
|
||||
timeout = max(1, min(300, int(args.get('timeout', 30) or 30)))
|
||||
timeout = timeouts.budget(args, 'termux')
|
||||
hit = _try_termux(command, str(args.get('cwd') or ''), timeout)
|
||||
if hit is not None:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user